	// ------------------------------------------------------
	// Evertaut Functions - new site April 2006
	// ------------------------------------------------------
	var thisSitesUrl = "http://www.evertaut.co.uk/";


	// re-arrange search results
	function reOrderResults(ascOrDesc,catName,catID,iStart,iOffset){
		document.location.href="evertaut_product_ranges.asp?"+catName+"WPqQ"+catID+"WPqQ"+ascOrDesc+"WPqQ"+iStart+"WPqQ"+iOffset+"";
	}
	
	// ------------------------------------------------------
	// Character Counter
	// ------------------------------------------------------
	
	function characterCount(frmName,fldName,mxLength,wchChars){
		var theForm = eval("document.forms."+frmName);
		var theField = eval("theForm."+fldName);
		if((mxLength - theField.value.length) ==0){
			alert("You have  now reached the maximum permitted length for this field");
		}
		if((mxLength - theField.value.length) <0){
			var tooManyBy = (mxLength - theField.value.length);
			tooManyBy = tooManyBy.toString();
			tooManyBy = tooManyBy.replace("-","")
			alert("You have now exeeded the maximum permitted length for this field\n\nPlease reduce the text by "+tooManyBy+" characters");
		}
		eval("document.getElementById('"+wchChars+"')").innerHTML = (mxLength - theField.value.length);
	}

	// ------------------------------------------------------
	// Image rollovers
	// ------------------------------------------------------

	function changeEmDanno(imgNme,imgSrc){
		var thisImage = eval("document.images."+imgNme)
		thisImage.src = imgSrc;
	}

	function changeEmDanno2(frmNme,itmNme,imgSrc){

		// alert(frmNme+","+itmNme+","+imgSrc)

		var whichImage = eval("document.images."+itmNme);
		whichImage.src = imgSrc;
		
	}	
	
	// ------------------------------------------------------
	// Cell / table colour changes
	// ------------------------------------------------------
	
	
	// ------------------------------------------------------
	// Miscellaneous
	// ------------------------------------------------------

	if(top.window.name == ""){
		top.window.name = "evt_master_win";
	}else{
		if(top.window.name == "editWindow"){
		    top.window.name = "evt_master_win";
		}
	}

	function waitToShow (delay) { 
		if (delay > 1) {
			setTimeout("waitToShow(1)",3000);
		} else {
			document.getElementById("buttonDiv").style.display = '';
		}
	}
	
	function hideButton () {
		document.getElementById("buttonDiv").style.display = 'none';
		window.print();
		eval("waitToShow(2)");
	}
	
	function printOrder(){
		var url = "print_order.asp";
		var alertMssg = "Please note that printed orders will not be shown in your online account\n\nWe will contact you confirming your order on receipt.";
		
		if(document.getElementById("order_cust_reference").value != ""){
			url += "?ocr=" + document.getElementById("order_cust_reference").value;
		}
		var evtPrintWin = window.open(url,"evtPrintWin","top=10,left=10,width=690,height=600,scrollbars=yes,toolbars=no,location=no,status=no");
		evtPrintWin.focus();
		alert(alertMssg);
	}

	function printThis(){
		var prnButt = document.getElementById("print_button");
		prnButt.style.visibility = "hide";
		// top.window.print();
	}
		
	function orderOnAccount(){
		document.forms.evertautOrderForm.paymentOption.value = "order_on_account";
		document.forms.evertautOrderForm.submit();
	}

	function highlightLifestyle(lsString){
		var thisValue = "";
		var theForm = document.forms.newProductForm;
		var theField = theForm.product_lifestyle_group;
		var lsFieldLength = theField.options.length;
		
		if(lsString.indexOf("^") == -1){
			lsString = lsString + "^";
		}
		var lsArray = lsString.split("^");
		
		for(i=0;i<lsArray.length;i++){
			for(n=0;n<lsFieldLength;n++){
				thisValue = theField.options[n].value.split("$");
				if(thisValue[0] == lsArray[i]){
					theField.options[n].selected = true;
				}
			}
		}
	}

	function highlightRange(rgString){
		var thisValue = "";
		var theForm = document.forms.newProductForm;
		var theField = theForm.product_range;
		var rgFieldLength = theField.options.length;
		
		if(rgString.indexOf("^") == -1){
			rgString = rgString + "^";
		}
		var rgArray = rgString.split("^");
		
		for(i=0;i<rgArray.length;i++){
			for(n=0;n<rgFieldLength;n++){
				thisValue = theField.options[n].value.split("$");
				if(thisValue[0] == rgArray[i]){
					theField.options[n].selected = true;
				}
			}
		}
	}
	
	function highlightScats(scString){
		var theForm = document.forms.newProductForm;
		var theField = theForm.product_subcategory;
		var subcatFieldLength = theField.options.length;
		
		if(scString.indexOf("^") == -1){
			scString = scString + "^";
		}
		var scatArray = scString.split("^");
		
		for(i=0;i<scatArray.length;i++){
			for(n=1;n<subcatFieldLength;n++){
				if(theField.options[n].value == scatArray[i]){
					theField.options[n].selected = true;
				}
			}
		}
	}
	
	// Animates a button when clicked.
	// To call, use onClick="startAnim(this);"
	function startAnim(btn) {
		var objClickedBtn = '';
		var i = 0;
		var bolAnimating = false;
		if (!bolAnimating) {
			objClickedBtn = btn;
			objClickedBtn.style.backgroundColor = '#999999';
			objClickedBtn.value = 'Please wait   ';
			bolAnimating = true;
			btnanim = setInterval('moretext()', 250);
		}
	}
	 
	function moretext() {
		if (i == 0) {
			objClickedBtn.value = 'Please wait.  ';
		}
		else if (i == 1) {
			objClickedBtn.value = 'Please wait.. ';
		}
		else if (i == 2) {
			objClickedBtn.value = 'Please wait...';
		}
		else if (i == 3) {
			objClickedBtn.value = 'Please wait   ';
			i = -1;
		}
		i++;
	}

	function paginator(pageNum){
		document.forms.paginationForm.action = document.forms.paginationForm.action + "?page="+pageNum
		document.forms.paginationForm.page.value = pageNum;
		document.forms.paginationForm.submit();
	}

	function displayDate(){

		var dToday = new Date();
		var dyNum = dToday.getDay();
		var dyOfMonth = dToday.getDate();
		var dyName = "";
		var mnName = "";
		var mnNum = dToday.getMonth();
		var yrNum = dToday.getFullYear();
	
		var mnArray = new Array(12)
		mnArray[0] = "January"
		mnArray[1] = "February"
		mnArray[2] = "March"
		mnArray[3] = "April"
		mnArray[4] = "May"
		mnArray[5] = "June"
		mnArray[6] = "July"
		mnArray[7] = "August"
		mnArray[8] = "September"
		mnArray[9] = "October"
		mnArray[10] = "November"
		mnArray[11] = "December"
		mnName = mnArray[mnNum];
	
		var dyNmeArray = new Array(7);
		dyNmeArray[1] = "Monday";
		dyNmeArray[2] = "Tuesday";
		dyNmeArray[3] = "Wednesday";
		dyNmeArray[4] = "Thursday";
		dyNmeArray[5] = "Friday";
		dyNmeArray[6] = "Saturday";
		dyNmeArray[7] = "Sunday";
		dyName = dyNmeArray[dyNum];
		// alert(mnArray[mnNum]);
	
		// FORMAT: Thursday: August 11 2005
		var tDate =  dyName + ": " + mnName + " " +dyOfMonth + " " + yrNum

		document.write(tDate);	
	}

	function updateBasket() {
	
		var uCount = document.forms.basketForm.maxCount.value;
		var qString = "";
		var fCount = 0;
		
		for(n = 1; n <= uCount; n++){
		
			var thisQty = eval("document.forms.basketForm.Qty"+n+".value")
			//var thisSH = eval("document.forms.basketForm.isSh"+n+".value")
		
			qString = qString + "$" + eval("document.forms.basketForm.pID"+n+".value") + "^" + eval("document.forms.basketForm.Qty"+n+".value")
			
			if(isNaN(thisQty)){
				fCount ++
			}
			
			if(thisQty == "" || thisQty == " " || thisQty == "  " || thisQty == "   "){
				fCount ++
			}
			
		}
		
		if(fCount >0){
			alert("Please enter only numbers for product quantity");
		}else{
			document.location.href = "basketUpdate.asp?qString=" + qString;
		}
	}	

	function qb(product_ID,product_name,product_qty,product_code){
		if(product_ID != ""){
			document.location.href = "a2qb.asp?pidString="+product_ID+"^"+product_name+"^"+product_qty+"^"+product_code;
		}
	}

	function vqb(){
			top.opener.location.href = thisSitesUrl + "registered_users/quotation_basket.asp";
			top.window.close();
	}

	function imageSwap(imageName,imageSrc,imageExt){
		var theImage = eval("document.getElementById('"+imageName+"')")
		theImage.src = thisSitesUrl + "images/buttons/" + imageSrc + "." + imageExt;
	}

	function calcProductInfo(zeroOrOne){
	
		var theForm = document.forms.newProductForm;
		if(zeroOrOne == 0){
			theForm.action="calculator.asp?n=3"
		}else{
			theForm.action="calculator2.asp?u=3"
		}
		theForm.submit();
	}

	function setFocus(frmName,fldName) {
	
		var theForm = eval("document.forms."+frmName);
		var theField = eval("theForm."+fldName);
		theField.focus();

	}
	
	function selField(frmName,fldName){
	
		var theForm = eval("document.forms."+frmName);
		var theField = eval("theForm."+fldName);
		theField.select();
	
	}
	
	function delRangeImage(rid,img){
	
		var confMssg = "You are about to delete this range's image\n\nClick OK to continue";
		if(confirm(confMssg)){
			document.location.href = "delImage.asp?rid="+rid+"&img=" + img;
		}
	
	}

	function delProductImage(pid,img,ext){
	
		var confMssg = "You are about to delete this product's image\n\nClick OK to continue";
		if(confirm(confMssg)){
			document.location.href = "delImage.asp?pid="+pid+"&img=" + img + "&ext=" + ext;
		}
	
	}

	function markCatandSubs(formName,category_ID,subcatString){
	

		var theField = document.forms.newRangeForm.range_subcategory;
		var fieldLength = theField.length;
		var subcatArray = subcatString.split("^");
			
		for(n=0;n<=fieldLength-1;n++){
			for(i=1;i<subcatArray.length -1;i++){
				if(theField.options[n].value == subcatArray[i]){
					theField.options[n].selected = true;
				}
			}
		}
	
	}

	function createSubcatString(){
		var theForm = document.forms.newRangeForm;
		var theField = theForm.range_subcategory;

		for(i=0;i<theField.length;i++){
			if(theField.options[i].selected == true){
				//alert(theField.options[i].value);
				subCatString = subCatString + "^" + theField.options[i].value;
			}
		}
	}
	
	function delRegisteredUser(user_ID,user_company,user_name){
	
		var confMssg = "You are about to delete the registered user account for \n\n"+user_company+" - "+user_name+"\n\nTo continue click 'OK'";
		if(confirm(confMssg)){
			document.location.href = "del_registered_user.asp?uid="+ user_ID;
		}
	
	}

	function approveRegisteredUser(user_ID){

		var theForm = document.forms.registerForm;
		var ok2go = 1;
		var user_password = theForm.user_password.value;
		
		if(theForm.user_login.value == "" || theForm.user_login.value == " "){
			alert("Please complete both username and password fields");
			theForm.user_login.focus();
			ok2go = 0;
			//alert(ok2go);
		}
		if(ok2go ==1){
			if(theForm.user_password.value == "" || theForm.user_password.value == " "){
				alert("Please complete both username and password fields");
				theForm.user_password.focus();
				ok2go = 0;
				//alert(ok2go);
			}
		}
		if(ok2go ==1){
			// alert(ok2go);
			document.location.href = "approve_registered_user.asp?uid="+ user_ID+"&user_password="+ user_password;
		}
	
	}


	function loadOptionalExtras(){
		var theForm = document.forms.productEditForm;
		var evt_optional_extraString = "<%=evt_optional_extraString%>";
		var evt_optional_extraArray = evt_optional_extraString.split("¬");
		if(evt_optional_extraArray.length>1){
			alert("got " + evt_optional_extraArray.length);
		}
	}
	
	function oepCount(){
		var opexCount = 0;
		var theForm = document.forms.productEditForm;
		for(i=0;i<=10;i++){
			var thisVal = eval("theForm.elements["+i+"].name");	
			if(thisVal.substring(0,5) == "opex_"){
				opexCount++
			//	theForm.oepCount.value = ;
			}
		}

	}

	function createOepString(formName){
		var theForm = eval("document.forms."+formName); //productEditForm;
		// alert(theForm.evt_optional_extraString.value);
		var opexCount = 0;
		var oepString = "";
		
		var thisVal = "";
		for(i=0;i<theForm.elements.length;i++){
			thisVal = eval("theForm.elements["+i+"].name");	
			if(thisVal.substring(0,5) == "opex_"){
				if(eval("theForm.elements["+i+"]").checked != false){
					oepString = oepString + "¬" + eval("theForm.elements["+i+"].value");
				}
			}
		}
		theForm.evt_optional_extraString.value = oepString;
		// alert(theForm.evt_optional_extraString.value);

	}

	function createOepString2(formName){
		var theForm = eval("document.forms."+formName); //productEditForm;
		var opexCount = 0;
		var oepString = "";
		
		var thisVal = "";
		for(i=0;i<theForm.elements.length;i++){
			thisVal = eval("theForm.elements["+i+"].name");	
			if(thisVal.substring(0,5) == "opex_"){
				if(eval("theForm.elements["+i+"]").checked != false){
					oepString = oepString + "¬" + eval("theForm.elements["+i+"].value");
				}
			}
		}
		theForm.evt_optional_extraString.value = oepString;
	}
	
	function loadProductOptions(optionString){
		
		var theForm = document.forms.productEditForm;
		//var optionString = "<%'=optionString%>";
		var optionArray = optionString.split("^");
		var thisField = "";
		// alert(optionString);
		
		for(n=1;n<=5;n++){
			thisField = eval("theForm.evt_Application_"+n);
			for(i=1;i<=thisField.options.length-1;i++){
				if(thisField.options[i].value == optionArray[n]){
					// alert(thisField.options[i].value);
					thisField.options[i].selected = true;
				}
			}
		}
		
/*		for(p=1;p<=5;p++){
			thisField = eval("theForm.evt_Market_"+p);
			for(i=1;i<=thisField.options.length-1;i++){
				if(thisField.options[i].value == optionArray[p+5]){
					thisField.options[i].selected = true;
				}
			}
		}
*/
		for(q=1;q<=5;q++){
			thisField = eval("theForm.evt_Category_"+q);
			for(i=1;i<=thisField.options.length-1;i++){
				if(thisField.options[i].value == optionArray[q+10]){
					thisField.options[i].selected = true;
				}
			}
		}
/*
		for(r=1;r<=5;r++){
			thisField = eval("theForm.evt_Range_"+r);
			for(i=1;i<=thisField.options.length-1;i++){
				if(thisField.options[i].value == optionArray[r+15]){
					thisField.options[i].selected = true;
				}
			}
		}
*/
	}
	
	function deleteProductImage(whichImage,pID){
	
		var confMssg = "You have selected to delete image " + whichImage +" for this product\n\nTo proceed click OK otherwise click Cancel";
		if(confirm(confMssg)){
			document.location.href = "delete_image.asp?evt_productID="+pID+"&whichImage="+whichImage;
		}
	}

	function buildFunctions(functionTotal,formName){
		var theForm = eval("document.forms."+formName);
		var thisField = "";
		var evt_functionString = "";
		var replacer = / /g;
		for(i=0;i<functionTotal;i++){
			thisField = eval("theForm.productFunction"+i);
			if(thisField.checked == true){
				evt_functionString = evt_functionString + "^" + thisField.value;
			}
		}
		evt_functionString = evt_functionString.replace(replacer, "_");
		theForm.evt_functionString.value = evt_functionString;
	}

	function buildOptionalFunctions(functionTotal,formName){
		var theForm = eval("document.forms."+formName);
		var thisField = "";
		var evt_optional_functionString = "";
		var replacer = / /g;
		for(i=0;i<functionTotal;i++){
			thisField = eval("theForm.productOptionalFunction"+i);
			if(thisField.checked == true){
				// evt_functionString = evt_functionString + "^" + thisField.value;
				evt_optional_functionString = evt_optional_functionString + "^" + thisField.value;
			}
		}
		evt_optional_functionString = evt_optional_functionString.replace(replacer, "_");
		theForm.evt_optional_functionString.value = evt_optional_functionString;
	}	

	// -------------------------------------------------------
	// HTML Editor
	// -------------------------------------------------------
	function displayunicode(e){
		var unicode=e.keyCode? e.keyCode : e.charCode
		// alert(unicode)
		return unicode;
	}

	function ghostType(fldID,charCode){
		if(charCode == 13){
			//alert(charCode);
			//formatText(document.getElementById('page_content_holderCommand'),'<br',' />');
		}
		var commandField = fldID + "Command";
		if(document.getElementById(commandField).value == ""){
		}else{
			//document.getElementById(fldID).innerHTML = document.getElementById(commandField).value.replace(/(\n|\r)/g,'<br />');
			document.getElementById(fldID).innerHTML = document.getElementById(commandField).value.replace(/(\r)/g, "<br \/>");
			document.getElementById('contentHolder').value = document.getElementById(commandField).value.replace(/(\r)/g, "<br \/>");
			// alert(document.getElementById('contentHolder').value);
		}
	}

	function insertlink2(tag, desc, el){
		if(tag == "mailto:"){
			var u = prompt("Please enter the email address", "");
		}else{    
		    	var u = prompt("Please enter the url", "http://")
		}
		var tagstart = "<a href='" + tag + u +"'>";
		var tagend = "<";
		tagend +="/";
		tagend += "a>";
		formatText(el,tagstart,tagend);
	}
	 
	function formatText(el,tagstart,tagend) {
		var textArea = document.getElementById(el);
		var newText = "";
		var newerText = "";
		var selectedText = "";
		tagstart = tagstart.replace(/\'/g , "\"");
		if(el.setSelectionRange) {
			selectedText = el.value.substring(el.selectionStart,el.selectionEnd);
			if((selectedText.indexOf(tagstart) >=0 && selectedText.indexOf(tagend) <0) || (selectedText.indexOf(tagstart) <0 && selectedText.indexOf(tagend) >=0)){ 
				alert("ATTENTION!\n\nYou have already applied this style to the selected text\n\nTo remove the style highlight the text from the beginning of the opening " + tagstart + " to the end of the " + tagend + " tag.");
			}else if(selectedText.indexOf(tagstart) >=0 && selectedText.indexOf(tagend) >=0){
				newText = selectedText;
				newerText = newText.replace(tagstart, "");
				newerText = newerText.replace(tagend, "");
				el.value = el.value.substring(0,el.selectionStart) + newerText + el.value.substring(el.selectionEnd,el.value.length);
			}else{
				el.value = el.value.substring(0,el.selectionStart) + tagstart + selectedText + tagend + el.value.substring(el.selectionEnd,el.value.length);
			} 				
		}else{
			selectedText = document.selection.createRange().text; 
			if (selectedText != "") { 
				if((selectedText.indexOf(tagstart) >=0 && selectedText.indexOf(tagend) <0) || (selectedText.indexOf(tagstart) <0 && selectedText.indexOf(tagend) >=0)){ 
					alert("ATTENTION!\n\nYou have already applied this style to the selected text\n\nTo remove the style highlight the text from the beginning of the opening " + tagstart + " to the end of the " + tagend + " tag.");
				}else if(selectedText.indexOf(tagstart) >=0 && selectedText.indexOf(tagend) >=0){
					newText = selectedText;
					newerText = newText.replace(tagstart, "");
					newerText = newerText.replace(tagend, "");
					document.selection.createRange().text = newerText; 
				}else{
					newText = tagstart + selectedText + tagend;
					document.selection.createRange().text = newText; 
				}
			} 
		}
	}

	function deleteSap(sap_id){
		confMssg = "You have chosen top delete this item!\n\nTo proceed click 'OK'\n\nTo cancel this action click 'Cancel'";
		if(confirm(confMssg)){
			document.location.href = "delete_sap.asp?sap_id=" + sap_id;
		}
	}
	// -------------------------------------------------------
	// VALIDATORS
	// -------------------------------------------------------

	function validateLogin(){

		var theForm = document.forms.loginForm;
		var user_login = theForm.user_login;
		var user_password = theForm.user_password;

		if(user_login.value.length <6){
				alert("Please enter your username");
				user_login.select();
				return false;
		}
		if(user_password.value == "" || user_password.value == " "){
				alert("Please enter your password");
				user_password.select();
				return false;
		}
	}

	function validateThis(frmName) {
 	
 		var theForm = eval("document.forms."+frmName);
 		
 		//name
 		if(! theForm.name.value.match(/^[a-zA-Z0-9 \-]{2,20}$/)){
	 		alert("Please enter your name");
	 		theForm.name.focus();
	 		return false;
 		}

		//email
		if(! theForm.email.value.match(/^[a-zA-Z0-9\-_\.]*\@[a-zA-Z0-9\-]{3,}(\.)?([a-zA-Z]{2})?\.[a-zA-Z]{2,4}$/)){
			alert("Please fill in an appropriate email address");
			theForm.email.focus();
			return false;
		}
 		
		//enquiry
		if(theForm.enquiry.value == "" || theForm.enquiry.value == " "){
			alert("Please fill complete your enquiry");
			theForm.enquiry.focus();
			return false;
		}

		//if(! theForm.enquiry.value.match(/^[a-zA-Z0-9 \-\.,]*$/)){
		//	alert("Please fill complete your enquiry");
		//	theForm.enquiry.focus();
		//	//return false;
		//}
		
		theForm.submit();
 	
 	}

	function validateQuoteSubmit(){
	
		var theForm = document.forms.basketForm;
		if(theForm.maxCount.value <1){
			alert("Your quotation basket is empty");
			return false;
		}
	
	}

	function validateRangeForm(formName,fieldString){

		var theForm = eval("document.forms." + formName);
		var fieldArray = fieldString.split("^");
		var thisField = "";
		var theField = theForm.range_subcategory;
		var subCatString = "";
		var subCatNameString = "";

		for(a=0;a<fieldArray.length;a++){
			thisField = eval("theForm."+fieldArray[a]);
			if(thisField.value == "" || thisField.value == " "){
				alert("Please complete ALL required fields");
				thisField.focus();
				return false;
			}
		}

		for(i=0;i<theField.length;i++){
			if(theField.options[i].selected == true){
				//alert(theField.options[i].value);
				subCatString = subCatString + "^" + theField.options[i].value;
				subCatNameString = subCatNameString + "^" + theField.options[i].text;
			}
		}

		subCatString = subCatString + "^";
		theForm.subcatString.value = subCatString;
		theForm.subcatNameString.value = subCatNameString;
	}

	function validateProductForm(formName,fieldString){

		var theForm = eval("document.forms." + formName);
		var fieldArray = fieldString.split("^");
		var thisField = "";

		for(a=0;a<fieldArray.length;a++){
		/*	thisField = eval("theForm."+fieldArray[a]);
			if(thisField.value == "" || thisField.value == " "){
				alert("Please complete ALL required fields");
				thisField.focus();
				return false;
			}*/
		}
		createOepString('productEditForm');
		
		if(theForm.FILE){
			theForm.imgPath.value = theForm.FILE.value;
		}
		
		//return false;

	}

	function validateForm(formName,fieldString,buttName,buttVal){
		
		var theForm = eval("document.forms." + formName);
		var fieldArray = fieldString.split("^");
		var thisField = "";
		for(a=0;a<fieldArray.length;a++){
			thisField = eval("theForm."+fieldArray[a]);
			// alert(thisField.name);
			if(thisField.value == "" || thisField.value == " "){
				alert("Please complete ALL required fields");
				thisField.focus();
				return false;
			}
		}
		
		SubmitTheForm(formName,buttName,buttVal)

	}

	function SubmitTheForm(formName,buttName,buttVal) {
		var submitted;
		var theForm = eval("document.forms."+formName);
		var theButton = eval("theForm."+buttName);

		if(submitted == true) { return; }
		//document.myform.submit();
		//document.myform.mybutton.value = buttVal;
		//document.myform.mybutton.disabled = true;
		
		theForm.submit();
		theButton.value = buttVal;
		theButton.disabled = true;
		submitted = true;
	}

	function validateQForm(){

		var theForm = document.forms.quoteCompleteForm;
		if(theForm.qString.value.indexOf("n")>0){
			alert("Not all items have been quoted for");
			// thisField.focus();
			return false;
		}
		
		var confMssg = "If you are sure this quotation is complete click 'OK'\n\nOtherwise click 'cancel'"
		if(!confirm(confMssg)){
			return false;
		}
	}

	function validateRegUserForm(formName,fieldString){


		var theForm = eval("document.forms." + formName);
		var fieldArray = fieldString.split("^");
		var thisField = "";

		for(a=0;a<fieldArray.length;a++){
			thisField = eval("theForm."+fieldArray[a]);
			if(thisField.value == "" || thisField.value == " " || thisField.value == "username" || thisField.value == "password"){
				alert("Please complete ALL required fields");
				thisField.focus();
				return false;
			}
		}

		/* check for a cookie */
		if (document.cookie == ""){
		    /* if a cookie is not found - alert user -
		     change cookieexists field value to false */
		    //alert("COOKIES need to be enabled!");

		    /* If the user has Cookies disabled an alert will let him know 
		        that cookies need to be enabled to log on.*/ 

		    theForm.cookieexists.value ="false"  
		  } else {
		   /* this sets the value to true and nothing else will happen,
		       the user will be able to log on*/
		    theForm.cookieexists.value ="true"
		  }

	}

	function chkNumeric(strString){
		//check for valid numeric strings	

		var strValidChars = "0123456789.-";
		var strChar;
		var blnResult = true;

		if (strString.length == 0) return false;

		//  test strString consists of valid characters listed above
		for (i = 0; i < strString.length && blnResult == true; i++){
			strChar = strString.charAt(i);
      			if (strValidChars.indexOf(strChar) == -1){
				blnResult = false;
			}
		}
   
   		return blnResult;
	}

	function validateCDForm(){

		var theForm = document.forms.controlDataForm;
		var thisField = "";
		var cdArray = new Array(16);
		cdArray[0] ="latest_currency";
		cdArray[1] ="latest_inspection_percent";
		cdArray[2] ="latest_pallet_cube_m3";
		cdArray[3] ="latest_pallet_rate";
		cdArray[4] ="latest_whouse_cost_pallet";
		cdArray[5] ="latest_CUBE_40ftLCL_m3";
		cdArray[6] ="latest_FOB_MARGIN";
		cdArray[7] ="latest_DIRECT_CONTAINER_MARGIN";
		cdArray[8] ="latest_EX_BREDBURY_MARGIN";
		cdArray[9] ="latest_DD_HDD_MARGIN";
		cdArray[10] ="latest_extras_settlement";
		cdArray[11] ="latest_extras_marketing_cont";
		cdArray[12] ="latest_extras_discount";
		cdArray[13] ="latest_extras_retro";
		cdArray[14] ="latest_extras_staff_comms";
		cdArray[15] ="latest_extras_returns";

		thisField = eval("theForm." +cdArray[0]);
		if(thisField.value == "" || thisField.value == " "){
			alert("Complete ALL required fields");
			thisField.focus();
			return false;
		}
		if(chkNumeric(thisField.value) == false){
			alert("Please enter a numeric value for this field");
			thisField.select();
			return false;
		}

		thisField = eval("theForm." +cdArray[1]);
		thisField.value = thisField.value.replace("%", "")
		if(chkNumeric(thisField.value) == false){
			alert("Please enter a numeric value for this field");
			thisField.select();
			return false;
		}
		if(thisField.value.indexOf("%")<1){
			thisField.value = thisField.value + "%";
			//alert("Please select the file to upload\n\nThe file MUST be tab delimited with a .txt file extension\n\nData must be ordered identically to the 'new costings' spreadsheet");
			//thisField.focus();
			//return false;
		}
		
		for(n=2;n<16;n++){
			thisField = eval("theForm." +cdArray[n]);
			if(thisField.value == "" || thisField.value == " "){
				alert("Complete ALL required fields");
				thisField.focus();
				return false;
			}
			if(chkNumeric(thisField.value) == false){
				alert("Please enter a numeric value for this field");
				thisField.select();
				return false;
			}
		}

	}

	function validateXLForm(formName,fieldString){

		var theForm = document.forms.importForm;
		var thisField = theForm.import_file;

		if(thisField.value == "" || thisField.value == " "){
			alert("Please select the file to upload");
			thisField.focus();
			return false;
		}

		if(thisField.value.indexOf(".txt")<2){
			alert("Please select the file to upload\n\nThe file MUST be tab delimited with a .txt file extension\n\nData must be ordered identically to the 'new costings' spreadsheet");
			thisField.focus();
			return false;
		}

	}
	
/*
	function validateRegInterest(){
	
		var theForm = document.forms.int_registerForm;

		if(theForm.int_firstName.value == "" || theForm.int_firstName.value == " "){
			alert("Please enter your first name");
			theForm.int_firstName.focus();
			return false;
		}

		if(theForm.int_lastName.value == "" || theForm.int_lastName.value == " "){
			alert("Please enter your last name");
			theForm.int_lastName.focus();
			return false;
		}

		if(theForm.int_emailAddress.value == "" || theForm.int_emailAddress.value == " "){
			alert("Please enter your email address so we can contact you.");
			theForm.int_emailAddress.focus();
			return false;
		}

		if(theForm.int_lookingFor.value == "" || theForm.int_lookingFor.value == " "){
			alert("Please let us know the type of article(s) you are seeking");
			theForm.int_lookingFor.focus();
			return false;
		}
			
	}

	function validateEmailAddressReq(){
	
		var theForm = document.forms.emailAddressReqForm;
		
		if(theForm.emailAddress.value == "" || theForm.emailAddress.value == " "){
			alert("Please enter your registered email address");
			theForm.emailAddress.focus();
			return false;
		}
	
	}
	
	function validateLogin() {
	
		var theForm = document.forms.loginForm;
		
		if(! theForm.emailAddress.value.match(/^[a-zA-Z0-9\-_\.]*\@[a-zA-Z0-9\-]{3,}(\.)?([a-zA-Z]{2})?\.[a-zA-Z]{2,4}$/)){
			alert("Please enter your email address");
			theForm.emailAddress.focus();
			return false;
		}
		
		if(theForm.userPassword.value == "" || theForm.userPassword.value == " " || theForm.userPassword.value == " ENTER your password" || theForm.userPassword.value == "ENTER your password"){
			alert("please enter your password");
			theForm.userPassword.focus();
			return false;
		}		
	}
	
	function validateSearch() {
	
		var theForm = document.forms.searchForm;
		
		if(theForm.searchPhrase.value == "" || theForm.searchPhrase.value == " "){
			alert("please enter your search criteria");
			theForm.searchPhrase.focus();
			return false;
		}		
	}

	function updateForm(updMe) {
		var theForm = document.forms.newPForm;
		theForm.action = "edit_project_svd.asp";
		theForm.updateMe.value = "yes";
		theForm.submit();
	}
	
	function selImage2(pjID) {
	
		var url = "selectImage.asp?nsv=1&pjID="+pjID;
		var vwWidth = 500;
		var vwHeight = 260;
		var imgWin = window.open(url,"viewWin","width="+vwWidth+",height="+vwHeight+",scrollbars=no,status=no")
		imgWin.moveTo( ((screen.width / 2) - (vwWidth /2)), ((screen.height / 2) - (vwHeight /2)) );
		imgWin.focus();
	
	}	


	// -------------------------------------------------------
	// DOWNLOADING STUFF
	// -------------------------------------------------------
	
	function getPDF(){
	
		var url = "../images/projects/<%=projectID%>.pdf";
		// var url = "viewPDF.asp?projectID=<%'=projectID%>";
		var pdfWin = window.open(url,"pdfWin","scrollbars=yes");
		pdfWin.focus();
	
	}
	
	function printText(pjID,pjTTL) {
	
		var url = "printText.asp?pjID="+pjID+"&pjTTL="+ pjTTL;
		var vwWidth = 10;
		var vwHeight = 10;
		var prnWin = window.open(url,"viewWin","width="+vwWidth+",height="+vwHeight+",scrollbars=yes")
		// prnWin.moveTo( ((screen.width / 2) - (vwWidth /2)), ((screen.height / 2) - (vwHeight /2)) );
		prnWin.moveTo( (-200), (-1) );
		prnWin.blur();
	}
	
	function dlText(pjID,pTTL) {
		document.location.href = "download_text.asp?pjID="+pjID+"&pName="+pTTL;
	}
	
	function dlImage(ok2go,pjID,pjTTL,fileExt,flSize) {
		if(ok2go == 1){
			document.location.href = "download_image.asp?pjID="+pjID+"&pName="+pjTTL+"&pExt="+fileExt+"&Size="+flSize;
		}else{
			alert("Image not available for download");
		}
	}
*/	
	//------------------------------------------------------------
	// WINDOW POPUPS / Redirects
	//------------------------------------------------------------
	function showInstallations(whichInstall,bMark){
		// 'auditorium','model'
		var url = "../installations_and_testimonials.asp?wci="+whichInstall+"WPqQ"+bMark+"#"+bMark;
		var iwinHeight = 255;
		var iwinWidth = 604;
		var iwinTop = (screen.availHeight / 2) - (iwinTop / 2);
		var iwinLeft = (screen.availWidth / 2) - (iwinWidth / 2);
		var installWin = window.open(url,"installWin","top="+iwinTop+",left="+iwinLeft+",height="+iwinHeight+",width="+iwinWidth+",scrollbars=yes,resizable=no");
		installWin.focus();
	}
	function showSpecification(wSpec,wRng){
		//bookmark / range
		var url = "../specification.asp#"+wRng+"_"+wSpec;
		var iwinHeight = 500;
		var iwinWidth = 604;
		var iwinTop = (screen.availHeight / 2) - (iwinTop / 2);
		var iwinLeft = (screen.availWidth / 2) - (iwinWidth / 2);
		var installWin = window.open(url,"installWin","top="+iwinTop+",left="+iwinLeft+",height="+iwinHeight+",width="+iwinWidth+",scrollbars=yes,resizable=no");
		installWin.focus();	
	}

	function activeWinSize() {
		var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    //myWidth = document.documentElement.clientWidth;
		    //myHeight = document.documentElement.clientHeight;
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;		    
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		  }
		  //window.alert( 'Width = ' + myWidth );
		  //window.alert( 'Height = ' + myHeight );
		var activeWinWidth = myWidth;
		var activeWinHeight = myHeight;
	}

	function activeWinSize2(width,height){

		activeWinWidth = window.screenX;
		activeWinTop = window.screenY;
		var centerX = 0;
		var centerY = 0;
		var left = 0;
		var top = 0;
	
		   if (window.screenX != null && window.outerWidth) {
		      centerX = window.screenX + (window.outerWidth / 2);
		      centerY = window.screenY + (window.outerHeight / 2);
			left = window.screenX //+ window.outerWidth;
			top = window.screenY //+ window.outerHeight;
		   }
		   else if (window.screenLeft) {
		      if (document.documentElement) {
		         centerX = window.screenLeft + (document.documentElement.offsetWidth / 2);
		         centerY = window.screenTop + (document.documentElement.offsetHeight / 2);
			left = window.screenLeft //+ document.documentElement.offsetWidth;
			top = window.screenTop //+ document.documentElement.offsetHeight;
		      }
		      else if (document.body && document.body.offsetWidth) {
		         centerX = window.screenLeft + (document.body.offsetWidth / 2);
		         centerY = window.screenTop + (document.body.offsetHeight / 2);
			left = window.screenLeft //+ document.documentElement.offsetWidth;
			top = window.screenTop //+ document.documentElement.offsetHeight;
		      }
		   }
		   //var x = parseInt(centerX - (width / 2));
		   //var y = parseInt(centerY - (height / 2));
		//var x = parseInt(centerX - (left /2));
		//var y = parseInt(centerY - (top /2))
		x = left;
		y = top;

		activeWinLeft = x;
		activeWinTop = y;

	}

	function viewFunctions(ch_function,tblContent){
		// var helpOption = eval("document.forms.newPForm.helpTip"+tblContent+".value");
		// var url = thisSitesUrl + "pop_up_help.asp?pgNm="+pgNme+"&tblContent="+tblContent;
		var url = thisSitesUrl + "chair_functions.asp?"+ch_function+"#"+ch_function;
		var vwWidth = 300;
		var vwHeight = 500;
		activeWinSize2(vwWidth,vwHeight);
		var vwLeftPos = activeWinLeft;
		var vwTopPos = activeWinTop;
		var actWin = window.open(url,"actWin","top="+vwTopPos+", left="+vwLeftPos+",scrollbars=yes,width="+vwWidth+",height="+vwHeight)
		actWin.focus();
	}
	
	function chooseFabrics(){
		//var fabric_selector_window = window.open("http://evertaut.interfacefabrics.com/","fabric_selector_window");
		var leftPos = (screen.width/2) - 395;
		var fabric_selector_window = window.open(thisSitesUrl+"colour_fabric_options.asp","fabric_selector_window","width=790,height=650,top=0,left="+leftPos+",scrollbars=yes,resizable=yes");
		fabric_selector_window.focus();
	}

	function popupRedirect(mssg){
		top.opener.location.href= thisSitesUrl + "registered_users/error.asp?" + mssg;
		top.window.close();
	}
	

	function goMapZoom(bmid) {
	
		var mapwin = window.open(thisSitesUrl +"how_to_find_evertaut_zoom.htm#" + bmid,"mapWin","top="+((screen.height/2)-134)+",left="+((screen.height/2)-162)+",width=324,height=285");
		//mapWin.focus();
	
	}
	
	function viewPD(pid){
		var winTop = 100;
		var winLeft = (screen.width /2) -350;
		var pdUrl = "registered_users/product_detail.asp?evertaut_pid=" + pid
		var evertaut_detailWin = window.open(pdUrl,"evertaut_detailWin","top="+winTop+",left="+winLeft+",width=700,height=500,scrollbars");
		evertaut_detailWin.focus();
	}

	function quotePD(pidString){
		var winTop = 100;
		var winLeft = (screen.width /2) -385;
		var pidArray = pidString.split("^");
		pid = pidArray[0];
		quote_ID = pidArray[1];
		item_num = pidArray[2];
		var pdUrl = "product_quotation.asp?evertaut_pid=" + pid + "&quote_ID="+quote_ID+"&item_num="+item_num
		var evertaut_detailWin = window.open(pdUrl,"evertaut_detailWin","top="+winTop+",left="+winLeft+",width=770,height=500,scrollbars");
		evertaut_detailWin.focus();
	}
	
	function vQuotePD(pidString){
		var winTop = 100;
		var winLeft = (screen.width /2) -385;
		var pidArray = pidString.split("|");
		pid = pidArray[0];
		quote_ID = pidArray[1];
		item_num = pidArray[2];
		qDetail = pidArray[3];
		var pdUrl = "view_product_quotation.asp?evertaut_pid=" + pid + "&quote_ID="+quote_ID+"&item_num="+item_num+"&qDetail="+qDetail
		var evertaut_detailWin = window.open(pdUrl,"evertaut_detailWin","top="+winTop+",left="+winLeft+",width=770,height=500,scrollbars");
		evertaut_detailWin.focus();
	}
	
	function viewQuoteDetail(formNum){
	
		var theForm = eval("document.forms.quoteReqForm"+formNum);
		theForm.submit();
	
	}

	function closeAndGo(winName,whereToGo){

		var url = thisSitesUrl + whereToGo;
		top.opener.location.href = url;
		top.window.close();
	
	}

// stop image stealery!!
var clickmessage="Copyright Evertaut Ltd 2006.\n\nUnauthorised use is prohibited";


function disableclick(e) {
	if (document.all) {
		if (event.button==2||event.button==3) {
			if (event.srcElement.tagName=="IMG"){
				alert(clickmessage);
			return false;
			}
		}
	}
	else if (document.layers) {
		if (e.which == 3) {
			alert(clickmessage);
		return false;
		}
	}
	else if (document.getElementById){
		if (e.which==3&&e.target.tagName=="IMG"){
			alert(clickmessage)
		return false
		}
	}
}

function associateimages(){
	for(i=0;i<document.images.length;i++){
		document.images[i].onmousedown=disableclick;
	}
}

if (document.all){
	document.onmousedown=disableclick;
}else if (document.getElementById){
	document.onmouseup=disableclick;
}else if (document.layers){
	associateimages()
}

// IE PNG enabler
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 var imgAttribs = img.attributes;
		 for (var j=0; j<imgAttribs.length; j++)
			{
			var imgAttrib = imgAttribs[j];
			if (imgAttrib.nodeName == "align")
			   {		  
			   if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			   if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			   break
			   }
            }
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
if(document.all && window.attachEvent){
	window.attachEvent("onload", correctPNG);
}