function navOn(nav) {
	oldsrc = document.getElementById(nav).src;
	newsrc = oldsrc.split(".jpg");
	document.getElementById(nav).src = newsrc[0]+"on.jpg";
}

function navOff(nav) {
	oldsrc = document.getElementById(nav).src;
	newsrc = oldsrc.split("on.jpg");
	document.getElementById(nav).src = newsrc[0]+".jpg";
}

function subNav(subnav) {
	if(document.getElementById(subnav).style.display == "block") {
		document.getElementById(subnav).style.display = "none";
	}
	else {
		document.getElementById("subnav2").style.display = "none";
		document.getElementById("subnav5").style.display = "none";
		document.getElementById(subnav).style.display = "block";
	}
}

function FTshowpic(el,src) {
	document.getElementById(el).src = src;
}

function FTshowvehicle(el,src) {
	document.getElementById(el).src = src;
}

function FTchangethumbs(el,page,photopath)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
		catch (e)
  		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
  		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(el).innerHTML=xmlHttp.responseText;
		}
	}
	if(el=="ft-thumbs") {
		xmlHttp.open("GET","inc/ajax-FTchangethumbs.php?page="+page+"&photopath="+photopath);
	}
	else if(el=="ft-vehicles") {
		xmlHttp.open("GET","inc/ajax-FTchangevehicles.php?page="+page+"&photopath="+photopath);
	}
	else if(el=="mastthumbs") {
		xmlHttp.open("GET","inc/ajax-changemastheads.php?start="+page);
	}
	else if(el=="masthead") {
		xmlHttp.open("GET","inc/ajax-changemasthead.php?what="+page);
	}
	xmlHttp.send(null);
}

function FTchangethumbs2(el,page,photopath)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
		catch (e)
  		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
  		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(el).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","inc/ajax-FTchangethumbs3.php?page="+page+"&photopath="+photopath);
	xmlHttp.send(null);
}

function Fchangethumbs(el,page,photopath)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
		catch (e)
  		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
  		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(el).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","inc/ajax-FTchangethumbs2.php?page="+page+"&photopath="+photopath);
	xmlHttp.send(null);
}

function stayInformed() {
	if(document.stayinformed.firstname.value=="") { alert("Please enter your first name"); document.stayinformed.firstname.focus(); return false(); }
	if(document.stayinformed.lastname.value=="") { alert("Please enter your last name"); document.stayinformed.lastname.focus(); return false(); }
	if(document.stayinformed.email.value=="") { alert("Please enter your email"); document.stayinformed.name.focus(); return false(); }
	var firstname = document.stayinformed.firstname.value;
	var lastname = document.stayinformed.lastname.value;
	var usefox = document.stayinformed.usefox.value;
	var interested = document.stayinformed.interested.value;
	var live = document.stayinformed.live.value;
	var email = document.stayinformed.email.value;
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
		catch (e)
  		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
  		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('stayinformedform').innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","inc/ajax-stayinformed.php?firstname="+firstname+"&lastname="+lastname+"&usefox="+usefox+"&interested="+interested+"&live="+live+"&email="+email);
	xmlHttp.send(null);
}

function mhLoad(what,url,target) {
	document.getElementById("masthead").setAttribute("class", "loading"); 
	document.getElementById("masthead").setAttribute("className", "loading");
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
		catch (e)
  		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
  		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('masthead').innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","inc/ajax-changemasthead.php?what="+what+"&url="+url+"&target="+target);
	xmlHttp.send(null);
	document.getElementById("masthead").setAttribute("class", "done"); 
	document.getElementById("masthead").setAttribute("className", "done");
}

function launchAR(feature,arname) {
	window.open("pageconfig/features/"+feature+"-extras/ar/"+arname+".html","mywindow","menubar=0,resizable=0,location=0,status=0,scrollbars=0,width=680,height=520");
}

function startSwap(what, url, target) {
	if(fading==false) {
		var masthead = document.getElementById("masthead2");
		masthead.style.display = "block";
		masthead.style.filter = "alpha(opacity:0)";
		masthead.style.KHTMLOpacity = 0;
		masthead.style.MozOpacity = 0;
		masthead.style.opacity = 0;
		document.getElementById("masthead2").innerHTML = "<a href=\""+url+"\" target=\""+target+"\"><img src=\"images/mastheads/masthead-"+what+".jpg\" border=\"0\" width=\"861\" height=\"393\" /></a>";
		fadeIn(0, what, url, target);
	}
}

function fadeIn(opacity, what, url, target) {
	var masthead = document.getElementById("masthead2");
	if (opacity <= 100) {
		fading = true;
		opacity += 20;
		masthead.style.filter = "alpha(opacity:"+opacity+")";
		masthead.style.KHTMLOpacity = opacity/100;
		masthead.style.MozOpacity = opacity/100;
		masthead.style.opacity = opacity/100;
		window.setTimeout("fadeIn("+opacity+",'"+what+"','"+url+"','"+target+"')", 50);
	}
	else {
		fading = false;
		document.getElementById("masthead").innerHTML = "<a href=\""+url+"\" target=\""+target+"\"><img src=\"images/mastheads/masthead-"+what+".jpg\" border=\"0\" width=\"861\" height=\"393\" /></a>";
	}
}

mastHeads = new Array(
["koh2011","teamfox.php?discipline=offroad&member=campbell","_self"],
["5atvchamps","5atvchamps","_self"],
["2010-baja1000","2010-baja1000","_self"],
["shoxneedlove","shoxneedlove","_self"],
["301greaves","teamfox.php?discipline=offroad&member=greaves","_self"],
["301thacker","teamfox.php?discipline=snowmobile&member=thacker","_self"],
["pikespeak","pikespeak","_self"],
["160mm","160","_self"],
["180mm","180","_self"],
["1429","../1429/","_blank"],
["hall-of-fame","../hall-of-fame/","_blank"],
["xgames","../xgames14/","_blank"]
);

var count = 1;

function autoPlay() {
	startSwap(mastHeads[count][0],mastHeads[count][1],mastHeads[count][2]);
	if(count > mastHeads.length-2) {
		count = 0;
	}
	else {
		count++;
	}
}

function chgImg(o, n) {
	document.getElementById(o).src = n;
}
