    function relocateTo(pageLocation)
    {
        if(pageLocation != "")
        {
            document.location.href=pageLocation;
        }
    }
    
	function lookup(url)
	{
		document.location.href= url;
	}
	
	function getStockists()
	{
		var errorMessg = "Before proceeding please complete the following information:";
		var errorMessgO = errorMessg;

		if(document.getElementById("sPcd").value == "" || document.getElementById("sPcd").value == "Your postcode"){
			errorMessg += "\n* Your Postcode";
		}
		if(document.getElementById("sDist").value == "0"){
			errorMessg += "\n* Maximum Distance (radius from your postcode) in km/miles";
		}
		if(document.getElementById("sReq").value == ""){
			errorMessg += "\n* Max Stockists";
		}
		if(errorMessgO != errorMessg)
		{
			alert(errorMessg);
		}else{
			getStockistInfo(document.getElementById("sDist").value,30,document.getElementById("sPcd").value,document.getElementById("sMkm").value);
		}
	}

	function changeInputVal(fieldID,fieldDefaltValue)
	{
		if(document.getElementById(fieldID).value == fieldDefaltValue)
		{
			document.getElementById(fieldID).value = "";
		}
		/*else if(document.getElementById(fieldID).value == ""){
			document.getElementById(fieldID).value = fieldDefaltValue;
		}*/
	}
	
	function operate_search_fields(fieldId)
	{
		switch(fieldId)
		{
			case "Application":
				if(document.getElementById(fieldId).value == "0")
				{
					// document.getElementById("ProductType").disabled = true;
					// document.getElementById("Style").disabled = true;
					// document.getElementById("Finish").disabled = true;
					document.getElementById("ProductType").disabled = false;
					document.getElementById("Style").disabled = false;
					document.getElementById("Finish").disabled = false;
				}else{
					document.getElementById("ProductType").disabled = false;				
				}
				break;
			
			case "ProductType":
				if(document.getElementById(fieldId).value == "0")
				{
					// document.getElementById("Style").disabled = true;
					// document.getElementById("Finish").disabled = true;
					document.getElementById("Style").disabled = false;	
					document.getElementById("Finish").disabled = false;
				}else{
					document.getElementById("Style").disabled = false;				
				}				
				break;
			
			case "Style":
				if(document.getElementById(fieldId).value == "0")
				{
					//document.getElementById("Finish").disabled = true;
					document.getElementById("Finish").disabled = false;
				}else{
					document.getElementById("Finish").disabled = false;				
				}				
				break;
			
			case "Finish":
				
				break;
			
			default:
				break;
			
			
		}
	}

	function initialiseSearchFields()
	{
		//var CurrentOption = searchApplication
		
		//alert (CurrentOption)
		
		//if (CurrentOption != ""){
		//	document.getElementById("Application").selectedIndex=parseInt(CurrentOption);
		//}else{	
		//	document.getElementById("Application").selectedIndex=0;
		//}	
		document.getElementById("ProductType").disabled = true;
		document.getElementById("Style").disabled = true;
		document.getElementById("Finish").disabled = true;
		/*
		document.getElementById("ProductType").selectedIndex = 0;
		document.getElementById("Style").selectedIndex = 0;
		document.getElementById("Finish").selectedIndex = 0;
		*/
		
	}

	function zoom_product(onoroff)
	{
		if(onoroff == 1){
			document.getElementById("large_image").style.display = "";
		}else{
			document.getElementById("large_image").style.display = "none";
		}
	}
	
	function zoom_product_win(onoroff,productid)
	{
		if(onoroff == 1){
			var url = "zoom_product.asp?ProductId="+productid;
			var toppos = (screen.height /2) - 337;
			var leftpos = (screen.width) - 293;
			var uf_zoomwin = window.open(url,uf_zoomwin,"width=586,height=674,top="+toppos+",left="+leftpos+",status=no");
			uf_zoomwin.focus();
			// document.getElementById("large_image").style.display = "";
		}else{
			top.window.close();
			//document.getElementById("large_image").style.display = "none";
		}
	}
	
	function re(reVal)
	{
		
	}
	
	function paginateSearch(sStart,sOffset)
	{
		document.getElementById("Start").value = sStart;
		document.getElementById("Offset").value = sOffset;
		document.getElementById("search_form").submit();
	}
	
	function validateform(formid,str2validate)
	{
		var theform = document.getElementById(formid);
		var strErrorOriginal = "Please complete the following before continuing :-\n";
		var strError = strErrorOriginal;
		if(str2validate != "")
		{
			var searchArray = str2validate.split("^");
			
			for(p=1;p<searchArray.length;p++)
			{
				//field = document.getElementById(searchArray[p]);
				//alert(field.type);
				
				if(document.getElementById(searchArray[p]).value == "")
				{
					strError += "\n   : " + searchArray[p].replace("_", " ");
					document.getElementById(searchArray[p]).style.background='yellow';
				}else{
					document.getElementById(searchArray[p]).style.background='#FFF';
				}
				
			}
		}	
		
		if(strError != strErrorOriginal)
		{
			alert(strError);
			return false;
		}
	}

// -----------------------------------------------
// Trade Search frame
// -----------------------------------------------
	function changeFrame1b(){
	    document.getElementById("shoppinglist-frame").src = "trade-product-list-frame1.asp?Search=" + document.getElementById("searchString").value;
	}
		
	function checkDefaults(fieldId)
	{
			//document.getElementById('search_suggest').innerHTML = '';
			var productcodePosition = document.getElementById(fieldId).value.indexOf("Product Code");
			var productnamePosition = document.getElementById(fieldId).value.indexOf("Product Name");
			
			//alert(productcodePosition + " - " + productnamePosition);
			
			if(productcodePosition >= 0)
			{
				document.getElementById(fieldId).value = document.getElementById(fieldId).value.replace("Product Code", "");
			}
			if(productnamePosition >= 0)
			{
				document.getElementById(fieldId).value = document.getElementById(fieldId).value.replace("Product Name", "");
			}
		   
	}
	function changeFrame1(){
		   	var ok2go = 1;
		    var searchStringCode = document.getElementById("txtSearch");
		    var searchStringName = document.getElementById("searchStringName");
		    var sUrl = "trade-product-list-frame1.asp?";
			// alert(sUrl);
		    
		    if((searchStringCode.value.toLowerCase() == "product code" && searchStringName.value.toLowerCase() == "product name") || (searchStringCode.value == "" && searchStringName.value.toLowerCase() == "product name") ||(searchStringCode.value.toLowerCase() == "product code" && searchStringName.value == "")){
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }
		    if((searchStringCode.value.length == 0 && searchStringName.value.length == 0))
		    {
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product name");
		            searchStringName.select();
		            ok2go = 0;
		        }
		    }

// ----------------------------
			if(ok2go == 1)
		    {
		        if((searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code") && (searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name"))
		        {
		            sUrl += "SearchName=" + searchStringName.value;
					sUrl += "&SearchCode=" + searchStringCode.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }
// ----------------------------


		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name")
		        {
		            sUrl += "SearchName=" + searchStringName.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product code");
		            searchStringCode.select();
		            ok2go = 0;
		        }
		    }
		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code")
		        {
		            sUrl += "SearchCode=" + searchStringCode.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }

            if(searchStringCode.value == "")
            {
                searchStringCode.value = "Product Code";
            }
            if(searchStringName.value == "")
            {
    		searchStringName.value = "Product Name";
    	}

}
	
	function processOrder()
	{
		totalsString = "";
		totalsString += document.getElementById("subTotalHolder").innerHTML;
		//totalsString += "^" + document.getElementById("shippingTotalHolder").innerHTML;
		totalsString += "^" + document.getElementById("VATHolder").innerHTML;
		totalsString += "^" + document.getElementById("grandTotalHolder").innerHTML;
		document.location.href = "trade-process-order2.asp?action=confirm_delivery&tstr=" + totalsString;
	}
	
	function processOrder2()
	{
		document.location.href = "trade-process-order.asp?action=confirm_delivery"
	}

	function changeFrame1All(URL){
		document.forms[0].searchString.value = ""
		window.frames['FRAME1'].location = URL;
	}
	
	function changeFrame2(URL){
		window.frames['FRAME2'].location = URL;
	}

	function changeFrames1and2(CallType){
		if (CallType == "Calculation"){
			window.frames['FRAME2'].location = "trade-shopping-basket.asp";
		}
		//var CurrentNumberOfItems = window.frames['FRAME2'].document.getElementById('tradeform2').CurrentNumberOfBasketItems.value
		//var NewNumberOfItems = window.frames['FRAME2'].document.getElementById('tradeform2').NewNumberOfBasketItems.value
 
		//var CurrentLevel
		//var NewLevel
		
		//if (CurrentNumberOfItems <= 24){
		//	CurrentLevel = "ONE"
		//}else{
		//	if (CurrentNumberOfItems <= 49){
		//		CurrentLevel = "TWO"
		//	}else{
		//		CurrentLevel = "THREE"
		//	}	
		//}
		
		//if (NewNumberOfItems <= 24){
		//	NewLevel = "ONE"
		//}else{
		//	if (NewNumberOfItems <= 49){
		//		NewLevel = "TWO"
		//	}else{
		//		NewLevel = "THREE"
		//	}	
		//}
		
		//if (CurrentLevel != NewLevel){
			window.frames['FRAME1'].location = "trade-product-list-frame1.asp?Search=" + window.frames['FRAME1'].document.getElementById('tradeform1').SearchString.value + "&SearchCode=" + window.frames['FRAME1'].document.getElementById('tradeform1').SearchStringCode.value + "&SearchName=" + window.frames['FRAME1'].document.getElementById('tradeform1').SearchStringName.value;
		//}
	}



	function addPageToBasket2(){
	var productCount = window.frames['FRAME1'].document.getElementById('tradeform1').counter.value;
	var thisBoxVal = "";
	var productString = "";
	
	for(i=1;i<= (productCount-1);i++){
		FieldName = eval("window.frames['FRAME1'].document.getElementById('tradeform1').qt" + i)
		FieldName2 = eval("window.frames['FRAME1'].document.getElementById('tradeform1').pr" + i)
		if(! isNaN(FieldName.value)){
			if(FieldName.value > 0){
				thisBoxVal = FieldName2.value.replace("QTYHERE", FieldName.value);
				productString += "$" + thisBoxVal;
				FieldName.value = 0
				}
			}
		}
	
		if(productString == ""){
			alert("To add an item or items to your basket you must enter a quantity greater than 0");
		}else{
			changeFrame2("trade-shopping-basket.asp?action=add_page&itemstring=" + productString);
		}
	}

	function addPageToBasket() {
	    var productCount = window.frames['FRAME1'].document.getElementById('tradeform1').counter.value;
	    var thisBoxVal = "";
	    var productString = "";

	    for (i = 1; i <= (productCount - 1); i++) {
	        //alert("1: " = i);
	        FieldName = eval("window.frames['FRAME1'].document.getElementById('tradeform1').qt" + i)
	        //alert("2: " = i);
	        FieldName2 = eval("window.frames['FRAME1'].document.getElementById('tradeform1').pr" + i)
	        //alert("3: " = i);
	        
	        if (!isNaN(FieldName.value)) {
	            if (FieldName.value > 0) {
	                thisItemParts = FieldName2.value.split("^")

	                thisItemPriceBreak = thisItemParts[3].split("~")

	                thisItemPriceBreakQty = thisItemPriceBreak[3].split("|")

	                //alert ("break " + thisItemPriceBreakQty[0])
	                
	                if (parseInt(FieldName.value) < parseInt(thisItemPriceBreakQty[0])) {
	                    alert("This product has a minimum order quantity of " + thisItemPriceBreakQty[0] + ", please amend your quantity")
	                    productString = "REJECT"
	                } else {
	                    thisBoxVal = FieldName2.value.replace("QTYHERE", FieldName.value);
	                    thisBoxVal = FieldName2.value.replace("QTYMIX",  FieldName.value);
	                    productString += "$" + thisBoxVal;
	                    FieldName.value = 0
	                }
	            }
	        }
	    }

	    if (productString == "") {
	        alert("To add an item or items to your basket you must enter a quantity greater than 0");
	    } else {
	        if (productString != "REJECT") {
	            changeFrame2("trade-shopping-basket.asp?action=add_page&itemstring=" + productString);
	            changeFrames1and2("Add");
	        }
	    }
	}


	function orig_addPageToBasket() {

	    var productCount = window.frames['FRAME1'].document.getElementById('tradeform1').counter.value;
	    var thisBoxVal = "";
	    var productString = "";


	    for (i = 1; i <= (productCount - 1); i++) {
	        
		    FieldName = eval("window.frames['FRAME1'].document.getElementById('tradeform1').qt" + i)
		    FieldName2 = eval("window.frames['FRAME1'].document.getElementById('tradeform1').pr" + i)

		    if(! isNaN(FieldName.value)){
    			if(FieldName.value > 0){
				    thisItemParts = FieldName2.value.split("^")
    				
				    thisItemPriceBreak = thisItemParts[3].split("~")
    				
				    thisItemPriceBreakQty = thisItemPriceBreak[3].split("|")
    				
    				
				     alert ("break " + thisItemPriceBreakQty[0])
                        				
				    if(parseInt(FieldName.value) < parseInt(thisItemPriceBreakQty[0])){
    					alert ("This product has a minimum order quantity of " + thisItemPriceBreakQty[0] + ", please amend your quantity")
					    productString = "REJECT"
					}
				    else{	
    					thisBoxVal = FieldName2.value.replace("QTYHERE", FieldName.value);
					    productString += "$" + thisBoxVal;
					    FieldName.value = 0
				    }		
				}
			}
		}

	    if(productString == ""){
			alert("To add an item or items to your basket you must enter a quantity greater than 0");
        }
		else{
    		if(productString != "REJECT"){
			    changeFrame2("trade-shopping-basket.asp?action=add_page&itemstring=" + productString);
			    changeFrames1and2("Add");
		    }
	    }
	}


	function clearSearchName()
	{
		document.getElementById("searchStringName").value = "";
	}
	
	
	
// ----------------------------------------------------
// Check enter key was pressed and submit form fields
// ----------------------------------------------------
	function checkEnter(e,func2call)
	{ 
		// alert(func2call);
		
		//e is event object passed from function invocation
		var characterCode 
		//literal character code will be stored in this variable
		
		if(e && e.which){ 
			//if which property of event object is supported (NN4)
			e = e
			characterCode = e.which 
			//character code is contained in NN4's which property
		}
		else{
			//e = event.keyCode
			characterCode = e.keyCode 
			//character code is contained in IE's keyCode property
		}
		
		if(characterCode == 13){ 
			//if generated character code is equal to ascii 13 (if enter key)
			//document.forms[0].submit() 
			//submit the form
			if(func2call)
			{
				return eval(func2call + "()");
			}else{
				alert("enter key pressed");
				return false;
			}
			return false 
		}
		else{
			return true 
		}
	
	}
// ----------------------------------------------------
// AJAX SEARCH OPTIONS
// ----------------------------------------------------
/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/	
var ajax = new Array();

function getSearchList(sel,targetField)
{
	var oSearchCode = sel.options[sel.selectedIndex].value;
	
	document.getElementById('Style').options.length = 0;
	var thisObj = document.getElementById('Style');
	thisObj.options[0] = new Option('product style','0');
	document.getElementById('Finish').options.length = 0;
	thisObj = document.getElementById('Finish');
	thisObj.options[0] = new Option('finish','0');
	if(oSearchCode.length>0){
		//if(oSearchCode == '0')
		//{
			document.getElementById(targetField).options.length = 0;	// Empty city select box
			var index = ajax.length;
			ajax[index] = new sack();
			ajax[index].requestFile = 'includes/pages/get_search_options_items.asp?Application='+oSearchCode;	// Specifying which file to get
			ajax[index].onCompletion = function(){ createSearchList(index,targetField) };	// Specify function that will be executed after file has been found
			ajax[index].runAJAX();		// Execute AJAX function
	}
	var fieldArray = new Array();
	fieldArray[0] = '';
	fieldArray[1] = 'Application';
	fieldArray[2] = 'ProductType';
	fieldArray[3] = 'Style';
	fieldArray[4] = 'Finish';
	fieldArray[5] = 'PriceBand';
	var ajax1 = "";
	var ajax2 = "";
	var ajax3 = "";
	var ajax4 = "";
	var ajax5 = "";
	
/*
	for(i=3; i<= 5;i++)
	{
		//setTimeout(resetSearchField(fieldArray[i]),1250);
		
		resetSearchField(fieldArray[i]);
		pausecomp(500);
		
	}
*/
}

function resetSearchField(targetField)
{
	document.getElementById(targetField).focus();
	//pausecomp(500);
		ajax = new Array();
		document.getElementById(targetField).options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/pages/reset_search_options_items.asp?whichField='+targetField;	// Specifying which file to get
		//alert(ajax[index].requestFile);
		ajax[index].onCompletion = function(){ createSearchList(index,targetField) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	
}

function pausecomp(millis) 
{
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); } 
	while(curDate-date < millis);
} 


function getSearchList2(sel,targetField)
{
	var aSearchCode = document.getElementById("Application").value;
	var oSearchCode = sel.options[sel.selectedIndex].value;
	
	document.getElementById('Style').options.length = 1;
	document.getElementById('Finish').options.length = 1;
	
	if(oSearchCode.length>0){
		document.getElementById(targetField).options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
			
		ajax[index].requestFile = 'includes/pages/get_search_options_items.asp?whichField='+sel.name+'&Application='+aSearchCode+'&'+sel.name+'='+oSearchCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSearchList(index,targetField) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function getSearchList3(sel,targetField)
{
	var aSearchCode = document.getElementById("Application").value;
	var bSearchCode = document.getElementById("ProductType").value;
	var oSearchCode = sel.options[sel.selectedIndex].value;
	if(oSearchCode.length>0){
		document.getElementById(targetField).options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
			
		ajax[index].requestFile = 'includes/pages/get_search_options_items.asp?whichField='+sel.name+'&Application='+aSearchCode+'&ProductType='+bSearchCode+'&'+sel.name+'='+oSearchCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSearchList(index,targetField) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function getSearchListFinal(sel,targetField)
{
	var aSearchCode = document.getElementById("Application").value;
	var bSearchCode = document.getElementById("ProductType").value;
	var cSearchCode = document.getElementById("Style").value;
	var oSearchCode = sel.options[sel.selectedIndex].value;
	if(oSearchCode.length>0){
		//if(oSearchCode != '0')
		//{
			// alert('Application='+aSearchCode+'&ProductType='+bSearchCode+'&Style='+cSearchCode);
			document.getElementById(targetField).options.length = 0;	// Empty city select box
			var index = ajax.length;
			ajax[index] = new sack();
				
			// ajax[index].requestFile = 'includes/pages/get_search_options_items.asp?whichField='+sel.name+'&Application='+aSearchCode+'&ProductType='+bSearchCode+'&'+sel.name+'='+oSearchCode;	// Specifying which file to get
			ajax[index].requestFile = 'includes/pages/get_search_options_items.asp?whichField='+targetField+'&Application='+aSearchCode+'&ProductType='+bSearchCode+'&Style='+cSearchCode;
			ajax[index].onCompletion = function(){ createSearchList(index,targetField) };	// Specify function that will be executed after file has been found
			ajax[index].runAJAX();		// Execute AJAX function
		//}
	}
}

function createSearchList(index,targetField)
{
	var obj = document.getElementById(targetField);
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

//------------------------------------------
// SPARES HISTORY FUNCTION  - UPDATED 07/JAN/2008
//------------------------------------------
function ajaxForSpares(aUrl,targetDiv)
{
	if(aUrl.length>0){
		//document.getElementById(targetField).options.length = 0;	// Empty city select box
		var index = ajax.length;
		ajax[index] = new sack();
			
		ajax[index].requestFile = aUrl;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createHistoryList(index,targetDiv) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createHistoryList(index,targetDiv)
{
	var obj = document.getElementById(targetDiv);
	document.getElementById(targetDiv).innerHTML = ajax[index].response;
	//eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

//------------------------------------------

function changeSparesFrame1(){
		   	var ok2go = 1;
		    var searchStringCode = document.getElementById("txtSearch");
		    var searchStringName = document.getElementById("searchStringName");
		    var sUrl = "spares-product-list-frame1.asp?";
			// alert(sUrl);
		    
		    if((searchStringCode.value.toLowerCase() == "product code" && searchStringName.value.toLowerCase() == "product name") || (searchStringCode.value == "" && searchStringName.value.toLowerCase() == "product name") ||(searchStringCode.value.toLowerCase() == "product code" && searchStringName.value == "")){
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }
		    if((searchStringCode.value.length == 0 && searchStringName.value.length == 0))
		    {
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product name");
		            searchStringName.select();
		            ok2go = 0;
		        }
		    }

// ----------------------------
			if(ok2go == 1)
		    {
		        if((searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code") && (searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name"))
		        {
		            sUrl += "SearchName=" + searchStringName.value;
					sUrl += "&SearchCode=" + searchStringCode.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }
// ----------------------------


		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name")
		        {
		            sUrl += "SearchName=" + searchStringName.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product code");
		            searchStringCode.select();
		            ok2go = 0;
		        }
		    }
		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code")
		        {
		            sUrl += "SearchCode=" + searchStringCode.value;
		            window.frames['FRAME1'].location = sUrl;
		            ok2go = 0;
		        }
		    }

            if(searchStringCode.value == "")
            {
                searchStringCode.value = "Product Code";
            }
            if(searchStringName.value == "")
            {
    		searchStringName.value = "Product Name";
    	}

}

function changeSparesFrame1All(URL){
		document.forms[0].searchString.value = ""
		window.frames['FRAME1'].location = URL;
	}
	
function changeSparesFrame2(URL){
		window.frames['FRAME2'].location = URL;
	}

function ShowProductSpares(ProductCode){
		window.frames['FRAME1'].location = "spares-product-spares-frame1.asp"
	}


// NEW SPARES FUNCTIONS
	function sparesSearch(){
		var ok2go = 1;
		var searchStringCode = document.getElementById("txtSearch");
		var searchStringName = document.getElementById("searchStringName");
		var sUrl = "spares-ajax-product-list.asp?";
	
		    if((searchStringCode.value.toLowerCase() == "product code" && searchStringName.value.toLowerCase() == "product name") || (searchStringCode.value == "" && searchStringName.value.toLowerCase() == "product name") ||(searchStringCode.value.toLowerCase() == "product code" && searchStringName.value == "")){
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }
		    if((searchStringCode.value.length == 0 && searchStringName.value.length == 0))
		    {
		        alert("Please enter either a product code OR product name");
		        searchStringCode.focus();
		        ok2go = 0;
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product name");
		            searchStringName.select();
		            ok2go = 0;
		        }
		    }

// ----------------------------
			if(ok2go == 1)
		    {
		        if((searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code") && (searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name"))
		        {
		            sUrl += "SearchName=" + searchStringName.value;
					sUrl += "&SearchCode=" + searchStringCode.value;
		            // window.frames['FRAME1'].location = sUrl;
					ajaxForAll(sUrl, 'ContentLeft');
		            ok2go = 0;
		        }
		    }
// ----------------------------


		    if(ok2go == 1)
		    {
		        if(searchStringName.value.length >0 && searchStringName.value.length >=3 && searchStringName.value.toLowerCase() != "product name")
		        {
		            sUrl += "SearchName=" + searchStringName.value;
		           //  window.frames['FRAME1'].location = sUrl;
					ajaxForAll(sUrl, 'ContentLeft');
		            ok2go = 0;
		        }
		    }

		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length <3)
		        {
		            alert("Please enter at least 3 characters for the product code");
		            searchStringCode.select();
		            ok2go = 0;
		        }
		    }
		    if(ok2go == 1)
		    {
		        if(searchStringCode.value.length >0 && searchStringCode.value.length >=3 && searchStringCode.value.toLowerCase() != "product code")
		        {
		            sUrl += "SearchCode=" + searchStringCode.value;
		            // window.frames['FRAME1'].location = sUrl;
					ajaxForAll(sUrl, 'ContentLeft');
		            ok2go = 0;
		        }
		    }

            if(searchStringCode.value == "")
            {
                searchStringCode.value = "Product Code";
            }
            if(searchStringName.value == "")
            {
    		searchStringName.value = "Product Name";
    	}	
	}
	
	function cleanup() {
		if (objXMLHTTP)
		{
			objXMLHTTP.abort();
		}
	}

	function ajaxForAll(url, divId)
	{
		cleanup;
//alert ('ajaxforall 1');
		var objXMLHTTP = false;
	
		if (window.XMLHttpRequest)
			objXMLHTTP = new XMLHttpRequest()
		else if (window.ActiveXObject){
			try { objXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP") } 
			catch (e){
				try{ objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP") }
				catch (e){}
			}
		}
//alert ('ajaxforall 2');	
		objXMLHTTP.open('GET', url, true);
		objXMLHTTP.send(null);
	
		objXMLHTTP.onreadystatechange = function(){
			switch (objXMLHTTP.readyState) {
				case 1:
				//alert ('ajaxforall 3 - ReadyState is:' + objXMLHTTP.readyState + ' ' + objXMLHTTP.status);
				case 2:
				//alert ('ajaxforall 4 - ReadyState is:' + objXMLHTTP.readyState + ' ' + objXMLHTTP.status);
				case 3:
				//alert ('ajaxforall 5 - ReadyState is:' + objXMLHTTP.readyState + ' ' + objXMLHTTP.status);
				case 4:
				//alert ('ajaxforall 6 - ReadyState is:' + objXMLHTTP.readyState + ' ' + objXMLHTTP.status);
				if (objXMLHTTP.status == '200') {
					document.getElementById(divId).innerHTML = objXMLHTTP.responseText;
				}	
			}
		}
		cleanup;
//alert ('ajaxforall 7 ' + objXMLHTTP.readyState);	
	}
	
	function checkUserName(){
		if (document.getElementById("UserName").value == "" || document.getElementById("UserName").value == " "){
			alert ("Please enter your name")
			document.getElementById("UserName").focus();
			return false; 
		}
	}	
	
	
	function addPageToSparesBasket(){
		var productCount = window.frames['FRAME1'].document.getElementById('sparesform1').counter.value;
		var productString = "";
		var FieldName = "";
		var FieldName2 = "";
		
		if(eval("window.frames['FRAME1'].document.getElementById('sparesform1').qt0") != null)
		{
	
			for(i=0;i<= productCount;i++){
				FieldName = eval("window.frames['FRAME1'].document.getElementById('sparesform1').qt" + i);
				FieldName2 = eval("window.frames['FRAME1'].document.getElementById('sparesform1').itm" + i);
				if(! isNaN(FieldName.value)){
					if(FieldName.value >0)
					{
						productString += "$" + FieldName2.value + "^" + FieldName.value;
					}
				}else{
					FieldName.value = 0;
				}
		
			}	
	
			if(productString == ""){
				alert("To add an item or items to your basket you must enter a quantity greater than 0");
			}else{
				if(productString != "REJECT"){
					changeFrame2("spares-shopping-basket.asp?action=add_page&itemstring=" + productString);
					changeSparesFrames1and2("Add");
				}
			}
			
		}
	}
	
	function changeSparesFrames1and2(CallType){
		if (CallType == "Calculation"){
			window.frames['FRAME2'].location = "spares-shopping-basket.asp";
		}
		window.frames['FRAME1'].location = "spares-show-product-spares-frame1.asp?" + window.frames['FRAME1'].document.getElementById('sparesform1').SearchString.value;
	}

	function processSparesOrder2()
	{
		document.location.href = "spares-checkout.asp?action=confirm_delivery"
	}
	
	function removeFieldText(fieldId, defaultText)
	{
		var fieldTest = document.getElementById(fieldId)
		if(fieldTest != null)
		{
			if(fieldTest.value == defaultText)
			{
				fieldTest.value = "";
			}
		}
	}

// ------------------------------
// ONLOAD EVENT
// ------------------------------

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

//var message="You may not copy images from this website.";
//function click(e) {
//if (document.all) {
//if (event.button==2||event.button==3) {
//alert(message);
//return false;
//}
//}
//if (document.layers) {
//if (e.which == 3) {
//alert(message);
//turn false;
//
//
//
// (document.layers) {
//document.captureEvents(Event.MOUSEDOWN);
//}
//document.onmousedown=click;

var message="";

function clickIE()
 
{if (document.all)
{(message);return false;}}
 
function clickNS(e) {
if
(document.layers||(document.getElementById&&!document.all))
{
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.  onmousedown=clickNS;}
else
{document.onmouseup=clickNS;document.oncontextmenu  =clickIE;}
 
//document.oncontextmenu=new Function("return false")

// *********************************************
// *BEGIN TEMP SCROLL SCRIPT 2*/
// *********************************************
     var scrolling = null;
  
     function scroll_up(divid) {
         var d = document.getElementById(divid);
  
         d.scrollTop = d.scrollTop - 1;
  
         scrolling = window.setTimeout(function() {
             scroll_up(divid);
         }, 10);
     }
  
     function scroll_down(divid) {
         var d = document.getElementById(divid);
  
         d.scrollTop = d.scrollTop + 1;
  
         scrolling = window.setTimeout(function() {
             scroll_down(divid);
         }, 10);
     }
  
     function stop_scroll() {
         window.clearTimeout(scrolling);
     }
	 
/*END TEMP SCROLL SCRIPT 2*/

function dnt(){}

function getCurrentPageName()
{
    var sPath = window.location.pathname.toLowerCase();
    //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    return sPage;
}

function goToProductDatasheets(){
    if(document.getElementById("Datasheets").value != "Please Select"){
        url = "http://www.ultra-group.co.uk/" + document.getElementById("Datasheets").value
        window.open(url, "Win3");
    }    
}

function goToProductFittingInstructions(){
    if(document.getElementById("FittingInstructions").value != "Please Select"){
        url = "http://www.ultra-group.co.uk/" + document.getElementById("FittingInstructions").value
        window.open(url, "Win1");
    }    
}

function goToProductDetail(){
    if(document.getElementById("ProductCode").value != "Please Select"){
        url = "http://www.ultra-group.co.uk/" + document.getElementById("ProductCode").value
        window.open(url, "Win2");
    }    
}

function showTechnicalFlyOut(){
    document.getElementById("technicalFlyOut").style.display="block";
}

function hideTechnicalFlyOut(){
    document.getElementById("technicalFlyOut").style.display="none";
}

function checkTerms(){
    if(document.getElementById('acceptOrNot-yes').checked){
    }else{
    alert ("Please indicate that you accept our Download Terms & Conditions, or click Back");
    return false;
    }
}

