/*

:: 022904
:: dave@imaginary-designs.com

This file formats the "red" display, and mostly is just responsbile 
for setting up the itnro countdown text and then the navigation sheme.

It looks at global variable called "page_type" that is created in func_redView.php
to determine what type of navigation to display. 

It stores a quick session only cookie to decide if to show the intro text or not each time.

*/



function timeWriteHtml()
{

	if (getCookie("visit") != null)
	{
		displayNav(0, page_type);	//show nav NOW.
	
	} else {			//show intro.

		//store cookie to determine if we show the intro
		var cName = "visit";
		var cValue = 1;
		
		var exp = new Date();											//create date object to reference
		var two_weeks = exp.getTime() + (14 * (24 * 60 * 60 * 1000));	//set expiration to 2 weeks using now time
		
		exp.setTime(two_weeks);											//set the time object value to be two weeks from now.
		setCookie(cName, cValue, exp);
		
		//dont like the droplets, lets wait on these.
		//set droplets to true in cookie
		//var cName = "droplets";
		//var cValue = true;
		//setCookie(cName, cValue);


		//create word array
		var wordArray = new Array(	"woman", "motorcycle", "toaster", "movie", "tiger", "hand tool", "house", 
									"mountain", "ocean", "skyline", "stary night", "ardvark", "computer", "vegetable",
									"fact", "science", "peom", "sound", "idea", "cat", "friend", "drawing", "hair-do", 
									"fire place", "science", "man", "duck", "is", "fact", "vaccum", "VCR", "monkey",
									"concept", "microwave oven",
									"<b>science</b>", "vegetarian", "is", "basketball", "<b>fact</b>", "mouse", "beauty", 
									"table", "<b>is</b>", "golden retriever", "truth", "bed spread", "egg", "shoe",   
									"science", "web page", "<b>is</b>", "telephone", "fact", "hat", "<b>beauty</b>", 
									"character", "is", "imagination", "<b>truth</b>", 	
									"<b>science</b>", "is", "<b>fact</b>", "beauty", "<b>is</b>", "truth",
									"<b>science</b>", "is", "<b>fact</b>", "<b>beauty</b>", "is", "<b>truth</b>" 
								);

		var iArray = new Array (	 "imagine", "the", "difference", "imagine", "the", "difference", "imagine", "the", "difference",
									"<b>imagine</b>", "the", "<b>difference</b>", "imagine", "<b>the</b>", "difference", "<b>imagine</b>", "the", "<b>difference</b>", 
									"imagine", "<b>the</b>", "difference", "<b>imagine</b>", "the", "<b>difference</b>", "<b>imagine</b>", "the", "<b>difference</b>"
								);



		var textArray = new Array();
		var singleWord = new Array();

		//populate the text array
		for (var j=0; j < wordArray.length; j++ )
		{
			textArray[textArray.length] = "<p>...a beautiful "+wordArray[j]+",</p>";
			singleWord[singleWord.length] = "..."+wordArray[j];
		}

		sndStr = '<p>when was the last time you saw...</p>';
		writeHtml(sndStr);

		sndStrA = '<p>...a beautiful sunset,</p>';
		setTimeout('writeHtml(sndStrA)', 3000);

		sndStrB = '<p>...a beautiful painting,</p>';
		setTimeout('writeHtml(sndStrB)', 4500);

		startTime = 6000;

		//display the sentences
		for (var i=0; i < textArray.length; i++)
		{
			eval("sndStr"+i+" = textArray[i]");
			tmpTime = startTime + 200;
			
			eval("setTimeout('writeHtml(sndStr"+i+")', startTime)");
			startTime = tmpTime;
		}

		startTime = startTime + 150;

		//start the single words
		for (var i=54; i < textArray.length; i++)
		{
			eval("sndStr"+i+" = singleWord[i]");
			tmpTime = startTime + 400;
			
			eval("setTimeout('writeHtml(sndStr"+i+")', startTime)");
			startTime = tmpTime;
		}

		//pause
		startTime = startTime + 2000;
		sendStrC = "what would you create if the sky wasn't the limit?";
		setTimeout('writeHtml(sendStrC)',startTime);
		
		//pause 2
		startTime = startTime + 4000;
		sendStrD = "would you know where to start?";
		setTimeout('writeHtml(sendStrD)',startTime);	

		//pause after pause 2
		startTime = startTime + 4000;

		//start imagine the difference
		for (var i=0; i < iArray.length; i++)
		{
			eval("sndStr_"+i+" = iArray[i]");	//note the addition of the _ character to change var
			tmpTime = startTime + 70;
			
			eval("setTimeout('writeHtml(sndStr_"+i+")', startTime)");
			startTime = tmpTime;
		}

		//imagine the difference static
		startTime = startTime + 70;
		sendStrE = "<b>imagine</b>";
		setTimeout('writeHtml(sendStrE)',startTime);
		
		//imagine the difference static
		startTime = startTime + 600;
		sendStrF = "<b>imagine</b> the";
		setTimeout('writeHtml(sendStrF)',startTime);

		//imagine the difference static
		startTime = startTime + 600;
		sendStrG = "<b>imagine</b> the difference.";
		setTimeout('writeHtml(sendStrG)',startTime);

		//show the nav
		startTime = startTime + 3000;
		displayNav(startTime, page_type);
	}
}

//----------------------------
function displayNav(inTime, format)
{
	var spacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

	//255 is home, 1 is interior
	if (format == 255)
	{
		navHtml = '<p><a href="index.php?t2=0">web & hosting <img src="images/img_plus.gif" height="7" width="7" border="0"></a></p>'
				+ '<p><a href="index.php?t2=1">print & multimedia <img src="images/img_plus.gif" height="7" width="7" border="0"></a></p>'
				+ '<p><a href="index.php?t2=2">racing products <img src="images/img_plus.gif" height="7" width="7" border="0"></a></p>';
	} else {
		navHtml = '<nobr><a href="index.php?t2=0">web & hosting <img src="images/img_plus.gif" height="7" width="7" border="0"></a>'
				+ spacer +'<a href="index.php?t2=1">print & multimedia <img src="images/img_plus.gif" height="7" width="7" border="0"></a>'
				+ spacer +'<a href="index.php?t2=2">racing products <img src="images/img_plus.gif" height="7" width="7" border="0"></a></nobr>';
	}


	setTimeout('writeHtml(navHtml)', inTime);	//display nav
	
	//do we show the mouse droplets?
	//if (getCookie("droplets") == true)
	//	setTimeout('JSFX.Droplets(40,0)', inTime);
}

//----------------------------------
function writeHtml(inStr)
{
	var ele = document.getElementById("textDisplay");
	//var textNode= ele.childNodes[0];
	
	//this works in IE, not DOM compatible however.
	ele.innerHTML = inStr;
}



/*code for extending String object with method that writes text backwards*/
//core custom method for writing text backwards
function outputbackwards()
{
	for (i=this.length-1;i>=0;i--)
		document.write(this.charAt(i))	
}

//Attach custom method to string object
String.prototype.writeback=outputbackwards


/*

The above code may not look like much, but it just added a whole new functionality to
the default string object- the ability to output any text backwards! Here are a few examples:

var message1="Welcome to my site!"
message1.writeback()
var message2="Today is a beautiful day"
message2.writeback()

*/


