GXportal = {
	Variables:{
		iframehide:"no",
		browser:new GXPChkBrw()
	}
}		
	
var version4 = (navigator.appVersion.charAt(0) == "4"); 
var popupHandle;

function GXPClosePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close();
}

function GXPOpenPopup(position,url,wName,wWidth,wHeight,wOptions) {
evnt = (version4 ? event : null);

// position=1 POPUP: makes screen display up and/or left, down and/or right 
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center

var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
if(navigator.appName == "Microsoft Internet Explorer") {
//screenY = document.body.offsetHeight;
screenY = window.screen.availHeight;
screenX = window.screen.availWidth;
}
else {
screenY = window.outerHeight
screenX = window.outerWidth
}
if(wWidth == 0) {
 wWidth = screenX;
}
if(wHeight == 0) {
 wHeight = screenY;
}
var properties = "toolbar = 0, location = 0, scrollbars = 1 ,height = " + wHeight;
properties = properties + ", width=" + wWidth;
if(position == 1)	{ // if POPUP not CENTER
cursorX = evnt.screenX;
cursorY = evnt.screenY;
padAmtX = 10;
padAmtY = 10;
if((cursorY + wHeight + padAmtY) > screenY) {
// make sizes a negative number to move left/up
padAmtY = (-30) + (wHeight * -1);
// if up or to left, make 30 as padding amount
}
if((cursorX + wWidth + padAmtX) > screenX)	{
padAmtX = (-30) + (wWidth * -1);	
// if up or to left, make 30 as padding amount
}
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = cursorX + padAmtX;
topprop = cursorY + padAmtY;
}
else {
leftprop = (cursorX - pageXOffset + padAmtX);
topprop = (cursorY - pageYOffset + padAmtY);
   }
}
else{
leftvar = (screenX - wWidth) / 2;
rightvar = (screenY - wHeight) / 2;
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = leftvar;
topprop = rightvar;
}
else {
leftprop = (leftvar - pageXOffset);
topprop = (rightvar - pageYOffset);
   }
}
if(evnt != null) {
properties = properties + ", left = " + leftprop;
properties = properties + ", top = " + topprop;
}
if(position != 3) { 
GXPClosePopup();
}
if(wOptions != null) {
properties = properties + ", " + wOptions;
}
popupHandle = open(url,wName,properties);
}

function GXPConfOpenPopup(MsgConf,wURL,wName,wWidth,wHeight,wOptions){
	if (confirm(MsgConf)) {GXPOpenPopup(2,wURL,wName,wWidth,wHeight,wOptions)}
}

//Compare two URLs and return true if the same server
function GXPSameServer(url1,url2){
var i=0;var j=0;var prt_url1;var srv_url1;var prt_url2;var srv_url2;
i=url1.indexOf('://');prt_url1=url1.substr(0,i);i+=3;
j=url1.indexOf('/',i);srv_url1=url1.substr(i,j-i);
i=url2.indexOf('://');prt_url2=url2.substr(0,i);i+=3;
if(prt_url1==prt_url2){
  j=url2.indexOf('/',i);
  srv_url2=url2.substr(i,j-i);
  if(srv_url1==srv_url2){return true}
}else{
  if(prt_url2==''){return true}
}
return false;
}

//Change color of the row when Mouse Over
function ClrMouseOvr(src,clrOver) {
	src.style.backgroundColor = clrOver;
}

function ClrMouseOut(src,clrIn) {
	src.style.backgroundColor = clrIn;
}

//Change image of the row when Mouse Over
function ImgMouseOvr(src,clrOver) {
	src.style.backgroundImage = 'url('+clrOver+')';
}

function ImgMouseOut(src,clrIn) {
	src.style.backgroundImage = 'url('+clrIn+')';
}

//Change image of the option when Mouse Over
function PutImage(nameimg,imagen){
	document.images[nameimg].src = imagen;
}

//Display application in IFRAME selected
function GXPAppIntDsp(Container,url,wintitle){
	GXPSetWinTitle(wintitle);document.getElementById(Container).src = url;
}

function GXPShowTable(){
if (GXportal.Variables.browser.ie){
	return "inline";}
else{
	return "table-row";}
}
function GXPShowCollapse(){
if (GXportal.Variables.browser.ie){
	return "inline";}
else{
	return "inline-table";}
}

//Get Application Operation Services
function GXPAppIntGetOpe(CntNro,OpeKey,SrvId){
	//alert('1 Refrezcar Container:'+CntNro+'  OpeKey:'+OpeKey+'  Servicio:'+SrvId);
	var CntNroInt = CntNro/1; 
	if (CntNro.lenght == 1 || CntNroInt < 10) CntNro = '0'+ CntNroInt;
	GXPAppIntSetOpeSrvSel(CntNro,SrvId);
	if (OpeKey!=""){
		var lastsfsectorTDNode;
		var parNode = document.getElementById("GXPAppIntCnt"+CntNro+"IF");
		var found = false;
		do{
			if (parNode){
				parNode = parNode.parentNode;
				if (parNode){
					if (parNode.nodeName == 'TD') lastsfsectorTDNode = parNode;
					if (parNode.nodeName == 'TABLE'){
						if (parNode.id.indexOf('SFSECTOR') != -1) found = true;
					}
				}
			}
		}
		while (parNode && !found)
		//alert('2 Refrezcar Container:'+CntNro+'  OpeKey:'+OpeKey+'  Servicio:'+SrvId);
		if (lastsfsectorTDNode){
			if (OpeKey == "none"){
				lastsfsectorTDNode.style.display = "none";
			}
			else if (OpeKey == "refresh"){
				lastsfsectorTDNode.style.display = "inline";
				URL = document.getElementById("GXPAppIntCnt"+CntNro+"IF").src;
				GXPAppIntDsp("GXPAppIntCnt"+CntNro+"IF",URL);
			}
			else{
				lastsfsectorTDNode.style.display = "inline";
				URL = document.getElementById("GXPAppIntCntURL"+CntNro).value+','+OpeKey+','+SrvId;
				GXPAppIntDsp("GXPAppIntCnt"+CntNro+"IF",URL);
			}
		}
	}
}

//Set Application Operation Service Selected 
function GXPAppIntSetOpeSrvSel(CntNro,SrvId){
	var CntNroInt = CntNro/1; 
	if (CntNro.lenght == 1 || CntNroInt < 10) CntNro = '0'+ CntNroInt;
	GXPAppIntCntOpeSrv = parent.document.getElementById("GXPAppIntCntOpeSrv"+CntNro);
	if (GXPAppIntCntOpeSrv) GXPAppIntCntOpeSrv.value = SrvId;
}
	

//Get Application Operation Service Selected 
function GXPAppIntGetOpeSrvSel(CntNro){
	var CntNroInt = CntNro/1; 
	if (CntNro.lenght == 1 || CntNroInt < 10) CntNro = '0'+ CntNroInt; var SrvId = 0;
	GXPAppIntCntOpeSrv = parent.document.getElementById("GXPAppIntCntOpeSrv"+CntNro);
	if (GXPAppIntCntOpeSrv) SrvId = GXPAppIntCntOpeSrv.value;
	return SrvId;
}

//Refresh IFRAME and Windows title
function GXPRedirToIF(url,wintitle){
	GXPSetWinTitle(wintitle);
	document.getElementById('gxpiframe').src = url;
}

//Redir from iFRAME
function GXPRedirFromIF(url){
	parent.location.href = url;
}

//Redir from iFRAME
function GXPRedirTo(url,wintitle){
	if (wintitle!='') parent.document.title = wintitle;
	location.href = url;
}

//Change Windows title
function GXPSetWinTitle(wintitle){
	if (wintitle) document.title = wintitle;
}

//Open NewWindow
function GXPOpenWin(wURL,wName,wOptions)
{wOptions1='scrollbars=1,location=1,menubar=1,toolbar=1,directories=1,status=1,resizable=1,'+wOptions;window.open(wURL,wName,wOptions1);}

//Auto-Resize iFrame
function GXPResizeiFrame(frameid){
    var currentfr=document.getElementById(frameid)
	try{
	    if (currentfr){
	        currentfr.style.display="block"
			if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight){ //ns6 syntax
			    currentfr.height = 5;
			    currentfr.height = currentfr.contentDocument.body.scrollHeight;
			    currentfr.height = currentfr.contentDocument.body.scrollHeight+1;
			} else{
				if (currentfr.Document && currentfr.Document.body.scrollHeight){ //ie5+ syntax
					currentfr.height = currentfr.Document.body.scrollHeight;				
				}
			}
			if (currentfr.addEventListener){
		  		currentfr.addEventListener("load", GXPReadjustiFrame, false); 				
			} else{
				if (currentfr.attachEvent){
		    		currentfr.detachEvent("onload", GXPReadjustiFrame) // Bug fix line
		    		currentfr.attachEvent("onload", GXPReadjustiFrame)
				}
			}
		}
	} 
	catch(error){
		if (currentfr)
			currentfr.style.height = "100%";
	}
	if ((document.all || document.getElementById) && GXportal.Variables.iframehide=="no"){
	    var tempobj=document.all? document.all[frameid] : document.getElementById(frameid)
		if (tempobj) tempobj.style.display="block"
	}

	var url_cur=document.location.href;
	var pos=url_cur.indexOf('hgxpp004');
	if(pos>1){
		var iFrameName = document.getElementById("GXPAppIntCntName");
		if (iFrameName)
			parent.GXPResizeiFrame(iFrameName.value);
	}
}


function GXPReadjustiFrame(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
	     GXPResizeiFrame(iframeroot.id);
}

function GXPAutoResizeiFrame(Idif){
	var my_iframe=document.getElementById(Idif);

	if (window.addEventListener){
	    my_iframe.addEventListener("load", function(){GXPResizeiFrame(Idif)}, false);
	    window.addEventListener("resize", function(){GXPResizeiFrame(Idif)}, false);
	}
	else {
	    if (window.attachEvent){
	        my_iframe.attachEvent("onload", function(){GXPResizeiFrame(Idif)})
	        window.attachEvent("onresize", function(){GXPResizeiFrame(Idif)})
	    }
		else{
		    my_iframe.onload=function(){GXPResizeiFrame(Idif)}
		    window.onresize=function(){GXPResizeiFrame(Idif)}
		}
	}
}


//Redir de Menú de combos
function GXPMnuCombo(selObj){
link=selObj.options[selObj.selectedIndex].value;
//Open PopUp?
if (link.substr(0,1)!='Y'){
 link = link.substr(1,500);
 if (link.substr(0,11)=='javascript:'){
  link=link.substr(11,500);eval(link);
 }else{
  if(link!='*'){
   eval("location='"+link+"'");}}
}else{link=link.substr(1,500);GXPOpenWin(link,'','');}
}

//To collapse sectors
function gxptablestatus(tableName, flag, image, imgExpand, imgCollapse)
{table = document.getElementById(tableName);
 if( table.style.display == "none"){table.style.display = GXPShowCollapse();image.src = imgCollapse;flag.value = "0";}
 else {	table.style.display = "none";image.src = imgExpand;flag.value = "1";}}

//To Hide and show Tables
function gxptableHS(tableName)
{table = document.getElementById(tableName);
if (table){
	if( table.style.display == "none"){table.style.display = GXPShowTable();}
	else {	table.style.display = "none";}
}
}

//To change Anchor and TD class
function GXPChgClassOve(src,AnchId,ClassName) 
{if (src) 
  {src.style.cursor = 'pointer';
   if (ClassName!=''){AnchId.className='A'+ClassName;src.className='TD'+ClassName;}
}}

function GXPChgClassOut(src,AnchId,ClassName) 
{if (src) 
  {src.style.cursor = 'default';
   if (ClassName!=''){AnchId.className='A'+ClassName;src.className='TD'+ClassName;}
}}

//Add class Over to Anchor and TD
function GXPAddClsOve(src,anchId,subMenu) 
{if (src){
	src.style.cursor = 'pointer';
	if (anchId)
		var sectorId = anchId.id.substring(1, 13);
	else
		var sectorId = src.id.substring(2, 14);
	var className = 'S' + sectorId
	if (subMenu == 1){ className += 'SM'; }
	className += 'Ove';	
	if (className!=''){
		if (anchId) $(anchId).addClassName("A" + className);
		$(src).addClassName("TD" + className);
	}
}
}

//Remove class Over in Anchor and TD
function GXPRemClsOve(src,anchId,subMenu) {
if (src){
	src.style.cursor = 'default';
	if (anchId)
		var sectorId = anchId.id.substring(1, 13);
	else
		var sectorId = src.id.substring(2, 14);
	var className = 'S' + sectorId
	if (subMenu == 1){ className += 'SM'; }
	className += 'Ove';
	if (className!=''){
		if (anchId) $(anchId).removeClassName("A" + className);
		$(src).removeClassName("TD" + className);
	}
}
}
			
function GXPMnuOptClk(clickId, btnMode, mnuStyle, subMnuWhenDisplay){
	var sectorId = clickId.substring(0, 12);
	var subMenuLevel = clickId.substring(12, 13);
	var subMnuChild = parseInt(subMenuLevel) + 1;
	//Actualizo clase de los Anchor
	if (subMenuLevel==1){
		//Analizo primer nivel del menu
		$$("table#TMNU" + sectorId + " .AS" + sectorId + "Sel").each(function(element){
			element.removeClassName("AS" + sectorId + "Sel").addClassName("AS" + sectorId);
		});
		$("A" + clickId).removeClassName("AS" + sectorId).addClassName("AS" + sectorId + "Sel");
	}
	else{
		//Analizo los submenus del sector
		$$("table#TS" + sectorId + " .TSM" + subMenuLevel ).each(function(element){
				$$("table#" + element.id + " .AS" + sectorId + "SMSel" ).each(function(element2){
					element2.removeClassName("AS" + sectorId + "SMSel").addClassName("AS" + sectorId + "SM");
				});
			});		
		$("A" + clickId).removeClassName("AS" + sectorId + "SM").addClassName("AS" + sectorId + "SMSel");
	}
	
	//Actualizo clase de las celdas de la tabla
	if (btnMode == 1){
		if (subMenuLevel==1){
			//Analizo primer nivel del menu
			if (mnuStyle=='T'){
				//Menu Tabs no cambio el fondo 
			}
			else{
				$$("table#TMNU" + sectorId + " .TDS" + sectorId + "Sel").each(function(element){
					element.removeClassName("TDS" + sectorId + "Sel").addClassName("TDS" + sectorId);
				});
				$("TD" + clickId).removeClassName("TDS" + sectorId).addClassName("TDS" + sectorId + "Sel");
			}
		}
		else{
			//Analizo los submenus en el sector
			$$("table#TS" + sectorId + " .TSM" + subMenuLevel ).each(function(element){
				$$("table#" + element.id + " .TDS" + sectorId + "SMSel" ).each(function(element2){
					element2.removeClassName("TDS" + sectorId + "SMSel").addClassName("TDS" + sectorId + "SM");
				});
			});
			$("TD" + clickId).removeClassName("TDS" + sectorId + "SM").addClassName("TDS" + sectorId + "SMSel");
		}
	}
	
	if (subMnuWhenDisplay == "O"){
			$$("table#TS" + sectorId + " table.TSM" + subMnuChild ).each(function(element){
				element.setStyle({
					display: ("TSM" + clickId == element.id) ? ((element.getStyle("display") == GXPShowTable())? "none" : GXPShowTable()) : "none"
				});
			});
	}
	else{
		gxptableHS("TSM" + clickId);
	}
}
 
//Close Windows
function GXPClose() {
	window.close();
}

//
function GXPCloseAndRefresh() {
window.close();
if (window.opener) {parentdoc = window.opener.document;} 
else {parentdoc = window.dialogArguments.document;}
parentdoc.forms[0].submit();
}

//
function GXPCloseAndReload(){
window.close();
if (window.opener) {parentdoc = window.opener.location.reload(true);} 
else {parentdoc = window.dialogArguments.document;}
parentdoc.location.reload(true);}

//
function GXPCloseAndRedir(vURL) {
if (opener != null) {self.close();window.opener.document.location.replace(vURL);}}

//To display Flash
function GXPShowSWF(fileSWF,widthSWF,heightSWF){
var quality="high";
var linehtml="";
if (fileSWF){
  linehtml ='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"'
  if (!widthSWF){widthSWF=100};if (!heightSWF){heightSWF=100};
  linehtml+='WIDTH="'+widthSWF+'" HEIGHT="'+heightSWF+'" >\n'
  document.write(linehtml);
  linehtml ='<PARAM NAME=movie VALUE="'+fileSWF+'" />\n'
  document.write(linehtml);
  linehtml ='<PARAM NAME=quality VALUE='+quality+'>\n'
  document.write(linehtml);
  linehtml ='<PARAM NAME=wmode VALUE="transparent" /\n>'
  document.write(linehtml);
  linehtml ='<EMBED SRC="'+fileSWF+'" QUALITY="'+quality+'" WMODE="transparent" WIDTH="'+widthSWF+'" HEIGHT="'+heightSWF+'" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>'
  document.write(linehtml);
  linehtml ='</OBJECT>\n'
  document.write(linehtml);
}}

//
function InitScrollbar(SectorId, SizeDragBar, ScrollSchema, EnableHScroll, EnableVScroll, ShowTrack, ShowSector){
var wndo = new dw_scrollObj('WN' + SectorId, 'LYR' + SectorId, 'TS' + SectorId);
wndo.bSizeDragBar = SizeDragBar;
if (ScrollSchema != 'Y' & ShowTrack == 'Y'){
if (EnableVScroll == 'Y'){wndo.setUpScrollbar('DBV' + SectorId, 'TRV' + SectorId, 'v', 1, 1);}
if (EnableHScroll == 'Y'){wndo.setUpScrollbar('DBH' + SectorId, 'TRH' + SectorId, 'h', 1, 1);}}
if (ShowSector == 'N'){document.getElementById('SCR' + SectorId).style.display = 'none';}}

//
function GXPChgSecSize(sectorId, sectorHeight, sectorWidth)
{sectorTable = document.getElementById(sectorId);
if (sectorHeight != '' || sectorWidth != ''){
if (sectorTable){
var parNode = sectorTable;var found = false;var sfsectorNode;var sfsectorverNode;var lastsfsectorverTDNode;var lastsfsectorTDNode;
do{if (parNode){
parNode = parNode.parentNode;
if (parNode){
if (parNode.nodeName == 'TD' && !sfsectorNode){lastsfsectorTDNode = parNode;}
if (parNode.nodeName == 'TD' && !sfsectorverNode){lastsfsectorverTDNode = parNode;}
if (parNode.nodeName == 'TABLE'){
if (parNode.id.indexOf('SFSECTORVER') != -1){found = true;sfsectorverNode = parNode;}
else{
if (parNode.nodeName == 'TABLE' && parNode.id.indexOf('SFSECTOR') != -1){sfsectorNode = parNode;}}}}}}
while (parNode && !found)
if (sfsectorNode && sfsectorverNode && lastsfsectorverTDNode && lastsfsectorTDNode){
if (sectorHeight != ''){sfsectorNode.style.height = '100%';sfsectorverNode.style.height = '100%';lastsfsectorverTDNode.style.height = sectorHeight;}
if (sectorWidth != ''){lastsfsectorTDNode.style.width = sectorWidth;}}}}}

//Change cursor image on MouseOver/MouseOut
function GXPSwapCursor(object){
 if ((object.style.cursor=="default") || (object.style.cursor=="")) {
  if (GXportal.Variables.browser.ie){object.style.cursor="hand";}else{object.style.cursor="pointer";}
 }else{object.style.cursor="default";}
}

//Check Browser
function GXPChkBrw(){
	var brwsr = {ie: !(navigator.userAgent.indexOf("MSIE")==-1), ns: (navigator.userAgent.indexOf("MSIE")==-1)};
	return brwsr;
}

//
function GXPDynCode(codeTxt, codeType)
{
	this.code = codeTxt;
	this.type = codeType;
	return this;
}

//
function GXPProcessDynCode(aDynCode, aDynCodeCounter){
	i = 0;
	while (i < aDynCodeCounter)
	{
		if ((aDynCode[i] != null) & (aDynCode[i].code != null))
		{
			if (aDynCode[i].type != null)
			{
				if (aDynCode[i].type == "JS"){
					eval(aDynCode[i].code);
				}
				else {
					if (aDynCode[i].type == "HTML") {
						document.write(aDynCode[i].code);
					}
				}
			}
		}
		i += 1;
	}
}

//
function GXPChangeLng(LngId, CallerId, InFrame)
{
	if (InFrame == 1)
		docLocation = parent.location;
	else
		docLocation = document.location;
	
	qMarkPos = docLocation.href.indexOf("?");
	if (qMarkPos > -1)
		locHref = docLocation.href.substring(0, qMarkPos);
	else
		locHref = docLocation.href + ((CallerId == 1) ? "" : "?");
		
	GXPParms = docLocation.search.split(",");
	queryString = "";
	if (CallerId == 1 || (CallerId == 3 && docLocation.href.indexOf("/hgxpp001") == -1))
	{
		if (CallerId == 1)
		{
			sitePos = 3;
			pgmName = "hgxpt001";
		}
		else
		{
			sitePos = 2;
			pgmName = "hgxpt002";
		}
		locHref = locHref.replace(pgmName, "hgxpp003");
		hgxpt00xPos = docLocation.href.lastIndexOf("/") + 1;
		hgxpt00x = docLocation.href.substr(hgxpt00xPos, docLocation.href.length - hgxpt00xPos + 1);
		queryString = "?" + ((GXPParms[sitePos]) ? GXPParms[sitePos] : "") + ",P," + LngId + "," + escape(hgxpt00x);
	}
	else
	{		
		for (i = 0; (i < 8); i++)
		{
			if (i == 4)
				queryString += LngId;
			else
			{
				if (i == 6 && InFrame == 1)
				{
					queryString += "0";
				}
				else
				{
					if (GXPParms[i])
						queryString += GXPParms[i];
				}
				
			}
			if (i < 7)
				queryString += ",";
		}
	}
	docLocation.href = locHref + queryString;
}

function getElementId(el)
{
	if (el)
	{
		if (el.id && el.id != "")
			return el.id;
		else
		{
			if (el.name)
				return el.name;
		}
	}
	else
		return "";
}
