function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}


function showPopOver(divID) {

	loadScreen();
	document.getElementById(divID).style.display = "block";
	document.getElementById(divID).style.left = ((myWidth / 2)-(document.getElementById(divID).offsetWidth / 2))+"px";
	document.getElementById(divID).style.top = ((myHeight / 2)-(document.getElementById(divID).offsetHeight / 2)+myScroll)+"px";
}

function closePopOver(divID) {

	document.getElementById(divID).style.display = "none";
}

var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;

function loadScreen() {
	if (document.all) {
		// IE
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		// NON-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}

	if (window.innerHeight && window.scrollMaxY) { 
		// NON-IE
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		// IE
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	 } else {
		// IE MAC
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}

function hidePopOver(e){
    var target = (e && e.target) || (event && event.srcElement);
    var node = target;
    if((target.getAttribute("onClick")&& target.getAttribute("onClick").toString().indexOf("showPopOver") > -1)){
        return;
    }
    while(node.parentNode){
        if(node.className == "popover"){
            return;
        }
        node=node.parentNode;
    }
    if(target.className != "popover" && target.parentNode.className != "popover"){
        var divs = document.getElementsByTagName("div");
        for(var i=0; i<divs.length;i++){
            if(divs[i].className == "popover"){
                divs[i].style.display="none";
            }
        }
    }
    var appVer = navigator.appVersion;
    if(navigator.appVersion.indexOf("MSIE 6") > 0) {
        var selects = document.getElementsByTagName("select");
        if(selects.length>0){
            for(var i=0; i< selects.length; i++){
               selects[i].style.display="block";
            }
        }
    }
}

document.onclick=hidePopOver;
