if(document.images){
	home1 = new Image();
	home1.src = "/home/spc_on.jpg";
	home2 = new Image();
	home2.src = "/home/kfm_on.jpg";
	home3 = new Image();
	home3.src = "/home/tmub_on.jpg";
	
}


function clearField(theForm, theField, theDefault) {
		if (document [theForm] [theField].value == theDefault){
			document [theForm] [theField].value = "";
		}
}

function openGenericPopup(theURL, theWidth, theHeight){
	win = window.open(theURL,"winPopUpGeneric" , 'menubar=no,status=no,resizable=yes,scrollbars=1,width='+theWidth+',height='+theHeight);
}

function openPopup(theImage){
	win = window.open("popup.asp?image="+theImage,"winPopUp" , 'menubar=no,status=no,resizable=yes,scrollbars=0,width=600,height=630');
}
function openZoom(theSmall, theLarge, theDefault){
	if(theLarge == ''){
		openPopup(theDefault);
	}else{
		win = window.open("zoom.asp?smallImage="+theSmall+"&largeImage=" + theLarge,"winPopUp" , 'menubar=no,status=no,resizable=yes,scrollbars=0,width=550,height=405');
	}
}

function bo_echo(theCode){
	document.write(theCode);
}

if(document.images){
	the_btn_search_off = new Image();
	the_btn_search_off.src = "/kent/btn_search.gif"
	the_btn_search_on = new Image();
	the_btn_search_on.src = "/kent/btn_search_on.gif"

	the_btn_submit_off = new Image();
	the_btn_submit_off.src = "/kent/btn_submit.gif"
	the_btn_submit_on = new Image();
	the_btn_submit_on.src = "/kent/btn_submit_on.gif"

	var cached=1;
}

function formImageOn(imgName, formImg) {
	if (cached==1) {
	lineOn = eval("the_" + imgName + "_on.src");
	formImg.src= lineOn;
	}
}

function formImageOff(imgName, formImg) {
	if (cached==1) {
	lineOff = eval("the_" + imgName + "_off.src");
	formImg.src= lineOff;
	}
}

function checkForm(theForm, theFields, theTitles){
	var hasError = 0;
	var missingFields = "";

	highlightColor = "#ffffff";
	defaultColor = "#D9D9D9";
	thisForm = theForm;

	var arrFields = theFields;
	var arrTitles = theTitles;

	for(i=0; i<arrFields.length; i++){
		theField = arrFields[i];
		theTitle = arrTitles[i];

		if(isNaN(thisForm[theField].length) || ! isNaN(thisForm[theField].selectedIndex)){
			if(thisForm[theField].value == ""){
				missingFields += theTitle + "\n";
				thisForm[theField].style.background = highlightColor;
				if(hasError == 0){thisForm[theField].focus()}
				hasError = 1;
			}else{
				thisForm[theField].style.background = defaultColor;
			}
		}else{
			var hasNodeSelected = 0;
			for(j=0; j<thisForm[theField].length; j++){
				if(thisForm[theField][j].checked){
					hasNodeSelected++;
				}
			}
			if(hasNodeSelected == 0){
				hasError = 1;
				missingFields += theTitle + "\n";
			}
		}
		
		if(theTitle == 'Email'){
			if(thisForm[theField].value.indexOf("@") == -1){
				hasError = 2;
			}
		}

	}

	if(hasError > 0 && hasError < 2){
		alert('Please complete the following fields:\n' + missingFields);
		return false;
	}else if(hasError == 2){
		alert('Please enter a valid email address.\n');
		return false;
	}else{
		return true;
	}

}


function getStockist(theArea){
	theItem = document.theStockistForm.stockistsDD.selectedIndex;
	if(theItem != ""){
		document.location.href = "stockist_" + document.theStockistForm.stockistsDD.options[theItem].value + ".asp";
	}
}