// ALL OF THE FOLLOWNUIG JS IS PERFORMED AFTER THE PAGE LOADS AND IS HIDDEN FROM THE SCRIPT
function doInlineJs() {
	// LAST PAGE LINK
	if (document.getElementById('lastPage')) {
		var lastPage=document.getElementById('lastPage');
		var backSymbol="%ab";
		// GO BACK WHEN CLICKED
		lastPage.onclick=function () {
			window.history.back();
			}
		// MOUSE OVER UNDERLINES AND SHOWS STATUS TEXT
		lastPage.onmouseover=function () {
			lastPage.style.textDecoration="underline";
			window.status=unescape(backSymbol)+" Back to last page";
			}
		// MOUSE OUT RETURNS TO NORMAL
		lastPage.onmouseout=function () {
			lastPage.style.textDecoration="none";
			window.status="";
			}
		// BACK LINK TO HAVE FOLLOWING TEXT
		lastPage.innerText=unescape(backSymbol)+" Back to last page";
		}
	
	
	// THIS LOT ACTS AS THE CLICK OPERATION ON THE PRODUCT MENU
	// TO ADD A NEW PRODUCT MENU ADD ITS "DROPID" AND "CATID" TO THE ARRAYS BELOW, THEN COPY THE IF STATEMENT BELOW MAKING SURE TO INCREMENT THE ARRAY NUMBER IN IT.
	var drops=new Array('drop_1','drop_2','drop_3','drop_4','drop_5','drop_6','drop_7','drop_8','drop_9','drop_10','drop_11','drop_12','drop_13','drop_14','drop_15','drop_16','drop_17','drop_18','drop_19','drop_20');
	var cats=new Array('cat_1','cat_2','cat_3','cat_4','cat_5','cat_6','cat_7','cat_8','cat_9','cat_10','cat_11','cat_12','cat_13','cat_14','cat_15','cat_16','cat_17','cat_18','cat_19','cat_20');
	if (document.getElementById(drops[0])) {
		document.getElementById(drops[0]).onclick=function() {
			switchMenu(cats[0]);
			return false; } }
	if (document.getElementById(drops[1])) {
		document.getElementById(drops[1]).onclick=function() {
			switchMenu(cats[1]);
			return false; } }
	if (document.getElementById(drops[2])) {
		document.getElementById(drops[2]).onclick=function() {
			switchMenu(cats[2]);
			return false; } }
	if (document.getElementById(drops[3])) {
		document.getElementById(drops[3]).onclick=function() {
			switchMenu(cats[3]);
			return false; } }
	if (document.getElementById(drops[4])) {
		document.getElementById(drops[4]).onclick=function() {
			switchMenu(cats[4]);
			return false; } }
	if (document.getElementById(drops[5])) {
		document.getElementById(drops[5]).onclick=function() {
			switchMenu(cats[5]);
			return false; } }
	if (document.getElementById(drops[6])) {
		document.getElementById(drops[6]).onclick=function() {
			switchMenu(cats[6]);
			return false; } }
	if (document.getElementById(drops[7])) {
		document.getElementById(drops[7]).onclick=function() {
			switchMenu(cats[7]);
			return false; } }
	if (document.getElementById(drops[8])) {
		document.getElementById(drops[8]).onclick=function() {
			switchMenu(cats[8]);
			return false; } }
	if (document.getElementById(drops[9])) {
		document.getElementById(drops[9]).onclick=function() {
			switchMenu(cats[9]);
			return false; } }
	if (document.getElementById(drops[10])) {
		document.getElementById(drops[10]).onclick=function() {
			switchMenu(cats[10]);
			return false; } }
	if (document.getElementById(drops[11])) {
		document.getElementById(drops[11]).onclick=function() {
			switchMenu(cats[11]);
			return false; } }
	if (document.getElementById(drops[12])) {
		document.getElementById(drops[12]).onclick=function() {
			switchMenu(cats[12]);
			return false; } }
	if (document.getElementById(drops[13])) {
		document.getElementById(drops[13]).onclick=function() {
			switchMenu(cats[13]);
			return false; } }
	if (document.getElementById(drops[14])) {
		document.getElementById(drops[14]).onclick=function() {
			switchMenu(cats[14]);
			return false; } }
	if (document.getElementById(drops[15])) {
		document.getElementById(drops[15]).onclick=function() {
			switchMenu(cats[15]);
			return false; } }
	if (document.getElementById(drops[16])) {
		document.getElementById(drops[16]).onclick=function() {
			switchMenu(cats[16]);
			return false; } }
	if (document.getElementById(drops[17])) {
		document.getElementById(drops[17]).onclick=function() {
			switchMenu(cats[17]);
			return false; } }
	if (document.getElementById(drops[18])) {
		document.getElementById(drops[18]).onclick=function() {
			switchMenu(cats[18]);
			return false; } }
	if (document.getElementById(drops[19])) {
		document.getElementById(drops[19]).onclick=function() {
			switchMenu(cats[19]);
			return false; } }
	if (document.getElementById(drops[20])) {
		document.getElementById(drops[20]).onclick=function() {
			switchMenu(cats[20]);
			return false; } }			
	}
	
	
	




// MAILING LIST FORM FUNCTIONS
function searchForm() {
	// CHECK SEARCH BOX EXISTS
	if (document.getElementById('mailing_email')) {
		/*
		// INITIAL VALUES
		var initialName='your name';
		var initialEmail='email address';
		*/
		// RETRIEVE START VALUES
		//var defaultName=document.getElementById('mailing_name').value;
		var defaultEmail=document.getElementById('mailing_email').value;
		// ON FOCUS - REMOVE START NAME AND EMAIL
		/*document.getElementById('mailing_name').onfocus=function() {
			if (document.getElementById('mailing_name').value==defaultName) {
				document.getElementById('mailing_name').value='';
				return false; } } */
		document.getElementById('mailing_email').onfocus=function() {
			if (document.getElementById('mailing_email').value==defaultEmail) {
				document.getElementById('mailing_email').value='';
				return false; } } 
		// REPLACE START NAME AND EMAIL ON BLUR IF BLANK
		/*document.getElementById('mailing_name').onblur=function() {
			if (document.getElementById('mailing_name').value=='') {
				document.getElementById('mailing_name').value=defaultName;
				return false; } }*/
		document.getElementById('mailing_email').onblur=function() {
			if (document.getElementById('mailing_email').value=='') {
				document.getElementById('mailing_email').value=defaultEmail;
				return false; } }
		// DON'T ALLOW MAILING LIST FORM TO BE SUBMITTED IF NO VALUE ENTERED (OR DEFAULT VALUE ENTERED)
		if (document.getElementById('mailing_list')) {
			document.getElementById('mailing_list').onsubmit=function() {
				if (document.getElementById('mailing_email').value==defaultEmail||document.getElementById('mailing_email').value=='') {
					alert("Please enter your email address in order to join the mailing list.                    ");
					return false; } } } } }



function manfPreferences() {
	// SELECT AND DISABLE ALL MANUFACTURER CHECKBOXES WHEN CHOOSING 'ALL'
	if (document.getElementById('interest_all')) {
		document.getElementById('interest_all').onclick=function() {
			if (document.getElementById('interest_all').checked==true) {
				var interest='';
				for (i=1;i<=20;i++) {
					interest='interest_'+i;
					document.getElementById(interest).checked=true;
					}
				}
			else {
				var interest='';
				for (i=1;i<=20;i++) {
					interest='interest_'+i;
					document.getElementById(interest).checked=false;
					}
				}
			}
		}
	}

function showAllButton() {
	if (document.getElementById('show_all')) {
		document.getElementById('show_all').style.display='block';
		}
	}


function doFunctions() {
	doInlineJs();
	searchForm();
	manfPreferences();
	showAllButton();
	}



window.onload=doFunctions;

