// JavaScript Document





function popuparticle(page_id, articlebox) {
	
	var top = ((articlebox * 151) + 69) + "px";
	
	document.getElementById('articlecontent').innerHTML = "Vent venligst...";

	for (i = 1; i < 5; i++) {
		if (document.getElementById('articlebox'+i)) { 
			document.getElementById('articlebox'+i).style.opacity = 0.4; 
			document.getElementById('articlebox'+i).style.MozOpacity = 0.4;
			document.getElementById('articlebox'+i).style.filter = "alpha(opacity=40)";
		}
	}
	
	document.getElementById('articlecontent').innerHTML = asyncQuery(page_id);

	document.getElementById('articlepopup').style.top = top;
	document.getElementById('articlepopup').style.display = "block";

}

function hidearticle() {
	
	document.getElementById('articlepopup').style.display = "none";

	for (i = 1; i < 5; i++) {
		if (document.getElementById('articlebox'+i)) { 
			document.getElementById('articlebox'+i).style.opacity = 1; 
			document.getElementById('articlebox'+i).style.MozOpacity = 1;
			document.getElementById('articlebox'+i).style.filter = "alpha(opacity=100)";
		}
	}
	
}


// JavaScript Document

function GetXmlHttpObject(handler) {

	var objXMLHttp=null

	if (window.XMLHttpRequest) {

		objXMLHttp=new XMLHttpRequest()

	} else if (window.ActiveXObject) {

		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")

	}

	return objXMLHttp
}

function stateChanged() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		rslt=xmlHttp.responseText;

		if (rslt=="refresh") {

			window.location.reload(true);

		} else if ((rslt == "ok") || (rslt == 1)) {

			// Everything fine - no output

		} else {

			// alert(rslt);

		}

	}

}


function asyncQuery(page_id) {

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; }

	var url = "fileadmin/template/get_page.php";
	var postdata = "page_id="+page_id;

	xmlHttp.open("POST",url,false)
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.send(postdata)

	return xmlHttp.responseText;

}


function changeCalendarImage(uid) {
    
    var calendarbox = document.getElementById('calendarbox');
    calendarbox.style.backgroundImage = 'url(fileadmin/template/fetchcontentimage.php?uid='+uid+')';
    
}

