// JavaScript Document

var xmlreqs = new Array();
var scriptPath = "";

function CXMLReq(freed) {
	this.freed = freed;
	this.xmlhttp = false;
	if (window.XMLHttpRequest) {
		this.xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function simpleConnector(url, divID, postValues) {
		
	// Get the divID to up date when html is return from php
	if (divID != null) {
		var obj = document.getElementById(divID);
		obj.innerHTML = '<img src="images/ani2.gif" width="134" height="30">';
	}
	
	var pos = -1;
	for (var i=0; i<xmlreqs.length; i++) {
		if (xmlreqs[i].freed == 1) { pos = i; break; }
	}
	if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
	if (xmlreqs[pos].xmlhttp) {
		xmlreqs[pos].freed = 0;
		xmlreqs[pos].xmlhttp.open("POST",url);
		xmlreqs[pos].xmlhttp.onreadystatechange = function() {
			if(xmlreqs[pos].xmlhttp.readyState == 4 && xmlreqs[pos].xmlhttp.status == 200) {
				var scriptResponseTXT = xmlreqs[pos].xmlhttp.responseText;
				
				// a response is expected...
				if (divID != null) {
					if (scriptResponseTXT != 'ok') {
						obj.innerHTML = scriptResponseTXT;
					} 
				}
				
				xmlreqs[pos].freed = 1;
			}
		}
		
		//alert(postValues);
		xmlreqs[pos].xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlreqs[pos].xmlhttp.send(postValues);
	}
}

function message() {

	var myWidth = 0, myHeight = 0;

	if(typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}  
  
  document.getElementById('EDIT_CONTENT').style.left =  ((myWidth/2) - 250) + 'px';
}
	
function openOverlay(editPage, divID, editIDs)
{
	simpleConnector(editPage, divID, editIDs);

	var myWidth = 0, myHeight = 0;

	if(typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	document.getElementById('EDIT_BACKGROUND').style.visibility = 'visible'; 
	document.getElementById('EDIT_BACKGROUND').style.display = 'block';
	
	document.getElementById('EDIT_CONTENT').style.visibility = 'visible'; 
	document.getElementById('EDIT_CONTENT').style.display = 'block';
	document.getElementById('EDIT_CONTENT').style.left =  ((myWidth/2) - 250) + 'px';
}

function closeOverlay() 
{
	document.getElementById('EDIT_CONTENT').style.visibility = 'hidden'; 
	document.getElementById('EDIT_CONTENT').style.display = 'none';
	
	document.getElementById('EDIT_BACKGROUND').innerHTML = ''; 
	document.getElementById('EDIT_BACKGROUND').style.visibility = 'hidden';
	document.getElementById('EDIT_BACKGROUND').style.display = 'none';
}

