function writetopage(whatdiv,writethis)
	{
  	writethis = writethis.replace(/~/g, '"');
  	tothis = whatdiv;
		if (document.getElementById(tothis))
		{
  	document.getElementById(tothis).innerHTML = writethis;
		}
		else
		{
		alert("element "+tothis+" not found!")
		}
	}
	

	
function emptyfield (doingthis, fieldname,defaultvalue)
{

if (doingthis == "blur")
{
	if (document.getElementById(fieldname).value == "")
	{
		document.getElementById(fieldname).value = defaultvalue
	}
}
else
{
	if (document.getElementById(fieldname).value == defaultvalue)
	{
		document.getElementById(fieldname).value = ""
	}
}

}


function showdiv(thisdiv,showhide)
{
	if (showhide != null && showhide != "")
	{
  	if (document.getElementById(thisdiv)) 
  	{
  		document.getElementById(thisdiv).style.display = showhide
  	}
	}
	else
	{
  	if (document.getElementById(thisdiv).style.display == "block")
  	{
//  	alert("showing")
  		document.getElementById(thisdiv).style.display = "none"
  	}
  	else
  	{	
  		document.getElementById(thisdiv).style.display = "block"
  	}
	}

}


function changeimg(tothis,thisimage)
  {
  	document.getElementById(thisimage).src=tothis
  }
	
	function zoominout(whichway)
	{
		if (whichway == "in")
		{
			document.getElementById("bigimg").style.display = "block"
			document.getElementById("img").style.display = "none"
		}
		else
		{
			document.getElementById("bigimg").style.display = "none"
			document.getElementById("img").style.display = "block"
		}
	}
	
	
	function showzoom(imgsrc)
	{
		alert(imgsrc)
		embed = "<object classid=~clsid:d27cdb6e-ae6d-11cf-96b8-444553540000~ codebase=~http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0~ width=~200~ height=~410~ id=~container~ >"
    embed += "<param name=~allowScriptAccess~ value=~sameDomain~ />"
    embed += "<param name='movie' value='imgviewer2.swf?"+imgsrc+"'>"
		embed += "<param name=~quality~ value=~high~ />"
		embed += "<param name=~bgcolor~ value=~#ffffff~ />"
		embed += "<embed src=~imgviewer2.swf?"+imgsrc+"~ quality=~high~ bgcolor=~#ffffff~ width=~200~ height=~410~ name=~container~ align=~middle~ allowScriptAccess=~sameDomain~ type=~application/x-shockwave-flash~ pluginspage=~http://www.macromedia.com/go/getflashplayer~ />"
    embed += "</object><br /><br />"
		
		embed += "<a href='#' onclick=~zoominout('out');~ ><img src=~images/zoom-out.gif~ alt=~zoom out~></a>"
	
	
	
	writetopage('bigimg',embed)
	}
	
function checktc()
	{
  	if (document.getElementById("tcs").checked != true)
    	{
      	alert('Please tick the box to indicate you have read our terms and conditions')
        return false;
      }
  }	
	
function writetopage(whatdiv,writethis)
	{
  	writethis = writethis.replace(/~/g, '"');
  	tothis = whatdiv;
		if (document.getElementById(tothis))
		{
  	document.getElementById(tothis).innerHTML = writethis;
		}
		else
		{
		alert("element "+tothis+" not found!")
		}
	}

function styleswap(thisid,thisclass){
	document.getElementById(thisid).className=thisclass;
}	
	
function formatCurrency(num) {
  num = num.toString();
  if(isNaN(num))
  num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
  cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '&pound;' + num + '.' + cents);
  }

function urlencode(str) {
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}

function urldecode(str) {
str = str.replace('+', ' ');
str = unescape(str);
return str;
}

function getoptions(theseoptions,productID,pID)
{
	savewhat = "&productprice="+document.getElementById("productprice").value+"&"
	optionslist = theseoptions.split("|")
	
	for (i=0;i<=(optionslist.length)-2;i++) 
{
		savewhat += optionslist[i]+"="+document.getElementById(optionslist[i])[document.getElementById(optionslist[i]).selectedIndex].value+"&"
		
 // alert("optiosn list "+optionslist[i])
}

		savewhat += "optionslength="+((optionslist.length*1)-1)

	ajax('getoptions',savewhat+"&productID="+productID+"&pID="+pID)

}



	function check_tick(dothis,savewhat,saveid,tickon, tickoff)
{
 
 if (document.getElementById(savewhat).checked)
 {
 	savethis = "true"
 }
 else
 {
 	savethis = "false"
 }
	
	if (document.getElementById(savewhat).checked)
	{
		ajaxDothis(dothis,savewhat,saveid,savethis)
	}
	else
	{
		ajaxDothis(dothis,savewhat,saveid,savethis)
	}

}
	
	
	function ajax(dothis,thesevars)
  {
	
	var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari    
				xmlHttp=new XMLHttpRequest();    }
  catch (e)
    {   
		 // Internet Explorer  
		try
      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}
    catch (e)
      { 
				try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						}
      catch (e)
        {        alert("Your browser does not support AJAX!");
						        return false;
						}
			  }
		}
		
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
							var result = xmlHttp.responseText
							
							if (dothis == "addtobasket")
							{
								//alert(result)
							}
						//	alert(result)
  					eval(result)

        }
  			}
				
		//alert("ajax.asp?dothis="+dothis+"&savewhat="+savewhat+"&saveid="+saveid+"&savethis="+savethis)
				
  xmlHttp.open("GET","ajax.asp?dothis="+dothis+"&"+thesevars,true);
	xmlHttp.send(null);  
}