// Use the following variable to
// specify the number of messages

var messages = new Array();

messages[0] = "When all else fails... buy No Water Balls...";
messages[1] = "Novelty golf balls clearly state your intentions. No Water, No Sand, and No Trees. Pretend to give yourself the advantage over course hazards with these technological wonders of the 21st Century!";
messages[2] = "Stay on the Fairway with NoWaterBall hazard avoidance balls. Combined with your golfing ability, NoWaterballs can keep you out of trouble. Just choose one for your particular needs. No Water to keep dry, No Sand to keep off the beach, or No Trees to stay out of jail.";
messages[3] = "These balls just might save your life! Course hazards today can raise blood-pressures to dangerous levels. Stay calm by staying out of trouble with the NoWaterBalls.";
messages[4] = "So many hazards, so little time. Give these to your partner to give him a boost of confidence, or give one to your opponent to remind him of what lies ahead. Either way, NoWaterBall golf balls are great on the course. Stay dry, stay out of jail, and stay off the beach.";
messages[5] = "Stay dry, stay off the beach, and keep clear of the trees with NoWaterBall";
messages[6] = "Great golfers avoid hazards. You're not a great golfer. Maybe these will help.";
messages[7] = "The only good golfers are on TV.";
messages[8] = "If you're gonna keep your head down, you might as well have a picture to look at.";
messages[9] = "Did your partner get over the water or out of the sand? Give him or her a NoWaterBall to commemorate the occasion.";
messages[10] = "For the golfer who has everything . . . except luck. NoWaterBall. Now with Luck-Infused for the statistically challenged golfer.";
messages[11] = "Great gift idea... bla bla bla whatever... Just buy the balls. They're funnier than anything we're going to put on this site.";
messages[12] = "Course hazards should not be tolerated. We don't tolerate course hazards. At NoWaterBall...ok... not sure where I was going with this one...";
messages[13] = "\"Nine out of Ten golfers agree: Sand, Water, and Trees are a real bummer.\"";
messages[14] = "All golfers agree that golf is more fun in the fairway. Stay there with NoWaterBall brand golf balls. Now 50% more reluctant to go into water.";
messages[15] = "NoWaterBalls: You've tried everything else, why not try these?";
messages[16] = "Is that a sleeve of NoWaterBalls in your pocket, or are you thinking about the beer cart girl?";
messages[17] = "Yes they really work. (As long as you hit the ball right.)";
messages[18] = "Your golf game will someday be telecast live over national television. (not)";
messages[19] = "Funny balls.";
messages[20] = "You can never spend enough on golf. Don't think about it, just buy them, you know you want them. Just think of how cool you'll be whipping one of these babies out on the tee box. Show them to the beer-cart girl. Give one to your partner. A great conversation starter.";
messages[21] = "Get some balls.";
messages[22] = "3 Novelty balls. But you already knew that, didn't you?";
messages[23] = "These balls are guaranteed to improve your play, help you lose weight, and be popular with the opposite sex. Um, actually, none of that is true, but the balls are pretty funny.";
messages[24] = "\"These balls are made with a space-aged polymer and have been blessed by priests. (not really, but they're pretty cool golf balls eh?\"";
messages[25] = "Wanna shoot par? Take lessons. Want some cool golf balls to show your friends? Buy these balls.";
messages[26] = "Do you want to improve your game and actually make money playing golf? Don't count on it. Want to get a laugh from your golf buddies? Buy NoWaterBall golf balls.";
messages[27] = "You want them... You know you want them...";
messages[28] = "You make enough money. You're successful. You're a golfer.";
messages[29] = "If you can't waste money on novelty golf balls to show your golf buddies . . .";
messages[30] = "I think a man once said . . . \"Don't go in there.\" He was talking about trees, water, and sand. Or was he talking about something else.";
messages[31] = "Space-aged polymer. GPS Tracking. Onboard course maps. Satellite guided flight path. Angle of attack sensors. Gyros. Military grade weapons guidance technology. These balls have none of that. But wouldn't it be cool to pretend that they did?";
messages[32] = "Developed with weapons grade guidance and tracking technology. Moisture avoidance coating. Space-aged polymers used by NASA. These balls have none of those things. But that would be cool, wouldn't it?";
messages[33] = "Send these to dad. He'll think they are funny.";
messages[34] = "Ask your doctor if NoWaterBall golf balls are right for you.";
messages[35] = "May cause serious injury if struck incorrectly.";
messages[36] = "Results may vary.";
messages[37] = "Winning Trajectory. Trusted Results. Yeah, Right.";
messages[38] = "These balls can't help you play better golf. But wouldn't it be neat if they could?";
messages[39] = "It's only a game.";
messages[40] = "Golf is a game of balance between power and accuracy. You have neither. But you can have some fun with NoWaterBall golf balls.";
messages[41] = "Here, you might need these... NoWaterBall.com";
messages[42] = "Who's yer daddy... That's right, NoWaterBall is...";
messages[43] = "Golf Lessons...   $350.00 <br>Sleeve of NoWaterBalls...  $9.99<br>Not putting your ball in the drink...   PRICELESS...";
messages[44] = "Keeping your balls dry, so you don't have to...That's the NoWaterBall Promise.";
messages[45] = "Keep your balls dry...";
messages[46] = "If you don't buy a sleeve of NoWaterBalls... the Terrorists win!!!";

function rotateEvery()
{
	document.getElementById('textrotator').style.backgroundColor = chooseRandomBGColor();

	var strMessage = "";
	var which = Math.round(Math.random()*(messages.length - 1));
//which = 46;
	strMessage = messages[which];
	document.getElementById('textrotator').innerHTML = strMessage;

	sec = (strMessage.length / 20) + 3;

	setTimeout('rotateEvery()', sec*1000);
}

function chooseRandomBGColor() {
	var intTotalColorOptions = 8;
	var strColor = "";
	switch (String(Math.round(Math.random()*intTotalColorOptions))) {
		case "0":
			strColor = "#4E7A2D";
			break;
		case "1":
			strColor = "#B23F50";
			break;
		case "2":
			strColor = "#007FBA";
			break;
		case "3":
			strColor = "#0D67A3";
			break;
		case "4":
			strColor = "#5F2B2D";
			break;
		case "5":
			strColor = "#545153";
			break;
		case "6":
			strColor = "#443838";
			break;
		case "7":
			strColor = "#3A6520";
			break;
		case "8":
			strColor = "#9F7D40";
			break;
		default:
			strColor = "#4E7A2D";
			break;
	}
	return strColor;
}

function dropTextHere(strWidth) {
	document.write("<br>&nbsp;<br><table style=\"width:"+ strWidth +";\"><tr><td style=\"padding:2 4 4 4;color:white;font:500 10pt Comic Sans MS;\" id=\"textrotator\"><!--Quotations will be displayed here--></td></tr></table>");
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function checkNumberSaved() {
    var datStarted = "6/1/2006";

    //Refersh the Number anywhere from 1 to 8 seconds
    intRandomAmount = Math.round(Math.random()*(7)) + 1;

    intRandomMissOrMake = Math.round(Math.random()*(3)) - 1;   // -1, 0 or +1

    intCurrentCount = DateDiff(new Date(), datStarted);

    // always incrementing (as long as time increases, our number of hazards avvoided will increase.
    intCurrentCount = (intCurrentCount / 42);

    // heheheh... sometimes we hit a few hazards :)
    intCurrentCount += intRandomMissOrMake;
    strCount = FormatNumber(intCurrentCount, 0, false, false, false);
    var strImageCount = "";

    for (i = 0; i < strCount.length; i++) {
    	strImageCount += "<img src='/images/counter/"+ strCount.charAt(i) +".gif'>";
    }

    document.getElementById('number_saved').innerHTML = strImageCount;

    setTimeout('checkNumberSaved()', (intRandomAmount * 205));

}

function dropNumberSavedHere(strAlgin) {
    document.write("<table align=\""+ strAlgin +"\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"background-color:white;height:15;padding:0 4 0 4;color:black;font:700 10pt Helvetica;\">Number of Hazards Avoided: </td><td style=\"padding:0 2 0 2;\" id=\"number_saved\"><!--Number Saved will be displayed here--></td></tr></table><br>");
    if (strAlgin == "right")
    	document.write("<br clear=\"all\"><br>");
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function DateDiff(date1, date2)
{
    //BETA VERSION - for now returns difference in seconds only.
    var objDate1=new Date(date1);
    var objDate2=new Date(date2);
    return (objDate1.getTime()-objDate2.getTime())/100;
}

function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
    IN:
        NUM - the number to format
        decimalNum - the number of decimal places to format the number to
        bolLeadingZero - true / false - display a leading zero for
                                        numbers between -1 and 1
        bolParens - true / false - use parenthesis around negative numbers
        bolCommas - put commas as number separators.

    RETVAL:
        The formatted number!
 **********************************************************************/
{
        if (isNaN(parseInt(num))) return "NaN";

    var tmpNum = num;
    var iSign = num < 0 ? -1 : 1;       // Get sign of number

    // Adjust number so only the specified number of numbers after
    // the decimal point are shown.
    tmpNum *= Math.pow(10,decimalNum);
    tmpNum = Math.round(Math.abs(tmpNum))
    tmpNum /= Math.pow(10,decimalNum);
    tmpNum *= iSign;                    // Readjust for sign


    // Create a string object to do our formatting on
    var tmpNumStr = new String(tmpNum);

    // See if we need to strip out the leading zero or not.
    if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
        if (num > 0)
            tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
        else
            tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);

    // See if we need to put in the commas
    if (bolCommas && (num >= 1000 || num <= -1000)) {
        var iStart = tmpNumStr.indexOf(".");
        if (iStart < 0)
            iStart = tmpNumStr.length;

        iStart -= 3;
        while (iStart >= 1) {
            tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
            iStart -= 3;
        }
    }

    // See if we need to use parenthesis
    if (bolParens && num < 0)
        tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

    return tmpNumStr;       // Return our formatted string!
}
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------

function preLoadCounterImages() {
	if (document.images)
	{
	   img0 = new Image();
	   img1 = new Image();
	   img2 = new Image();
	   img3 = new Image();
	   img4 = new Image();
	   img5 = new Image();
	   img6 = new Image();
	   img7 = new Image();
	   img8 = new Image();
	   img9 = new Image();
	   img0.src = "/images/counter/0.gif";
	   img1.src = "/images/counter/1.gif";
	   img2.src = "/images/counter/2.gif";
	   img3.src = "/images/counter/3.gif";
	   img4.src = "/images/counter/4.gif";
	   img5.src = "/images/counter/5.gif";
	   img6.src = "/images/counter/6.gif";
	   img7.src = "/images/counter/7.gif";
	   img8.src = "/images/counter/8.gif";
	   img9.src = "/images/counter/9.gif";
	}
}

function initScreen() {
	rotateEvery();
	checkNumberSaved();
	preLoadCounterImages();
}

window.onload = initScreen;
