
/*
*******************************************************
** 	This file holds the javascripts for the website
*******************************************************
*/

// updateWindow function used to update the iFrame when a button is clicked
function updateWindow(frame,source){
	document.getElementById(frame).src = source;
}

// redirect is used to redirect the whole window somewhere else
function redirect(location)	{ 
	window.location = location;
}

// checkIe is used to call the BrowserDetect functions and check whether or not a user is using
// internet explorer
function checkIe(ieLocation,otherLocation)
{
	if(BrowserDetect.browser == 'Explorer')
	{
		if( confirm("You're using a version of Internet Explorer, would you like to get Firefox to better view this website?") == false )
			redirect(ieLocation);
		else
			redirect("http://www.getfirefox.com/")
	}
	else
	{
		redirect(otherLocation)
	}
}

function getHost()
{
	theHost = top.location.host;
	theHost = theHost.replace('www.','');
	// return theHost;
	alert(theHost);
}

/*
	Here starts the stuff for the banners at the top.
*/
var count=1;
// This holds the images for the right image bar
var right= new Array;
	right[1]="images/smallSlideShow/1.jpg";
	right[2]="images/smallSlideShow/2.jpg";
	right[3]="images/sponsors/JCraig.jpg"; 
	right[4]="images/sponsors/fireknite.jpg";
// This holds the images for the left image bar
var left= new Array;
	left[1]="images/smallSlideShow/4.jpg";
	left[2]="images/smallSlideShow/3.jpg";
	left[3]="images/smallSlideShow/2.jpg";
	left[4]="images/smallSlideShow/1.jpg";
function swapbanner(){
	if (count<4) {
		document.getElementById('slideShow1').src=right[count];
		document.getElementById('slideShow').src=left[count];
		count=count+1; 
	}
	else{
		document.getElementById('slideShow1').src=right[count];
		document.getElementById('slideShow').src=left[count];
		count=1
	}
}
function timebanner(){
	setTimeout ("swapbanner(); timebanner();", 5000);
}
                                                                                

// ======================================================================
// = schedule function used to post upcoming rages to the schedule page =
// ======================================================================
function schedule(date,location,color){
	if (color == false){
		document.write(
		"<tr>" +
			"<td>" +	date + "</td>" +
			"<td>" + location + "</td>" + 
			"<td>" + "101 -- Garrett Alberson<br>" + 
			"241 -- Brady Alberson</td></tr>" 
			);                                                                    
		}
	else{
		 document.write(
		"<tr class='color'>" +
			"<td>" +	date + "</td>" +
			"<td>" + location + "</td>" + 
			"<td>" + "101 -- Garrett Alberson<br>" + 
			"241 -- Brady Alberson</td></tr>" 
			);                                                                    
		}       
}           

// ===============================================================================
// = results funciton used to post results of a given race to the schedule page. =
// ===============================================================================
function results(date,location,color,gPlace,bPlace){ 
	if( color == false ){ document.write( "<tr>" ); }                          
	else{ document.write( "<tr class='color'>" ); }
	
	document.write(
		"<td>" + date + "</td>" + 
		"<td>" + location + "</td>"
		);   
		
	if( gPlace == "1st" && bPlace != "DNR" ){ 
		document.write( "<td><font color='yellow'>101 -- Garrett Alberson -- " + gPlace + "</font><br>" +
		 				"241 -- Brady Alberson -- " + bPlace + "</td>" ); 
		}
	else if( gPlace == "1st" && bPlace == "DNR" ){
		document.write( "<td><font color='yellow'>101 -- Garrett Alberson -- " + gPlace + "</font></td>" );
	}
	else if( bPlace == "1st" && gPlace != "DNR" ){
		document.write( "<td>101 -- Garrett Alberson -- " + gPlace + "<br>" +
		 				"<font color='yellow'>241 -- Brady Alberson -- " + bPlace + "</font></td>" ); 
		}
	else if( bPlace == "1st" && gPlace == "DNR" ){
		document.write( "<td><font color='yellow'>241 -- Brady Alberson -- " + bPlace + "</font></td>" );		
	}
	else if( gPlace == "DNR" ){
		document.write( "<td>241 -- Brady Alberson -- " + bPlace + "</td>" );
	}
	else if( bPlace == "DNR" ){
		document.write( "<td>101 -- Garrett Alberson -- " + gPlace + "</td>" );
	}
	else{
		document.write( "<td>101 -- Garrett Alberson -- " + gPlace + "<br>" +
		 				"241 -- Brady Alberson -- " + bPlace + "</td>" ); 
		}
		                 
}










