function checkcard(thiscard)
							{
								if (thiscard == "VISA" || thiscard == "MC" || thiscard == "American Express")
									{
										document.getElementById("startdate").style.display = ""
										document.getElementById("issuenumber").style.display = "none"
									}
								else
									{
										document.getElementById("startdate").style.display = "none"
										document.getElementById("issuenumber").style.display = ""
									}
						}
						
/*************************productOptions*/
function changetocase(whatcase,what,text)
{
	if (document.getElementById(what))
	{
	if (whatcase == "p")
	{
		document.getElementById(what).value = pCase(text) 
	}
	else
	{
		document.getElementById(what).value = text.toUpperCase() 
	}
	}
}



function pCase(s) 
    { 
        return s.replace(/(\w)(\w*)/g,function 
        ( 
            strMatch, 
            strFirst, 
            strRest, 
            intMatchPos, 
            strSource 
        ) 
        { 
            return strFirst.toUpperCase() 
            +strRest.toLowerCase(); 
        }); 
    } 
		
function getprodoptions(theseoptions,productID,pID,optionids)
{

	document.getElementById("unavailable").value="";
	savewhat = "&";
	optionslist = theseoptions.split("|")
	optionidslist = optionids.split("|")
	//alert(theseoptions)
	for (i=0;i<=(optionslist.length)-2;i++) 
  {
  	savewhat += optionslist[i]+"="+document.getElementById(optionidslist[i]).value+"&"	
  }

		savewhat += "optionslength="+((optionslist.length*1)-1)
	//alert(savewhat)
	ajax('getprodoptions',"&optionslist="+savewhat+"&productID="+productID+"&pID="+pID+"&productprice="+document.getElementById("productprice").value)
}
//////////////////////////////////productOptions*/


function showdiv(thisdiv,showhide)
{
thisparent = ""
	showhide = showhide.toUpperCase();
	
  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 formattxt(thistxt)
{

thistxt = thistxt.replace(/~/g, '"');
thistxt = thistxt.replace(/#GBP#/g, '£');

return thistxt
}	
	
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 swapimg(imgid,tothisimg,windowvalue,currentfolder,selectid)
{
	if (tothisimg != windowvalue)
	{
		if (imgid != "")
		{
			document.getElementById(imgid).src=tothisimg;
		}
	}
	else
	{
	tb_show("new Window", "uploads.asp?preview="+selectid+"_preview&insertinto="+selectid+"&c=1&currentfolder="+currentfolder+"&height=750&width=870&KeepThis=true&TB_iframe=true", false)
	}
}

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 addOption(selectbox,text,value,clearfirst)
{
//
//	text = text.replace("£","&pound;")
	text = formattxt(text)
	
  if (document.getElementById(selectbox))
	{
	if (clearfirst){
	
	document.getElementById(selectbox).options.length = 0
	}
	
	
  	var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
  	document.getElementById(selectbox).options.add(optn);
	}
}


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 ajax(dothis,thesevars)
	{
		ajaxDothis(dothis,thesevars,'','')
	}
	
	
	function ajaxDothis(dothis,savewhat,saveid,savethis)
  {
	//alert("dothis: " + dothis)
	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 (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)
								eval(result)
							
							}
						
							}
  			}
				//alert("savethis: "+savethis)
	//alert("ajax.asp?dothis="+dothis+"&"+savewhat+"&saveid="+saveid+"&savethis="+savethis)
				
  xmlHttp.open("GET",dotdotdash+"ajax.asp?dothis="+dothis+"&"+savewhat+"&saveid="+saveid+"&savethis="+savethis,true);
	xmlHttp.send(null);  
}