﻿// NAVIGATION /////////////////////////////////////////////////

var Base="images/interface/nav/";

if (document.images) {     
	biodieselDIM = new Image();   biodieselDIM.src = Base + "biodieselDIM.gif";
    biodieselLIT = new Image();   biodieselLIT.src = Base + "biodieselLIT.gif";

    performanceDIM = new Image();   performanceDIM.src = Base + "performanceDIM.gif";
    performanceLIT = new Image();   performanceLIT.src = Base + "performanceLIT.gif";
               
    progressDIM = new Image();   progressDIM.src = Base + "progressDIM.gif";
    progressLIT = new Image();   progressLIT.src = Base + "progressLIT.gif";

    futureDIM = new Image();   futureDIM.src = Base + "futureDIM.gif";
    futureLIT = new Image();   futureLIT.src = Base + "futureLIT.gif";

    buyDIM = new Image();   buyDIM.src = Base + "buyDIM.gif";
    buyLIT = new Image();   buyLIT.src = Base + "buyLIT.gif";

    homeDIM = new Image();   homeDIM.src = Base + "homeDIM.gif";
    homeLIT = new Image();   homeLIT.src = Base + "homeLIT.gif";            
}             
                
function imgOn(imgName,target) {
	if (document.images) {
		document[target].src = eval(imgName + "LIT.src");       
	}
}
                
function imgOff(imgName,target) {
	if (document.images) {
		document[target].src = eval(imgName + "DIM.src");       
	}
}


// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
         rnd.seed = (rnd.seed*9301+49297) % 233280;
         return rnd.seed/(233280.0);
};
function rand(number) {
         return Math.ceil(rnd()*number);
};
// end central randomizer. -->


// WINDOW CLOSE AND LOADER /////////////////////////////////////////////////
function supressError() {
        return true;
    }

    function load(url) {

        window.onerror = supressError;
        opener.location.href = url;
        setTimeout('self.close()',1000);
  	}


// ENLARGEMENT WINDOW OPENER /////////////////////////////////////////////////

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



// WINDOW OPENER /////////////////////////////////////////////////

var myWindow = 'LinkWindow';

function win(fileName) {
        window.open(fileName,myWindow,'scrollbars=yes,resizable=yes,status=yes,toolbar=yes,width=550,height=400,screenX=0,screenY=0,top=0,left=235')
}

var myWindow = 'LinkWindow';

function winVER(fileName) {
        window.open(fileName,myWindow,'scrollbars=yes,resizable=yes,status=yes,toolbar=yes,width=400,height=500,screenX=0,screenY=0,top=0,left=235')
}


var myWindow = 'LinkWindow';

function winSML(fileName) {
        window.open(fileName,myWindow,'scrollbars=yes,resizable=yes,status=yes,toolbar=no,width=420,height=440,screenX=0,screenY=0,top=0,left=235')
}


// DATE ///////////////////////////////////////////////////////////
	var today=new Date();
	
	function nameDay() {
	  var arg1=nameDay.arguments;
	  for (var i=0; i < arg1.length; i++) {
	    this[i]=arg1[i];
	  }
	  this.length=arg1.length;
	}
	
	function nameMonth() {
	  var arg2=nameMonth.arguments;
	  for (var i=0; i < arg2.length; i++) {
	    this[i]=arg2[i];
	  }
	  this.length=arg2.length;
	}

	function getString(date) {
	  var day=new nameDay("Sunday", "Monday", "Tuesday","Wednesday", "Thursday", "Friday","Saturday");
	  var month=new nameMonth("January","February","March","April","May","June","July","August","September","October","November","December");
	  var yy = date.getYear();
	  var year = (yy < 1000) ? yy + 1900 : yy;
	  
	  return day[date.getDay()] + ", " + month[date.getMonth()] + " " + date.getDate() + ", " + year;
	}
	
	function printDate(){	
		var display=getString(today);
		document.write(display);
	}
    
   function validateGameForm() {
    if (document.gameform.firstname.value=="") {
    	alert('You must fill in the First Name field before submitting');
    	document.gameform.firstname.focus();
    	return false;
    }
    if (document.gameform.lastname.value=="") {
    	alert('You must fill in the Last Name field before submitting');
    	document.gameform.lastname.focus();
    	return false;
    }
    if (document.gameform.email.value=="") {
    	alert('You must fill in the Email field before submitting');
    	document.gameform.email.focus();
    	return false;
    }
    if (document.gameform.email.value.indexOf("@")<0) {
    	alert('You have entered an invalid email address.  Please correct before submitting');
    	document.gameform.email.focus();
    	return false;
    }
    if (document.gameform.address.value=="") {
    	alert('You must fill in the Address field before submitting');
    	document.gameform.address.focus();
    	return false;
    }
    if (document.gameform.city.value=="") {
    	alert('You must fill in the City field before submitting');
    	document.gameform.city.focus();
    	return false;
    }
    if (document.gameform.state.value=="") {
    	alert('You must fill in the State field before submitting');
    	document.gameform.state.focus();
    	return false;
    }
    if (document.gameform.zipcode.value=="") {
    	alert('You must fill in the Zip field before submitting');
    	document.gameform.zipcode.focus();
    	return false;
    }
    if (document.gameform.phone.value=="") {
    	alert('You must fill in the Phone field before submitting');
    	document.gameform.phone.focus();
    	return false;
    }
    if (document.gameform.employmentStatus[3].checked) {
    	alert('This game is only available for commercial truck drivers or for commercial trucking industry');
    	return false;
    }
    if (document.gameform.thoughts[0].checked == false && document.gameform.thoughts[1].checked == false) {
    	alert('You must answer question 2a before submitting.');
    	return false;
    }
    if (document.gameform.thirtydays[0].checked == false && document.gameform.thirtydays[1].checked == false && document.gameform.thirtydays[2].checked == false) {
    	alert('You must answer question 2b before submitting.');
    	return false;
    }
    if (document.gameform.mainReason[0].checked == false && document.gameform.mainReason[1].checked == false && document.gameform.mainReason[2].checked == false && document.gameform.mainReason[3].checked == false && document.gameform.mainReason[4].checked == false) {
    	alert('You must answer question 2c before submitting.');
    	return false;
    }    
    if (document.gameform.eligible[1].checked) {
    	alert('You have checked that you are not eligible to participate in this contest at this time.');
    	return false;
    }
    
    
   }    
