
/***************************************************************


 ***************************************************************/

var sFlag="";
var sFlagURL = "";

// ---- Browser check

var browser=navigator.appName;
var details=navigator.userAgent;





function displaySmartdeal( sSRC , sURL, sALT ) {
		if ( MM_FlashCanPlay ) {
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,29,0" width="165" height="183"><param name="movie" value="' + sSRC + '.swf?clickTag=' + sURL + '"><param name="wmode" value="transparent"><param name=quality value=high><embed src="' + sSRC + '.swf?clickTag=' + sURL + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent" type="application/x-shockwave-flash" width="165" height="183"></embed></object>');
		} else{
			// Flash is NOT installed.  Show animated gif.
		    document.write('<a href="' + sURL + '"><img src="' + sSRC + '.gif" alt="' + sALT + '" width="165" height="183" border="0"></a>');
		} 
}

	
	


// ---- Tab mouseOver/mouseOut event

function mOverTab( aImg ) {
	aImg.src = aImg.src.replace(".gif", "_over.gif");
}
function mOutTab( aImg ) {
	aImg.src = aImg.src.replace("_over.gif", ".gif");
}


// ---- CIN login script -->

function OpenThinClientEnglish()
{
	OpenThinClient("en_US");
}

function OpenThinClientFlemish()
{
	OpenThinClient("fl_BE");
}

function OpenThinClientFrench()
{
	OpenThinClient("fr_BE");
}

function OpenThinClient(langcode)
{
	var rand = Math.round(Math.random()*100000);

	var url = "https://www.internetnumber.citibank.com/Athena/PageServlet/thinclient.xsl?lang=" + langcode;
	var flags = "width=320,height=200,status=yes";
	
	//alert(url);
	
	if (InternetExplorer)
	{
		flags = flags + ",resizable=no";
	}
	else
	{
		flags = flags + ",resizable=yes";
	}		
	window.open(url,"WebCardThinClient"+rand,flags);
}

function OpenThinClientEnglishAOL()
{
	var rand = Math.round(Math.random()*100000);

	var url = "https://www.internetnumber.citibank.com/Athena/PageServlet/thinclient.xsl?lang=en_US";
	window.open(url,"WebCardThinClient"+rand,"width=465,height=200,resizable=no,status=yes");
}

function OpenThinClientFlemishAOL()
{
	var rand = Math.round(Math.random()*100000);

	var url = "Athena/PageServlet/thinclient.xsl?lang=fl_BE";
	window.open(url,"WebCardThinClient"+rand,"width=465,height=200,resizable=no,status=yes");
}

function OpenThinClientFrenchAOL()
{
	var rand = Math.round(Math.random()*100000);

	var url = "Athena/PageServlet/thinclient.xsl?lang=fr_BE";
	window.open(url,"WebCardThinClient"+rand,"width=465,height=200,resizable=no,status=yes");
}
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// ---- Netscape Resize CSS Fix

function WM_netscapeCssFix() {

  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}
function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}
WM_netscapeCssFixCheckIn()


// ---- Close popup window */

function closeWindow () 
{
	window.close();
}




if (!Array.prototype.push) Array.prototype.push = function() {
    for (var i=0; i<arguments.length; i++) this[this.length] = arguments[i];
    return this.length;
}

Array.prototype.find = function(value, start) {
    start = start || 0;
    for (var i=start; i<this.length; i++)
        if (this[i]==value)
            return i;
    return -1;
}

Array.prototype.has = function(value) {
    return this.find(value)!==-1;
}

// FUNCTIONAL

function map(list, func) {
    var result = [];
    func = func || function(v) {return v};
    for (var i=0; i < list.length; i++) result.push(func(list[i], i, list));
    return result;
}

function filter(list, func) {
    var result = [];
    func = func || function(v) {return v};
    map(list, function(v) { if (func(v)) result.push(v) } );
    return result;
}


// DOM

function getElem(elem) {
    if (document.getElementById) {
        if (typeof elem == "string") {
            elem = document.getElementById(elem);
            /*if (elem===null) throw 'cannot get element: element does not exist'*/;
        } else if (typeof elem != "object") {
            /*throw 'cannot get element: invalid datatype'*/;
        }
    } else /*throw 'cannot get element: unsupported DOM'*/;
    return elem;
}

function hasClass(elem, className) {
    return getElem(elem).className.split(' ').has(className);
}

function getElementsByClass(className, tagName, parentNode) {
    parentNode = !isUndefined(parentNode)? getElem(parentNode) : document;
    if (isUndefined(tagName)) tagName = '*';
    return filter(parentNode.getElementsByTagName(tagName),
        function(elem) { return hasClass(elem, className) });
}


// DOM EVENTS

function listen(event, elem, func) {
    elem = getElem(elem);
    if (elem.addEventListener)  // W3C DOM
        elem.addEventListener(event,func,false);
    else if (elem.attachEvent)  // IE DOM
        elem.attachEvent('on'+event, function(){ func(new W3CDOM_Event(elem)) } );
        // for IE we use a wrapper function that passes in a simplified faux Event object.
    else /*throw 'cannot add event listener'*/;
}

function mlisten(event, elem_list, func) {
    map(elem_list, function(elem) { listen(event, elem, func) } );
}

function W3CDOM_Event(currentTarget) {
    this.currentTarget  = currentTarget;
    this.preventDefault = function() { window.event.returnValue = false }
    return this;
}


// MISC CLEANING-AFTER-MICROSOFT STUFF

function isUndefined(v) {
    var undef;
    return v===undef;
}

// POP-UP

var _POPUP_FEATURES = '200,300';

function popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
}

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function event_popup(e) {
    // to be passed as an event listener
    // pops up a window grabbing the url from the event source's href
    link_popup(e.currentTarget);
    e.preventDefault();
}

function event_popup_features(features) {
    // generates an event listener similar to event_popup, but allowing window features
    return function(e) { link_popup(e.currentTarget, features); e.preventDefault() }
}

 

// ---- COOKIES
// eg. used in loans forms

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

// ---- FORMS

function disableElem( el ) {
    //alert( "disable " + el );
	document.getElementById(el).style.background = "#F1F1F1";
	document.getElementById(el).disabled = true;	
}

function enableElem( el ) {
	document.getElementById(el).style.background = "#FFFFFF";
	document.getElementById(el).disabled = false;	
}

// ---- Rollover behaviours buttons, links

function swap_over(e) { 
	if (document.getElementById) {
		var lImgID; 
		if ( e.target ) { lImgID = e.target.id } 
		else if ( window.event.srcElement ) { lImgID =  window.event.srcElement.id  }
		if ( lImgID ) {
			var lImg = document.getElementById(lImgID + "_img" );
			if ( lImg && lImg.src ) {
				var lImgSRC = lImg.src;
				lImgSRC = lImgSRC.replace("_over.gif","");
				lImgSRC = lImgSRC.replace(".gif","");
				lImg.src = lImgSRC + "_over.gif" ;
			}
		}
	}
	e.preventDefault();
}

function swap_out(e) {
	if (document.getElementById) {
		var lImgID; 
		if ( e.target ) { lImgID = e.target.id } 
		else if ( window.event.srcElement ) { lImgID =  window.event.srcElement.id  }
		if ( lImgID ) {
			var lImg = document.getElementById(lImgID + "_img" );
			if ( lImg && lImg.src ) {
				var lImgSRC = lImg.src;
				lImgSRC = lImgSRC.replace("_over.gif","");
				lImgSRC = lImgSRC.replace(".gif","");
				lImg.src = lImgSRC + ".gif" ;
			}
		}
	}
	e.preventDefault();
}

function swap_over_button(e) { 
	if (document.getElementById) {
		var lImgID; 
		if ( e.target ) { lImgID = e.target.id } 
		else if ( window.event.srcElement ) { lImgID =  window.event.srcElement.id  }
	    if ( lImgID ) {
			var lImg = document.getElementById(lImgID);
			if ( lImg && lImg.src ) {
				var lImgSRC = lImg.src;
				if (lImgSRC.indexOf("_over.gif") != -1 ) lImgSRC = lImgSRC.replace("_over.gif","");
				else if (lImgSRC.indexOf(".gif") != -1 ) lImgSRC = lImgSRC.replace(".gif","");
				lImg.src = lImgSRC + "_over.gif" ;
			}
		}
	}
	e.preventDefault();
}

function swap_out_button(e) {
	if (document.getElementById) {
		var lImgID; 
		if ( e.target ) { lImgID = e.target.id } 
		else if ( window.event.srcElement ) { lImgID =  window.event.srcElement.id  }
		if ( lImgID ) {
			var lImg = document.getElementById(lImgID);
			if ( lImg && lImg.src ) {
				var lImgSRC = lImg.src;
				if (lImgSRC.indexOf("_over.gif") != -1 ) lImgSRC = lImgSRC.replace("_over.gif","");
				else if (lImgSRC.indexOf(".gif") != -1 ) lImgSRC = lImgSRC.replace(".gif","");
				lImg.src = lImgSRC + ".gif" ; 
			}
		}
	}
	e.preventDefault();
}


// ---- Go to URL

function gotoURL(url) {
    location.href = url;
}

// ---- Tooltips


var offsetxpoint=-60; //Customize x offset of tooltip
var offsetypoint=20; //Customize y offset of tooltip
var ie=document.all;

//Detect IE5.5+
var ieVersion = 0;
if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE");
	ieVersion=parseFloat(temp[1]);
}


var ns6=document.getElementById && !document.all;

var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

var fields_arr;
function ddrivetip(thetext, thecolor, thewidth, fieldsToHide){
	
	if ( ns6|| (ie && ieVersion>=5.5) ){ 

		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		if ( fieldsToHide != undefined ) {
			//alert( fieldsToHide );
			if (typeof fieldsToHide!="undefined" && fieldsToHide!="" && fieldsToHide.indexOf(',')!=-1  ) {
				
				fields_arr = fieldsToHide.split(",");
				for ( var i=0; i<fields_arr.length; i++ ) {
					document.getElementById(fields_arr[i]).style.display = "none";
				}
			}
		}
		tipobj.innerHTML=thetext
		enabletip=true
		return false
		
	}
	else {
		/* Adapted by KDE
		   open a popup in browsers that do not support the tooltip  */
		var lTarget = "_blank";
		var lFeatures = "width=200,height=150";
		var myPop = raw_popup("", lTarget, lFeatures);
		myPop.document.open();
		myPop.document.write(thetext);
		myPop.document.close();
	}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
	if (ns6||ie) {
		enabletip=false;
		tipobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
		if (fields_arr!=undefined) {
		for ( var i=0; i<fields_arr.length; i++ ) {
			document.getElementById(fields_arr[i]).style.display = "block";
		}
		}
		fields_arr = [];
	}
}

// ---- speedbumps

/*
function goToExtURL( lURL ) {
	window.opener.location.href = lURL;
	//window.open( lURL );
	closeWindow();
}  KDL : adjusted function for N4 browsers : */
function goToExtURL( lURL ) {
	if (window.opener) { 
		window.opener.location.href = lURL; 
		closeWindow(); 
	}
	else { 
	  location.href = lURL;
	}
}


// ---- listeners

document.onmousemove=positiontip	

if (document.getElementById) {
listen('load', window, function() {
	mlisten('mouseover', getElementsByClass('l_apply','a'), swap_over );
	mlisten('mouseout', getElementsByClass('l_apply','a'), swap_out );
	mlisten('mouseover', getElementsByClass('l_detail','a'), swap_over );
	mlisten('mouseout', getElementsByClass('l_detail','a'), swap_out );
	mlisten('mouseover', getElementsByClass('button','a'), swap_over_button );
	mlisten('mouseout', getElementsByClass('button','a'), swap_out_button );
	
});
}


// ---- disable right click in IE ( called oncontextmenu )

function cutBubble()
{
    window.event.returnValue=false
}




function fn_flag(s)
{   

	sFlag ="1";
	
	document.location.href = s;

    
}


