/* MAIN MENU MOUSEOVERS */

function reviewsMouseOver()
{
document.reviews.src ="images/reviews2.gif";
}

function reviewsMouseOut()
{
document.reviews.src ="images/reviews.gif";
}


function photosMouseOver()
{
document.photos.src ="images/photos2.gif";
}
function photosMouseOut()
{
document.photos.src ="images/photos.gif";
}


function sponsorsMouseOver()
{
document.sponsors.src ="images/sponsors2.gif";
}
function sponsorsMouseOut()
{
document.sponsors.src ="images/sponsors.gif";
}


function classifiedsMouseOver()
{
document.classifieds.src ="images/classifieds2.gif";
}
function classifiedsMouseOut()
{
document.classifieds.src ="images/classifieds.gif";
}


function othergoodstuffMouseOver()
{
document.othergoodstuff.src ="images/othergoodstuff2.gif";
}
function othergoodstuffMouseOut()
{
document.othergoodstuff.src ="images/othergoodstuff.gif";
}


function guestbookMouseOver()
{
document.guestbook.src ="images/guestbook2.gif";
}
function guestbookMouseOut()
{
document.guestbook.src ="images/guestbook.gif";
}




/* HOME PAGE IMAGE SWAP*/

var homepageImageFileName = new Array(10);
homepageImageFileName[0] = "images/homepageimage1.gif";
homepageImageFileName[1] = "images/homepageimage2.gif";
homepageImageFileName[2] = "images/homepageimage3.gif";
homepageImageFileName[3] = "images/homepageimage4.gif";
homepageImageFileName[4] = "images/homepageimage5.gif";
homepageImageFileName[5] = "images/homepageimage6.gif";
homepageImageFileName[6] = "images/homepageimage7.gif";
homepageImageFileName[7] = "images/homepageimage8.gif";
homepageImageFileName[8] = "images/homepageimage9.gif";
homepageImageFileName[9] = "images/homepageimage10.gif";

var index = Math.round(10*Math.random());

function homePageImageSwap(){
	if(index>=0 && index<=9){
    document.getElementById("image").src=homepageImageFileName[index];

    }
    else{
    index=0;
    document.getElementById("image").src=homepageImageFileName[index];

    }
}

/* HOME PAGE GET TIP */

var tipDatabase = new Array(20);
tipDatabase[0] = "Before heading out on the track, remember to check your oil level. Most cars need to run a little extra oil to prevent oil pressure loss in high G corners.";
tipDatabase[1] = "Talk to more experienced drivers at the track and see what&#39;s working for them. Make note of their tire preference, preparation, and habits.";
tipDatabase[2] = "Use air pressure to fine tune handling. Higher air pressure will effectively &#39;stiffen&#39; your tires side wall, creating more resistance to body roll. Varying pressures front to rear can help improve the cars balance.";
tipDatabase[3] = "Prepare tools for common repairs. I have a separate box with tools for replacing brakes and taking wheels off. I use these more often, so I keep them together.";
tipDatabase[4] = "If you feel exhausted or are making mistakes at an HPDE, pull into the pit lane. Accidents happen when you don’t devote 100% attention. Better to pull in early than get towed back on the wrecker.";
tipDatabase[5] = "There are fast corners and there are slow corners. Learn the difference.";
tipDatabase[6] = "Smooth is fast. Driving beyond your limits or the car&#39;s limits wastes time and often results in expensive learning opportunities.";
tipDatabase[7] = "Drive with a soft grip of the steering wheel. You can&#39;t feel what the tires are telling you with the grip of death.";
tipDatabase[8] = "Mentally prepare yourself by memorizing the track layout and racing line.";
tipDatabase[9] = "Practice is far more important than modifications. Learn to drive before deciding what to modify.";
tipDatabase[10] = "Get a good night&#39;s sleep before race day and drink plenty of water to stay hydrated.";
tipDatabase[11] = "Make a checklist of everything you need to pack before the event. Forgetting you helmet, extra tires, or even keys at home does you no good at the track.";
tipDatabase[12] = "Can&#39;t afford to road race? Try HPDE. If HPDE is still too expensive, autox is very fun, safe, competitive, and CHEAP.";
tipDatabase[12] = "Friends don’t let friend apex early.";
tipDatabase[13] = "Figure out where to place the car, then drive slow enough to put it there.";
tipDatabase[14] = "Balance the car in a corner by applying throttle. You should never be coasting through a corner.";
tipDatabase[15] = "Look ahead, no look even <em>farther</em> ahead.";
tipDatabase[16] = "Tighter lines use less distance. Wider lines take more distance, but at a slightly higher speed. Tighter is usually faster.";
tipDatabase[17] = "Keeping the wife happy at the track increases your joy exponentially.";
tipDatabase[18] = "Brake earlier, but slow down less. Many drivers overcook turn entry. Braking a few feet earlier, but intentionally trying to carry more speed, will help you be smoother and faster.";
tipDatabase[19] = "Give up speed at a corner entry to get it back at the end of the following straight. Rushing the corner entrance only reduces your acceleration coming out of it.";



var randomTip = Math.round(20*Math.random());

function getTip(){
	if(randomTip>=0 && randomTip<=20){
	return("<p>" + tipDatabase[randomTip] + "</p>");
    }
    else{
    randomTip=0;
    return("<p>" + tipDatabase[randomTip] + "</p>");
    }
}



/* HOME PAGE GET QUOTE */

var quoteDatabase = new Array(19);
quoteDatabase[0] = "Every car has a lot of speed in it. The trick is getting the speed out of it.";
quoteDatabase[1] = "Glory, it&#39;s the one thing that makes this dangerous, expensive, all consuming sport worthwhile.";
quoteDatabase[2] = "Speed is a great asset; but it's greater when it's combined with quickness - and there&#39;s a big difference.";
quoteDatabase[3] = "The world land speed record requires the minimum of skill and the maximum of courage.";
quoteDatabase[4] = "My speed is my greatest asset.";
quoteDatabase[5] = "A well-used race car carries all the creases and scars of a sport that is harder on machinery than any other human activity I can think of, other than war.";
quoteDatabase[6] = "If everything seems under control, you're just not going fast enough.";
quoteDatabase[7] = "Racing is LIFE..everything before and after is simply waiting.";
quoteDatabase[8] = "I lifted, because otherwise I would have scratched the roof.";
quoteDatabase[9] = "The snow is not a handicap. It is your best training partner. Racers don&#39;t have an off-season.";
quoteDatabase[10] = "Racing is the process of turning money into noise.";
quoteDatabase[11] = "Faster, faster! Until the thrill of speed overcomes the fear of death!";
quoteDatabase[12] = "I'm Valentino Rossi. And I want to be a person, not an icon.";
quoteDatabase[13] = "No risk, no fun.";
quoteDatabase[14] = "The same moment that you are seen as the best, the fastest, and somebody that cannot be touched, you are enormously fragile.";
quoteDatabase[15] = "Fear is exciting for me.";
quoteDatabase[16] = "If you have God on your side, everything becomes clear.";
quoteDatabase[17] = "More people die fishing than die in Formula One cars.";
quoteDatabase[18] = "Understeering is when you hit the wall with the front of the car and oversteering is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall, torque is how far you take the wall with you.";



var authorDatabase = new Array(19);
authorDatabase[0] = "A J Foyt";
authorDatabase[1] = "Sam Posey";
authorDatabase[2] = "Ty Cobb";
authorDatabase[3] = "Tommy Wisdom";
authorDatabase[4] = "Peter Bondra";
authorDatabase[5] = "Peter Egan";
authorDatabase[6] = "Mario Andretti";
authorDatabase[7] = "Steve McQueen";
authorDatabase[8] = "Steve Millen";
authorDatabase[9] = "Ryosuke Takahashi";
authorDatabase[10] = "A Wise Racer";
authorDatabase[11] = "H.S. Thompson";
authorDatabase[12] = "Valentino Rossi";
authorDatabase[13] = "Michael Schumacher";
authorDatabase[14] = "Ayrton Senna";
authorDatabase[15] = "Ayrton Senna";
authorDatabase[16] = "Ayrton Senna";
authorDatabase[17] = "Jackie Stewart";
authorDatabase[18] = "Anonymous";



var randomQuote = Math.round(19*Math.random());

function getQuote(){
	if(randomQuote>=0 && randomQuote<=19){
	return("<p class='quote'>" + quoteDatabase[randomQuote] + "</p>" + "<p class='author'>" + authorDatabase[randomQuote] + "</p>");
    }
    else{
    randomQuote=0;
    return("<p class='quote'>" + quoteDatabase[randomQuote] + "</p>" + "<p class='author'>" + authorDatabase[randomQuote] + "</p>");
    }
}





/* PHOTO PAGE MOUSEOVERS */

var thumbnail = 0;

var openWindow;

function imageEnlarge(){
openwindow = window.open("photoenlarge.html", "windowname", "height=300, width=400, menubar=no, status=no, scrollbars=no, toolbar=no, top=150, left=150, resizable=no");
openwindow.focus();
setTimeout("closeImageEnlarge()", 3000);
}

function closeImageEnlarge(){
openwindow.window.close();
}

function imageLarge(){

}





/* SPONSORS MOUSEOVER  */

function contactmeMouseOver()
{
document.contactme.src ="images/sponsors/contactme2.gif";
}

function contactmeMouseOut()
{
document.contactme.src ="images/sponsors/contactme.gif";
}





/* CLASSIFIEDS MOUSEOVER  */

function contactme1MouseOver()
{
document.contactme1.src ="images/classifieds/contactmeB.gif";
}

function contactme1MouseOut()
{
document.contactme1.src ="images/classifieds/contactmeA.gif";
}

function contactme2MouseOver()
{
document.contactme2.src ="images/classifieds/contactmeB.gif";
}

function contactme2MouseOut()
{
document.contactme2.src ="images/classifieds/contactmeA.gif";
}



/* GUESTBOOK POST VALIDATION */


var emailCheck = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;


function validatePost() {
if(document.forms[0].name.value==""){
window.alert("Please enter your name or handle.");
return false;
}


else if (document.forms[0].email.value=="") {
window.alert("Please enter an email address.");
return false;
}

else if (emailCheck.test(document.forms[0].email.value) == false){
window.alert("Please enter a valid email address. It will not be posted.");
return false;
}

else if (document.forms[0].comments.value==""){
window.alert("Please compose a message before submitting.");
return false;
}

else if (document.forms[0].number.value==""){
window.alert("Please enter the verification code.");
return false;
}

else{
publishPost();

}
}


var today = new Date();


var monthDatabase = new Array(12);
monthDatabase[0]="1";
monthDatabase[1]="2";
monthDatabase[2]="3";
monthDatabase[3]="4";
monthDatabase[4]="5";
monthDatabase[5]="6";
monthDatabase[6]="7";
monthDatabase[7]="8";
monthDatabase[8]="9";
monthDatabase[9]="10";
monthDatabase[10]="11";
monthDatabase[11]="12";

var month = monthDatabase[today.getMonth()];


var date = today.getDate();

var year = today.getFullYear();


var postDate = month + "\/" + date + "\/" + year;



/* CONTACT FORM VALIDATION */

var emailCheck = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

function validateForm() {
if(document.forms[0].name.value==""){
window.alert("Please enter your name.");
return false;
}


else if (document.forms[0].email.value=="") {
window.alert("Please enter an email address.");
return false;
}

else if (emailCheck.test(document.forms[0].email.value) == false){
window.alert("Please enter a valid email address.");
return false;
}

else if (document.forms[0].comments.value==""){
window.alert("Please enter a comment before submitting.");
return false;
}
else{
return true;
}
}


