/* Global Variables */
var url = location.href;
var XEUrl = location.href;
var headerImage = '<table border="0" cellspacing="0" cellpadding="0" class="mainWidth"><tr><td class="sideWidth"><img src="http://www.xe.com/gen/images/clear.gif" width="15" height="1" /></td><td><img src="gen/images/printHeader.gif" alt="XE header" width="670" height="95" border="0" usemap="#MapHeader" /></td></tr></table>';
var headerPopImage = '<!--[if IE]><![if !IE]><![endif]-->  <table border="0" cellspacing="0" cellpadding="0" class="mainWidth">  <!--[if IE]><![endif]><![endif]--><!--[if lte IE 6]>  <table border="0" cellspacing="0" cellpadding="0" class="mainWidth" style="margin-top:-18px;"><![endif]--><tr><td class="sideWidth"><img src="http://www.xe.com/gen/images/clear.gif" width="15" height="1" /></td><td><img src="gen/images/printHeaderPop.gif" width="665" height="45" alt="XE header" /></td></tr></table>';

/*
  ------------------------------------
  Changes document element to suit browser
  ------------------------------------
*/
function browser(element){
	if (document.all){
		docElement = document.all.element;
	}else if (document.getElementById && !document.all){
		docElement = document.getElementById(element);
	}else if (document.layers){
		docElement = document.layers[element];
	}
}


function ad() {
	alert('hi');
	if (xmlhttp) {
		var url = 'adLeaderboard.php';
	  	xmlhttp.open("GET",url,true);
	  	xmlhttp.onreadystatechange=loadAd;
	  	xmlhttp.send(null)
	}
}
function loadAd() {
	browser("ad");
	if (xmlhttp.readyState==4) {
	  	docElement.innerHTML=xmlhttp.responseText;
	}
}

/*
  ------------------------------------
  Pop-up window for currency assitants
  ------------------------------------
*/
function PopAndBack()
    {
      CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=215,width=665');
      CurrencyWindow.focus();
      CurrencyWindow.location.href = win;
      history.back();
    }

/*
  ------------------------------------
  Search functions
  ------------------------------------
*/
function SearchInt() {
      document.xesearch.action = 'http://xesearch-int.xe.com/find.html';
      document.xesearch.method= 'get';
    }

    function SearchExt() {
      document.xesearch.action = 'http://xesearch-ext.xe.com/xe/search.php';
      document.xesearch.method= 'post';
    }

    function SearchSub() {
      document.xesearch.query.value = document.xesearch.q.value;
      document.xesearch.submit();
    }


/*
  ------------------------------------
  Focuses on the form element selected before refresh
  ------------------------------------
*/
function Reset60(URL) {
      xeRefresh=setTimeout("document.location.href=URL",60000);
    }


/*
  ------------------------------------
  Creating go to links on currency select objects
  ------------------------------------
*/

    function CheckMore(formName) {
	    var from = document.forms[formName].From;
	  var to = document.forms[formName].To;

	  if (to.options.selectedIndex == -1) {
        to.options.selectedIndex = 0; }
      if (from.options.selectedIndex == -1) {
        from.options.selectedIndex = 0; }

	  var toValue = to.options[to.selectedIndex].value;
	  var fromValue = from.options[from.selectedIndex].value;

      var txtFrom = from.options[from.options.selectedIndex].text;
	  var txtTo = to.options[to.options.selectedIndex].text;
      if (toValue.indexOf("/") != -1) {
		document.location.href = toValue;
	  }
	  if (fromValue.indexOf("/") != -1) {
		document.location.href = fromValue;
	  }

    }


/*
  ------------------------------------
  Creating a Favourite Link
  ------------------------------------
*/
function Bookmark(url,passTitle) {
	  if (passTitle != void 0){
		  var bookmarkTitle = passTitle;
	  } else if (document.title){
		  var bookmarkTitle = document.title;
	  } else {
		  var bookmarkTitle = "XE.com - The World's Favorite Currency Site";
	  }
	  if (window.sidebar) { // firefox
        window.sidebar.addPanel(bookmarkTitle,url,"");
      } else if (document.all) { //MSIE
        window.external.AddFavorite(url,bookmarkTitle);
      } else if (window.opera && window.print) {
        return true;
      }
    }
function XEBookmark(url,passTitle) {
	  if (passTitle != void 0){
		  var bookmarkTitle = passTitle;
	  } else if (document.title){
		  var bookmarkTitle = document.title;
	  } else {
		  var bookmarkTitle = "XE.com - The World's Favorite Currency Site";
	  }
	  if (window.sidebar) { // firefox
        window.sidebar.addPanel(bookmarkTitle,url,"");
      } else if (document.all) { //MSIE
        window.external.AddFavorite(url,bookmarkTitle);
      } else if (window.opera && window.print) {
        return true;
      }
    }


/*
  ------------------------------------
  General Pop-up Windows
  ------------------------------------
*/
function NewWindow(mypage, myname, w, h, scroll,amountFrom,to,template) {
	if (amountFrom != void 0 || to != void 0){
		  splitArray = amountFrom.split(' ');
		  if (template != void 0 ){
		  	convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to + '&template=' + template;
		  }else{
			convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to;
		  }
	  } else {
		  convertPage='';
	  }
	mypage = mypage + convertPage;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	win = window.open(mypage, myname, winprops);
}
function XENewWindow(mypage, myname, w, h, scroll,amountFrom,to,template) {
	if (amountFrom != void 0 || to != void 0){
		  splitArray = amountFrom.split(' ');
		  if (template != void 0 ){
		  	convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to + '&template=' + template;
		  }else{
			convertPage = 'Amount=' + splitArray[0] + '&From=' + splitArray[1] + '&To=' + to;
		  }
	  } else {
		  convertPage='';
	  }
	mypage = mypage + convertPage;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	win = window.open(mypage, myname, winprops);
}



/*
  ------------------------------------
  Creating a Favourite Link
  ------------------------------------
*/
function XESwitchClass(){
	if (document.getElementById("XEblink").className == "XEred"){
		document.getElementById("XEblink").className = "XEwhite";
	}else{
		document.getElementById("XEblink").className = "XEred";
	}
}


/*
  ------------------------------------
  Search Form Hide and Show Feature
  ------------------------------------
*/
function hidediv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.display = 'none';
document.getElementById('search_link').innerHTML = '<a href="javascript:showdiv()">Search</a>&nbsp;';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.display = 'none';
document.search_link.innerHTML = '<a href="javascript:showdiv()">Search</a>&nbsp;';
}
else { // IE 4
document.all.hideshow.style.display = 'none';
document.all.search_link.innerHTML = '<a href="javascript:showdiv()">Search</a>&nbsp;';
}
}
}
function showdiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.display = 'block';
document.getElementById('search_link').innerHTML = '';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.display = 'block';
document.search_link.innerHTML = '';
}
else { // IE 4
document.all.hideshow.style.display = 'block';
document.all.search_link.innerHTML = '';
}
}
}


/*
  ------------------------------------
  PVII Menu CSS Express Drop-Down Menu
  by Project Seven Development
  www.projectseven.com
  ------------------------------------
*/
function P7_ExpMenu(){ //v1.1.0.2 by PVII-www.projectseven.com
 if(navigator.appVersion.indexOf("MSIE")==-1){return;}
 var i,k,g,lg,r=/\s*p7hvr/,nn='',c,cs='p7hvr',bv='p7menubar';
 for(i=0;i<10;i++){g=document.getElementById(bv+nn);if(g){
 lg=g.getElementsByTagName("LI");if(lg){for(k=0;k<lg.length;k++){
 lg[k].onmouseover=function(){c=this.className;cl=(c)?c+' '+cs:cs;
 this.className=cl;};lg[k].onmouseout=function(){c=this.className;
 this.className=(c)?c.replace(r,''):'';};}}}nn=i+1;}
}