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)}
}

//Change color of the row when Mouse Over
function ClrMouseOvr(src,clrOver) {if (!src.contains(event.fromElement)) {src.bgColor = clrOver;}}
function ClrMouseOut(src,clrIn) {if (!src.contains(event.toElement)) {src.bgColor = clrIn;}}
//Change image of the row when Mouse Over
function ImgMouseOvr(src,clrOver) {if (!src.contains(event.fromElement)) {src.background = clrOver;}}
function ImgMouseOut(src,clrIn) {if (!src.contains(event.toElement)) {src.background = clrIn;}}
//Change image of the option when Mouse Over
function PutImage(nameimg,imagen){document.images[nameimg].src = imagen;}
//Refresh IFRAME and Windows title
function GXPRedirToIF(url,wintitle) 
{GXPSetWinTitle(wintitle);document.frames["gxpiframe"].location.href = 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;}
//Cahnge Windows title
function GXPSetWinTitle(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);}
//Redir de Menú de combos
function GXPMnuCombo(selObj){
link = selObj.options[selObj.selectedIndex].value;
if(link.substr(0,11)=='javascript:'){link=link.substr(11,500);eval(link);}
else if(link!='*'){eval("location='"+selObj.options[selObj.selectedIndex].value+"'");}
}
//To change Anchor and TD class
function GXPChgClassOve(src,AnchId,ClassName) 
{if (!src.contains(event.fromElement)) 
  {src.style.cursor = 'hand';
   if (ClassName!=''){AnchId.className='A'+ClassName;src.className='TD'+ClassName;}
}}
function GXPChgClassOut(src,AnchId,ClassName) 
{if (!src.contains(event.toElement)) 
  {src.style.cursor = 'default';
   if (ClassName!=''){AnchId.className='A'+ClassName;src.className='TD'+ClassName;}
}}
//To collapse sectors
function gxptablestatus(tableName, flag, image, imgExpand, imgCollapse)
{table = document.getElementById(tableName);
 if( table.style.display == "none"){table.style.display = "inline";image.src = imgCollapse;flag.value = "0";}
 else {	table.style.display = "none";image.src = imgExpand;flag.value = "1";}}

//function gxptablestatus(tableName, flag, image, imgExpand, imgCollapse)
//{table = document.getElementById(tableName);
// if( table.style.display == "none"){table.style.display = "inline";image.src = imgCollapse;flag.value = "0";}
// else {	table.style.display = "none";image.src = imgExpand;flag.value = "1";}}

//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);}}
