//change this based on server hostname
var v_hostname = "cam-qa.transunion.com"
//var v_hostname = "www.centralamerica.com"

var dCurrDate=new Date(); var dCurrYear=dCurrDate.getFullYear();
var v_copyright = "&copy;"+dCurrYear+" The copyright herein is owned by TransUnion Limited.&nbsp;<br> All rights are hereby reserved.";
var v_copyright_es = "&copy;"+dCurrYear+" TransUnion Todos los derechos reservados";

//global DOM defs
if(typeof Node=="undefined") {var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}}

//various globals:
var aLangCodes=[{"lang":"English","code":"en"},{"lang":"French","code":"fr"},{"lang":"Chinese","code":"zh"},{"lang":"Spanish","code":"es"}];
var countriesArray = new Array( ), mapArray = new Array(), startCountry, startLang;
var objOpened = null, objClosed = null, opened = false;
var aDecrImages = new Array, aIncrImages = new Array;
//fontsize range in em, with default index:
var aFontSizes=[.4375, .53125, .625, .71875, .8125, .90625], iDefFontIndex=2;
var iFontIndex = iDefFontIndex;
//messages:
var sMsgSelect="Please make a selection.";

//various onLoad events:
(window.attachEvent)?window.attachEvent('onload',footerFix):window.addEventListener('load',footerFix,false);
//initiate locator menu and flip lang if necessary:
(window.attachEvent) ? window.attachEvent('onload', initMenu) : window.addEventListener('load', initMenu, false);
//IE 7.x bug fix (footer placement):
if( navigator.userAgent.indexOf( 'MSIE 7.' ) != -1 ) {
//  (window.attachEvent) ? window.attachEvent('onload', footerFix ) : window.addEventListener('load', footerFix, false);
  (window.attachEvent) ? window.attachEvent('onload', ie7wrapper ) : window.addEventListener('load', ie7wrapper, false);
} //if IE7.x

//2006/11/01 pmackie@transunion.com
//if this is a "print" page, start processing:
if(isPrintable( document.URL )) {
  (window.attachEvent) ? window.attachEvent('onload', printPageRef ) : window.addEventListener('load', printPageRef, false);
} else { //for non-printables check font-size:
  (window.attachEvent) ? window.attachEvent('onload', initResize ) : window.addEventListener('load', initResize, false);
} //isPrintable

//2006/11/09 pmackie@transunion.com
//onload event handler for printable pages
//if this is a printable page, call printPage function with "current" target
function printPageRef() {
  var isPrintAll = getPrintAllValue( document.URL );
  if ( isPrintAll == '' ) isPrintAll = true;
  printPage( "current", isPrintAll );
} //printPageRef

//2006/12/11 pmackie@transunion.com
//various fixes for IE7.x
function ie7wrapper() {
  //footerFix();
  flipCSS();
}

//=============================COOKIES==============================
function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) {
  var sCookie = sName + "=" + encodeURIComponent(sValue);
  if (oExpires) sCookie += "; expires=" + oExpires.toGMTString();
  if (sPath) sCookie += "; path=" + sPath;
  if (sDomain) sCookie += "; domain=" + sDomain;
  if (bSecure) sCookie += "; secure";
  document.cookie = sCookie;
} //setCookie()
                                
function getCookie(sName) {
  var sRE = "(?:; )?" + sName + "=([^;]*);?";
  var oRE = new RegExp(sRE);
  return (oRE.test(document.cookie)) ? decodeURIComponent(RegExp["$1"]) : null;
} //getCookie()

function deleteCookie(sName, sPath, sDomain) {
  var sCookie = sName + "=; expires=" + (new Date(0)).toGMTString();
  if (sPath) sCookie += "; path=" + sPath;
  if (sDomain) sCookie += "; domain=" + sDomain;
  document.cookie = sCookie;
} //deleteCookie()
//=============================END OF COOKIES===========================


//helper function to open popup windows
function popWin( url, title, width, height ) {  
  var v_url = url;
  var params = 'toolbar=yes,location=no,status=yes,scrollbars=yes,resizable=yes';
  //append popup parameters:
  if( width ) params += ',width=' + width + ',height=' + height;
  var newWindow = window.open( v_url, title, params );
} //popWin()

//helper functions for pulldowns
//onClick goto selected page, where selected value is destination URL with optional arguments
//arguments might be appended to URL deciding on target:
//  window={ current | new | popupWIDTHxHEIGHT }
//    current will open in current window, new will open new window,

//    popup will open new window with specified width and height
//if no value is selected ( value == -1 | null ) then user will be prompted
//  to make a selection
function gotoLocale() {
  var v_selected=document.locale_form.listLocaleItems.options[document.locale_form.listLocaleItems.selectedIndex].value;
  var v_url, v_target;
  if(v_selected && v_selected != -1) {
    var v_argStart=v_selected.lastIndexOf("?");
	if(v_argStart == -1) { //no args passed, reload current page with passed url
		window.location=v_selected;
	} else { //parse args
		v_url=v_selected.slice(0,v_argStart);
		v_target=v_selected.substr(v_argStart+1).replace("window=","");
		if(v_target.substr(0,5)=='popup') { //popup, extract WIDTHxHEIGHT
			var v_numbers=v_target.substr(5);
			var v_width=v_numbers.substr(0,v_numbers.indexOf("x"));
			var v_height=v_numbers.substr(v_numbers.indexOf("x")+1);
			popWin(v_url,'popup',v_width,v_height) //open popup
		} else if(v_target.substr(0,3)=='new') {
			popWin(v_url,'popup',0,0) //open new window
		} else {  //all others open as current
			window.location=v_selected.substr(0,v_selected.indexOf("?"));
		} //if
    } //if
  } else { alert(sMsgSelect); }
} //gotoLocale()

function gotoLogin() {
  var v_selected=document.login_form.listLoginItems.options[document.login_form.listLoginItems.selectedIndex].value;
  var v_url, v_target;
  if(v_selected && v_selected != -1) {
	var v_argStart=v_selected.indexOf("&") != -1?v_selected.lastIndexOf("&"):v_selected.lastIndexOf("?");
	if(v_argStart == -1) { //no args passed, reload current page with passed url
	  window.location=v_selected;
	} else { //parse args
		v_url=v_selected.slice(0,v_argStart);
		v_target=v_selected.substr(v_argStart+1).replace("window=","");
		if(v_target.substr(0,5)=='popup') { //popup, extract WIDTHxHEIGHT
		  var v_numbers=v_target.substr(5);
		  var v_width=v_numbers.substr(0,v_numbers.indexOf("x"));
		  var v_height=v_numbers.substr(v_numbers.indexOf("x")+1);
		  popWin(v_url,'popup',v_width,v_height) //open popup
		} else if(v_target.substr(0,3)=='new') {
		  popWin(v_url,'popup') //open new window
		} else { //all others open as current
		  window.location=v_url;
		} //if
    } //if
  } else { alert(sMsgSelect); }
} //gotoLogin()

//Home Page true credit links that open in popup window
function popupHome(url)
{
  var opts = "location=no,status=no,titlebar=no,menubar=no,addressbar=no,scrollbars=yes,directories=no,resizable=no,screenX=0,screenY=0,toolbar=no,height=310,width=800, top=0, left=300";
  var hWnd = window.open(url,'mywindow', opts);
  hWnd.focus();
  return(false);
}

//popup for dispute wizard link
function disputeWizardWin(url) {
  var opts = "width=775,height=500,left=10,top=10,resizable=1,scrollbars=1,status=1,menubar=0,directories=0,location=0,toolbar=0";
  var hWnd = window.open(url,'DisputeOnlineWizard', opts);
  hWnd.focus();
}

//2006/11/01 pmackie@transunion.com
//fix footer for IE7.x
function footerFix() {
//alert('fixing IE7.x footer...');
    var divs = document.getElementsByTagName('div');
    for (var i=0; i < divs.length; i++) {
      if ('iw_component' == divs[i].className) {
        var hasPercentHeight = false;
        var elts = divs[i].childNodes;
        for (var j=0; !hasPercentHeight && (j<elts.length); j++) {
          if (1 == elts[j].nodeType) {
            var h = elts[j].getAttribute('height') || elts[j].style.height;
            if (-1 != h.indexOf('%')) hasPercentHeight = true;
          }
        }
        if (!hasPercentHeight) {
          var oldStyleHeight = divs[i].style.height;
          var expl = divs[i].offsetHeight;
          divs[i].style.height = 'auto';
          var auto = divs[i].offsetHeight;
          if (expl > auto) divs[i].style.height = oldStyleHeight;
        }
      }
    }
} //footerFix()

//2006/12/11 pmackie@transunion.com
//for IE7.x apply specific stylesheets
function flipCSS() {
  //array of stylesheet files:
/*
  var aStyles=[{"origName" : "siteCommon.css", "newName" : "siteCommonWrap.css"},
			   {"origName" : "promotion.css", "newName" : "promotionWrap.css"},
			   {"origName" : "leftNav.css", "newName" : "leftNavWrap.css"},
			   {"origName" : "siteBullets.css", "newName" : "siteBulletsWrap.css"},
			   {"origName" : "topNav.css", "newName" : "topNavWrap.css"}];
*/
  //array of IE7 flippable stylesheet files, append "_IE7" to filename, so d3.css will become d3_IE7.css
  var aStyles=["d3.css", "hp3.css", "h2p3.css", "p3.css", "pt3.css"];
  for(var i=0; i<document.styleSheets.length; i++)
	for(var j=0; j<aStyles.length; j++) {
	  var sHref=document.styleSheets[i].href;
	  if(sHref.substr(sHref.lastIndexOf('/')+1)==aStyles[j]) {
		//document.styleSheets[i].href=sHref.substring(0,sHref.lastIndexOf('/')+1)+aStyles[j].newName;
		document.styleSheets[i].href=sHref.substring(0,sHref.lastIndexOf('.'))+"_IE7.css";
		break;
	  } //if
	} //for aStyles
} //flipCSS()

/*
//function to check screen resolution and if crazy, reposition footer component to cover background image
function checkScreenRes() {
	//alert( 'in checkScreenRes' );
}
*/
//2006/08/02 pmackie@transunion.com
//function to remove trailing questionmark in link URL
//this is a workaround for LiveSite generated links with $PAGE_LINK[page] token
function removeQuestionMark( url ) {
  var v_url = url;
  if( v_url.lastIndexOf("?")!=-1 && v_url.lastIndexOf("?") == ( v_url.length-1 ) ) {
    v_url = v_url.substr( 0, v_url.length-1 );
  } //if
  return v_url;
} //removeQuestionMark()

function formAbandonment() {
  var v_object = document.getElementById('loadFile'); //check if dynamic form
  if( v_object ) {
    //there should be only 1 form except for login and locale forms
	var forms = document.forms;
    for( var i=0; i<forms.length; i++) {
      if( forms[i].name != 'locale_form' && forms[i].name != 'login_form') {
        //alert( 'will track form: ' + forms[i].name );
        fc_form_track = forms[i].name + "}" + forms[i].name;
      } //if form
    } //for
  } //if v_object
} //formAbandoment()

//2006/08/25 pmackie@transunion.com
//FireClick tracking, following are tracked (what==>how):
//popups==>media, external links==>ad, documents==>download
function track(_link, type) {
  if(type!='') {
    var v_url=_link.href;
    var v_name=_link.name;
    //if no friendly name exists, use href value
    if(v_name=="")v_name=v_url;
    //only allow type: ad, media, download. If ad, make sure the link is external
    if((type=='ad' && v_url.match(v_hostname)==null)
		|| type=='media' || type=='download')return fc_click(v_name, type);
    } else return true;
} //track()

//2007/01/10 pmackie@transunion.com
//same as track(), but URL is passed instead of link, used by LeftNav
function trackURL(sURL, sType) {
  if(sType!='')if((sType=='ad' && sURL.match(v_hostname)==null) || sType=='media' || sType=='download') return fc_click(sURL , sType);
  else return true;
} //trackURL()

//===========================FONT SIZE CHANGE===========================
//2006/11/22 pmackie@transunion.com
function preloadFontChangeImages() {
  aDecrImages[0] = new Image(); aDecrImages[0].src = "/images/artifacts/iconDecreaseOff.gif";
  aDecrImages[1] = new Image(); aDecrImages[1].src = "/images/artifacts/iconDecrease.gif";
  aIncrImages[0] = new Image(); aIncrImages[0].src = "/images/artifacts/iconIncreaseOff.gif";
  aIncrImages[1] = new Image(); aIncrImages[1].src = "/images/artifacts/iconIncrease.gif";
} //preloadFontChangeImages()

//2006/12/07 pmackie@transunion.com
//if font size stored in Cookie, use it:
function initResize() {
  var sFontIndex=getCookie("TUFontSize");
  if(sFontIndex) {
	iFontIndex=sFontIndex;
	document.body.style.fontSize = aFontSizes[sFontIndex] + 'em';
	var sMax = String(aFontSizes.length-1);
	switch( sFontIndex ) {
	  case "0":
	    var oButton=document.getElementById("font-minus");
		if(oButton) { oButton.src = aDecrImages[0].src; oButton.style.cursor = "default"; }
	    break;
	  case sMax:
	    var oButton=document.getElementById("font-plus");
		if(oButton) { oButton.src = aIncrImages[0].src; oButton.style.cursor = "default"; }
	    break;
	} //switch sFontIndex
  } //if sFontIndex
} //initResize()

//2006/10/16 pmackie@transunion.com
//change font-size globally by increment/decrement of .15em
//the range is 2 down and 3 up from default of .625em, and offset is .09375em (.15em * .625)
function changeFontSize( oButton, sOtherButton ) {
  if( !document.body.style.fontSize ) document.body.style.fontSize = aFontSizes[iDefFontIndex] + 'em';
  var buttonName = oButton.name, oOtherButton = document.getElementById( sOtherButton );
  switch( buttonName ) {
	case "font-minus":
	  //iFontIndex = iFontIndex <= 1 ? 0 : --iFontIndex;
	  if(iFontIndex <= 1) {
		iFontIndex = 0;
	    oButton.src = aDecrImages[0].src;
	    oButton.style.cursor = "default";
	  } else {
		--iFontIndex;
	    oOtherButton.src = aIncrImages[1].src;
	    oOtherButton.style.cursor = "pointer";
	  } //if
	  break;
	case "font-plus":
	  //iFontIndex = iFontIndex >= aFontSizes.length -2 ? aFontSizes.length -1 : ++iFontIndex;
	  if(iFontIndex >= aFontSizes.length -2) {
		iFontIndex = aFontSizes.length -1;
	    oButton.src = aIncrImages[0].src;
	    oButton.style.cursor = "default";
	  } else {
		++iFontIndex;
	    oOtherButton.src = aDecrImages[1].src;
	    oOtherButton.style.cursor = "pointer";
	  }
	  break;
  } //switch buttonName
  document.body.style.fontSize = aFontSizes[iFontIndex] + 'em';
  storeInCookie( iFontIndex );
} //changeFontSize()

function storeInCookie( sFontIndex ) {
  //var expires = new Date(); expires.setFullYear(expires.getFullYear() + 1); setCookie("TUFontSize", sFontIndex, expires);
  setCookie("TUFontSize", sFontIndex, '', '/');
} //storeInCookie
//===========================END OF FONT SIZE CHANGE===========================

//===========================PRINTABLE PAGE===========================
//2006/11/15 pmackie@transunion.com
//change line-height css property by parameter
//for all printable divs
function changePrintableLineHeight( fOffset ) {
  var divs = document.getElementsByTagName("div");
  for( var i=0; i < divs.length; i++ ) {
    if( divs[i].attributes.getNamedItem("printable") )
	  if( divs[i].attributes.getNamedItem("printable").nodeValue == "true" ) {
		//FIX: line height chagne
	  } //if nodeValue == true
  } //for divs
} //changePrintableLineHeight()

//2006/10/28 pmackie@transunion.com
//prepare and print print-friendly page
function printPage( printTarget, isPrintAll ) {
  var url = document.URL;
  var title = "printablePage";
  var firstDelimiter = getFirstDelimiter( url );
  /*if target is "current" generate printable page
    otherwise call popWin with appended url
    the popup (or new window) will then call this function again on load
	with current target and appended print arguments */
  switch( printTarget ) {
	case "popup":
	  url += firstDelimiter + "isPrintAll=" + isPrintAll + "&isClosable=true";
	  popWin( url, title, 640, 480 );
	  break;
	case "new":
	  url += firstDelimiter + "isPrintAll=" + isPrintAll + "&isClosable=true";
	  popWin( url, title );
	  break;
	case "current":  //generate printer friendly page:
	  if( isPrintAll == "false" ) {
        document.body.style.backgroundImage="none";
        ascendPrintables();  //propagate printable attribute to parent iw-components
		disableLinks();  //IE6 allow clicking even on modal window
        //liveSite creates horizontal wrapper layout divs, f.ex: <div style="width:931px;">
        //loop through these, and check if any children are printable
        var currNode = document.getElementsByTagName("div")[0];  //1st div is always 1st layout div
        truncateDiv(currNode,625);
		if( navigator.userAgent.indexOf( 'MSIE' ) == -1 ) { //don't print header for IE (bug, fix!)
          createPrintHeader( currNode );  //create popup print header before currNode
		} //if !IE7
        var isRelatedLinks = checkRelatedLinks(); //this will determine width truncation
        //create a treeWalker object to walk through layout divs, and process nodes:
        var walker = document.createTreeWalker( currNode, NodeFilter.SHOW_ELEMENT, null, false );
        do {
	      if( currNode.tagName == "DIV" ) processPrintNode( currNode, isRelatedLinks );
        }  while( currNode = walker.nextSibling() );
        createPrintFooter();  //create popup print footer
	  } //if !isPrintAll
	  setTimeout(printAndClose, 1000);
	  break;
  } //switch target
} //printPage()

function printAndClose() {
  window.print();
  if(isClosable(document.URL)) self.close();
} //printAndClose()

function disableLinks() {
  for (var i=0;i < document.links.length;i++) document.links[i].onclick = retFalse;
} //disableLinks()
function retFalse () {
  return false;
} //retFalse()

//2006/10/18 pmackie@transunion.com
//check which part of current node is appropriate for printing
//hide the rest
function processPrintNode( currNode, isRelatedLinks ) {
  //if current node have printable elements check which ones
  //otherwise hide the whole node:
  if( containsPrintableDivs( currNode ) ) {
	truncateDiv(currNode,625);
	//found a printable, by default print the whole div layout node 
	//  except for explicitly defined non-printable descendants
	//  and printable images as text
	var iWidth = isRelatedLinks ? 705 : 625;
	truncateWidth (currNode,iWidth);
    var divs = currNode.getElementsByTagName("div");
	for( var i=0; i < divs.length; i++ ) {
	  if( divs[i].attributes.getNamedItem("printable") ) {
		var printableValue = divs[i].attributes.getNamedItem("printable").nodeValue;
        switch( printableValue ) {
	      case "false":
	        hideNodeTree( divs[i] );
	        break;
	      case "text":
			convertImageToText( divs[i] );
		    break;
		} //switch printableValue
	  } //if printable defined
	} //for divs
  } else {  //no printables in current node, hide the whole div layout node
	hideNodeTree( currNode );
  } //if containsPrintableDivs
} //processPrintNode();

//2006/10/18 pmackie@transunion.com
//check if current node has any printable div elements (descendants incl. self)
//i.e. elements with "printable=true" attribute
function containsPrintableDivs( currNode ) {
  if( currNode.attributes.getNamedItem("printable") ) {  //check self
	if( currNode.attributes.getNamedItem("printable").nodeValue == "true" ) {
	  return true;
	}
  } else { //check descendants
    var divs = currNode.getElementsByTagName("div");
	for( var i=0; i < divs.length; i++ ) {
	  if( divs[i].attributes.getNamedItem("printable") ) {
	    if( divs[i].attributes.getNamedItem("printable").nodeValue == "true" ) { 
		  return true;
		} //if printable true
	  } //if printable defined
	} //for divs
  } //if self/descendants
  return false;
} //containsPrintableDivs()

//2006/10/19 pmackie@transunion.com
//hide whole node tree (currNode and div descendants)
function hideNodeTree( currNode ) {
  currNode.style.display = "none";
  var divs = currNode.getElementsByTagName( "div" );
  for( var i=0; i < divs.length; i++ ) {
	divs[i].style.display = "none";
  } //for divs
} //hideNodeTree()

//2006/10/19 pmackie@transunion.com
//create custom print header based on popup template
//insert before currNode, which is 1st layout div
function createPrintHeader( currNode ) {
  //header consists of 3 main div wrappers:
  var headerDiv1 = document.createElement( "div" );
  var headerDiv2 = document.createElement( "div" );
  var headerDiv3 = document.createElement( "div" );
  headerDiv1.setAttribute( "style", "width:626px;" );
  headerDiv2.setAttribute( "style", "width:626px;" );
  headerDiv3.setAttribute( "style", "width:626px;" );
  if(getLang(location.pathname)!='en') { //Chinese header:
headerDiv1.innerHTML = '\n'
+'<div style="clear:both;display:inline;float:left;">\n'
+'<div style="display:inline;float:left;">\n'
+'<div class="iw_component" style="clear:both;width:600px;height:80px;display:inline;float:left;">\n'
+'<div id="header" printable="false">\n'
+'<div class="floatLeftImage">\n'
+'<a name="dummy" class="imageLinkClass" href="dummy"><img class="imageClass" title="TransUnion ??" alt="TransUnion ??" src="/images/global/logo1.gif"></a></div>\n'
+'<div class="globalUtility">\n'
+'<div class="globalUtilityLinkDiv">\n'
+'<a name="dummy" class="globalUtilityLink" href="dummy"????</a></div>\n'
+'</div></div></div></div></div>\n';
} else { //English header:
headerDiv1.innerHTML = '\n'
+'<div style="clear:both;display:inline;float:left;">\n'
+'<div style="display:inline;float:left;">\n'
+'<div class="iw_component" style="clear:both;width:600px;height:80px;display:inline;float:left;">\n'
+'<div id="header" printable="false">\n'
+'<div class="floatLeftImage">\n'
+'<a name="dummy" class="imageLinkClass" href="dummy"><img class="imageClass" title="TransUnion logo" alt="TransUnion logo" src="/images/global/logo1.gif"></a></div>\n'
+'<div class="globalUtility">\n'
+'<div class="globalUtilityLinkDiv">\n'
+'<a name="dummy" class="globalUtilityLink" href="dummy">Close Window</a></div>\n'
+'</div>\n</div>\n</div>\n</div>\n</div>\n';
  } //if
headerDiv2.innerHTML = '\n'
+  '<div style="clear: both; display: inline; float: left;">\n'
+    '<div style="display: inline; float: left;">\n'
+      '<div class="iw_component" style="clear: both; width: 625px; height: auto; display: inline; float: left;"><img src="/images/artifacts/colorBlockDark.gif" alt="" style="border: 0px solid rgb(0, 0, 0);" height="30" width="625">\n'
+      '</div>\n'
+	'</div>\n'
+  '</div>\n';
headerDiv3.innerHTML = '\n'
+  '<div style="clear: both; display: inline; float: left; margin-top: 1px;">\n'
+    '<div style="display: inline; float: left;">\n'
+      '<div class="iw_component" style="clear: both; width: 625px; height: auto; display: inline; float: left;">\n'
+        '<div class="imageClass" printable="true">\n'
+          '<img style="margin: auto; display: block; position: relative; top: 0px;" title="" alt="" src="/images/artifacts/divider12.gif" height="6" width="625"></div>\n'
+        '</div>\n'
+      '</div>\n'
+	'</div>\n'
+  '</div>\n';
  document.body.insertBefore( headerDiv3, currNode );
  document.body.insertBefore( headerDiv2, headerDiv3 );
  document.body.insertBefore( headerDiv1, headerDiv2 );
}  //createPrintHeader()

//2006/10/19 pmackie@transunion.com
//create custom print footer based on popup template
//insert as last child of body
function createPrintFooter() {
  var footerDiv=document.createElement("div");
  footerDiv.setAttribute("style","width:626px;"); 
  document.body.appendChild(footerDiv);
  if(getLang(location.pathname)!='en') { //Spanish footer:
footerDiv.innerHTML = '<div style="clear:both;display:inline;float:left;margin-top:1px;">\n'
+'<div style="display:inline;float:left;">\n'
+'<div class="iw_component" style="clear:both;width:625px;height:40px;display:inline;float:left;">\n'
+'<div id="footerPopup" printable="false">\n'
+'<div class="footerText">'+v_copyright_es+'</div>\n'
+'<div class="footerPipe">\n'
+'<img class="imageClass" title="" alt="" src="/images/global/footerPipe.gif"></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">Mapa del Sitio</a></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">Pol\u00edtica de Privacidad</a></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">T\u00e9rminos de Uso</a></div>\n'
+'</div>\n</div>\n</div>\n</div>\n';
  } else { //English footer:
  footerDiv.innerHTML = '<div style="clear:both;display:inline;float:left;margin-top:1px;">\n'
+'<div style="display:inline;float:left;"><div class="iw_component" style="clear:both;width:625px;height:40px;display:inline;float:left;">\n'
+'<div id="footerPopup" printable="false">\n'
+'<div class="footerText">'+v_copyright+'</div>\n'
+'<div class="footerPipe"><img class="imageClass" title="" alt="" src="/images/global/footerPipe.gif"></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">Site Map</a></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">Privacy Policy</a></div>\n'
+'<div class="footerLinkDiv">\n'
+'<a name="dummy" class="footerLink" href="dummy">Terms of Use</a></div>\n'
+'</div>\n</div>\n</div>\n</div>\n';
  } //if
}  //createPrintFooter()

//2006/10/20 pmackie@transunion.com
//loop through divs and images for oNode, and truncate their width property
//according to rules:
//for related links pages: if > 415 set to 415
//for non-related links pages: if > 626 set to 625
//
//also for divs: change left-margin property, if > 25 set to 25
function truncateWidth( oNode, sWidth ) {
  var objWidth = '', objMarginLeft = '';
  var divs = oNode.getElementsByTagName('div'); //truncate descendant divs
  for( var i=0; i < divs.length; i++ ) {
	truncateDiv(divs[i],sWidth);
    objMarginLeft = divs[i].style.marginLeft;
	if( objMarginLeft != '' && parseInt( objMarginLeft ) > 25 )
	  divs[i].style.marginLeft = 25 + "px";
  } //for divs
  var images = oNode.getElementsByTagName('img');
  for( var i=0; i < images.length; i++ ) {
	if( images[i].attributes.getNamedItem("width") ) {
      objWidth = images[i].attributes.getNamedItem("width").nodeValue;
      if(objWidth!='' && parseInt(objWidth)>626)images[i].attributes.getNamedItem("width").nodeValue = 625;
      else if(objWidth!='' && parseInt(objWidth)>415)images[i].attributes.getNamedItem("width").nodeValue = 415;
	} //if
  } //for images
} //truncateWidth()

function truncateDiv(oNode, sWidth) {
  if( oNode.attributes.getNamedItem("style") ) {
    objWidth = oNode.style.width;
    if(objWidth!='' && parseInt(objWidth)>sWidth) oNode.style.width = parseInt(sWidth) + "px";
  } 
} //truncateDiv()

//2006/10/20 pmackie@transunion.com
//loop through all divs with printable attribute and copy to parent iw_component
function ascendPrintables() {
  var divs = document.getElementsByTagName('div');
  for( var i=0; i < divs.length; i++ ) {
	if( divs[i].attributes.getNamedItem("printable") )
	  ascendPrintable( divs[i], divs[i].attributes.getNamedItem("printable").nodeValue );
  } //for divs
}  //ascendPrintables()

//2006/10/20 pmackie@transunion.com
//copy printable attribute to iw-component parent div (if exists):
//by default copy printable value as is, exception is "text" value which copies as "true"
function ascendPrintable( oNode, printable ) {
  //create a treeWalker object to find oNode's parent
  var walker = document.createTreeWalker( oNode, NodeFilter.SHOW_ELEMENT, null, false );
  var parentNode = walker.parentNode();
  if( parentNode.tagName == "DIV" && parentNode.attributes.getNamedItem("class") ) {
	if( parentNode.attributes.getNamedItem("class").nodeValue == "iw_component" ) {
	  if( printable == "text" ) printable = "true";
      parentNode.setAttribute( "printable", printable );
	} //if iw_component
  } //if DIV
} //ascendPrintable()

//2006/11/01 pmackie@transunion.com
//convert image inside oNode to text
function convertImageToText( oNode ) {
  var sText = "NO ALT TEXT DEFINED";
  var images = oNode.getElementsByTagName( "img" ); //should have only 1 image
  if( images[0].attributes.getNamedItem("alt") )
	sText = images[0].attributes.getNamedItem("alt").nodeValue;  //retrieve text from alt
  //create textDiv and replace image div with it:
  var textDiv = document.createElement( "div" );
  //textDiv.setAttribute( "style", "margin-top: 25px;" ); 
  oNode.parentNode.replaceChild( textDiv, oNode );
  textDiv.innerHTML = '<h1 style="padding-left:25px; margin-top:25px;">' + sText + '</h1>'
+ '<div style="width:1px; height:20px;">'
+ '<img src="/images/global/spacer.gif" />';
+ '</div>';
} //convertImageToText()

//2006/10/20 pmackie@transunion.com
//check if page has at least 1 related links component
function checkRelatedLinks() {
  var divs = document.getElementsByTagName('div');
  for( var i=0; i < divs.length; i++ ) {
	if( divs[i].attributes.getNamedItem("class") ) {
	  if( divs[i].attributes.getNamedItem("class").nodeValue.indexOf( "relatedLinks" ) != -1 )
	    return true;
	} //if class
  } //for divs
  return false;
}  //checkRelatedLinks()

//2006/10/30 pmackie@transunion.com
//check if a questionmark exists already in passed url
//if yes, return "&", otherwise return "?"
function getFirstDelimiter( url ) {
  return (url.indexOf("?")!=-1) ? "&" : "?";
} //getFirstDelimiter

//2006/10/30 pmackie@transunion.com
//check passed url has "isClosable=true" argument pair
function isClosable( url ) {
  return (url.match("isClosable=true")!=null) ? true : false;
} //isClosable()

//2006/10/30 pmackie@transunion.com
//check if passed url has "isPrintAll="
function isPrintable( url ) {
  return (url.match("isPrintAll=")!=null) ? true : false;
} //isPrintable()

//2006/10/30 pmackie@transunion.com
//get isPrintAll value from url arguments
//return null if non-existent
function getPrintAllValue( url ) {
  var printPos = url.indexOf( "isPrintAll=" );
  if( printPos != -1 ) {
    var args = url.substr( printPos );
	if( args.match( "&" ) != null ) args = args.substring( 0,  args.indexOf( "&" ) );
	return args.substr( args.indexOf( "=" ) + 1 );
  } //if isPrintAll
  return null;
} //getPrintAllValue()
//===========================END OF PRINTABLE PAGE===========================

//===========================LOCATOR===========================
function initMenu() {
  //if((location.pathname=='/' || location.pathname=='') && getCookie("TULang")=='en')location.href="http:\/\/"+v_hostname+"/home_en.html"; //redirect no-path URL to English if English cookie set
  if((location.pathname=='/' || location.pathname=='') && getCookie("TULang")=='en')location.href="home_en.html"; //redirect no-path URL to English if English cookie set
  initLocator();
  updateLocator(); //on soft refresh read from selections from pulldowns
  document.getElementById('imageClosed').onclick = toggleMenu;
  document.getElementById('imageOpened').onclick = closeMenu;
  var oGo=document.getElementById('imageGo');
  oGo.onclick = locatorGo;
  //oGo.style.cursor="pointer"; //defined in css
  (window.attachEvent) ? document.attachEvent('onclick', possiblyClose) : window.addEventListener('click', possiblyClose, false);
  //don't close opened locator if click inside locator:
  document.getElementById('locatorWrap').onclick = stopBubble;  
  //see if lang stored in cookie, if yes point selector to that lang:
  var sLang=getCookie("TULang");
  if(sLang) {  //cookie exists
    var oLang=document.getElementById('selectLanguage');
	if(oLang) {
	  var sLang=oLang.options[oLang.selectedIndex].text;
	  //alert('sLang = '+sLang);
	} //if oCountry
	//alert('selected lang = '+oLang.options[oLang.selectedIndex].text);
  } //if sLang cookie

}  //initMenu()

function locatorGo() {
  updateLocator();
  closeMenu();
  flipLanguageWrap(document.locatorForm.selectLocator,document.locatorForm.selectLanguage);
} //locatorGo()

function stopBubble( oEvent ) {
  ( typeof oEvent == "undefined" ) ? event.cancelBubble = true : oEvent.stopPropagation();
} //stopBubble()

function closeMenu() {
  objOpened = document.getElementById('locatorOpened');
  objClosed = document.getElementById('locatorClosed');
  objOpened.style.display = 'none';
  objClosed.style.display = 'block';
  opened = false;
}  //closeMenu()

function possiblyClose() {
  if( opened ) closeMenu();
} //possiblyClose()

function toggleMenu() {
  objOpened = document.getElementById('locatorOpened');
  objClosed = document.getElementById('locatorClosed');
  if( opened ) {
    objOpened.style.display = 'none';
    objClosed.style.display = 'block';
    opened = false;
  } else {
    objClosed.style.display = 'none';
    objOpened.style.display = 'block';
    opened = true;
  } //if opened
}  //toggleMenu()

//update locator display based on selects:
function updateLocator() {
  var docForm = document.locatorForm;
  var loc = docForm.selectLocator.options[docForm.selectLocator.selectedIndex].text;
  var locLen = loc.length + 1;
  var objDispLoc = document.getElementById( 'locCountry' );
  var objDispLang = document.getElementById( 'locLanguage' );
  objDispLoc.innerHTML = loc + ':';
  //loop through languages, check which selected, and generate output:
  var langs = '', langsLen = 0;
  var selIndex = docForm.selectLanguage.selectedIndex;
  //langs += docForm.selectLanguage.options[selIndex].text;
  langs += '<a onclick="toggleMenu(); return false;" class="locLanguageLink">'+docForm.selectLanguage.options[selIndex].text+'</a>';
  for( var i = 0; i < docForm.selectLanguage.length; i++ ) {
	langsLen += docForm.selectLanguage.options[i].text.length;
    if(i==selIndex)continue; //skip selected, already printed
	langs += '&nbsp;<img class="localePipeAlign" src="/images/artifacts/localePipe.gif"/>&nbsp;';
	var sText = docForm.selectLanguage.options[i].text, sURL = docForm.selectLanguage.options[i].value;
	langs += '<a class="localeLink" onclick="updateLocator2('+i+');flipLanguage(\''+loc+'\',\''+sText+'\',\''+sURL+'\');return false;" href="' + docForm.selectLanguage.options[i].value + '">' + sText + '</a>';
  } //for langs
  adjustLocatorWidth(locLen, langsLen, objDispLang, docForm.selectLanguage.length);
  objDispLang.innerHTML = langs;
} //updateLocator()

//update locator display based on click:
function updateLocator2(sLangIndex) {
  var oSelLang=document.getElementById('selectLanguage');
  oSelLang.selectedIndex=sLangIndex;
  updateLocator();
} //updateLocator2()

function adjustLocatorWidth(sLocLen, sLangsLen, oDispLang, sLength) {
  var objLocWrap = document.getElementById('locatorWrap');
  var objLocClosed = document.getElementById('locatorClosed');
  var objLocOpened = document.getElementById('locatorOpened');
  var langsWidth = 40, width = 200;  //defaults
  if(sLength > 1) {  //calculated width if more than 1 language
    langsWidth=6.0*sLangsLen+10*(sLength-1);
    width = 6.5*sLocLen + langsWidth + 50;
  }  //if selectLanguage.length
  width = width<175?175:width; //make sure no less than min
  oDispLang.style.width = langsWidth + 'px';
  objLocWrap.style.width = width + 'px';
  objLocClosed.style.width = width + 'px';
  objLocOpened.style.width = width + 'px';
} //adjustLocatorWidth()

//initialize locator selects:
function initLocator() {
  //populate countries:
  var countrySelect=document.getElementById('selectLocator');
  for(var i=0; i<countriesArray.length; i++) {
	var sText=countriesArray[i].substr(0,countriesArray[i].indexOf('|'));
	var sSelected=countriesArray[i].substr(countriesArray[i].lastIndexOf('|')+1)=="Yes"?true:false;
    countrySelect.options[i]=new Option(sText,i,sSelected,sSelected);
	if(sSelected){
	  countrySelect.selectedIndex=i; //IE Bug workaround
	  startCountry=sText;
	} //if sSelected
  }  //for countries
  populateLanguages(countrySelect.selectedIndex);  //populate languages based on country selection
  updateLocator();  //write to "closed" div current selection
} //initLocator()

//populate languages based on country selection:
function populateLanguages(countryIndex) {
  var languageSelect=document.getElementById('selectLanguage');
  languageSelect.length=0; //nullify first
  if( countryIndex<0)countryIndex=0;  //make sure there is a default
  //extract option values from mapArray:
  for(var i=0; i<mapArray[countryIndex].length; i++) {
	var sMap=mapArray[countryIndex][i];
	var sText=sMap.substr(0,sMap.indexOf('|'));
    var sURL=sMap.substring(sMap.indexOf('|')+1, sMap.lastIndexOf('|'));
	var sSelected=sMap.substr(sMap.lastIndexOf('|')+1)=="Yes"?true:false;
	languageSelect.options[i]=new Option(sText,sURL,sSelected,sSelected );
	if(sSelected) {
	  languageSelect.selectedIndex=i; //IE Bug workaround
	  startLang=sText;
	} //if sSelected
  }  //for languages
}  //populateLanguages()

//2006/11/22 pmackie@transunion.com
//get country, language, and url from selects, and pass along to flipLanguage()
function flipLanguageWrap(oLocSelect,oLangSelect) {
  flipLanguage(oLocSelect.options[oLocSelect.selectedIndex].text,oLangSelect.options[oLangSelect.selectedIndex].text,oLangSelect.options[oLangSelect.selectedIndex].value);
} //flipLanguage()

//2006/11/22 pmackie@transunion.com
//flip language on current page based on clicked oLink
//if both current and destination pages have lang in URL (_<lang>.suffix) use current filename with flipped lang
//otherwise goto sURL. If lang can be defined bake cookie with proper lang code.
function flipLanguage(sCountry,sLang,sURL) {
  if(sCountry==startCountry) {
    var sCurrLang, sDestLang;
    sCurrLang=getLang(location.pathname);
    if(sCurrLang)sDestLang=getLang(sURL);
    if(sDestLang) { //lang is flipped, so change sURL and bake 1yr cookie
	  sURL=flipLangInURL(location.pathname,sCurrLang,sDestLang);
	  saveLangInCookie(sDestLang);
    } else { //no sDestLang, but still need to bake cookie, try to retrieve it from aLangCodes object
      var sLangCode=getLangCode(sLang);
	  if(sLangCode)saveLangInCookie(sLangCode);
    } //if sDestLang
  } //if same country
  //alert( 'will go to: ' + sURL );
 window.location = sURL;
} //flipLanguage()

//2007/02/23 pmackie@transunion.com
//extract lang from path, for example: blah_fr.page will return "fr"
//return undefined if not found
function getLang(sPath) {
  var sNoSuffix=sPath.substr(0,sPath.lastIndexOf('.'));
  return sNoSuffix.indexOf('_')!=-1?sNoSuffix.substr(sNoSuffix.lastIndexOf('_')+1):undefined;
} //getLang()

function getLangCode(sLang) {
  for(var i=0; i<aLangCodes.length; i++)if(aLangCodes[i].lang==sLang)return aLangCodes[i].code;
  return undefined;
} //getLangCode()

//2007/02/23 pmackie@transunion.com
//flip lang in sURL from sCurrLang to sDestLang
function flipLangInURL(sURL,sCurrLang,sDestLang) {
  var sStr="_";
  var sOld=sStr.concat(sCurrLang).concat(".");
  var sNew=sStr.concat(sDestLang).concat(".");
  return sURL.replace(sOld,sNew);
} //flipLangInURL()

//2007/02/23 pmackie@transunion.com
//bake cookie with sLang
function saveLangInCookie(sLang) {
  var expires=new Date(); expires.setFullYear(expires.getFullYear()+1); setCookie("TULang", sLang, expires, '/');
} //saveLangInCookie()
//===========================END OF LOCATOR===========================
