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 showdiv(thisdiv,showhide)
{
thisparent = ""
	
  if (document.getElementById(thisdiv))
  {
  thisparent = ""
  }
  else
  {
		if (parent.document.getElementById(thisdiv))
    {
    	thisparent = "parent."
    }
		else
		{
			if (top.document.getElementById(thisdiv))
      {
      	thisparent = "top."
      }
		}
  }
	
		
	if (showhide != null && showhide != "")
  	{
		
    	if (eval(thisparent+"document.getElementById('"+thisdiv+"') != null") )
    		{
			
					if (navigator.userAgent.indexOf("Firefox")!=-1)
					{
						
					//alert(thisdiv + " - " + showhide)
      			if(showhide == "block")
    				{
    					showhide = "table-row"
    				}
				
						
					}
					
							if (showhide  == "block-block")
						{
						showhide = "block"
						}
						
    			eval(thisparent+"document.getElementById('"+thisdiv+"').style.display = '"+showhide+"'")
    		}
    }
  else
    {
		
						
      if (eval(thisparent+"document.getElementById('"+thisdiv+"').style.display == 'table-row' "))
      	{
					eval(thisparent+"document.getElementById('"+thisdiv+"').style.display = 'none' ")
      	}
      else
      	{	
				eval(thisparent+"document.getElementById('"+thisdiv+"').style.display = 'table-row' ")
      	}
    }

}

	
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)

	ajaxDothis('getoptions',savewhat,productID,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,vars)
	{
		
			ajaxDothis(dothis,"&"+vars,"fromajax","","")
	}
	
	function ajaxDothis(dothis,savewhat,saveid,savethis)
  {
	savethis = savethis
	//alert("dothis: " +dothis + "; savewhat: "+savewhat+"; saveid:" + saveid + "; savethis: " +savethis)
	
	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)
							}
						if (result.slice(2,12) == "<!DOCTYPE " || result.slice(2,12) == "font face=")
							{
							document.write(result)
							alert(result)
							 alert("Sorry, there has been an error.")
				
							 
							}
							else
							{
							//	alert(result)
//							document.write(result)
								eval(result)
						
							}

        }
  			}
				//alert("savethis: "+savethis)
	//	alert("ajax.asp?dothis="+dothis+"&savewhat="+savewhat+"&saveid="+saveid+"&savethis="+savethis)
				
  xmlHttp.open("GET","ajax.asp?dothis="+dothis+"&savewhat="+savewhat+"&saveid="+saveid+"&savethis="+savethis,true);
	xmlHttp.send(null);  
}