		function Nav(s) {
			document.location.href="/default.asp?t=2&sp="+s+"&l="+document.getElementById('location').options[document.getElementById('location').selectedIndex].value+"&c="+document.getElementById('county').options[document.getElementById('county').selectedIndex].value
		}
		
		function changecounty() {
			document.location.href="/default.asp?t=2&l=&c="+document.getElementById('county').options[document.getElementById('county').selectedIndex].value
		}
		
		function changelocation() {
			document.location.href="/default.asp?t=2&l="+document.getElementById('location').options[document.getElementById('location').selectedIndex].value+"&c="+document.getElementById('county').options[document.getElementById('county').selectedIndex].value
		}
		
		function changestartletter() {
			document.location.href= "/default.asp?t=2&l=&c="+document.getElementById('county').options[document.getElementById('county').selectedIndex].value
		}
		
		function refreshpage(p) {
			document.location.href="/default.asp?t="+p
		}
/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}		

	function buy(prod,imageref) {
		var curBasket = readCookie("basket");
		if(curBasket==null) {
			curBasket="";
		}
		var newBasket = curBasket + prod + "," + imageref + "|"
		
		createCookie("basket",newBasket,30)
		
		alert("Item has been added to your basket")
		
		//var url = "/ajax/addtobasket.asp";
		//var params = "product="+prod+"&imageref="+imageref
		//var res = new Ajax.Request(url,{method: 'post',parameters: params, onComplete: buy_Complete, onFailure: buy_Error, asynchronous: true});	
		
		return true




		//read basket coookie to get current basket
		//var curBasket = getCookie("basket");
		//alert(curBasket)
		//append new product
		//var newBasket = curBasket + prod + "," + imageref + "|"

		//set expiration date
		//var today = new Date();
		//var nextMonth = new Date(today.getYear(), today.getMonth()+1, today.getDate());
		
		//alert(newBasket)
		
		//write new cookie
		//setCookie("basket", newBasket, nextMonth);			
		
		
	}
	
	function showbasketstring() {
		alert(readCookie("basket"));
	}
	
	function emptybasket() {
		if(confirm("Are you sure you want to empty your basket?\n\nThis will permanently remove all items from your basket.")) {
			createCookie("basket","",30)
		}
	}
	
	function removebasketitem(itemindex) {
		if(confirm("Are you sure you want to remove this item from your basket?")) {
			var curBasket = readCookie("basket");
			var basket = curBasket.split("|");
			var newBasket = "";
			
			for(x=0;x<basket.length-1;x++) {
				if(x!=itemindex) {
					newBasket+=basket[x]+"|";
				}
			}
			
			createCookie("basket",newBasket,30)
			
			refreshpage(5)
		}
	}
	
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}	
	
	function buy_Complete(originalRequest) {
		var xmlDoc = originalRequest.responseXML.documentElement;
		var reqStatus = xmlDoc.getElementsByTagName("status")[0].firstChild.data;
		switch(reqStatus) {
			case "0":
				alert("Item has been added to your basket")
				break;
			case "1":
				alert("You are not logged-in!")
			default:
				alert("There was a problem adding this item to your basket")
				break;
		}			
				
			
	}
	
	function buy_Error() {
		alert("Error adding to basket")
	}
function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure)
{
 	var szCookieText = 	   escape(szName) + '=' + escape(szValue);
	szCookieText +=	 	   (szExpires ? '; EXPIRES=' + szExpires.toGMTString() : '');
	szCookieText += 	   (szPath ? '; PATH=' + szPath : '');
	szCookieText += 	   (szDomain ? '; DOMAIN=' + szDomain : '');
	szCookieText += 	   (bSecure ? '; SECURE' : '');
	
	document.cookie = szCookieText;
}

//******************************************************************************************
// This functions reads & returns the cookie value of the specified cookie (by cookie name) 
//
// Prototype : getCookie(szName)
//******************************************************************************************

function getCookie(szName)
{
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{
       	var arr = 		  document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}

//******************************************************************************************
// To delete a cookie, pass name of the cookie to be deleted
//
// Prototype : deleteCookie(szName)
//******************************************************************************************

function deleteCookie(szName)
{
 	var tmp = 	  			 	 getCookie(szName);
	if(tmp) 
	{ setCookie(szName,tmp,(new Date(1))); }
}		

	function AddToBasket() {
		var url = "/addtobasket.asp";
		var params = "product="+p
	
		var res = new Ajax.Request(url,{method: 'post',parameters: params, onComplete: WriteOrderData_Complete, onFailure: WriteOrderData_Error, asynchronous: true});	
		
		return true
	}
	
	function checkitout() {
			
	}