/*
This is the javascript file for the Video page for The Junction, Inc. - KJP
Created July 6, 2009
*/

/* objectives:
1. clear center area
2. build DOM structure for specific images
3. Show images
*/


var picArray = new Array(

/* page 1 for truck / SUV */
['11','DSC00862.JPG'],
['11','IMG_2611.JPG'],
['11','DSC00863.JPG'],
['11','IMG_2614.JPG'],
['11','DSC00866.JPG'],
['11','IMG_2619.JPG'],
['11','IMG_2610.JPG'],
['11','IMG_2612.JPG'],
['11','DSC00869.JPG'],
['11','IMG_2615.JPG'],
['11','DSC00871.JPG'],
['11','IMG_2616.JPG'],
['11','IMG_2617.JPG'],
['11','IMG_2618.JPG'],
['11','DSC00872.JPG'],	/*	H2 hummer 	*/
['11','DSC00870.JPG'],
['11','DSC00865.JPG'],
['11','DSC00868.JPG'],
['11','DSC00864.JPG'],
['11','DSC00867.JPG'],
['11','IMG_2613.JPG'],

['11','DSC00884.JPG'],
['11','DSC00885.JPG'],
['11','DSC00886.JPG'],
['11','DSC00890.JPG'],
['11','DSC00887.JPG'],	/*	Excursion 	*/
['11','DSC00888.JPG'],
['11','DSC00889.JPG'],

/* page 2 for truck / SUV */
['12','IMG_2774.JPG'],
['12','IMG_2679.JPG'],
['12','IMG_2683.JPG'],
['12','IMG_2680.JPG'],
['12','IMG_2681.JPG'],  /*	show truck	*/
['12','IMG_2685.JPG'],
['12','IMG_2682.JPG'],

['12','IMG_2635.JPG'],
['12','DSC00835.JPG'],
['12','DSC00829.JPG'],
['12','DSC00830.JPG'],	/*	trailblazer	*/
['12','DSC00831.JPG'],
['12','DSC00834.JPG'],
['12','DSC00833.JPG'],
['12','DSC00832.JPG'],

['12','IMG_2654.JPG'],
['12','IMG_2651.JPG'],	/*	explorer	*/
['12','IMG_2652.JPG'],
['12','IMG_2653.JPG'],

['12','IMG_2631.JPG'],
['12','IMG_2632.JPG'],
['12','DSC00911.JPG'],	/* toyota	*/
['12','DSC00909.JPG'],
['12','DSC00910.JPG'],

/* page 3 for truck / SUV */
['13','IMG_2769.JPG'],
['13','IMG_2768.JPG'],
['13','DSC00846.JPG'],
['13','DSC00847.JPG'],
['13','DSC00852.JPG'],
['13','DSC00853.JPG'],
['13','DSC00854.JPG'],
['13','DSC00849.JPG'],
['13','DSC00850.JPG'],	/*	escalade	*/
['13','DSC00851.JPG'],
['13','DSC00848.JPG'],


/* page 1 for domestic cars */
['21','IMG_2696.JPG'],
['21','IMG_2770.JPG'],
['21','IMG_2705.JPG'],
['21','IMG_2698.JPG'],
['21','IMG_2699.JPG'],
['21','IMG_2700.JPG'],
['21','IMG_2701.JPG'],	/*	dodge srt-8	*/
['21','IMG_2703.JPG'],
['21','IMG_2704.JPG'],
['21','IMG_2702.JPG'],
['21','IMG_2708.JPG'],


/* page 1 for import cars */
['31','IMG_2771.JPG'],
['31','IMG_2689.JPG'],
['31','IMG_2690.JPG'],
['31','IMG_2686.JPG'],	/*	infinity	*/
['31','IMG_2687.JPG'],
['31','IMG_2688.JPG'],
['31','IMG_2684.JPG'],
['31','DSC00880.JPG'],
['31','DSC00881.JPG'],
['31','DSC00883.JPG'],
['31','IMG_2761.JPG'],

['31','IMG_2691.JPG'],
['31','IMG_2695.JPG'],
['31','IMG_2694.JPG'],	/*	lexus	*/
['31','IMG_2763.JPG'],
['31','IMG_2692.JPG'],
['31','IMG_2693.JPG'],
['31','IMG_2762.JPG'],
['31','IMG_2764.JPG'],

['31','IMG_2644.JPG'],
['31','IMG_2643.JPG'],

/* page 2 for import cars */
['32','IMG_2773.JPG'],
['32','IMG_2662.JPG'],	/*	gti white	*/
['32','IMG_2661.JPG'],
['32','IMG_2674.JPG'],
['32','IMG_2750.JPG'],
['32','IMG_2660.JPG'],

['32','IMG_2706.JPG'],
['32','IMG_2709.JPG'],	/* gti black	*/
['32','IMG_2747.JPG'],
['32','IMG_2707.JPG'],
['32','IMG_2746.JPG'],
['32','IMG_2710.JPG'],

['32','IMG_2667.JPG'],
['32','IMG_2668.JPG'],	/*	jetta	*/

/* page 3 for import cars */
['33','IMG_2663.JPG'],
['33','IMG_2753.JPG'],
['33','IMG_2754.JPG'],
['33','IMG_2665.JPG'],
['33','IMG_2664.JPG'],
['33','IMG_2758.JPG'],	/*	gti silver	*/
['33','IMG_2751.JPG'],
['33','IMG_2755.JPG'],
['33','IMG_2666.JPG'],
['33','IMG_2756.JPG'],
['33','IMG_2757.JPG'],
['33','IMG_2752.JPG'],

['33','IMG_2724.JPG'],
['33','IMG_2725.JPG'],	/*	honda SI	*/
['33','IMG_2726.JPG'],
['33','IMG_2727.JPG'],


/* page 4 for import cars */
['34','IMG_2714.JPG'],
['34','IMG_2789.JPG'],
['34','IMG_2745.JPG'],
['34','IMG_2732.JPG'],	/*	audi	*/
['34','IMG_2748.JPG'],
['34','IMG_2711.JPG'],
['34','IMG_2713.JPG'],
['34','IMG_2715.JPG'],

['34','IMG_2737.JPG'],	/*	s2000 black	*/
['34','IMG_2736.JPG'],
['34','IMG_2735.JPG'],
['34','IMG_2739.JPG'],
['34','IMG_2738.JPG'],
['34','IMG_2740.JPG'],

['34','IMG_2742.JPG'],	/*	s2000 silver	*/
['34','IMG_2743.JPG'],
['34','IMG_2744.JPG'],
['34','IMG_2741.JPG'],

/* page 5 for import cars */
['35','DSC00837.JPG'],
['35','IMG_2630.JPG'],
['35','DSC00836.JPG'],
['35','DSC00844.JPG'],
['35','DSC00843.JPG'],
['35','DSC00842.JPG'],
['35','DSC00840.JPG'],
['35','DSC00841.JPG'],	/* honda white	*/
['35','DSC00845.JPG'],
['35','IMG_2629.JPG'],
['35','DSC00839.JPG'],

['35','IMG_2675.JPG'],
['35','IMG_2749.JPG'],
['35','IMG_2671.JPG'],
['35','IMG_2672.JPG'],
['35','IMG_2673.JPG'],	/* honda gray	*/
['35','IMG_2677.JPG'],
['35','IMG_2678.JPG'],
['35','IMG_2676.JPG'],

['35','IMG_2638.JPG'],
['35','DSC00855.JPG'],
['35','DSC00857.JPG'],
['35','IMG_2637.JPG'],	/*	BMW M3	*/
['35','DSC00861.JPG'],
['35','DSC00860.JPG'],
['35','DSC00856.JPG'],
['35','DSC00858.JPG'],
['35','DSC00859.JPG'],



/* page 1 for motorcycle */
['41','IMG_2775.JPG'],
['41','IMG_2626.JPG'],
['41','IMG_2657.JPG'],	/*	motorcycle	*/
['41','IMG_2766.JPG'],
['41','DSC00913.JPG'],
['41','DSC00914.JPG'],
['41','DSC00915.JPG'],
['41','IMG_2767.JPG'],
['41','IMG_2628.JPG'],
['41','IMG_2658.JPG'],
['41','IMG_2659.JPG'],
['41','IMG_2627.JPG'],


/* page 1 for classics / performance */
['51','DSC00894.JPG'],
['51','DSC00891.JPG'],
['51','DSC00896.JPG'],
['51','DSC00897.JPG'],
['51','DSC00895.JPG'],
['51','DSC00898.JPG'],
['51','DSC00899.JPG'],



['51','IMG_2634.JPG'],

['51','DSC00918.JPG'],
['51','DSC00919.JPG'],
['51','DSC00920.JPG'],
['51','DSC00921.JPG'],
['51','DSC00922.JPG'],
['51','DSC00923.JPG'],	/*	classics / performance	*/
['51','DSC00924.JPG'],
['51','DSC00925.JPG'],
['51','DSC00926.JPG'],
['51','DSC00927.JPG'],
['51','DSC00928.JPG'],
['51','DSC00929.JPG'],
['51','DSC00931.JPG'],
['51','DSC00932.JPG'],

['51','IMG_2620.JPG'],
['51','IMG_2621.JPG'],
['51','IMG_2622.JPG'],
['51','IMG_2623.JPG'],
['51','IMG_2624.JPG'],
['51','IMG_2625.JPG'],
['51','IMG_2639.JPG'],
['51','IMG_2640.JPG'],
['51','IMG_2642.JPG'],


/* page 1 for event */
['61','DSC_0176sm.jpg'],
['61','DSC_0048sm.jpg'],
['61','DSC00905.JPG'],
['61','DSC00906.JPG'],
['61','DSC00907.JPG'],
['61','DSC00908.JPG'],


/* page 1 for trophy list */
['71','DSC_0169sm.jpg'],
['71','DSC_0167sm.jpg'],
['71','DSC_0156sm.jpg'],
['71','DSC_0157sm.jpg'],
['71','DSC_0158sm.jpg'],
['71','DSC_0159sm.jpg'],
['71','DSC_0160sm.jpg'],
['71','DSC_0161sm.jpg'],
['71','DSC_0162sm.jpg'],
['71','DSC_0163sm.jpg'],
['71','DSC_0164sm.jpg'],
['71','DSC_0165sm.jpg'],
['71','DSC_0166sm.jpg']


)


function showVideo(whichOne){
	var video = whichOne;

	clearCenterArea();

	//make videoAreaContent

	var videoAreaContentBox = document.createElement("div"); //this is for the 2 columns of images
	videoAreaContentBox.setAttribute("id","videoAreaContent");

	document.getElementById('videoArea').appendChild(videoAreaContentBox);

	AC_FL_RunContent(
		"classid","D27CDB6E-AE6D-11cf-96B8-444553540000",
		"codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0",
		"allowFullScreen","true",
		"allowScriptAccess","sameDomain",
		"movie",video,
		"quality","high",
		"height","270",
		"width","350",
		"pluginspage","http://www.macromedia.com/go/getflashplayer",
		"type","application/x-shockwave-flash",
		"src","http://www.thejunctioninc.com/videoOutside/"+video
	)
}


function showPage(pageNum){
	var page = pageNum;

	clearCenterArea();

	var videoAreaContentBox = document.createElement("div"); //this is for the 2 columns of images
	videoAreaContentBox.setAttribute("id","videoAreaContent");

	document.getElementById('videoArea').appendChild(videoAreaContentBox);

	//go through the array and build unordered list of images

	var modelPicsBox = document.createElement("div"); //this is for the smaller thumbs
	modelPicsBox.setAttribute("id","modelPics");

	var ulBox = document.createElement("ul");
	ulBox.setAttribute("id","thumbPics");
	
	for (u=0;u<picArray.length;u++){
		var yu = u;
		if (picArray[yu][0]==page){
				var addImage = createListElement(yu);
				ulBox.appendChild(addImage);
		}
	}
	modelPicsBox.appendChild(ulBox)
	
	document.getElementById('videoAreaContent').appendChild(modelPicsBox);
	
	
}




function garageCam(folder,categ,make,model,year){
	//clear center area
	clearCenterArea()
	//build DOM model


	//go through the array to see what images there are

	var modelPicsBox = document.createElement("div"); //this is for the smaller thumbs
	modelPicsBox.setAttribute("id","modelPics");

	var ulBox = document.createElement("ul");
	ulBox.setAttribute("id","thumbPics");
	
	var lastInSeries = "";
	for (u=0;u<imageArray.length;u++){
		var yu = u;
		if (imageArray[yu][1]==categ && imageArray[yu][2]==make && imageArray[yu][3]==model && imageArray[yu][4]==year){
			if (imageArray[yu][5]!="800x600"){
				var addImage = createListElement(yu);
				ulBox.appendChild(addImage);
				lastInSeries = yu;
			}
		}
	}
	modelPicsBox.appendChild(ulBox)


	//get images
//	document.getElementById('centerArea').appendChild(imageViewBox);
	document.getElementById('centerArea').appendChild(modelPicsBox);

	
}

function clearCenterArea(){

	var spanArea = document.getElementById("videoArea");

	try {
		var dropp = document.getElementById("videoAreaContent");
		if (dropp!=null){
			//remove all rows
			spanArea.removeChild(dropp);
		}
	} catch (e) {}
	
}

function createListElement(u){
	var listElement = document.createElement("li");
	image = document.createElement("img");
	image.setAttribute("src","../mountainfest/"+picArray[u][1]);
	image.setAttribute("width","300");
	image.width = "300";
	image.setAttribute("height","225");
	image.height = "225";
	image.setAttribute("border","1");

	aElement = document.createElement("a");
	aElement.setAttribute("href","javascript:showLargePic('"+picArray[u][1]+"');");
	aElement.appendChild(image);

	listElement.appendChild(aElement);
	
	return listElement;

}


function showLargePic(y){
	//just open a new window

	var w = window.open("","newWindow","scrollbars=yes,resizable=1,width=700,height=500");
	w.document.open();
	var t="";
	t+='<HTML>\n<TITLE>The Junction, Inc</TITLE>\n';
	t+='<HEAD>';
	t+='<SCRIPT LANGUAGE="Javascript">\n';
	t+='\<!--\n';
	t+='function enlarge() {\n';
	t+=' var pic=new Image;\n';
	t+=' pic.src="../mountainfest/'+y+'";\n';
	t+=' var wd=640;\n';
	t+=' var ht=480;\n';
	t+=' document.getElementById("foo").src=pic.src;\n';
	t+=' window.resizeTo(wd,ht);\n';
	t+='}\n';
	t+='\/\/-->\n';
	t+='<\/SCRIPT>\n';
	t+='</HEAD>\n';
	t+='<BODY onLoad="enlarge();" style="margin:20 30 30 20">\n';
	t+='<IMG ID="foo" ALT="The Junction, Inc">\n';
	t+='</BODY>\n</HTML>\n';
	w.document.write(t)
	w.document.close();
	w.focus();

}


