function go_country(){
	var dd = document.forms["frmCountries"].countryDLL;
	var thehref = dd.options[dd.selectedIndex].value;
	dd.selectedIndex = 0;
	window.location.href = thehref;
	return (false);
}
function checkSearch(name){
	
	if (name == "" || name == null){
		name = "sp-q";
	}
	var srch = document.getElementById( name );
	var sstr = srch.value;
	if (sstr=="") {
		return (false);
	} else {
		if(name=="sp-q"){
			sstr = escape(sstr.replace("&"," "));
		}
		srch.value = sstr;
		return (true);
	}
}
function printPreview(){
	var locn = window.location.pathname;
	var qs = window.location.search;
	if (qs != "") {
		locn = locn + qs;
	}
	window.open("/servlet/pwcPrintPreview?LNLoc=" + locn);
	return (true);
}
// This function replaces characters to be displayed back to the browser with xss safe characters
function removeSpecialChars(input) {
var output = "";
var char="";
for (count = 0 ; count < input.length ; count ++) {
	switch (input.charAt(count)) {
		case "<":
			output = output + "<";
			break;
		case ">":
			output = output + ">";
			break;
		case '"':
			output = output + '"';
			break;
		case "'":
			output = output + "'";
			break;
		case ")":
			output = output + ")";
			break;
		case "(":
			output = output + "(";
			break;
		case "+":
			output = output + "+";
			break;
		case "&":
			output = output + "&";
			break;
		case ";":
			output = output + ";";
			break;
		default:
			output = output + input.charAt(count);
			break;
	}
}
return output;
} // End removeSpecialChars(input)
var aRVP  = new Array();
var sRVPBoxTitle =  '<span class="RVPTitle">Recently visited pages</span>';
var sRVPCookieText = '<div class="RVPOffMessage">Please enable cookies on your browser to activate this functionality.</div><ul><li><a href="/gx/eng/main/privacy/index.html" target="_self" title="Privacy">Privacy</a></li></ul>';
var cookieDomain = "";
if( window.location.host.indexOf(".pwc.com") == -1 ){
	cookieDomain = "";
} else {
	cookieDomain = "; domain=pwc.com";
}
document.cookie = "PwC=PwC; path=/" + cookieDomain;
var cookieenabled = (document.cookie.indexOf("PwC=") != -1) ? true : false
//checks if current page needs to be recorded in the cookie
function processRVP()
{
     var pos;
  
  // checks if cookies are enabled
  if (!(cookieenabled)) {return;}
 
 //read cookie and load global array
  readRVPCookie();
   
   //check for the indicator to record this url
   // 0 = not to record; any value = record
   if (readMetaTag("RVPFlag") == "0")  return; 
  
   // check for # sign followed by any
       var tUrl = document.location.href;
       if (tUrl.indexOf('#') != -1) {tUrl = tUrl.substring(0,tUrl.indexOf('#')); }
        
   if (!(recentRVP(tUrl)))
   {
     
       // get link description
      var sRVPTitle = readMetaTag("RVPTitle");
      if (sRVPTitle == "") 
      {  
          //get title from <title> tag
         sRVPTitle = document.title;
          if (typeof sRVPTitle != "undefined")
          {
	             // searches for something like "..& PricewaterhouseCoopers:!## Test "
	             var mt = new RegExp(/^([^a-zA-Z0-9]*)PricewaterhouseCoopers([^a-zA-Z0-9]*)\s/i);
	             sRVPTitle = sRVPTitle.replace(mt,"");
           }
          else {sRVPTitle = "";}
      }
         
      //record values in the cookie 
     if ((sRVPTitle != "") && (typeof sRVPTitle != "undefined") && (sRVPTitle != "undefined"))
     { 
       var pageInfo = escape(tUrl) + "~~" + escape(sRVPTitle) + "~~_self~~0~~~" ;
        recordRVP(pageInfo);
       //repoopulate global array
       readRVPCookie();
     }
  
    }
 
}
  
// record in the cookie as requested
function processbyreqRVP(title,url,target)
{  
   // checks if cookies are enabled
   if (!(cookieenabled)) {return;}
  
   // checks if title and url are provided
   if ((title == "") || (url == "")) {return;}
  
   // check for # sign followed by any
       var tUrl = url;
       if (tUrl.indexOf('#') != -1) {tUrl = tUrl.substring(0,tUrl.indexOf('#')); }
        
   if (!(recentRVP(tUrl)))
   { 
     //record values in the cookie 
      if  ( (!(target)) || (target == '')) var pageInfo = escape(tUrl) + "~~" + escape(title) + "~~_blank~~1~~~" ;
      else var pageInfo = escape(tUrl) + "~~" + escape(title) + "~~" + target + "~~1~~~" ;
      recordRVP(pageInfo);
    
    //repoopulate global array
    readRVPCookie();
   }
   
 }
// record URL as most RVP in the cookie
function recordRVP(pageInfo)
{
   // checks if cookies are enabled
   if (!(cookieenabled)) {return;}
 
   var cookieSTR =  "RVPLinks=" + pageInfo;
   for (var i=0; i < aRVP.length; i++)
    { 
        if ((aRVP[i]) && (aRVP[i]  != "")) cookieSTR =  cookieSTR + aRVP[i] + "~~~";
        if (i >= 4) break; 
     }
   document.cookie = cookieSTR + ";path=/" + cookieDomain;
 }
// checks if URL is recorded as the most recent RVP
function recentRVP(url)
{
if ( (!(aRVP[0])) || (aRVP[0] == "") ) {return false;}
//checks first entry
var tRVP = aRVP[0].split("~~");
if (tRVP[0] == escape(url)) {return true;}
           
return false;
 }
// populate links for RVP box using cookie
function displayRVP()
{
   
 // checks if cookies are enabled and display appropriate message if cookies are disabled
 if (!(cookieenabled)) 
  {
document.write('<div class="RVPBox">' + sRVPBoxTitle + '<br/>' + sRVPCookieText + '</div>');
return;
   }
   
 //display  links
    var parmArray = new Array();
    var hdr = 0;
    var j = 0;
    var urlStr;
    var tUrl;
   
    //display cookie contents
    if ((aRVP[0]) && (aRVP[0] != "") )
    {
       for (var i=0; i < aRVP.length; i++)
      {  
         if (aRVP[i])
        { 
            parmArray = aRVP[i].split("~~");
            if (i == 0) {
		           // check for # sign followed by any
		           tUrl = document.location.href;
		           if (tUrl.indexOf('#') != -1) {tUrl = tUrl.substring(0,tUrl.indexOf('#')); }
            }
            if ( (parmArray[1]) && (parmArray[0]) && ( (i > 0) || ( (i == 0)  && (!recentRVP(tUrl))) ))
            {
                // write header
                if (hdr == 0) {hdr = 1; document.write('<div class="RVPBox">' + sRVPBoxTitle + '<ul>');}
        
//	         urlStr = '<li><a href="' + unescape(parmArray[0]) + '"';
	         urlStr = '<li><a href="' + removeSpecialChars(unescape(parmArray[0])) + '"';
	                
		         // window target
		         if ((parmArray[2]) && (parmArray[2] != 0))   {urlStr = urlStr + ' target="' + parmArray[2]  + '"';}
		          
		        //check to see if this needs to be tagged to record in RVP
		        if ((parmArray[3]) && (parmArray[3] == 1))  
		              {urlStr = urlStr + ' onClick="processbyreqRVP(\'' + unescape(parmArray[1]) + '\',\'' + unescape(parmArray[0]) + '\',\'' + parmArray[2] + '\');"';}
		        tUrl = unescape(parmArray[1]).replace("<","&lt;");
                      tUrl = tUrl.replace(">",">");
		        urlStr = urlStr + ' title="' + unescape(parmArray[1]) + '">' + tUrl +  '</a></li>';
		        document.write(urlStr);
		              
                 j = j + 1;
             }
             if (j >= 5) break;
          }
        }  //  end of for loop
if (hdr == 1) {document.write('</ul></div>');}
     }  
 
 }
// read cookie contents
function readRVPCookie()
{
var lnkStr = document.cookie;
var pos = lnkStr.indexOf("RVPLinks=");
if (pos == -1) return; 
// eliminate the text "PwC=PwC;RVPLinks=" from the string
lnkStr = lnkStr.substring(pos+9);
if (lnkStr.indexOf(";") > -1) {lnkStr = lnkStr.substring(0,lnkStr.indexOf(";"));}
//load  links in global array
aRVP = lnkStr.split("~~~");
}
// read meta tag for value
function readMetaTag(tagName)
{
  
  var content = "";
   
  // check for various browsers and versions  
 
  if (document.getElementById)   {  
        if (document.getElementById(tagName))  content = document.getElementById(tagName).content; 
     }
 else if (document.all) { 
        if (document.all[tagName])  content = document.all[tagName].content; 
     }  
 else if (document.layers) { 
        if (document.layers[tagName])  content = document.layers[tagName].content; 
     }
  
  return content;
  
}
processRVP();
//link vars
lpn_Key = [''];
lpn_Value = [''];
ssl = '';
var domain='';
var domain_imagessl='';
// These are the page configuration parameters
var topNavVersion='htmlhp2';
var sections=['0'];
var lang = 'eng';
var languageIdentifiers=['eng'];
var languageNames=['English'];
var languageURLs=['/'];
var section='0';
var country='gx';
var configVal = 0;
var css = 'Ocean';
var hideTopNav = 0;
if ( ( configVal - 128 ) >= 0 ){
   var hideTopNav = 1;
   configVal -= 128;
}
var hideTabMenu = 0;
if ( ( configVal - 64 ) >= 0 ){
   hideTabMenu = 1;
   configVal -= 64;
}
var hideSearchBox = 0;
if ( ( configVal - 32 ) >= 0 ){
   hideSearchBox = 1;
   configVal -= 32;
}
var hideCountryBox = 0;
if ( ( configVal - 16 ) >= 0 ){
   hideCountryBox = 1;
   configVal -= 16;
}
// Hide territory/country drop down box if site is using microsite topnav 
// and appropriate option value is selected in config document
if ("0"=="1"){
	hideCountryBox = 1;
}
var hideLPN = 0;
if ( ( configVal - 8 ) >= 0 ){
   hideLPN = 1;
   configVal -= 8;
}
var hideLang = 0;
if ( ( configVal - 4 ) >= 0 ){
   hideLang = 1;
   configVal -= 4;
}
// Hide language option 1 - Hide on all pages
if ("0"=="1"){
	hideLang = !hideLang;
}
// Hide language option 2 - Hide on all pages, except home page
if ("0"=="2"){
	if ("htmlhp2"!="ghp2" && "htmlhp2"!="htmlhp2"){
		hideLang = !hideLang;
	}
}
var hideGHPLink = 0;
if ( ( configVal - 2 ) >= 0 ){
   hideGHPLink = 1;
   configVal -= 2;
}
var hidePwCLogo = 0;
if ( configVal == 1 ){
   hidePwCLogo = 1;
}
//This processes LPN URLs
function lpnLink( url ){
	if( url == null ){
		return( "" );
	}
	if( url == "" ){
		return( "" );
	}
	urlTxt = new String( url );
	for( i = 0; i <= lpn_Key.length-1; i++ ){
		if( lpn_Key[ i ] == urlTxt ) {
			urlTxt = lpn_Value[ i ];
			break;
		}
		splitUrl = urlTxt.split( lpn_Key[ i ] );
		urlTxt = splitUrl.join( lpn_Value[ i ] );
	}
	return( urlTxt );
}
//This processes URLs
function link( url ){
	if( url == null ){
		return( "" );
	}
	if( url == "" ){
		return( "" );
	}
	if( domain =="" ){
		return( url );
	}
	if( url.charAt( 0 ) == "/" ){
		return( domain + url );
	}
	return( url );
}
// This function generates the language list in the topNav section of the document.
// If there is only 1 language it is not displayed.
function generateLanguageList(){
	var langClass = '';
	if( languageIdentifiers.length > 1 ){
		for(i = 0;  i < languageIdentifiers.length;  i++ ){
			if ( languageIdentifiers[ i ] == lang ){
				langClass = "class = 'languageLinkSelected' ";
			}
			else {
				langClass =  "class = 'languageLink' ";
			}
			if ( i == 0 ){
				langClass += "id = 'firstLanguageLink' ";
			}
			document.writeln( "<span " + langClass + "><a href='" + link( languageURLs[ i ] )  + "' target='_self' title='" + languageNames[ i ] + "' hreflang='" + languageIdentifiers[ i ] + "'>" + languageNames[ i ] + "</a></span>");
		}
	}
}
function pageTools(){
	document.writeln( "<div class='pageTools'>" );
	pageToolsPrinterFriendly();
	pageToolsEmailPage();
	document.writeln( "</div>" );
}
function pageToolsPrinterFriendly(){
	tmpStr = "Print-friendly version";	
	document.writeln( "<a accesskey='5' href='#' onclick='printPreview()' target='_self' title='" + tmpStr + "'><img src='" + domain_imagessl + "/images/ui/icons/generic/icon_printer.gif' border='0' alt='' hspace='5' vspace='7' />" + tmpStr + "</a><br />" );
}
function pageToolsEmailPage(){
	tmpStr = "Email to a colleague";
	var emailpageParam = "\""+country+"\",\""+lang+"\",\""+css+"\",\""+sections+"\"";
	document.writeln( "<a href='#' onclick='emailpage(" + emailpageParam + ")' target='_self' title='" + tmpStr + "'><img src='" + domain_imagessl + "/images/ui/icons/generic/icon_email.gif' border='0' alt='' hspace='5' vspace='0' />" + tmpStr + "</a><br />" );
}
// This function calls the OnLoad event.
function doOnLoadTasks(){
	//This function resides in the Standards.JS document
	startList();
}
window.focus();
