//	A "True" Preloader
//	Written by: Randy Girard - April 2003
//	You are free to redistribute or edit this code in
//	any way as long as this notice stays intact.

var DoRedirect = "true"; 	
var RedirectTo = "frameset.htm";	
var AmmountPreloads = 75;
var imgArray = CreateArray(AmmountPreloads + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75);

    //IMAGES
	imgArray[1][0] = "images/right_whole.jpg";
	imgArray[1][1] = "image"; 
	imgArray[2][0] = "images/right_top.jpg";
	imgArray[3][0] = "images/menu.jpg";
	imgArray[4][0] = "images/left_top.jpg";
	imgArray[5][0] = "images/left_bottom.jpg";
	imgArray[6][0] = "images/left_bottom.jpg";
	imgArray[7][0] = "images/welcome.jpg";
	imgArray[8][0] = "images/welcome_page.jpg";
	//BUTTON_ICONS
	imgArray[9][0] = "images/button_icons/home0.gif";
	imgArray[10][0] = "images/button_icons/guestbook0.gif";
	imgArray[11][0] = "images/button_icons/mailto0.gif";
	//BUTTON_ICONS-IN-CTIVE
	imgArray[12][0] = "images/button_icons/home.gif";
	imgArray[13][0] = "images/button_icons/guestbook.gif";
	imgArray[14][0] = "images/button_icons/mailto.gif";
	//MENU_ACTIVEBUTTONS
	imgArray[15][0] = "menu_buttons/1_welcome0.gif";
	imgArray[16][0] = "menu_buttons/1_facilities0.gif";
	imgArray[17][0] = "menu_buttons/1_advandidj0.gif";
	imgArray[18][0] = "menu_buttons/1_basketball0.gif";
	imgArray[19][0] = "menu_buttons/1_work0.gif";
	imgArray[20][0] = "menu_buttons/1_bbq0.gif";
	imgArray[21][0] = "menu_buttons/1_parties0.gif";
	imgArray[22][0] = "menu_buttons/1_theunicorn0.gif";
	//MENU_IN-ACTIVEBUTTONS
	imgArray[23][0] = "menu_buttons/1_welcome.gif";
	imgArray[24][0] = "menu_buttons/1_facilities.gif";
	imgArray[25][0] = "menu_buttons/1_advandidj.gif";
	imgArray[26][0] = "menu_buttons/1_basketball.gif";
	imgArray[27][0] = "menu_buttons/1_work.gif";
	imgArray[28][0] = "menu_buttons/1_bbq.gif";
	imgArray[30][0] = "menu_buttons/1_parties.gif";
	imgArray[31][0] = "menu_buttons/1_theunicorn0.gif";
	//MENU
	imgArray[32][0] = "menu_buttons/1_2lines.gif.gif";
	imgArray[33][0] = "menu_buttons/2_1lines.gif.gif";
	imgArray[34][0] = "menu_buttons/2_3lines.gif.gif";
	imgArray[35][0] = "menu_buttons/3_1lines.gif.gif";
	imgArray[36][0] = "menu_buttons/3_3lines.gif.gif";
	imgArray[37][0] = "menu_buttons/4_2.gif.gif";
	imgArray[38][0] = "menu_buttons/5_1.gif";
	imgArray[39][0] = "menu_buttons/5_3.gif";
	imgArray[40][0] = "menu_buttons/6_1lines.gif";
	imgArray[41][0] = "menu_buttons/6_3lines.gif";
	imgArray[42][0] = "menu_buttons/7_1lines.gif";
	imgArray[43][0] = "menu_buttons/7_3lines.gif";
	imgArray[44][0] = "menu_buttons/8_2lines.gif";
	imgArray[45][0] = "menu_buttons/9_endlines.gif";
	imgArray[46][0] = "menu_buttons/lines2advandidj.gif";
	imgArray[47][0] = "menu_buttons/lines2basketball.gif";
	imgArray[48][0] = "menu_buttons/lines2bbq.gif";
	imgArray[49][0] = "menu_buttons/lines2facilities.gif";
	imgArray[50][0] = "menu_buttons/lines2parties.gif";
	imgArray[51][0] = "menu_buttons/lines2work.gif";
	imgArray[52][0] = "menu_buttons/lines2unicorn.gif";
	//ADVNDIDJ
	imgArray[53][0] = "images/advandidj/top.jpg";
	imgArray[54][0] = "images/advandidj/advandidj0.jpg";
	//FCILTIES
	imgArray[55][0] = "images/facilities/top.jpg";
	imgArray[56][0] = "images/facilities/page2.jpg";
	imgArray[57][0] = "images/facilities/page1.jpg";
	//WORK
	imgArray[58][0] = "images/work/top.jpg";
	imgArray[59][0] = "images/work/page2.jpg";
	imgArray[60][0] = "images/work/page3.jpg";
	imgArray[61][0] = "images/work/page4.jpg";
	imgArray[62][0] = "images/work/page5.jpg";	
	//BSKTBALL
	imgArray[63][0] = "images/basketball/top.jpg";
	imgArray[64][0] = "images/basketball/down.jpg";
	//BBQ
	imgArray[65][0] = "images/bbq/top.jpg";
	imgArray[66][0] = "images/bbq/page1.jpg";
	//PARTIES
	imgArray[67][0] = "images/parties/top.jpg";
	imgArray[68][0] = "images/parties/page1.jpg";
	imgArray[69][0] = "images/parties/page2.jpg";
	imgArray[70][0] = "images/parties/page3.jpg";
	imgArray[71][0] = "images/parties/page4.jpg";
	//UNICRN
	imgArray[72][0] = "images/unicorn_houseboat/top.jpg";
	imgArray[73][0] = "images/unicorn_houseboat/page1.jpg";
	imgArray[74][0] = "images/unicorn_houseboat/page2.jpg";
	imgArray[75][0] = "images/unicorn_houseboat/down.jpg";
	

		//This function creates 2 dimension arrays
	function CreateArray(dim1) {
		if (CreateArray.arguments.length == 1) {
			return new Array(dim1);
		} else {
			var multiArray = new Array(dim1)
			for (var i = 0; i < dim1; i++) {
				multiArray[i] = new Array(CreateArray.arguments[1]);
			}
			return multiArray;
		}
	}

//This will print a hidden DIV layer for us to preload our stuff on.
window.document.write("<div id='preloadLayer' style='position:absolute; left:0px; top:0px; width:0px; height:1px; z-index:1; visibility: hidden;'>");

//Loop through all of our things to preload
var LastType = "";
for (loop = 1; loop < imgArray.length; loop++) {
	var PrintString = "";
	var CheckType = "";

	//Check to make sure the path to what we are preloading exists
	if ( imgArray[loop][0] ) {
	//Check if it is an image type of load
	if ( imgArray[loop][1] == "image" || (!imgArray[loop][1] && LastType == "image" )) {
		//A simple image code is written to the page
		PrintString = "<img src='" + imgArray[loop][0] + "'>";
	//Check if it is a flash type of load
	} else if ( imgArray[loop][1] == "flash" || (!imgArray[loop][1] && LastType == "flash" )) {
		//Again, a pretty simple flash code is written to the page
		PrintString = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'> <PARAM NAME=movie VALUE='" + imgArray[loop][0] + "'> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src='" + imgArray[loop][0] + "' quality=high bgcolor=#000000 ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>";
	//Self explanitary ^_^
	} else {
		//O NO!! The type of load they specified is not supported!! Lets alert the user
		alert("Preload Warning: File type '" + imgArray[loop][1] + "' is not supported!! Keep in mind this is Case-sensitive!!");
	}
	//If this loop has a type, lets set the LastType variable
	if ( imgArray[loop][1] ) { LastType = imgArray[loop][1]; } }

	//Lets print the string we have generated. if there isn't one, just a new line is printed.
	window.document.write("<br>" + PrintString);
}

//We're done printing out our stuff, so we need the closing tag for the div layer:
window.document.write("</div>");


//This function will redirect to the page specified at the top of this script
function Redirect() {
    window.location.replace(RedirectTo);
}

//Now lets set an event so that once the page fully loads, we will redirect to the next page.
//Also added an option to cancel the redirect.
if ( DoRedirect == "true" ) {
	window.onload = Redirect;
}