//************** STANDARD BROWSER CHECKING
IE4 = (document.all) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
ver4 =(NS4 || IE4) ? 1 : 0;
var NS6 = (document.getElementById && !document.all) ? true : false;
isMac = (navigator.appVersion.indexOf("Mac") != -1);


// allow up to 10 arrays of "makeVisible" arrays
var arrays 	= new Array(10);
var arrayNames	= new Array(10);
var numArrays 	= 0;
var lastIndex = "";					//This is used in the td rollover/placeholder scripts
var imagesPerDiv = 12;				//This is used in the proofsheet scripts


// initializes an array with the given name prefix
function getObjectPrefix(name) {
	var itemPrefix = null;
	 if (NS4) {
	 	itemPrefix = "document.document." + name;
		
	 } else if (IE4) {
	 	itemPrefix = "document.all." + name;
		
	} else if (NS6) {
		itemPrefix = "document.getElementById('" + name +"')";
	}
	return itemPrefix;
}

/* used for the next request at the end of request pages - DW
function getNextObjectPrefix(name) {
	var itemNextPrefix = null;
	 if (NS4) {
	 	itemNextPrefix = "document.document.Next.value='"+ name +"'";
		
	 } else if (IE4) {
	 	itemNextPrefix = "document.all.Next.value='"+ name +"'";
		
	} else if (NS6) {
		itemNextPrefix = "document.getElementById('Next').value='"+ name +"'";
	}alert(itemNextPrefix);
	return itemNextPrefix;
}
*/
function getNextObjectPrefix(name) {
	//var obj = null;
	 if (NS4) {
	 	obj = eval("document.document.Next");
		
	 } else if (IE4) {
	 	obj = eval("document.all.Next");
		
	} else if (NS6) {
		obj = eval("document.getElementById('Next')");
	}
	//alert("object:" + obj);
	if (obj != null)	{
		obj.value = name;
	}		
	//return itemNextPrefix;
}


function initArray(name)	{
	arrays[numArrays] = new Array(20);
	arrayNames[numArrays] = name;
	
  	itemPrefix = getObjectPrefix(name);

	 var nameIndex = 0;
	 var contentArray = arrays[numArrays];
	 
	 for (nameIndex = 0;eval(getObjectPrefix(name+nameIndex));++nameIndex) {
	 	if (nameIndex >= contentArray.length) {
			// grow the array
			tempArray = new Array(contentArray.length+10);
			for (x = 0;x<contentArray.length;++x) {
				tempArray[x] = contentArray[x];
	 		}
			arrays[numArrays] = tempArray;
			contentArray = tempArray;
		}
		contentArray[nameIndex] = eval(getObjectPrefix(name+nameIndex));
					
		
	}
	makeVisible(name,0);   //populates opening page with text
	++numArrays;
	//moveBlockAir(0);
}
// makes the item with name prefix and index visible... 
// makes all other items with this name prefix hidden

function makeVisible(name, visibleIndex) {
	var contentArray = getArray(name);
	if (contentArray == null)	{
		return;
	}		
	
	for (i = 0;i < contentArray.length && contentArray[i];++i) {
		if (NS4) {			
			if (i == visibleIndex) {
				contentArray[i].visibility="visible";
			}				
			else contentArray[i].visibility ="hidden";
		} else {
			if (i == visibleIndex) {
				contentArray[i].style.visibility="visible";
				if (name == "delivery") {
					
				}
			}					
			else contentArray[i].style.visibility ="hidden";
		}
	}
}



// returns the array for the given name prefix .. null if name does not exist
function getArray(name)	{
	for (i = 0; i < arrayNames.length; i++)	{
		if (name == arrayNames[i])	{
			return arrays[i];
		}
	}
	return null;
}


//this function will move the elements contained in the Air Request "block" div down the page to accommodate the expanded div of index1 when it's selected in the dropdown above
/*function moveBlockAir(index) {
	block = document.all.blockAirDiv.style;
	alert("selectDeliveryMethod " + document.all.selectDeliveryMethod.offsetTop + " " + document.all.selectDeliveryMethod.offsetHeight);
	block.xpos = parseInt(block.left);
	block.ypos = parseInt(block.top);
	if (index==1) {
		block.xpos = 10;
		block.ypos = document.all.selectDeliveryMethod.offsetTop + document.all.selectDeliveryMethod.offsetHeight;
		//block.top = block.ypos;	
		}
	else {
		block.xpos = 10;
		block.ypos = document.all.delivery1.top + 10;
		//block.left = block.xpos;
		//block.top = block.ypos;
		}
	}*/


//this function will move the elements contained in the Event Tickets Request "block" div down the page to accommodate the expanded div of index1 when it's selected in the dropdown above
/*function moveBlockTicket(index) {
	block = document.all.blockTicketDiv.style;
	block.xpos = parseInt(block.left);
	block.ypos = parseInt(block.top);
	if (index==1) {
		block.xpos = 10;
		block.ypos = 700;
		block.top = block.ypos;	
		}
	else if (index==0) {
		block.xpos = 10;
		block.ypos = 420;
		block.left = block.xpos;
		block.top = block.ypos;
		}
	}*/




//clicking function to toggle visibility from selectbox to textfield
function toggle (item, itemTo, itemBack, fieldFocus) {
if (NS6)  {
	var toggleTo=eval("document.getElementById('" +itemTo+ "')");
	var toggleFocus=eval("document.getElementById('" +fieldFocus+ "')");
	var toggleHidden=eval("document.getElementById('" +itemTo + "_back')");
	if (item.selectedIndex == item.length-1) {				//this designates that the "other" choice is to be found in the last position
		var menu=eval("document.getElementById('" +itemBack+ "')");
		menu.style.visibility="hidden";
		toggleTo.style.visibility="visible";
		toggleFocus.focus();
		toggleHidden.value=menu.id;
		//item.selectedIndex=0;
	}
}
	else  {
	var toggleTo=eval("document.all." +itemTo);
	var toggleFocus=eval("document.all." +fieldFocus);
	var toggleHidden=eval("document.all." +itemTo +"_back");
	if (item.selectedIndex == item.length-1) {				//this designates that the "other" choice is to be found in the last position
		var menu=eval("document.all." +itemBack);
		menu.style.visibility="hidden";
		toggleTo.style.visibility="visible";
		toggleFocus.focus();
		toggleHidden.value=menu.id;
		//item.selectedIndex=0;
		}
	}
}	



//clicking function to toggle visibility from textfield to selectbox
function toggleBack (itemTo) {
if (NS6) {
	var toggleTo=eval("document.getElementById('" +itemTo+ "_back')");
	var toggleMenu=eval("document.getElementById('" +toggleTo.value+ "')");
	var menu=eval("document.getElementById('" +itemTo + "')");
	var selectBox = eval("document.getElementById('" +toggleTo.value +"box')");
	menu.style.visibility="hidden";
	toggleMenu.style.visibility="visible";
	selectBox.selectedIndex=0;				//this resets the selectbox to the specified index when toggling back from textfield
	}
else  {
	var toggleTo=eval("document.all." +itemTo +"_back");
	var toggleMenu=eval("document.all." +toggleTo.value);
	var menu=eval("document.all." +itemTo);
	var selectBox = eval("document.all." +toggleTo.value +"box");
		menu.style.visibility="hidden";
		toggleMenu.style.visibility="visible";
		selectBox.selectedIndex=0;				//this resets the selectbox to the specified index when toggling back from textfield
	}
}




//this function ensures that all the values in the nameList are captured onSubmit
//function selectAllOptions(boxName)	{
	//var box = eval('document.all.'+ boxName);
	//for (i = 0; i < box.length; i++)	{
		//box.options[i].selected = 1;
	//}
//}


function placeChooser(index,on) {				//This function creates a rollover effect by turning the background color 'off' and 'on'
	if (NS4) {
		var marker = eval("document.document.thumb" + index);
	}
	if (IE4) {
		var marker = eval("document.all.thumb" + index);
	}
	else if (NS6) {
		var marker = eval("document.getElementById('thumb" + index+"')");
	}
	if (on) {
		marker.style.backgroundColor = "#ffffff";	//This sets the marker's background to 'on' or true color
	}
	else if (index != lastIndex) {
		marker.style.backgroundColor = "#000000";	//This sets the marker's background to 'off' or false color
	}
}
function holdPlace(index) {						//This forces the color 'on' whenever the object is clicked on
	var saveIndex = lastIndex;					//and removes the color from the previous selection
	lastIndex = index;
	if (saveIndex != "") {
		placeChooser(saveIndex,false);
	}
}
function next() {								//This function advances the listings by one
	var n = parseInt(lastIndex) + 1;
	if (n < totalImages) {						//n must be less than totalImages to allow for the +1 increment
		var index = "" + n;
		if (n == imagesPerDiv) {
			makeVisible('proofsheet','1');
		}
		placeChooser(index,true);					
		holdPlace(index);						//highlights the current thumbnail
		viewListing(index);						//grabs the next image
		makeVisible('listing',index);			//reveals the next text			
	}
}
function previous() {							//This function retreats the listings by one
	var n = parseInt(lastIndex) - 1;
	if (n >= 0) {								//This integer stays at 0
		var index = "" + n;
		if (n == (imagesPerDiv -1)) {
			makeVisible('proofsheet','0');
		}
		placeChooser(index,true);
		holdPlace(index);						//highlights the current thumbnail
		viewListing(index);						//grabs the previous image
		makeVisible('listing',index);			//reveals the previous text
	}
}

	