var menuon = false;

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function FixSize(){}
function Load_Start(){}

function menu_show(obj,menuid,l,t){
	var arrpos = Position.positionedOffset( obj );//findPos(obj);
	var lft = arrpos[0];
	var top = arrpos[1];
	
	menuon = menuid;
	
	document.getElementById(menuid).style.display = 'block';
	document.getElementById(menuid).style.visibility = 'visible';
	document.getElementById(menuid).style.left = lft+l+"px";
	document.getElementById(menuid).style.top = top+t+"px";
}

function menu_hide(obj,menuid){
	menuon = false;
	setTimeout( function(){
		if (menuon != menuid){
			menuon = false;
			document.getElementById(menuid).style.display = 'none';
			document.getElementById(menuid).style.visibility = 'hidden';
		}
	}, 500);
}

function visit_link(url){
	document.location.href=url;
}

function GetParentForm( node )
{
	while ( node.tagName.toLowerCase() != 'form' )
	{
		node = node.parentNode;
		if ( node == undefined )
			return undefined;
	}
	return node;
}

function UpdateState( div_id , country )
{
	new Ajax.Updater( div_id , 'province.php', {
		parameters: { Country: country }
	});
}

var xmlHttp;

function GetXmlHttpObject(){ 
	var objXMLHttp=null

	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	return objXMLHttp
} 

function getPAGE(url,target){

	targetDIV = target;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	if (url.indexOf("?") == -1){
		url=url+"?sid="+Math.random()
	}
	else{
		url=url+"&sid="+Math.random()
	}

	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			
			if (targetDIV > ""){			
				document.getElementById(targetDIV).innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}

function preload(id)
{
	document.getElementById(id).innerHTML = "<span style=\"color:red; font-style:italic; font-family:arial; font-size:12px;\">Loading...</span>";
}
