// JavaScript Document
function sendtofriend()
{
	var url = 'email_to_a_friend.php';
	var win_width = 550;
	var win_height = 224;	 
	if(document.all)
	{
		all_width = parseInt(document.body.scrollWidth);
	}
	else
	{
		all_width = parseInt(innerWidth);
	}
	document.getElementById('winiframe').src = "blank.htm";
	document.getElementById('winiframe').width = win_width-2;
	document.getElementById('winiframe').height = win_height-2;
	document.getElementById('winiframe').scrolling = "no";
	 
	
	if (document.body.scrollTop == 0)
 		document.getElementById('windiv').style.top = parseInt(document.documentElement.scrollTop+150)+'px';
 	 else
  	 	document.getElementById('windiv').style.top = parseInt(document.body.scrollTop+150)+'px';
	
	//document.getElementById('windiv').style.top = (all_height-win_height-225)/2+'px';
	document.getElementById('windiv').style.left = (all_width-win_width)/2+'px';
	document.getElementById('windiv').style.height = win_height+25+'px';
	document.getElementById('windiv').style.width = win_width+'px';
	document.getElementById('windiv').style.display='block';
	document.getElementById('winiframe').src = url;
}
function close_window()
{
	document.getElementById('winiframe').src = "blank.htm";	 
 	document.getElementById('windiv').style.display='none';
}
	var first1=1;
	var first2=1;
	
	
	function reclc(nid)
	{
		 var ctotal = 0;
		 var btotal =0;
		 var ttotal =0;
		 
		 	if(nid==1&&first1) 
			{
				document.orderform.Cardnum.value="";
				first1=0;  
			}
		 	if(nid==2&&first2) 
			{
				document.orderform.Booknum.value="";
				first2=0;  
			}	
		
		if (parseInt(document.orderform.Booknum.value))
		{
			document.getElementById("booktotal").innerHTML="&pound;"+eval(parseInt(document.orderform.Booknum.value)*bookcost);			
			btotal = parseInt(document.orderform.Booknum.value)*bookcost;
			 
		}	
		else
		{
		 
			document.getElementById("booktotal").innerHTML="";			 
		}
		
		if (parseInt(document.orderform.Cardnum.value))
		{
			document.getElementById("cardtotal").innerHTML="&pound;"+eval(parseInt(document.orderform.Cardnum.value)*cardcost);			
			ctotal = parseInt(document.orderform.Cardnum.value)*cardcost;
			 
		}	
		else
		{
			 
			document.getElementById("cardtotal").innerHTML="";			 
		}
		
		    if(reading_ordered)
			{
			    document.getElementById("total").innerHTML="&pound;"+eval(ctotal+btotal+readingcost);
			} else
		    	document.getElementById("total").innerHTML="&pound;"+eval(ctotal+btotal);
			 
			document.getElementById("totaltxt").innerHTML="<strong>TOTAL</strong>"; 
	}
	function on_load()
	{
		 
			reclc(0);
	}
	function setFocus(layerName)
	{
  		var layer = document.getElementById(layerName);
 		var focusIt = layer.getElementsByTagName('a')[0];
  		focusIt.focus();
	}
	function trim(str)
	{
  		return str.replace(/^\s+|\s+$/g, '')
	}
	function check_form()
	{
		var elems = new Array();
		elems = document.getElementsByTagName('input');
		for (i=0;i<elems.length;i++)
		{
			if(elems[i].name=="giftv")
			{
				continue;
			}
			if (elems[i].type=="text"&&elems[i].value&&elems[i].name=="Email")
			{
				 var tfld =trim(elems[i].value); 
 				 
				 var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/
 				 if (!email.test(tfld)) 
				 {
				 	 alert("Invalid Email Address!")
			 		 elems[i].focus();
			         return false;
				 }
			}
			else if (elems[i].type=="text"&&!elems[i].value&&elems[i].name!="address2")
			{
			 alert("Please fill in all required fields!")
			 elems[i].focus();
			 return false;
			}
		}
		 
		 
		 
		//alert(document.orderform.custom.value);
		
	}
function showmean()
{
	document.getElementById('aysha').style.display='none';
	document.getElementById('cmeaning').style.display='block';
	
}