// JavaScript Document

function fullScreen(theURL) {
window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
}

function openWin(sURL) {
		window.open(sURL,null,'toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=10,left=50,width=750,height=550');

}

function openWinSmall(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=480,height=60');
}

function openWinRate(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,top=200,left=100,width=680,height=350');

}


function openWinChart(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=500,height=500');

}

function openWinChartSmaller(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=500,height=400');

}

function openWinfact(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=300,left=200,width=205,height=200');

}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function footerText(year){
	if(!year){
		year="2005"
	}
	document.writeln( "<div class='footerText'>" );
	document.write("&copy; "+year+" PricewaterhouseCoopers. All rights reserved. PricewaterhouseCoopers refers to the network of member firms of PricewaterhouseCoopers International Limited, each of which is a separate and independent legal entity.");
	document.writeln( "</div>" );
}
function footerAccessKeyInfo(){
	document.writeln( "<!-- Supplementary Accesskey information for ALL PAGES -->" );
	document.writeln( "<a accesskey='0' href='http://www.w3c.org'><img src='images/tran.gif' width='1' height='1' border='0' alt='Accessibility information' /></a> <!-- Accessibility page-->" );
	document.writeln( "<a accesskey='2' href='#pageContent'><img src='images/tran.gif' width='1' height='1' border='0' alt='Skip navigation' /></a> <!-- Skip navigation -->" );
	document.writeln( "<a accesskey='3' href='/gx/eng/main/countriesonline/index_text.html'><img src='images/tran.gif' width='1' height='1' border='0' alt='Countries online' /></a> <!-- Countries online -->" );
}
function footerLinks(){
	document.writeln( "<div class='footerLinks'>" );
	if ( "Privacy" == "" ){
		//default privacy links
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/gx/eng/main/privacy/index.html" ) + "' title='Privacy'>Privacy</a></span>" );
	} else {
		//override privacy links
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/extweb/aboutus.nsf/docid/0B7D5841DBFA29F28525701300728571" ) + "' title='Privacy'>Privacy</a></span>" );
	}
	if ( "Legal" == "" ){
		//default legal links
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/gx/eng/main/legal/index.html" ) + "' title='Legal'>Legal</a></span>" );
	} else {
		//override legal links
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/extweb/aboutus.nsf/docid/55AD46183DF9500B85257013006FA934" ) + "' title='Legal'>Legal</a></span>" );
	}
	if ( "Disclaimer" == "" ){
		//default legal links
		document.writeln( "<span class='footerItem'><a href='" + link( "disclaimer.asp" ) + "' title='Disclaimer'>Disclaimer</a></span>" );
	} else {
		//override legal links
		document.writeln( "<span class='footerItem'><a href='" + link( "disclaimer.asp" ) + "' title='Disclaimer'>Disclaimer</a></span>" );
	}

	if ( "About Site Provider" == "" ){
		//default about provider
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/extweb/home.nsf/docid/3E49B726C8AFB26785256D7100693215" ) + "' title='About Site Provider'>About Site Provider</a></span>" );
	} else {
		//override about provider
		document.writeln( "<span class='footerItem'><a href='" + link( "http://www.pwc.com/extweb/home.nsf/docid/F1361860A8676D9A8525702000471181" ) + "' title='About Site Provider'>About Site Provider</a></span>" );
	}
	if ( "Email Webmaster" == "" ){
		//default Email Webmaster
		document.writeln( "<span class='footerItem'><a href='" + link( "mailto:andrew.j.moore@uk.pwc.com" ) + "' title='Email Webmaster'>Email Webmaster</a></span>" );
	} else {
		//override Email Webmaster
		document.writeln( "<span class='footerItem'><a href='" + link( "mailto:andrew.j.moore@uk.pwc.com" ) + "' title='Email Webmaster'>Email Webmaster</a></span>" );
	}
		document.writeln( "<span class='footerItem'><a href='" + link( "system.asp" ) + "' title='Site Map'>System Requirements</a></span>" );
	if ( "Site Map" == "" ){
		//default site map
		document.writeln( "<span class='footerItem' id='footerItem1'><a href='" + link( "http://www.pwc.com/extweb/home.nsf/docid/C1EC033FA11BBDEA85256F3900576F06" ) + "' title='Site Map'>Site Map</a></span>" );
	} else {
		//override site map
		document.writeln( "<span class='footerItem' id='footerItem1'><a href='" + link( "http://www.pwc.com/extweb/home.nsf/docid/79CDE8F54ED4105085257015006E0F63" ) + "' title='Site Map'>Site Map</a></span>" );
	}
	
		//default site map

	//START generic footer links
	if( "" != "" ){
		var FooterText = [""];
		var FooterURL = [""];
		for( n = 0; n < FooterText.length; n++)
		{
			if (n < FooterText.length - 1){
				document.writeln( "<span class='footerItem'><a href='" + link( FooterURL[ n ] ) + "' title='" + FooterText[ n ] + "'>" + FooterText[ n ] + "</a></span>" );
			} else {
				//last item needs an id property
				document.writeln( "<span class='footerItem' id='footerItem1'><a href='" + link( FooterURL[ n ] ) + "' title='" + FooterText[ n ] + "'>" + FooterText[ n ] + "</a></span>" );
			}
		}
	}
	//END generic footer links
	document.writeln( "</div>" );
}
function buildFooter(year){
	document.writeln( "<div id='footerContainer'>" );
	footerLinks();
	footerText("2003-2009");
	footerAccessKeyInfo();
	document.writeln( "</div>" );
}

function buildFooterLite(year){
	document.writeln( "<div id='footerContainer'>" );
	footerText("2003-2009");
	footerAccessKeyInfo();
	document.writeln( "</div>" );
}

function getSizeDifferences() {
parent = window.opener;
parentform = parent.document.forms[0];
difleft = window.screenLeft - parentform.Left.value;
diftop = window.screenTop - parentform.Top.value;
difwidth = window.document.body.clientWidth - parentform.Width.value;
difheight = window.document.body.clientHeight - parentform.Height.value;
// alert ("difleft= " + difleft + "  window.screenLeft=" + window.screenLeft + "\ndiftop=" + diftop + "  window.screenTop=" + window.screenTop + "\ndifwidth=" + difwidth + "  clientWidth=" + window.document.body.clientWidth + "\ndifheight=" + difheight + "  clientHeight=" + window.document.body.clientHeight);
}

function startList() {
	for (navCount=1; navCount<=1; navCount++) {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("nav"+navCount);
			if( navRoot != null ){
				for (i=0; i<navRoot.childNodes.length; i++) {
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
						node.onmouseover=function() {
							this.className+=" over";
						}
						node.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}

// This function calls the OnLoad event.
function doOnLoadTasks(){
	//This function resides in the Standards.JS document
	startList();
}

function inputValidation(form){
	var errorText;
	// Valid friends email
	errorText = form.ValidationField1.value;
	 if ( !validEmail( form.friendsEmail.value ) ){
		alert(errorText);
		form.friendsEmail.focus();
		return;
	}
	//Validate name
	errorText = form.ValidationField2.value;
	if (form.name.value == ""){
		alert(errorText);
		form.name.focus();
		return;
	}
	//Validate users email address
	errorText = form.ValidationField3.value;
	 if ( !validEmail( form.yourEmail.value ) ){
		alert(errorText);
		form.yourEmail.focus();
		return;
	}
	form.submit();
}
function validEmail( email ){
	return ( ( email.length > email.indexOf( "." ) + 1 ) && email.indexOf( "." ) > 2 ) && ( email.indexOf( "@" ) > 0 );
}


function createMailto(sourceForm) {
  

  
  var to      = sourceForm.friendsEmail.value;
  var subject = "I thought you might find this interesting";
  var body    = sourceForm.note.value;
  var urlSend = sourceForm.pageLoc.value + "\n\n";
  
  var urltext = "";

  if ( !validEmail( to ) ){
		alert("Please enter a correctly formatted email address for your friend");
		sourceForm.friendsEmail.focus();
		return;
  }

  if (to != "") {
    urltext += to;
  }

  if (subject != "") {
    urltext = addDelimiter(urltext);
    urltext += "Subject=" + escape(subject);
  }
  
  if (body != "") {
    urltext = addDelimiter(urltext);
    urltext += "Body=" + escape(urlSend + body);
  }
  
   urltext = "mailto:" + urltext;

  testMailto(urltext)
}

function addDelimiter(inputString) {
  var inString = inputString;

  if (inString.indexOf("?") == -1) {
    inString += "?";
  }
  else {
    inString += "&";
  }
  return inString;
}

function testMailto(loc) {
  var doc = loc;

  if (doc.indexOf("HREF=") != -1) {
    var doc = doc.substring(doc.indexOf("HREF=")+6, doc.indexOf(">")-1);
  }

  window.location = doc;
  window.close();
}

function emailCheck(email) {

        var emailvar = email
        var emailparts = emailvar.split("@")
        var emailnameonly = ""
        var minimumextlength = 2
        var maximumextlength = 4
        var urltestchar = ""
        var charok = 0
        var acceptable = new Array("a","b","c","d","e","f","g","h","i","j",
        "k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J",
        "K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","_",
        ".","1","2","3","4","5","6","7","8","9","0","@","_")
    if(email == "")
	{
    	alert("Please enter an email address");
	    return false;
	}	

// check to see if there are any @'s in the string
        if (emailparts.length > 2) 
        {
          alert("Please enter only one @ character in your email address.")
          return false
        }
        if (emailparts.length <= 1)
        {
          alert("Please include one @ character in your email address.")
          return false
        }
// There is one @ - now check for a dot 
// and data before and after the @

        var emailurl=(emailparts[emailparts.length - 1])
        for (var i=0; i < emailparts.length-1; i++) 
          {
          emailnameonly=emailnameonly+emailparts[i]
          }

// Examine emailurl for a dot and data in front of it 
// and two or three characters after the last dot

        var urlparts = emailurl.split(".")

// check to see if there are any dot's in the string
// more than one is ok

        if (urlparts.length <= 1)
        {
          alert("There are no dots in the domain portion of your email address.")
          return false
       }

// Check to see how long the last urlpart is
// Must be either two or three characters long
       
       if (urlparts[urlparts.length - 1].length < minimumextlength || 
           urlparts[urlparts.length-1].length > maximumextlength)
        {
          alert("The domain name extension must have 2 - 4 characters.")
		  return false
        }

// Check all characters of the address to make sure there are no
// invalid characters - default allows the use of an underscore
// although that is technically not allowed in a domain name
// it's not that big a risk as it is allowed in the email name.

        for (i=0; i < emailvar.length-1; i++) 
          {
            urltestchar = emailvar.substr(i,1)
            for (var ii=0; ii < acceptable.length; ii++) 
            {
              if (urltestchar == acceptable[ii])
              {
                charok = 1
              }
            }
              if (charok == 0)
            {  
              alert("You've entered an invalid character in your email address.")
              return false
            }
            charok = 0
          }

// check to make sure the length of the string prior to the 
// extension is greater than minimumextlength

        if (emailurl.length-urlparts[urlparts.length - 1].length-1 < minimumextlength)
        {
          alert("You've entered an incorrect domain name for your email address.  It should be at least 2 characters.")
          return false
        }

// check to make sure the length of the string prior to the 
// domain is greater than minimumextlength

        if (emailnameonly.length < minimumextlength)
        {
          alert("You've entered an invalid email name. It must be at least two characters long.")
          return false
        }

	return true;
}

function topNavMatJava (){

	document.write('<li class="navsingle"><a href="http://www.autofacts.com/index.asp" class="navstaticlink">Home</a></li>');
	document.write('<li class="navsingle"><a href="http://www.autofacts.com/aboutus.asp" class="navstaticlink" >About Us</a></li>')
	document.write('<li class="navsingle"><a  href="http://www.autofacts.com/forecast.asp" class="navstaticlink" >Forecast</a></li>')
	document.write('<li class="navsingle"><a  href="http://www.autofacts.com/briefings.asp"  class="navstaticlink" >Analyst Briefings</a></li>')
	document.write('<li class="navsingle"><a  href="http://www.autofacts.com/anotes.asp"  class="navstaticlink" >Analyst Notes</a></li>')
	document.write('<li class="navsingle"><a  href="http://www.autofacts.com/datacentre.asp" class="navstaticlink" >Public Data</a></li>')
	document.write('<li class="navsingle"><a  href="http://www.autofacts.com/contactus.asp" class="navstaticlink">Contact Us</a></li>')
}