var xmlHttp;
		
function getContent(id) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url = "getcontent.php";
	url = url + "?id=" + id;
	url = url + "&sid=" + Math.random();
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function stateChanged() { 
	showLayer();
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("box").innerHTML = xmlHttp.responseText;
	} else {
		document.getElementById("box").innerHTML = "<p align='center'><img src='images/ajax_action.gif' alt='working...' /></p>"
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		//Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function hideLayer() {
	document.getElementById("layer").style.top = -50 + "px";
	document.getElementById("box").style.top = -50 + "px";
	document.getElementById("layer").style.height = 0 + "px";
	document.getElementById("box").style.height = 0 + "px";
	document.getElementById("box").innerHTML = "";
	document.getElementById("top").style.visibility = "visible";
}

function showLayer() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		browserVersion = navigator.appVersion
		loc = browserVersion.indexOf("MSIE ");
		IENr = browserVersion.charAt(loc + 5);
		if (IENr == "5" || IENr == "6") { // IE 5 or 6 browser
			document.getElementById("layer").style.height = 1000 + "px";
		} else { // Non IE 6 IE browser
			document.getElementById("layer").style.height = 100 + "%";
		}
	} else { // Non IE browser
		document.getElementById("layer").style.height = 100 + "%";
	}
	
	document.getElementById("layer").style.top = 0 + "px";
	document.getElementById("box").style.top = 50 + "%";
	document.getElementById("box").style.height = 450 + "px";
	changeOpac(80, "layer");
	document.getElementById("top").style.visibility = "hidden";
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
