var http  = getHTTPObject(); 
function BrowserInfoForCom() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var infoBro = new BrowserInfoForCom();

function HideSelectBoxForIE(state)
{
	var selects = document.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++ ) {
		selects[i].style.visibility = state;
	}	
}
function create_overlay(page_url){
		//set page position
		window.scrollTo(0, 0);
		
		//prepare IE
		if (infoBro.name == "MSIE" && infoBro.version < 7)
			HideSelectBoxForIE("hidden");
			
		var height = '100%';
		var overflow = 'hidden';
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;
	
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow; 
		overlay_box 		= document.createElement('div');
		overlay_box.id		= 'overlay_box';
		lightbox_box		= document.createElement('div');
		lightbox_box.id		= 'lightbox_box';
		bod.appendChild(overlay_box);
		bod.appendChild(lightbox_box);
		document.getElementById('lightbox_box').innerHTML = 	'<div align="center" style="vertical-align:middle;width:350px;">' +
																'<br><br>&nbsp;&nbsp;<img src="/images/loader.gif" /><br><br>' +
																'</div>';
		page_url += "&rand=" + Math.round(1000*Math.random());
		http.open("GET", page_url, true);
		http.onreadystatechange = loadInfo; 
		http.send(null); 
	}
	
	function delete_overlay(){
		//prepare IE
		if (infoBro.name == "MSIE" && infoBro.version < 7)
			HideSelectBoxForIE("visible");
			
		var height = 'auto';
		var overflow = 'auto';
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;
	
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow; 
		overlay_box 		= document.getElementById('overlay_box');
		lightbox_box		= document.getElementById('lightbox_box');
		bod.removeChild(overlay_box);
		bod.removeChild(lightbox_box);
	}
	
	function loadInfo() {
		if (http.readyState == 4) {
			if (http.status == 200) {
				document.getElementById('lightbox_box').innerHTML = http.responseText;
			} else {
				window.location.reload();
			}
		}
	}
	
	function current_status() {
		if (http.readyState == 4) {
			if (http.status == 200) {
				document.getElementById('current_status').innerHTML = "<b>Status: </b> &nbsp; " +http.responseText + " ";
			} else {
				window.location.reload();
			}
		}
	}
	
	function getHTTPObject() { 
		var xmlhttp; 
		
		if(window.XMLHttpRequest){ 
			xmlhttp = new XMLHttpRequest(); 
			} 
		else if (window.ActiveXObject){ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			if (!xmlhttp){ 
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				} 
			} 
			return xmlhttp; 
		}
	
		



