//for testing cache
/*function moveToPrivacyPolicy()
{
		//sLink = 'Mrbase/br/Help/TermsAndConditionsPage.aspx?type=5&FromRegistration=1';
		sLink = '../br/Help/TermsAndConditionsPage.aspx?type=5&FromRegistration=1';
		submitPageFE(sLink)
		return true;
}*/

function goPage(strMRserverPath)
{
	window.document.forms[0].action= strMRserverPath + "/br/Login/LoginPreRegistration.aspx";
	window.document.forms[0].submit();
}
//cookie functions
function getCookie(NameOfCookie){	
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;      
        return document.cookie.substring(begin, end);
    } 
  }
  return null;
}

/*function setCookie(NameOfCookie, value, expiredays,path) {
	var ExpireDate = new Date ();	
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + value + 
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) +
    ((path) ? "; path=" + path : "" );
    
}*/

/*function delCookie (NameOfCookie,path) {	
  if (getCookie(NameOfCookie)) {	
	var Days=3*24*60*60*1000;
	var expDate=new Date()
	expDate.setTime(expDate.getTime()-Days);
    document.cookie = NameOfCookie + "=" +
    ((path) ? "; path=" + path : "" ) +
    "; expires=" + expDate.toUTCString;
  }  
}*/

/*function DoCookieStuff(cookiename,maxSearchValue)
{
	if(maxSearchValue<0)
	{
		return 0;
	}
	else
	{
		if(cookie_check()==1)
		{
			times_visited=eval(getCookie(cookiename))+1;	
			if (times_visited >maxSearchValue) 
			{	
				if(times_visited-maxSearchValue==1)
				{					
					//setCookie(cookiename,times_visited,365,"/");  
				}	
 				return 1;
			}
			else
			{	
				//setCookie(cookiename,times_visited,null,"/");  
				//setCookie(cookiename,times_visited,365,"/");  
				return 0;
			}
		}
		else
		{
			return 1;
		}	
	}
}*/

/*function cookie_check()
{
	document.cookie = "tnmcookie=set"
	if (document.cookie.indexOf("tnmcookie=set")!=-1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}*/

function Paging_PrevNext(iFlag)
	{
	    var objFrm = window.document.forms[0];//eval('document.'+strForm)
	   	if(iFlag == 0)
		{
			objFrm.hidPageNum.value= parseInt(objFrm.hidPageNum.value,10) -1
		}
		else
		{
			objFrm.hidPageNum.value= parseInt(objFrm.hidPageNum.value,10) + 1
		}
	}
	
	function Paging_SelectedIndexChanged(obj)
	{
	    var objFrm = window.document.forms[0];
	   	//alert(obj[obj.selectedIndex].value)
		objFrm.hidRecordsPerPage.value = obj[obj.selectedIndex].value
//		objFrm.hidSelectedIndexChanged.value='1'
		objFrm.hidPageNum.value = '1'
		
		var objTopPage = getObj("objTopPagingControl_cboRecordsPerPage",2)
		var objBottomPage = getObj("objBottomPagingControl_cboRecordsPerPage",2)
		if(typeof(objTopPage) =='object'){
			for(var i=0; i<objTopPage.length;i++){
				if(objTopPage.options[i].value == obj[obj.selectedIndex].value){
					objTopPage.selectedIndex = i;
				}
			}
		}
		if(typeof(objBottomPage) == 'object'){
			for(var i=0; i<objBottomPage.length;i++){
				if(objBottomPage.options[i].value == obj[obj.selectedIndex].value){
					objBottomPage.selectedIndex = i;
				}
			}
		}
		if (typeof objFrm.hidPagesizeChanged == 'object')
		{
			objFrm.hidPagesizeChanged.value = "TRUE";
		}
		objFrm.submit()
	}
	
	function setPagingComboValue(strValue){
		var objTopPage = getObj("objTopPagingControl_cboRecordsPerPage",2)
		var objBottomPage = getObj("objBottomPagingControl_cboRecordsPerPage",2)
		if(typeof(objTopPage) =='object'){
			for(var i=0; i<objTopPage.length;i++){
				if(objTopPage.options[i].value == strValue){
					objTopPage.selectedIndex = i;
				}
			}
		}
		if(typeof(objBottomPage) == 'object'){
			for(var i=0; i<objBottomPage.length;i++){
				if(objBottomPage.options[i].value == strValue){
					objBottomPage.selectedIndex = i;
				}
			}
		}
	}

function popupWin(url, parWidth, parHeight, ch, showStatus, popName,toreSize)
{
	showStatus = (arguments.length==4) ? 'yes' : showStatus;
	popName = (arguments.length==5) ? 'Popup' : popName;
	//toreSize = (arguments.length==6) ? 'no' : toreSize;
	
	if(arguments.length==7)
		toreSize = 'yes'
	else
		toreSize = 'no'
	popName = 'Popup';
		
	pWidth = (parWidth.toUpperCase()=='FULL') ? screen.availWidth : parWidth;
	pHeight = (parHeight.toUpperCase()=='FULL') ? screen.availHeight : parHeight;
	
	var topCal = ((screen.height  - pHeight)/2);
	var leftCal = ((screen.width - pWidth)/2);
	
	winArgs = 'resizable='+toreSize+',toolbar=0, location=0, directories=0, status=' + showStatus + ', scrollbars=' + ch + ', width=' + pWidth + ', height=' + pHeight + ', left=' + leftCal + ', top=' + topCal;
	//winArgs = 'dialogWidth:'+pWidth+'px;dialogHeight:'+pHeight+'px;dialogTop:'+topCal+'px;dialogLeft:'+leftCal+'px;scroll:'+ch+';status:'+showStatus;
	popWin = window.open("", popName, winArgs);
	//popWin = window.showModalDialog(url,'xxx',winArgs);
	//if(popWin=='true'){
	//	window.location.reload(true);
	//}
	var isQuestPresent = url.indexOf("?");
	var firstPartUrl ='';
	var middlePartUrl = '';
	if(isQuestPresent!=-1)
	{
		firstPartUrl = url.substring(0,isQuestPresent);
		if (url.indexOf("objBackTo") != -1)
		{
			middlePartUrl = firstPartUrl+"?objBackTo:hidFromModule=FRONTEND&"
			url = middlePartUrl+url.substring(isQuestPresent+1);
		}
	}
	else
	{
		url = url + "?objBackTo:hidFromModule=FRONTEND"
	}
	
	//Added for handling Unhandled Exceptions through web.config Redirection
	url = url + "&UExisPopup=1"
	
	popWin.location.href=url;
	
	if (parWidth.toUpperCase()=='FULL' && parHeight.toUpperCase()=='FULL')
		popWin.window.moveTo(0,0);
	
	popWin.window.resizeTo(pWidth,pHeight);
}
function submitPageFE(strQueryString)
{
	if ( typeof window.document.forms[0] == 'object')
	{
		window.document.forms[0].action = strQueryString;
		window.document.forms[0].submit();
	}
}

// Function by raju to enter key
NS4 = (document.layers) ? true : false;

function checkEnter(event,obj,validateFunName)
{ 	
	var code = 0;
	var objbtnlogin
	var bSubmitToValidate
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
		
	if (code==13)
	{
		if (typeof obj == 'object')
		{
			bSubmitToValidate = eval(validateFunName)
			
			if (bSubmitToValidate)
			{
				return true;
			}else
			{
				return false; 
			}
		}
	}
}

// addby raju
// This function called on on load of the body.
/*function onBodyLoad()
{
	objhidEnterClick = document.getElementById(objMastHeadName + '_hidEnterClick')			
		
	if (objhidEnterClick != null)
	{
		if (typeof objhidEnterClick == 'object')
			objhidEnterClick.value = 0;
	}
	
}*/

// added by raju, 
function winReload()
{
	// This code avoids the pop up of the Retry cancel Box and
	// resets the Listing page to the first Page
	window.document.forms[0].submit();
	return true;
		
}

function swapImgRestore(ctrlname,imgname) { 				
	//var e=window.document.getElementById(ctrlname) ;
	ctrlname.src=imgname;				
}

function swapImage(ctrlname,imgname) {
	//var e=window.document.getElementById(ctrlname);					
	ctrlname.src=imgname;	
}

 function setTabSelected(iSelectedIndex){
	var objForm=eval(document.forms[0]); 
	objForm.hidWhichTabSelected.value = iSelectedIndex;
	objForm.hidPageNum.value = '1'; // Page Number
	objForm.submit();
}

/*function moveToPrivacyPolicy(){
		sLink = '/HelpCenter/HelpCenter.aspx?type=5&FromRegistration=1';
		submitPageFE(sLink)
		return false;
	}*/
		
	function AssetSelectedIndexChanged(obj)
	{	
		var objFrm = window.document.forms[0];
		objFrm.hidAssetTypeChanged.value = "true";	
		objFrm.hidAssetTypeSelected.value = obj[obj.selectedIndex].value
		objFrm.submit();
	}

	function setTab(iSelectedIndex,iTabIndex)
	{
		var objForm=eval(document.forms[0]); 
		objForm.hidSelectedAssetTab.value = iSelectedIndex; //Actuall Tab Selected
		objForm.hidTabIndex.value = iTabIndex; //TAb Position.
		objForm.hidPageNum.value = '1'; // Page Number
		objForm.hidAssetTypeChanged.value = "true"; //For Asset Control	
		objForm.hidAssetTypeSelected.value = iSelectedIndex;
		objForm.submit();
	}

	function setOrderHistoryTab(iSelectedIndex){
	var objForm=eval(document.forms[0]); 
	objForm.hidTabSelected.value = iSelectedIndex;
	objForm.hidPageNum.value = '1'; // Page Number
	objForm.submit();
	}
	
	function countriesreveal() { // Show, hide or add to territory selector box		
	/*this client side javascript is modified to get the image version*/
	var ImgVersion = "";
	if (document.getElementById('IMGVERSION') != null)
	{
		var objImgVersion = document.getElementById('IMGVERSION');
		ImgVersion = objImgVersion.value;
	}	
	var hostName=window.location.hostname;
	var pathName=window.location.pathname.substring(1);
	var stopPos=pathName.indexOf("/");
	var virtualDirectoryName=pathName.substring(0,parseFloat(stopPos));	
	var fullPath='http://'+ hostName + '/' + virtualDirectoryName + '/Images/' + ImgVersion + 'ajaxclose.gif';
	/*modification of the cliet side javascript ends here*/
	
	var browser_detect = navigator.userAgent.toLowerCase();
	if ((browser_detect.indexOf("firefox") + 1))
	{
		var top=(document.getElementById('footer-wrapper').offsetParent.offsetTop - 86) + 'px';
	}
	else
	{
		var top=(document.getElementById('footer-wrapper').offsetTop - 202) + 'px';
	}
	
	//alert(document.getElementById('footer-wrapper').offsetTop);
	//alert(document.getElementById('footer-wrapper').offsetParent.offsetTop);
	document.getElementById('countriesbox').style.visibility = 'visible';
	document.getElementById('countriesbox').style.top = top;
	
  // Set the static lists (no longer ajax)
	document.getElementById('countriesboxhead').innerHTML = "";
	var countriesheader="<div id='countriestitle'>Commonly visited PwC sites</div><br clear='all' />";

	document.getElementById('countriescontents').innerHTML = "";
  var countriesoutput="<table id='countriestable' border='0'><tbody><tr><td><ul class='countrylist'><li><a href='http://www.pwc.com/'>Global</a></li><li><a href='http://www.pwc.com/au/en'>Australia</a></li> <li><a href='http://www.pwc.com/br/pt'>Brazil</a></li> <li><a href='http://www.pwc.com/ca/en'>Canada</a></li> <li><a href='http://www.pwccn.com'>China</a>&nbsp;/&nbsp;<a href='http://www.pwchk.com'>Hong Kong</a></li> <li><a href='http://www.pwc.fr'>France</a></li> <li><a href='http://www.pwc.de'>Germany</a></li> <li><a href='http://www.pwc.com/in/en'>India</a></li></ul></td><td><ul class='countrylist'><li><a href='http://www.pwc.com/it/it'>Italy</a></li> <li><a href='http://www.pwcjp.com/e/index.html'>Japan</a></li> <li><a href='http://www.pwc.com/mx/es'>Mexico</a></li><li><a href='http://www.pwc.com/m1/en'>Middle East</a></li> <li><a href='http://www.pwc.com/nl/nl'>Netherlands</a></li> <li><a href='http://www.pwc.com/ru/ru'>Russia</a></li> <li><a href='http://www.pwc.com/sg/en'>Singapore</a></li> <li><a href='http://www.pwc.com/za/en'>South Africa</a></li></ul></td><td valign='top'><ul class='countrylist'><li><a href='http://www.pwc.com/kr/ko'>South Korea</a></li> <li><a href='http://www.pwc.com/es/es'>Spain</a></li> <li><a href='http://www.pwc.com/se/sv'>Sweden</a></li> <li><a href='http://www.pwc.ch/'>Switzerland</a></li> <li><a href='http://www.pwc.co.uk/'>United Kingdom</a></li> <li><a href='http://www.pwc.com/us/en'>United States</a></li> </ul> </td></tr></tbody></table><br clear='all'> <p style='text-align: right; font-weight: bold;'><a href='http://www.pwc.com/gx/en/site-index.jhtml'>Complete list of PwC territory sites</a></p><br clear='all' />";
	
	// Finally write the output; close button, header & contents.
	document.getElementById('countriesboxclose').innerHTML = "<a href='#' onClick='countrieshide(); return false;'><img src=" + fullPath + " alt='Close' border='0' id='countriesclosebutton' /></a>"
	document.getElementById('countriesboxhead').innerHTML = countriesheader;
	document.getElementById('countriescontents').innerHTML = countriesoutput;
}

function countrieshide() { 	// Clear the contents of the box and hide the div
	document.getElementById('countriescontents').innerHTML = "";  
	document.getElementById('countriesbox').style.visibility = 'hidden';  
}

function clearsearchNew() { //Clear from initial focus
	document.getElementById("searchfield").value="";
}

var xmlHttp
function showResult(str) {
	// Clear the suggestions box when no chars
	if (str.length<=minchars) {
		document.getElementById("livesearch").innerHTML="";
		document.getElementById("livesearch").style.visibility="hidden";
		return
	}
	if (livesearchon!="true") {
		return
	}
	
	/*this client side javascript is modified to get the image version*/
	var ImgVersion = "";
	if (document.getElementById('IMGVERSION1') != null)
	{
		var objImgVersion = document.getElementById('IMGVERSION1');
		ImgVersion = objImgVersion.value;
	}	
	var hostName=window.location.hostname;
	var pathName=window.location.pathname.substring(1);
	var stopPos=pathName.indexOf("/");
	var virtualDirectoryName=pathName.substring(0,parseFloat(stopPos));	
	var fullPath='http://'+ hostName + '/' + virtualDirectoryName + '/Images/' + ImgVersion + '/ajaxload.gif';
	/*modification of the cliet side javascript ends here*/
	
	// Place the AJAX loading gif. Replaced with the clear icon after the request is complete (below)
	document.getElementById("livesearchbutton").src=fullPath;
	document.getElementById("livesearchbutton").className="";
	
	xmlhttp=null;
	var suggestionsfile = "http://www.pwc.com/en_GX/webadmin/ajax/livesearch/livesearch.xml"
	url = suggestionsfile; // Suggestions xml file taken from local.js

	if (window.XMLHttpRequest) {// code for IE7, Firefox, Mozilla, etc.
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {// code for IE5, IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange=processsearch;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	else {
		//alert("Your browser does not support XMLHTTP.");
		clearlivesearch();
		return;
	}
}

function clearlivesearch() { // Clear from the button & also hide the button

/*this client side javascript is modified to get the image version*/
	var ImgVersion = "";
	if (document.getElementById('IMGVERSION1') != null)
	{
		var objImgVersion = document.getElementById('IMGVERSION1');
		ImgVersion = objImgVersion.value;
	}	
	var hostName=window.location.hostname;
	var pathName=window.location.pathname.substring(1);
	var stopPos=pathName.indexOf("/");
	var virtualDirectoryName=pathName.substring(0,parseFloat(stopPos));	
	var fullPath='http://'+ hostName + '/' + virtualDirectoryName + '/Images/' + ImgVersion + 'tran.gif';
	/*modification of the cliet side javascript ends here*/
	
	document.getElementById("searchfield").value=" Search";
	document.getElementById("livesearch").innerHTML="";
	document.getElementById("livesearch").style.visibility="hidden";
	document.getElementById("livesearchbutton").src=fullPath;
	document.getElementById("livesearchbutton").className="";
}

function processsearch() { // Check if file is valid & if so do something with its contents

	// Take the current search string
	var str = document.getElementById("searchfield").value.toLowerCase();

	// Break the loop when http call is complete or there's an error
	if(xmlhttp.readyState!=4) return;
	if(xmlhttp.status!=200) {
		//alert("Problem retrieving XML data");
		clearlivesearch();
		return;
	}

	// Locate the link element to traverse
	x=xmlhttp.responseXML.documentElement.getElementsByTagName("link");
	var searchoutput = "";
	var searchoutputheader = "<div id='livesearchheader'>Recommended results</div>";
	var searchoutputfooter = "<div id='livesearchfooter'><a href='#'>View all results >></a></div>"; 
	if (str.length > minchars) {

		// Loop through all link elements
		for (i=0;i<x.length;i++) {

			xtitles=x[i].getElementsByTagName("title");
			xurls=x[i].getElementsByTagName("url"); {
			try {
				// The magic of string matching (must be lowercare)
				var testquery = xtitles[0].firstChild.nodeValue.toLowerCase();
				if (testquery.indexOf(str) !=-1) {
					searchoutput = searchoutput + "<a href='" + xurls[0].firstChild.nodeValue + "'>" + xtitles[0].firstChild.nodeValue + "</a><br />";
				} else {
					searchoutput = searchoutput + "";
				}
			}
				catch (er) { searchoutput = searchoutput + ""; }
			}				
		}

	}

	if (searchoutput=="") { 
		// Collapse the suggestions box when no matches & halt the ajax loading gif
		document.getElementById("livesearch").style.visibility="hidden";
		
		/*this client side javascript is modified to get the image version*/
	var ImgVersion = "";
	if (document.getElementById('IMGVERSION1') != null)
	{
		var objImgVersion = document.getElementById('IMGVERSION1');
		ImgVersion = objImgVersion.value;
	}	
	var hostName=window.location.hostname;
	var pathName=window.location.pathname.substring(1);
	var stopPos=pathName.indexOf("/");
	var virtualDirectoryName=pathName.substring(0,parseFloat(stopPos));	
	var fullPath='http://'+ hostName + '/' + virtualDirectoryName + '/Images/' + ImgVersion + 'ajaxclose.gif';
	/*modification of the cliet side javascript ends here*/
	
		document.getElementById("livesearchbutton").src=fullPath; // Show the close button, replacing the ajax gif
		document.getElementById("livesearchbutton").className="livesearchclose";
	} else {
		// Return the response, only when xml http call is done. Show the close button, replacing the ajax gif
		if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") { 
			document.getElementById("livesearch").style.visibility="visible";
			document.getElementById("livesearch").innerHTML=searchoutputheader + searchoutput + searchoutputfooter;
			document.getElementById("livesearchbutton").src=fullPath;
			document.getElementById("livesearchbutton").className="livesearchclose";
		} 
	}

}

/*** START Primary nav hover function for IE ***/

sfHover = function() {
if(window.location.pathname.search("TechDetail.aspx") >0 || window.location.pathname.search("MediaPreview.aspx") >0 || window.location.pathname.search("Intermediate.aspx") >0 || window.location.pathname.search("CommonEmailForm.aspx") >0 || window.location.pathname.search("PasswordHelp.aspx") >0 || window.location.pathname.search("PasswordNotify.aspx") >0 || window.location.pathname.search("TestConnection.aspx") >0)
{
}
else
{
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);