var sDiv;
var sLang = "EN";
var bLoading = false;

function showPage(url,Div,Lang,Loading)
{
	sDiv = Div;

	if (Lang && Lang.length > 0)
		sLang = Lang;
	
	if(Loading)
		bLoading = Loading;

	if (url.length==0)
	{	 
		document.getElementById(sDiv).innerHTML=""
		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 


function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   document.getElementById(sDiv).innerHTML=xmlHttp.responseText;
		
	else
		if (bLoading)
			if (sLang.toUpperCase() == "SP")
				document.getElementById(sDiv).innerHTML="<table width='100%' height='100%'><tr><td align='center'><table><tr><td><img src='images/loading.gif'></td><td class='subtitle'>Cargando...</td></tr></table></td></tr></table>";
			else
				document.getElementById(sDiv).innerHTML="<table width='100%' height='100%'><tr><td align='center'><table><tr><td><img src='images/loading.gif'></td><td class='subtitle'>Loading...</td></tr></table></td></tr></table>";		
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
		objXMLHttp=new XMLHttpRequest()
	else if (window.ActiveXObject)
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	
	return objXMLHttp
} 


//----TR Highlight--------
var iTR = "";
function setTRColor(obj,sColor){
	if (document.getElementById(obj).style.backgroundColor != '#ff6600')
		document.getElementById(obj).style.backgroundColor = sColor;
}

function setOnClick(obj,sColor){

	if (document.getElementById(iTR))
		document.getElementById(iTR).style.backgroundColor = sColor;
		
	document.getElementById(obj).style.backgroundColor = '#ff6600';
	iTR = obj;
}


//----Open/close DIV's--------
function checkDiv(sDiv,style,imgID,img1,img2){

	if (style)
		document.getElementById(sDiv).style.display = style;
	else
	{
		if (document.getElementById(sDiv).style.display == 'block')
		{
			document.getElementById(sDiv).style.display = "none";
		}
		else
		{
			document.getElementById(sDiv).style.display = "block";
		}	
	}

	if (imgID)
		if (document.getElementById(imgID).src.search(img1) > 0)
			document.getElementById(imgID).src = img2;
		else
			document.getElementById(imgID).src = img1;
}

function fOpenWin(url,param){
	var win;
	if (param)
		win = window.open(url,'MIF',param);
	else
		win = window.open(url,'MIF');
	win.focus();
}
