isIE = (navigator.appName.indexOf('Microsoft Internet Explorer')!=-1)?true:false;
// AJAX
function makeRequest(node,url) {
	var node = node;
	var url = url;
	if(node.id=='content'){
		setCookie('content_location',url,-1);
		setCookie('content_location',url,1/12);
	}else if(node.id=='menu'){
		setCookie('menu_location',url,-1);
		setCookie('menu_location',url,1/12);
	}
	if (window.XMLHttpRequest) { 
		var http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { 
		var http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(makeRequest.arguments.length == 4){
		var evalF = makeRequest.arguments[3];
		http_request.onreadystatechange = function(){ doStuff(http_request,node,evalF) };
	}else{ 
		http_request.onreadystatechange = function(){ doStuff(http_request,node) };}
	if(makeRequest.arguments.length >= 3 && makeRequest.arguments[2] != null){
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", makeRequest.arguments[2].length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(makeRequest.arguments[2]);
		return true;
	} else {
		http_request.open('GET', url, true);
		http_request.send(null);
		return true;
	}
}

function doStuff(http_request,node) {
	var node = node;
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			node.innerHTML = http_request.responseText;
			if(doStuff.arguments.length == 3) eval(doStuff.arguments[2]);
		} else {
			node.innerHTML = http_request.status;
		}
	}
}

pucon = false;
function showPUC(url,post,evt){
	if(pucon == true){
		if(window.pucTO) clearTimeout(pucTO);
		hidePUC();
	}
	pucon = true;
	puc.innerHTML = '';
	puc.className = 'selectFree';
	puc.style.display= '';
	pucIDiv = document.createElement('DIV');
	pucIDiv.className = 'bd';
	pucIDiv.innerHTML = '<span style="background-color:#6b9c1b; color:#FFFFFF; padding:5px">Fetching Calendar...</span>';
	puc.appendChild(pucIDiv);
	pucIIframe = document.createElement('IFRAME');
	puc.appendChild(pucIIframe);
	makeRequest(pucIDiv,url,post,"pucTO = setTimeout('hidePUC()',7000);");	
	if(evt!=null){
		if(isIE){
			puc.style.left = (event.clientX + 5) + 'px';
			puc.style.top = (event.clientY + 15) + 'px';
		}else{
			puc.style.left = parseInt(evt.pageX + 5) + 'px';
			puc.style.top = parseInt(evt.pageY + 15) + 'px';
		}
	}else{	
		puc.style.left = (showPUC.arguments[3]+ 5) + 'px';	
		puc.style.top = (showPUC.arguments[4]+ 15) + 'px';	
	}

}
function hidePUC(){
	pucon = false;
	puc.style.display= 'none';
}
function setInputVal(i1, i2, i3, val1, val2, val3){
	var i1 = document.getElementById(i1);
	var i2 = document.getElementById(i2);
	var i3 = document.getElementById(i3);
	i1.innerHTML=val1;
	i2.value=val2;
	i3.value=val3;
}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)	curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)	curtop += obj.y;
	return curtop;
}

