﻿
// THIS IS THE MAIN GALLERY SCRIPT
// FOR SARAH MOODY'S SITE
// 2007-2010 Levi DeKeyrel
// Hooray

var unColor = "#FFF";
var avColor = "#FFF";
var arNum = 1;

var blast = new Array('One','Two','Three','Four','Five', 'Six'); //this is the pages cell IDs
var pNums = new Array (1,2,3,4,5,6,7,8,9);


function pLoads() {
	pNums.length = pages;
}
/**/

function blaster(arNum,pages) {		
	nameMaker(arNum); 
	cellFiller();
	pageNavChange(arNum); 
	arrowChange(arNum); 
}

function cellFiller() {
	for (var f in blast) {
		thumbChange(f);
	}
}


function pageNavChange(arNum) { // changes Page sub nav according to how many pages
	for (var g in pNums) {
		if (pNums[g] == arNum) {
			document.getElementById(pNums[g]).innerHTML = pNums[g] + " |";
		} else {

		document.getElementById(pNums[g]).innerHTML = '<a class="pg_num" title="Page ' + pNums[g] + '" href="javascript:jumpPage(' + pNums[g] + ');">' + pNums[g] + '</a> | ';
		}
	}
}

function arrowChange(arNum) {
	var bck = document.getElementById('pgBk');
	var fwd = document.getElementById('pgFw');
	if (arNum == 1) {  // set bg color of BACk button based on ARRAY number
		bck.innerHTML = '&lt;&lt;';
	} else {
		bck.innerHTML = '<a class="pgArrows" title="Previous Page" href="javascript:PageBack();">&lt;&lt;</a>';
	}
	if (arNum == pages) { // set bg color of FORWARD button based on ARRAY number
		fwd.innerHTML = '&gt;&gt;';
	} else {
		fwd.innerHTML = '<a class="pgArrows" title="Next Page" href="javascript:PageForw();">&gt;&gt;</a>';
	}
	
}

// ADDED 2010 to folder call line

function thumbChange(f) { // fills each of the cells in the BLAST array with thumbnail images and links
		if (pageN[f] == 'space' || pageN[f] == '') {
			document.getElementById(blast[f]).innerHTML = '<img alt="Thumbnail" class="spaceThumb" src="images/spacer.gif" width="80" height="80" />';
		} else {
			document.getElementById(blast[f]).innerHTML = '<a href="javascript:coll1(\'' + pageN[f] + '\');"><img id="' + pageN[f] + '" title="' + pageN[f] + '" alt="Thumbnail" class="thumb" src="images/2010/thumb/' + pageN[f] + '.jpg"/></a>';
			
		}
}


function nameMaker(arNum) { //changes the name of the array to call

	if (arNum == 1) {
		pageN = stuff1;
	} else if (arNum == 2) {
		pageN = stuff2;	
	} else if (arNum == 3) {
		pageN = stuff3;
	} else if (arNum == 4) {
		pageN = stuff4;	
	} else if (arNum == 5) {
		pageN = stuff5;
	} else if (arNum == 6) {
		pageN = stuff6;
	} else if (arNum == 7) {
		pageN = stuff7;
	} else if (arNum == 8) {
		pageN = stuff8;
	} else if (arNum == 9) {
		pageN = stuff9;
	} 
	
	
}

function jumpPage(x) {
	cleaner();
	arNum = x;
	blaster(arNum);
}

function PageBack() {
	cleaner();
	arNum--;
	blaster(arNum);
	
}

function PageForw() {
	cleaner();
	arNum++;
	blaster(arNum);
}



function changer(titl,prc,txt,cart) {	//changes all descriptions and image size

	document.getElementById('title').innerHTML = titl + "<br \>&emsp;&emsp;" + prc;
	document.getElementById('cartButton').innerHTML = cart;
	
	
	if (txt == 1) {
		document.images.babyText.src = "images/2010/text/infT_nat.png";
	} else if (txt == 2) {
		document.images.babyText.src = "images/2010/text/lapT_wht.png";		
	} else if (txt == 3) {
		document.images.babyText.src = "images/2010/text/oneZ_blu.png";		
	} else if (txt == 4) {
		document.images.babyText.src = "images/2010/text/oneZ_nat.png";		
	} else if (txt == 5) {
		document.images.babyText.src = "images/2010/text/todT_nat.png";				
	} else if (txt == 6) {
		document.images.babyText.src = "images/2010/text/todT_pnk.png";				
	} else if (txt == 7) {
		document.images.babyText.src = "images/2010/text/todH_pnk.png";				
	} else if (txt == 8) {
		document.images.babyText.src = "images/2010/text/lapT_pnk.png";
	} else if (txt == 9) {
		document.images.babyText.src = "images/2010/text/oneZ_yel.png";
	} 
}

function cleaner() { // clears thumbnail cells, to get ready for filling
	for (var f in blast) {
		document.getElementById(blast[f]).innerHTML = '<img alt="Thumbnail" class="spaceThumb" src="images/spacer.gif"/>';	
	}
	document.getElementById('title').innerHTML = '<br/>';
	document.images.babyText.src = "images/spacer.gif";
	document.images.gallery.src= "images/info.gif";
	document.getElementById('cartButton').innerHTML = '&nbsp;';
	img = 'RM000';
}


function coll1(nm) {	// called when thumbnail is clicked, changes main image src, calls description changes 2010!!!! 
	document.images.gallery.src= "images/spacer.gif";
	document.images.babyText.src= "images/spacer.gif";	
	img = nm;
	gutZ();
	changer(titl,prc,txt,cart);
	document.images.gallery.src= "images/2010/gallery/" + nm + ".jpg";
}

function gutZ() {	// gets name of image, calls corresponding description change (in other js file)
	var goob = img; 
	var newGoob = (goob); 	
	
	window[newGoob]();	// calls available function with desription changes (other js file)
}

function fullsize() {
	if (img == 'RM000') {
		;
	} else {
	/*
	//window.open("images" + "/" + "fullsize" + "/" + sect + "/" + img + ".jpg");
	
	myWin= open();

	// open document for further output
	myWin.document.open();

	// create document
	myWin.document.write("<html><head><title>" + img);
	myWin.document.write("</title></head><body bgcolor='#3399cc' background='images/bg1.jpg'>");
	myWin.document.write("<div align='center'><br/><br/>");
	
	myWin.document.write("<a href='javascript:window.close();'><img style='border:solid 1px white' src='images/fullsize/" + sect + "/" + img + ".jpg' /></a><br/><br/>");
	
	//myWin.document.write("<a href='javascript:window.close();'>Close Window</a><br/><br/>")
	myWin.document.write("</div>");  
	myWin.document.write("</body></html>");

	// close the document - (not the window!)
	myWin.document.close();	
	*/
	 ;
	}
}
