/*
  Global section.
 */

var T = "";
var messages = new Array();
messages[0] = "Bem-vindo ao Citi";
messages[1] = "Bem-vindo ao C.i.t.i ";
messages[2] = "Bem-vindo";
messages[3] = "Bem-vindo ao C i t i ";
messages[4] = "Citi. Realiza com voc%EA.";
messages[5] = "Bem-vindo ao CITI ";
messages[6] = "Bem-vindo ao C:i:t:i ";
messages[7] = "";

//generarRandom(); //Change the title of the pages.

//==================================
//display the static page

function displayPage( mbName, url ) {
if( url != null && "" != url && url != "null" )
	window.location.href = '/'+mbName+'/JPS/portal/loadPage.do?path='+url;
}

//==================================
//display the static page with plain format

function displayPlainPage( mbName, url ) {
if( url != null && "" != url && url != "null" )
	window.location.href = '/'+mbName+'/JPS/portal/loadPlainPage.do?path='+url;
}

//==================================
//display the static page with plain format, neither header nor footer

function displayPopupPage( mbName, url, wn, winProp ) {
if( url != null && "" != url && url != "null" )
	url='/'+mbName+'/JPS/portal/loadPopupPage.do?path='+url;
	showPopup(url, wn, winProp);
}

function displayInPopupPage( mbName, url ) {
if( url != null && "" != url && url != "null" )
	window.location.href = '/'+mbName+'/JPS/portal/loadPopupPage.do?path='+url;
}

//==================================
//display the static page with help fotmat

function displayHelpPage( mbName, url ) {
if( url != null && "" != url && url != "null" )
	window.location.href = '/'+mbName+'/JPS/portal/displayHelp.do?path='+url;
}


//==================================
//Funcion para Sales forms

link = "https://www.latam.citibank.com/esales/";

function OpenWin(pais,prod, idio) {
	if (document.all) {
		var w = 800 - 10;
		var h = 600 - 57;
	}
	else if (document.layers) {
		var w = 800 - 10;
		var h = 600 - 57;
	} else {
		//asume netscape 6
		var w = 800 - 5;
		var h = 600 - 53;
	}

	winprops = "height=" + h + ",width=" + w + ",top=0,left=0,scrollbars=no,resizable=no,toolbar=no,status=yes,menubar=no";
	if (idio != null)
		win = window.open(link+"global/index.jsp?pais="+ pais +"&prod=" + prod + "&idioma=" + idio, "", winprops)
	else
		win = window.open(link+"global/index.jsp?pais="+ pais +"&prod=" + prod, "", winprops)
}


function getCurrentDateTime() {
    var currTime = new Date();
    var am_pm = "";
    var t_time = "";
    var hour="";
    var min = "";
    var sec = "";
    var year = "";
    var mon = "0";
    var day = "0";
    if(currTime.getHours() == 12) {
        hour=""+parseInt(currTime.getHours());
        am_pm="PM";
    }
    else if(currTime.getHours() > 12) {
        hour=""+parseInt(currTime.getHours());
        am_pm="PM";
    }
    else {
        hour=""+currTime.getHours();
        am_pm="AM";
    }
    if(currTime.getMinutes()<10)
        min="0"+currTime.getMinutes();
    else
        min=""+currTime.getMinutes();

    if(currTime.getSeconds()<10)
        sec=sec+currTime.getSeconds();
    else
        sec=""+currTime.getSeconds();

    t_time = hour + ":" + min;
    year = currTime.getYear();
    if( year < 2000 ) year= year + 1900;
    if(currTime.getMonth()+1<10)
        mon=mon+(currTime.getMonth()+1);
    else
        mon=""+(currTime.getMonth()+1);

    if(currTime.getDate()<10)
        day=day+currTime.getDate();
    else
        day=""+currTime.getDate();

    t_date = day + "/" + mon + "/" + year;
    return(t_date + "&nbsp;-&nbsp;" + t_time);
}

function abrirMaplink() {
  window.open('https://citi.bridgetrack.com/brazil/_redir.htm?BTData=7090D6B76686B684E554347B1BEB1AFA694938490FCFFF3EDEAC5C2DEFB91D51&BT_TRF=480206&BT_CON=62','MapLinkage','width=650,height=575,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes');
  var popup = displayPopupPage('BRGCB','/staticfiles/portuguese/resourcs/popup/branchespop.htm','Disclaimer','width=420,height=520,left=0,top=0,location=no,status=yes,scrollbars=no,resizable=yes,titlebar=yes,toolbar=no,directories=no,menubar=no');
}


function abrirMapLink(pagina) {
  window.open(pagina,"MapLinkPage","width=650,height=575,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes");
  var popup = displayPopupPage('BRGCB','/staticfiles/portuguese/resourcs/popup/branchespop.htm','Disclaimer','width=420,height=520,left=0,top=0,location=no,status=yes,scrollbars=no,resizable=yes,titlebar=yes,toolbar=no,directories=no,menubar=no');
}

function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
	   	return true;
	} else if (obj.attachEvent){
	   	var r = obj.attachEvent("on"+evType, fn);
	   	return r;
	} else {
	   	return false;
	}
}


/**
 * New layout functions and event handlers.
 *
 */


// Include a new script in the header.
//
function includeJS(jsUrl, force)
{
	try {
		if ( !force ) {
			var newJS = document.createElement('script');

			newJS.type = "text/javascript";
			newJS.language = "javascript";
			newJS.src = jsUrl;

			document.getElementsByTagName("head")[0].appendChild(newJS);
		}
		else {
			document.writeln('<script type="text/javascript" language="javascript" \
							  src="' + jsUrl + '" />');

		}

	}
	catch (err) {
		/* Force load? */

		document.writeln('<script type="text/javascript" language="javascript" \
						  src="' + jsUrl + '" />');
	}
}



/* ---------------------------------------------
   Function to change the Title of the pages
   ---------------------------------------------  */

function generarRandom() {
	num = Math.random() * 7;
	mC = Math.floor(num);
	T = messages[mC];
	cambiaTitle();
}

function cambiaTitle() {document.title = unescape(T);}



/* ---------------------------------------------
   Function to change the contact link at /BRGCB/ICARD/paysli/printPaymentSlip.do
   ---------------------------------------------  */

function changeContactLinkOfPaymentSlip() {
  var fnol = ( window.onload ? window.onload : null );
  window.onload = function() {
    if ( fnol ) fnol();
    var al = document.getElementsByTagName('a');
    for ( var k in al ) {
      var par = al[k].parentNode;
      if ( par.nodeName == 'TD' && par.className == 'apptxtlg' && al[k].className == 'linkNon' ) {
        al[k].href = '/atendimento';
        al[k].target = '_blank';
        break;
      }
    }
  }
}
if ( '/BRGCB/ICARD/paysli/printPaymentSlip.do' == location.pathname ) {
  changeContactLinkOfPaymentSlip();
}


