var selectLists = document.getElementsByTagName('select');
function DvLayerOpen(popLayer, popCon, TPos) {
    var DvLayerId = document.getElementById(popLayer); 	       // Var for Main full Opaque Layer
    var DvMessageId = document.getElementById(popCon);         // Var for Main content div popup Layer
    var ScrollHeight = document.documentElement.scrollHeight;  // Value for scroll height of the page
    var ScrollWidth = document.body.scrollWidth; 			   // Value for scroll width of the page
    var ClientHeight = document.documentElement.clientHeight;  // Value for browser height of the page
    var ClietnWidth = document.documentElement.clientWidth;    // Value for Browser width of the page
    var OffsetHeight = document.documentElement.offsetHeight;  // Value for scroll height for Safari of the page
    var OffsetWidth = document.documentElement.offsetWidth;    // Value for height height for Safari of the page

    //For Select DropBox Hide//
    for (var counter = 0; counter < selectLists.length; counter++) {
        version = parseInt(navigator.appVersion);
        if (navigator.appName == 'Microsoft Internet Explorer')
            selectLists[counter].style.visibility = 'hidden'
        else
            selectLists[counter].style.MozOpacity = .90;
        selectLists[counter].style.opacity = .90;
        selectLists[counter].style.filter = 'alpha(opacity=' + 90 + ')';
    }

    //For Select DropBox Hide//
    DvLayerId.style.display = "block";

    if (ScrollHeight > ClientHeight) {
        DvLayerId.style.height = ScrollHeight + "px";
    } else
        DvLayerId.style.height = ClientHeight + "px";
    var aaa = document.documentElement.scrollTop;
    document.documentElement.scrollTop = 0;
    DvMessageId.style.display = "block";
    var TotalW = document.body.clientWidth;
    var popW = DvMessageId.clientWidth;
    var centerPos = TotalW / 2;
    var movePos = popW / 2;
    var Lalign = centerPos - movePos;
    DvLayerId.style.width = ClietnWidth + "px";
    DvLayerId.style.top = 0 + "px";
    DvLayerId.style.left = 0 + "px";
    DvMessageId.style.left = Lalign + 'px';
    DvMessageId.style.top = TPos + 'px';
    if (DvMessageId.scrollHeight > ScrollHeight) {
        DvLayerId.style.height = DvMessageId.clientHeight + 300 + 'px';
    }


    //For maintaining the focus inside the popup on tab//	

    var allInputs = DvMessageId.getElementsByTagName("input");   // Creating an array of all the inputs present in div with id popCon
    var firstIP = allInputs[0]; 							   // Getting the first input from the array
    var firstIP;
    var lastIP;
    var allVisIn;
    var x;
    var y;

    for (i = 0; i < allInputs.length; i++) 						   //For finding the first input filed which is not hidden
    {
        x = i;
        if (allInputs[x].type != 'hidden' && allInputs[x].disabled == false) {
            firstIP = allInputs[x];
            break;
        }
    }

    for (j = 0; j < allInputs.length; j++)  						  //For finding the last input filed which is not hidden
    {
        y = j;
        if (allInputs[y].type != 'hidden' && allInputs[y].disabled == false) {
            lastIP = allInputs[y];
        }
    }

    if (DvLayerId.style.display == 'block')                      // For setting the focus on first input element in the form
    {
        if (firstIP != null) {
            firstIP.focus();
        }
    }
    if (lastIP != null) {
        lastIP.onblur = function setFocus()						  // For avoiding the focus to go into the background page
        {
            firstIP.focus();
        }
    }
}

function DvLayerHide(popLayer, popCon, popCon1) {
    document.getElementById(popLayer).style.display = 'none';
    document.getElementById(popCon).style.display = 'none';
    //document.getElementById(popCon1).style.display = 'none';
    //For Select DropBox Show//
    for (var counter = 0; counter < selectLists.length; counter++) {
        version = parseInt(navigator.appVersion);
        if (navigator.appName == 'Microsoft Internet Explorer')
            selectLists[counter].style.visibility = ''
        else
            selectLists[counter].style.MozOpacity = 1.0;
        selectLists[counter].style.opacity = 1.0;
        selectLists[counter].style.filter = 'alpha(opacity=' + 100 + ')';
    }
    //For Select DropBox Show//
}
function slsShow(id) {
    document.getElementById(id).style.visibility = 'visible';
}

function setOpen(divID) {
    var DvMessageId = document.getElementById(divID);          // Var for Main content div popup Layer
    var ScrollHeight = document.documentElement.scrollHeight;  // Value for scroll height of the page
    var ScrollWidth = document.body.scrollWidth; 			   // Value for scroll width of the page
    var ClientHeight = document.documentElement.clientHeight;  // Value for browser height of the page
    var ClietnWidth = document.documentElement.clientWidth;    // Value for Browser width of the page
    DvMessageId.style.display = "block";
    var leftPos = (ScrollWidth / 2) - (DvMessageId.clientWidth / 2);
    var topPos = (ClientHeight / 2) - (DvMessageId.clientHeight / 2);
    var scrollTop = document.documentElement.scrollTop;
    var mostTop = topPos + scrollTop
    DvMessageId.style.top = mostTop + "px";
    DvMessageId.style.left = leftPos + "px";
}
function setHide(divID) {
    document.getElementById(divID).style.display = 'none';
}

function DvLayerOpen2(popLayer, popCon, TPos) {
    var DvLayerId = document.getElementById(popLayer); 	       // Var for Main full Opaque Layer
    var DvMessageId = document.getElementById(popCon);         // Var for Main content div popup Layer
    var ScrollHeight = document.documentElement.scrollHeight;  // Value for scroll height of the page
    var ScrollWidth = document.body.scrollWidth; 			   // Value for scroll width of the page
    var ClientHeight = document.documentElement.clientHeight;  // Value for browser height of the page
    var ClietnWidth = document.documentElement.clientWidth;    // Value for Browser width of the page
    var OffsetHeight = document.documentElement.offsetHeight;  // Value for scroll height for Safari of the page
    var OffsetWidth = document.documentElement.offsetWidth;    // Value for height height for Safari of the page
    DvLayerId.style.display = "block";
    if (ScrollHeight > ClientHeight) {
        DvLayerId.style.height = ScrollHeight + "px";
    } else
        DvLayerId.style.height = ClientHeight + "px";
    var aaa = document.documentElement.scrollTop;
    document.documentElement.scrollTop = 0;
    DvMessageId.style.visibility = "visible";
    var TotalW = document.body.clientWidth;
    var popW = DvMessageId.clientWidth;
    var centerPos = TotalW / 2;
    var movePos = popW / 2;
    var Lalign = centerPos - movePos;
    DvLayerId.style.width = ClietnWidth + "px";
    DvLayerId.style.top = 0 + "px";
    DvLayerId.style.left = 0 + "px";
    DvMessageId.style.left = Lalign + 'px';
    DvMessageId.style.top = TPos + 'px';
    if (DvMessageId.scrollHeight > ScrollHeight) {
        DvLayerId.style.height = DvMessageId.clientHeight + 300 + 'px';
    }

}
function DvLayerHide2(popLayer, popCon) {
    document.getElementById(popLayer).style.display = 'none';
    document.getElementById(popCon).style.visibility = 'hidden';
}