function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2( document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter( new GLatLng(51.750707,-0.277877), 14);
		function createMarker(point, text, title) {
			var marker =
			new GMarker(point,{title:title});
			GEvent.addListener(
			marker, "click", function() {
			});
			return marker;
		}
		var marker = createMarker( new GLatLng(51.750707,-0.277877), 'Hi-Spek', 'Hi-Spek');
		map.addOverlay(marker);

		var map2 = new GMap2( document.getElementById("map2"));
		map2.addControl(new GSmallMapControl());
		map2.addControl(new GMapTypeControl());
		map2.setCenter( new GLatLng(51.619828,0.29912), 14);
		function createMarker(point, text, title) {
			var marker2 =
			new GMarker(point,{title:title});
			GEvent.addListener(
			marker2, "click", function() {
			});
			return marker2;
		}
		var marker2 = createMarker( new GLatLng(51.619828,0.29912), 'Hi-Spek', 'Hi-Spek');
		map2.addOverlay(marker2);
	}
}

function DelayChangeNumber()
{				
	//document.write(theURL);
	var MatchingProducts = document.getElementById("MatchingProducts");
	MatchingProducts.value = "";
	var theTextBox = document.getElementById("MatchingProducts");
	theTextBox.className="theTextBox";		
	setTimeout(ChangeNumber, 900);
}

function ChangeNumber()
{
	var theURL = window.location.toString();
	theURL = theURL.toLowerCase();
	theURL = theURL.replace("productlist.aspx", "productnumbers.aspx");
	theURL = theURL.replace("%5e", "^");
	
	var theTextBox = document.getElementById("MatchingProducts");
	var BrandList = document.getElementById("BrandList");
	if (BrandList.options[BrandList.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Brand=" + BrandList.options[BrandList.selectedIndex].value;
	}
	
	var PriceList = document.getElementById("PriceList");
	if (PriceList.options[PriceList.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Price=" + PriceList.options[PriceList.selectedIndex].value;
	}
	
	var Filter1 = document.getElementById("Filter1");
	if(Filter1 && Filter1.options[Filter1.selectedIndex].value &&
		Filter1.options[Filter1.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Filter1=" + Filter1.options[Filter1.selectedIndex].value;
	}
	var Filter2 = document.getElementById("Filter2");
	if(Filter2 && Filter2.options[Filter2.selectedIndex].value &&
		Filter2.options[Filter2.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Filter2=" + Filter2.options[Filter2.selectedIndex].value;
	}
	var Filter3 = document.getElementById("Filter3");
	if(Filter3 && Filter3.options[Filter3.selectedIndex].value &&
		Filter3.options[Filter3.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Filter3=" + Filter3.options[Filter3.selectedIndex].value;
	}
	var Filter4 = document.getElementById("Filter4");
	if(Filter4 &&
		Filter4.options[Filter4.selectedIndex].value.length > 0)
	{
		theURL = theURL + "&Filter4=" + Filter4.options[Filter4.selectedIndex].value;
	}
	var ran_number = Math.random();
	theURL = theURL + "&Rand=" + ran_number;
	
	//alert(theURL);
	xmlhttp.open("GET", theURL,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var MatchingProducts = document.getElementById("MatchingProducts");
			MatchingProducts.value = xmlhttp.responseText;
			theTextBox.className="theTextBox1";
		}
	}
	xmlhttp.send(null)
}

function openImage(product)
{
	var newwindow = open("/ShowFull.aspx?File=" + product,"","width=500,height=650,taskbar=no, scrollbars=yes, menubar=no,left=0,top=0,screenX=0,screenY=0", "");
		  
	if (!newwindow)
	{
		alert("Sorry, this window failed to open, make sure you haven't a pop-up blocker installed, and your Javascript settings are set correctly.");
	}
	newwindow.document.close();
}	
			
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 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 closeMenu() 
{	
	for (var i = 0; i<=30; i++) {
		if (document.getElementById('smenu'+i))
		{
			document.getElementById('smenu'+i).style.display='none';
		}
	}

	OpenSaved;
}

function OpenSaved()
{
	var cookie = readCookie("menuState");
	var menuState = cookie ? cookie : "1";
	openMenuItem(menuState);
}

function menuMouseOver(id)
{
//	var d = document.getElementById("smenu" + id);
//	var dd = document.getElementById("topmenu" + id);
	
//	if (d.style.display == 'none'){
//		dd.className = 'MenuOver';		
//	}	
}	

function menuMouseOut(id)
{
//	var d = document.getElementById("smenu" + id);
//	var dd = document.getElementById("topmenu" + id);
		
//	if (d.style.display == 'none'){
//		dd.className = 'dt';
//	}	
}

function StartMenuClosed()
{
	for (var i = 0; i<=30; i++) {
		if (document.getElementById('smenu'+i))
		{
			document.getElementById('smenu'+i).style.display='none';
			//document.getElementById('topmenu'+i).style.background='url(leftbutton.jpg)';
		}		
	}
}


function checkMenuItem(id)
{
	var d = document.getElementById("smenu" + id);
	//var e = document.getElementById("simage" + id);
	var dd = document.getElementById("topmenu" + id);

	if (document.getElementById('smenu'+id).style.display == 'block')
	{
		d.style.display='none';
		//e.style.display='block';
	}
	else
	{
		openMenuItem(id);
	}
}

function openMenuItem(id)
{
	var d = document.getElementById("smenu" + id);
	//var e = document.getElementById("simage" + id);
	var dd = document.getElementById("topmenu" + id);	
		
	for (var i = 0; i<=30; i++) {
		if (document.getElementById('smenu'+i))
		{
			document.getElementById('smenu'+i).style.display='none';
			//document.getElementById('simage'+i).style.display='block';
			//document.getElementById('topmenu'+i).style.background='url(leftbutton.jpg)';
		}		
	}

	if (d) {
		d.style.display='block';
		//dd.style.background='url(leftbutton_active.jpg)';
	}
	
	//if (e) {
	//	e.style.display='none';
		//dd.style.background='url(leftbutton_active.jpg)';
	//}
	// Save State
	createCookie("menuState", id, 365);
}


			
		function showTabs()
		{
			try
			{
				document.getElementById('Image1').style.visibility = 'visible';
				document.getElementById('Image2').style.visibility = 'visible';
				document.getElementById('Image3').style.visibility = 'visible';
				document.getElementById('Image4').style.visibility = 'visible';
			}
			catch(err)
			{				
			}				
		}	
			
//createCookie("BBtest","ere",30)
//alert(document.cookie);

		
function GetMenu()
{
	xmlhttp.open("GET", "/Includes/GetMenu.aspx",true);
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {			
			ShowText(xmlhttp.responseText);
		}
	}
	xmlhttp.send(null)
}

		
function CatListAJAX()
{
	xmlhttp.open("GET", "/Includes/getcatlistAJAX.aspx",true);
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {			
			ShowCatText(xmlhttp.responseText);
		}
	}
	xmlhttp.send(null)
}

		
function GetDeliveryQuote()
{
	var URL = "/Includes/getDeliveryAJAX.aspx?PID=" + document.getElementById('thePID').value + "&Postcode=" + document.getElementById('PostCode').value;
	xmlhttp.open("GET", URL,true);
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {	
			document.getElementById('DeliveryLit').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null)
}
function GetDeliveryQuoteSummary()
{
	var URL = "/Includes/getDeliveryAJAXSummary.aspx?PID=" + document.getElementById('thePID').value + "&Postcode=" + document.getElementById('PostCode').value;
	xmlhttp.open("GET", URL,true);
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {	
			document.getElementById('DeliveryLit').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null)
}

function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}

function ShowCatText(theText)
{	
	document.getElementById('CatListAJAX').innerHTML = theText;					
}

function ShowText(theText)
{	
	document.getElementById('Menu').innerHTML = theText;					
}

function openBigWindow(file)
			{
				var newwindow = open("/ShowFull.aspx?File=" + file,"","width=600,height=550,taskbar=no, scrollbars=yes, menubar=no,left=0,top=0,screenX=0,screenY=0", "");
		  
				if (!newwindow)
				{
					alert("Sorry, this window failed to open, make sure you haven't a pop-up blocker installed, and your Javascript settings are set correctly.");
				}
		 
				newwindow.document.close();
			}	
			function ShowPanel(panel)
			{
				HideAllPanels();
				var O1 = document.getElementById(panel);
				O1.style.display = '';
			}	
			function HideAllPanels()
			{
				document.getElementById("Panel0").style.display = 'none';
				document.getElementById("Panel1").style.display = 'none';
				document.getElementById("Panel2").style.display = 'none';
				document.getElementById("Panel3").style.display = 'none';
				document.getElementById("Panel4").style.display = 'none';
			}
			
			var aryImages = new Array(4);
			aryImages[0] = "/graphics/Tabs/overview.gif";
			aryImages[1] = "/graphics/Tabs/fulldetails.gif";
			aryImages[2] = "/graphics/Tabs/delivery.gif";
			aryImages[3] = "/graphics/Tabs/alternativeprods.gif";	
			aryImages[4] = "/graphics/Tabs/alternativepacks.gif";		
	
			function SelectTab(tab, image)
			{
				Swap('Image1',aryImages[0]);
				Swap('Image2',aryImages[1]);
				Swap('Image3',aryImages[2]);
				Swap('Image4',aryImages[3]);
				Swap('Image5',aryImages[4]);
				Swap(tab, '/graphics/Tabs/' + image);
			}
			
			function Swap(imageID, ThisSRC)
			{
				if (document.getElementById(imageID))
				{
					document.getElementById(imageID).src = ThisSRC;
				}
			}
			
			function addRemotely(Item)
			{
				var image = "AP" + Item;
				MM_swapImage(image,'','/graphics/shopbuttons/added.gif',1);	
				var URL = "/AddToOrder.aspx?PID="+ Item +"&Quantity=1&kill=true";			
				AJAXSend(URL);
			}	
		