var XMLHTTP_SUCCEED_CODE = 200;
var XMLHTTP_READY = 4;
function openDiv(divName) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		calculateLeft = Math.round(((document.body.clientWidth/2) - 270));
		calculateTop = 10;
	} else {
		calculateLeft = Math.round(((window.innerWidth/2) - 270));
		calculateTop = 10;
	}
	var oDiv  = document.getElementById(divName);
	var oGrey = document.getElementById('grey');
	var scrolled  = GetScrollTop();
	
	oGrey.style.position = 'absolute';
	oGrey.style.left = '0px';
	oGrey.style.top = scrolled+'px';	
	oGrey.style.visibility = 'visible';
	oGrey.style.width = '100%';
	oGrey.style.height = '100%';
	
	oDiv.style.visibility = 'visible';
	oDiv.style.width = '700px';
	oDiv.style.height = '540px';
	oDiv.style.position = 'absolute';
	oDiv.style.backgroundColor = '#ffffff';
	oDiv.style.top = calculateTop+"px";
	oDiv.style.left = calculateLeft+"px";
		
}
function closeDiv(divId) {
	var oDiv = document.getElementById(divId);
	oDiv.style.visibility = 'hidden';
	oDiv.style.width = '0px';
	oDiv.style.height = '0px';	
	oDiv.innerHTML = '';
	var oGrey = document.getElementById('grey');
	oGrey.style.visibility = 'hidden';
	oGrey.style.width = '0px';
	oGrey.style.height = '0px';	
}
function createXmlhttp() {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//if not, try older IE versions for even dumber people
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function reloadPage() {
	reloadHref = window.location.href;
	window.location = reloadHref;
}
function checkUrl (url) {
	var request = false;
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest;
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Microsoft.XMLHttp");
	}

	if (request) {
		request.open("GET", url);
		if (request.status == 200) { return true; }
	}
	return false;
}
function loadPage (serverPage, contentDiv) {
	xmlhttp = createXmlhttp();
	obj = document.getElementById(contentDiv);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == XMLHTTP_READY && xmlhttp.status == XMLHTTP_SUCCEED_CODE) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
function openFotoDiv(divId, width, height) {
	var oGreyDiv = document.getElementById('grey');
	//gray overlay first
	//header height
	var scrolled  = GetScrollTop();
	scrolled += 20;
	oGreyDiv.style.position = 'absolute';
	oGreyDiv.style.left = '0px';
	oGreyDiv.style.top = '0px';
	oGreyDiv.style.visibility = 'visible';
	oGreyDiv.style.width = '100%';
	oGreyDiv.style.height = calculateSiteHeight()+'px';
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { 
		calculateLeft = (Math.round(window.screen.availWidth/2) - (width/2));
	} else {
		calculateLeft = (Math.round(window.innerWidth/2) - (width/2));
	}
	calculateTop = scrolled+20;
	theDiv = document.getElementById(divId);
	theDiv.style.visibility = 'visible';
	//theDiv.style.height 	= height+'px';
	theDiv.style.height 	= '600px';
	//theDiv.style.width 		= width+'px';
	theDiv.style.width 		= '800px';
	//place the div
	theDiv.style.position = 'absolute';
	theDiv.style.top = Math.round(calculateTop)+"px";
	theDiv.style.left = calculateLeft+"px";	
}
function GetScrollTop() {
  return window.pageYOffset||
    document.documentElement&&document.documentElement.scrollTop||
    document.body.scrollTop||0;
}
function hideFotoDiv(divId) {
	var oGreyDiv = document.getElementById('grey');
	var obigFoto = document.getElementById(divId);
	obigFoto.style.visibility = 'hidden';
	obigFoto.style.width = '0px';
	obigFoto.style.height = '0px';
	obigFoto.innerHTML = "";
	oGreyDiv.style.width = '0px';
	oGreyDiv.style.height = '0px';
	oGreyDiv.style.visibility = 'hidden';
}
function closeDiv(divId) {
	var oDiv = document.getElementById(divId);
	oDiv.style.visibility = 'hidden';
	oDiv.style.width = '0px';
	oDiv.style.height = '0px';	
	oDiv.innerHTML = '';
}
function calculateSiteHeight () {
	return document.getElementById('site').offsetHeight;
}
