function GetXmlHttpObject()
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
      objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}


function find_address()
{
	if(trim(document.step3.post_code.value)=="")
	{
		alert("Please enter post code");
		document.step3.post_code.focus();
		return false;
	}	  	
	
  document.getElementById("step2_break_flow1").style.display="none";
  document.getElementById("step2_break_flow2").style.display="none";  
  document.getElementById("button_address1").style.display="none";
  document.getElementById("button_address2").style.display="block";
  document.getElementById('address_id').innerHTML = "";
  document.getElementById('address_id').style.display = 'none';	
  var postal_code = document.step3.post_code.value;    
  var url="find_address.php";   
  xmlHttp=GetXmlHttpObject();
  xmlHttp.open("POST", url, true);
  xmlHttp.onreadystatechange=show_address
  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlHttp.send("postcode_address="+postal_code+"&varcheck=1");
  
}


function show_address()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
	   document.step3.find_address_check.value = "1";
	   var xttpreturn = xmlHttp.responseText;	   
	   if(xttpreturn==0) { 		   
		   document.getElementById("step2_break_flow3").style.display="none";
		   document.getElementById("step2_break_flow1").style.display="block";
		   document.getElementById("step2_break_flow2").style.display="block";  
		   document.getElementById("button_address1").style.display="none";
		   document.getElementById("button_address2").style.display="block";
		   document.step3.address.value = "";
		   document.step3.town.value = "";
		   document.step3.county.value = "";			
		   
	   }
	   else
	   {
		   document.getElementById("step2_break_flow3").style.display="block";
		   document.getElementById("address_id").style.display="block";
		   document.getElementById('address_id').innerHTML = xttpreturn;
		   document.getElementById("button_address1").style.display="block";
		   document.getElementById("button_address2").style.display="none";
	   }
	}
}

function submit_address(id) {
	if(id=="0101")
	{			
			document.getElementById('step2_break_flow1').style.display = 'block';
			document.getElementById('step2_break_flow2').style.display = 'block';
			document.getElementById('step2_break_flow3').style.display = 'none';
			document.step3.address.value = "";
			document.step3.town.value = "";
			document.step3.county.value = "";
			document.step3.post_code.value = "";
			document.getElementById("townnp").style.backgroundColor="#FFFFFF";
			document.getElementById("countynp").style.backgroundColor="#FFFFFF";									
			document.getElementById("post_codenp").style.backgroundColor="#FFFFFF";
			document.step3.postcodesearch.value = "1";	
			tb_remove();
	}
	else
	{	  
	  var answer = confirm("Is this correct address you selected?");
	  if (answer){
		var new_css_id = "td_"+id;		  
	  document.getElementById(new_css_id).style.backgroundColor="#C1ECC1";		
	  var url="find_address_detail.php";   
	  xmlHttp=GetXmlHttpObject();
	  xmlHttp.open("POST", url, true);
	  xmlHttp.onreadystatechange=tb_remove_ajax
	  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	  xmlHttp.send("postcode_address_field="+id+"&varcheck=1");		
	}	
	  
	}
}


function show_address_detail()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	   
		var xttpreturn = xmlHttp.responseText;
		returnArr = xttpreturn.split("|");
		if(returnArr[0]==0 && returnArr[1]==0 && returnArr[2]==0 && returnArr[3]==0)
		{			
			document.getElementById('step2_break_flow1').style.display = 'block';
			document.getElementById('step2_break_flow2').style.display = 'block';
			document.getElementById('step2_break_flow3').style.display = 'none';
			document.step3.address.value = "";
			document.step3.town.value = "";
			document.step3.county.value = "";
			document.step3.post_code.value = "";	
			document.step3.postcodesearch.value = "1";	
			
		}
		else
		{			
			document.getElementById("button_address1").style.display="block";
			document.getElementById("button_address2").style.display="none";
			document.getElementById('address_id').innerHTML = "";
			document.getElementById('address_id').style.display = 'none';
			document.getElementById('step2_break_flow1').style.display = 'block';
			document.getElementById('step2_break_flow2').style.display = 'block';
			document.getElementById('step2_break_flow3').style.display = 'none';
			document.step3.address.value = trim(returnArr[0]);
			document.step3.town.value = trim(returnArr[1]);
			document.step3.county.value = trim(returnArr[2]);
			document.step3.post_code.value = trim(returnArr[3]);							
			document.step3.postcodesearch.value = "1";	
		}
	}
}
 
function check_voucher_value(parameter)
{   	
  document.step4.Deduct_Amount.value = "";  
  document.getElementById("neglect1").style.display="block";
  document.getElementById("neglect").style.display="none";
  var url="checking_voucher.php";   
  xmlHttp=GetXmlHttpObject();
  xmlHttp.open("POST", url, true);
  xmlHttp.onreadystatechange=show_voucher_status               
  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");              
  xmlHttp.send("voucher_Number="+parameter); 
 
}


function show_voucher_status()
{
 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {   
	document.getElementById("neglect1").style.display="none";
	var xttpreturn = xmlHttp.responseText;
	returnArr = xttpreturn.split("#");	
   if(returnArr[0]==1)
   {
		if(document.step4.package[0].checked==true)
			id="package1";

		if(document.step4.package[1].checked==true)
			id="package2";

		if(document.step4.package[2].checked==true)
			id="package3";			

	   if(id=="package1")
	   {
			document.getElementById("neglect").style.display="none";
		    document.getElementById("special_discount").style.display="block";						
			document.getElementById('price_value2dis').innerHTML = returnArr[1];
			new_peice_value = Number(1.99)- Number(returnArr[1]);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);;
			document.getElementById('price_value1').innerHTML = '5.99';
			document.getElementById('price_value2').innerHTML = '4.00';
			document.getElementById('price_value3').innerHTML = 'FREE';
			document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
			document.getElementById('price_value5').innerHTML = '0.00';
			document.getElementById('price_value6').innerHTML = 'Free Trial (14 days)';
			document.step4.Deduct_Amount.value = Number(returnArr[1]);			
	   }
	   else if(id=="package2")
	   {
			document.getElementById("neglect").style.display="none";
		    document.getElementById("special_discount").style.display="block";			
			document.getElementById('price_value2dis').innerHTML = returnArr[1];
			new_peice_value = Number(62.00)- Number(returnArr[1]);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);
			document.getElementById('price_value1').innerHTML = '0.00';
			document.getElementById('price_value2').innerHTML = document.step4.rp_saving.value;
			document.getElementById('price_value3').innerHTML = '&pound;'+document.step4.rp_regular.value;;
			document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
			document.getElementById('price_value5').innerHTML = document.step4.rp_regular.value;
			document.getElementById('price_value6').innerHTML = 'Regular Plan';
			document.step4.Deduct_Amount.value = Number(returnArr[1]);			
	   }
	   else if(id=="package3")
	   {
			document.getElementById("neglect").style.display="none";
			document.getElementById("special_discount").style.display="block";			
			document.getElementById('price_value2dis').innerHTML = returnArr[1];
			new_peice_value = Number(99.00)- Number(returnArr[1]);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);
			document.getElementById('price_value1').innerHTML = '0.00';
			document.getElementById('price_value2').innerHTML = document.step4.celeb_saving.value;
			document.getElementById('price_value3').innerHTML = '&pound;'+document.step4.celeb_regular.value;
			document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
			document.getElementById('price_value5').innerHTML = document.step4.celeb_regular.value;
			document.getElementById('price_value6').innerHTML = 'Celebrity Plan';
			document.step4.Deduct_Amount.value = Number(returnArr[1]);
	   }
		
		document.step4.Card_Number.focus();
   }
   else
   {
	   if(document.step4.package[0].checked==true)
			id="package1";

		if(document.step4.package[1].checked==true)
			id="package2";

		if(document.step4.package[2].checked==true)
			id="package3";	

	   document.getElementById("neglect1").style.display="none";
	   document.getElementById("neglect").style.display="block";
	   if(id=="package1")
	   {
		    document.getElementById("special_discount").style.display="none";									
			new_peice_value = Number(1.99);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);			
			document.step4.Deduct_Amount.value = "";
			

			
	   }
	   else if(id=="package2")
	   {
		    document.getElementById("special_discount").style.display="none";						
			new_peice_value = Number(62.00);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);			
			document.step4.Deduct_Amount.value = "";			
	   }
	   else if(id=="package3")
	   {
			document.getElementById("special_discount").style.display="none";						
			new_peice_value = Number(99.00);
			document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);			
			document.step4.Deduct_Amount.value = "";			
	   }
   }
  //document.getElementById("is_email_div_intial").innerHTML="";
  //document.getElementById("is_email_div_intial").innerHTML=xmlHttp.responseText;   
 }
}
 
 
 function popup(url,height,width)
 {
   mywindow = window.open(url,"mywindow","location=0,status=0,scrollbars=0,width="+width+",height="+height+"");
	widthc = (alertSize()/2)-250;
  mywindow.moveTo(widthc,250);
 } 


 function FSfncCheckCCexpire(FormField) {
	// Check credit expiry date is in valid format
	var CCexpire=FormField.value;
	if (CCexpire=="") {alert("Please enter your credit card expiry date."); FormField.focus(); return false}
	var ArrayCCexpr=CCexpire.split("/");
	if ((ArrayCCexpr.length!=2) || (ArrayCCexpr[0]=="") || (isNaN(ArrayCCexpr[0])) || (ArrayCCexpr[1]=="") || (isNaN(ArrayCCexpr[1])) || (ArrayCCexpr[0]<1) || (ArrayCCexpr[0]>12)) {alert("Expiry date is not in correct format."); FormField.focus(); return false}
	return true;
	}

function FSfncCheckCCnum(FormField) {	
	// Check credit/Switch card number is in valid format
	var ccRE=/\W/gi;	
	var CCnumber=FormField.value.replace(ccRE, "");
	if (isNaN(CCnumber)) {alert("Credit card number is not numeric."); FormField.focus(); return false}
	if ((CCnumber.length!=16) && (CCnumber.length!=18)) {alert("Incorrect number of digits in credit card number."); FormField.focus(); return false}
	var cardMath=0;
	for (i=CCnumber.length; i>0; i--) {
		if (i % 2 == 1) {
			var doubled = "" + (parseInt(CCnumber.substring(i - 1, i)) * 2);
			if (doubled.length==2) {doubled = parseInt(doubled.substring(0,1)) + parseInt(doubled.substring(1,2))}
			cardMath += parseInt(doubled);
			}
		else {cardMath += parseInt(CCnumber.substring(i - 1, i))}
		}
	if (cardMath % 10 != 0) {alert("Credit card number is invalid."); FormField.focus(); return false}
	return true;
	}



function dealyshow_player()
{
	document.getElementById("fixed4").style.display ="block";
	document.getElementById("fixed").style.display ="block";
}


 function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 // window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}

function validString(myString)
{
	var valid_string = new String("1234567890");
	for(var i=0;i<myString.length;i++)
	{
		var search_exp=myString.substr(i,1);
		if(search_exp=="+" || search_exp=="*" || search_exp=="|" || search_exp=="$" || search_exp=="^" || search_exp=="(" || search_exp==")" || search_exp=="{" || search_exp=="}" || search_exp=="[" || search_exp=="]" || search_exp==">" || search_exp=="?" || search_exp=="<" || search_exp=='\\'|| search_exp=="="  || search_exp=="_" || search_exp=="-")
		{
			var answerIdx = -1;
		}
		else
		{
			var answerIdx=valid_string.search(search_exp);
		}
		if(answerIdx==0)
		{
			if(search_exp==".")
			{
				return false;
			}
		}
		if(answerIdx==-1)
		{
			return false;
		}
	}
	return true;
}


function validStringphone(myString)
{
	var valid_string = new String("1234567890 ");
	for(var i=0;i<myString.length;i++)
	{
		var search_exp=myString.substr(i,1);
		if(search_exp=="+" || search_exp=="*" || search_exp=="|" || search_exp=="$" || search_exp=="^" || search_exp=="(" || search_exp==")" || search_exp=="{" || search_exp=="}" || search_exp=="[" || search_exp=="]" || search_exp==">" || search_exp=="?" || search_exp=="<" || search_exp=='\\'|| search_exp=="="  || search_exp=="_" || search_exp=="-")
		{
			var answerIdx = -1;
		}
		else
		{
			var answerIdx=valid_string.search(search_exp);
		}
		if(answerIdx==0)
		{
			if(search_exp==".")
			{
				return false;
			}
		}
		if(answerIdx==-1)
		{
			return false;
		}
	}
	return true;
}

function trim(str) 
{ 
	return str.replace(/^\s*|\s*$/g,""); 
}
		
function validateStep1()
{
	if(trim(document.step1.first_name.value)=="")
	{
		alert("Please enter first name");
		document.step1.first_name.focus();
		return false;
	}


	if(trim(document.step1.current_stone.value)=="")
	{
		alert("Please enter current weight in stone");
		document.step1.current_stone.focus();
		return false;
	}

	if(trim(document.step1.current_stone.value)=="0")
	{
		alert("Please enter your current weight");
		document.step1.current_stone.focus();
		return false;
	}

	if(trim(document.step1.current_stone.value)!="")
	{
		if(!validString(trim(document.step1.current_stone.value)))
		{
			alert("Please enter numeric value");
			document.step1.current_stone.focus();
			return false;
		}
	}
	if(trim(document.step1.current_lbs.value)=="")
	{
		alert("Please enter current weight in pounds");
		document.step1.current_lbs.focus();
		return false;
	}

	if(trim(document.step1.current_lbs.value)!="")
	{
		if(!validString(trim(document.step1.current_lbs.value)))
		{
			alert("Please enter numeric value");
			document.step1.current_lbs.focus();
			return false;
		}
	}

	if(trim(document.step1.goal_stone.value)=="")
	{
		alert("Please enter goal weight in stone");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.goal_stone.value)=="0")
	{
		alert("Please enter your goal weight");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.goal_stone.value)!="")
	{
		if(!validString(trim(document.step1.goal_stone.value)))
		{
			alert("Please enter numeric value");
			document.step1.goal_stone.focus();
			return false;
		}
	}
	if(trim(document.step1.goal_lbs.value)=="")
	{
		alert("Please enter goal weight in pound");
		document.step1.goal_lbs.focus();
		return false;
	}

	if(trim(document.step1.goal_lbs.value)!="")
	{
		if(!validString(trim(document.step1.goal_lbs.value)))
		{
			alert("Please enter numeric value");
			document.step1.goal_lbs.focus();
			return false;
		}
	}

	goal_weight_cal = Number(14)*(Number(document.step1.goal_stone.value))+Number(document.step1.goal_lbs.value);
	current_weight_cal = Number(14)*(Number(document.step1.current_stone.value))+Number(document.step1.current_lbs.value);		

	if(Number(goal_weight_cal)>Number(current_weight_cal))
	{
		alert("Goal weight should be less than current weight");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.height_feet.value)=="")
	{
		alert("Please select height feet value");
		document.step1.height_feet.focus();
		return false;
	}


	if(trim(document.step1.height_inch.value)=="")
	{
		alert("Please select height inch value");
		document.step1.height_inch.focus();
		return false;
	}

	if(document.step1.gender[0].checked==false && document.step1.gender[1].checked==false)
	{
		alert("Please select gender");
		document.step1.gender[0].focus();
		return false;
	}


	if(trim(document.step1.year_born.value)=="")
	{
		alert("Please select year born");
		document.step1.year_born.focus();
		return false;
	}
}



function validateStep1_split2()
{
	if(trim(document.step1.first_name.value)=="")
	{
		alert("Please enter first name");
		document.step1.first_name.focus();
		return false;
	}


	if(trim(document.step1.current_stone.value)=="")
	{
		alert("Please enter current weight in stone");
		document.step1.current_stone.focus();
		return false;
	}

	if(trim(document.step1.current_stone.value)=="0")
	{
		alert("Please enter your current weight");
		document.step1.current_stone.focus();
		return false;
	}

	if(trim(document.step1.current_stone.value)!="")
	{
		if(!validString(trim(document.step1.current_stone.value)))
		{
			alert("Please enter numeric value");
			document.step1.current_stone.focus();
			return false;
		}
	}
	if(trim(document.step1.current_lbs.value)=="")
	{
		alert("Please enter current weight in pounds");
		document.step1.current_lbs.focus();
		return false;
	}

	if(trim(document.step1.current_lbs.value)!="")
	{
		if(!validString(trim(document.step1.current_lbs.value)))
		{
			alert("Please enter numeric value");
			document.step1.current_lbs.focus();
			return false;
		}
	}

	if(trim(document.step1.goal_stone.value)=="")
	{
		alert("Please enter goal weight in stone");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.goal_stone.value)=="0")
	{
		alert("Please enter your goal weight");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.goal_stone.value)!="")
	{
		if(!validString(trim(document.step1.goal_stone.value)))
		{
			alert("Please enter numeric value");
			document.step1.goal_stone.focus();
			return false;
		}
	}
	if(trim(document.step1.goal_lbs.value)=="")
	{
		alert("Please enter goal weight in pound");
		document.step1.goal_lbs.focus();
		return false;
	}

	if(trim(document.step1.goal_lbs.value)!="")
	{
		if(!validString(trim(document.step1.goal_lbs.value)))
		{
			alert("Please enter numeric value");
			document.step1.goal_lbs.focus();
			return false;
		}
	}

	goal_weight_cal = Number(14)*(Number(document.step1.goal_stone.value))+Number(document.step1.goal_lbs.value);
	current_weight_cal = Number(14)*(Number(document.step1.current_stone.value))+Number(document.step1.current_lbs.value);		

	if(Number(goal_weight_cal)>Number(current_weight_cal))
	{
		alert("Goal weight should be less than current weight");
		document.step1.goal_stone.focus();
		return false;
	}

	if(trim(document.step1.height_feet.value)=="")
	{
		alert("Please select height feet value");
		document.step1.height_feet.focus();
		return false;
	}


	if(trim(document.step1.height_inch.value)=="")
	{
		alert("Please select height inch value");
		document.step1.height_inch.focus();
		return false;
	}

	if(document.step1.gender[0].checked==false && document.step1.gender[1].checked==false)
	{
		alert("Please select gender");
		document.step1.gender[0].focus();
		return false;
	}


	if(trim(document.step1.year_born.value)=="")
	{
		alert("Please select year born");
		document.step1.year_born.focus();
		return false;
	}

	document.step1.submit();
}


 function Is_Numeric(value1)
{
	var rxp = /^([0-9\-]+)$/;
	if(rxp.test(value1)!=true)
	{
		return false;
	}
	else
	{
		return true;
	}
}



function validateStep2()
{
	return true;
}

function change_price(id)
{
	if(id=="package1")
	{
		returnArr = document.step4.Deduct_Amount.value;
		new_peice_value = Number(1.99)- Number(returnArr);
		document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);
		document.getElementById('price_value1').innerHTML = '5.99';
		document.getElementById('price_value2').innerHTML = '4.00';
		document.getElementById('price_value3').innerHTML = 'FREE';
		document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
		document.getElementById('price_value5').innerHTML = '0.00';
		document.getElementById('price_value6').innerHTML = 'Free Trial (14 days)';
	}
	else if(id=="package2")
	{
		returnArr = document.step4.Deduct_Amount.value;	
		new_peice_value = Number(62.00)- Number(returnArr);
		document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);
		document.getElementById('price_value1').innerHTML = '0.00';
		document.getElementById('price_value2').innerHTML = document.step4.rp_saving.value;
		document.getElementById('price_value3').innerHTML = '&pound;'+document.step4.rp_regular.value;;
		document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
		document.getElementById('price_value5').innerHTML = document.step4.rp_regular.value;
		document.getElementById('price_value6').innerHTML = 'Regular Plan';
	}
	else if(id=="package3")
	{
		returnArr = document.step4.Deduct_Amount.value;
		new_peice_value = Number(99.00)- Number(returnArr);
		document.getElementById('price_value').innerHTML = new_peice_value.toFixed(2);
		document.getElementById('price_value1').innerHTML = '0.00';
		document.getElementById('price_value2').innerHTML = document.step4.celeb_saving.value;
		document.getElementById('price_value3').innerHTML = '&pound;'+document.step4.celeb_regular.value;
		document.getElementById('price_value4').innerHTML = 'FREE TRIAL';
		document.getElementById('price_value5').innerHTML = document.step4.celeb_regular.value;
		document.getElementById('price_value6').innerHTML = 'Celebrity Plan';
	}	
}


function validateStep3post()
{
	if(trim(document.step3.first_name1.value)=="")
	{
		alert("Please enter first name");
		document.step3.first_name1.focus();
		return false;
	}


	if(trim(document.step3.last_name.value)=="")
	{
		alert("Please enter last name");
		document.step3.last_name.focus();
		return false;
	}


	if(trim(document.step3.post_code.value)=="")
	{
		alert("Please enter post code");
		document.step3.post_code.focus();
		return false;
	}


	if(document.step3.post_code.value.length > 10 )
	{
		alert("Post code should not be more than 10 characters");
		document.step3.post_code.focus();
		return false;
	}	
	
	if(trim(document.step3.postcodesearch.value)=="0")
	{
		alert("Please enter post code and then submit to find the address");		
		return false;
	}


	if(document.getElementById("step2_break_flow1").style.display == "block" && document.getElementById("step2_break_flow2").style.display =="block") {


	if(trim(document.step3.address.value)=="")
	{
		alert("Please enter address");
		document.step3.address.focus();
		return false;
	}


	if(trim(document.step3.town.value)=="")
	{
		alert("Please enter town");
		document.step3.town.focus();
		return false;
	}


	if(trim(document.step3.county.value)=="")
	{
		alert("Please enter county");
		document.step3.county.focus();
		return false;
	}	


	if(trim(document.step3.phone.value)=="")
	{
		alert("Please enter phone");
		document.step3.phone.focus();
		return false;
	}

	if(trim(document.step3.phone.value)!="" && !validStringphone(document.step3.phone.value))
	{
		alert("Please enter valid phone number");
		document.step3.phone.value = trim(document.step3.phone.value);
		document.step3.phone.focus();
		return false;
	}


	if(trim(document.step3.email.value)=="")
	{
		alert("Please enter email");
		document.step3.email.focus();
		return false;
	}	
	if(document.step3.email.value.length >= 1)
	{
		emailStr = document.step3.email.value;
	  var emailPat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	  var matchArray = emailStr.match(emailPat);
	  if (matchArray == null)  {
	  alert("Invalid Email Address, Please try again");
	  document.step3.email.focus();
	  return false;
	  }
	}

	}
}



function validateStep3()
{
	if(trim(document.step3.first_name1.value)=="")
	{
		alert("Please enter first name");
		document.step3.first_name1.focus();
		return false;
	}


	if(trim(document.step3.last_name.value)=="")
	{
		alert("Please enter last name");
		document.step3.last_name.focus();
		return false;
	}


	if(trim(document.step3.address.value)=="")
	{
		alert("Please enter address");
		document.step3.address.focus();
		return false;
	}

	if(document.step3.address.value.length > 50 )
	{
		alert("Address should not be more than 50 characters");
		document.step3.address.focus();
		return false;
	}

	if(trim(document.step3.town.value)=="")
	{
		alert("Please enter town");
		document.step3.town.focus();
		return false;
	}


	if(trim(document.step3.county.value)=="")
	{
		alert("Please enter county");
		document.step3.county.focus();
		return false;
	}


	if(trim(document.step3.post_code.value)=="")
	{
		alert("Please enter post code");
		document.step3.post_code.focus();
		return false;
	}


	if(document.step3.post_code.value.length > 10 )
	{
		alert("Post code should not be more than 10 characters");
		document.step3.post_code.focus();
		return false;
	}


	if(trim(document.step3.phone.value)=="")
	{
		alert("Please enter phone");
		document.step3.phone.focus();
		return false;
	}

	if(trim(document.step3.phone.value)!="" && !validStringphone(document.step3.phone.value))
	{
		alert("Please enter valid phone number");
		document.step3.phone.value = trim(document.step3.phone.value);
		document.step3.phone.focus();
		return false;
	}


	if(trim(document.step3.email.value)=="")
	{
		alert("Please enter email");
		document.step3.email.focus();
		return false;
	}	
	if(document.step3.email.value.length >= 1)
	{
		emailStr = document.step3.email.value;
	  var emailPat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	  var matchArray = emailStr.match(emailPat);
	  if (matchArray == null)  {
	  alert("Invalid Email Address, Please try again");
	  document.step3.email.focus();
	  return false;
	  }
	}

}



function validateStep4()
{
	if(document.step4.package[0].checked==false && document.step4.package[1].checked==false && document.step4.package[2].checked==false)
	{
		alert("Please select package");
		document.step4.package[0].focus();
		return false;
	}

	/*
	if(trim(document.step4.Name_On_CC.value)=="")
	{
		alert("Please enter name on CC");
		document.step4.Name_On_CC.focus();
		return false;
	}
	*/


	if(trim(document.step4.Card_Number.value)=="")
	{
		alert("Please enter card number");
		document.step4.Card_Number.focus();
		return false;
	}

	if(trim(document.step4.CVV.value)=="")
	{
		alert("Please enter CVV");
		document.step4.CVV.focus();
		return false;
	}


	if(trim(document.step4.CVV.value)=="")
	{
		alert("Please enter CVV");
		document.step4.CVV.focus();
		return false;
	}

	if(document.step4.CVV.value.length < 3 )
	{
		alert("CVV number should be of three digit");
		document.step4.CVV.focus();
		return false;
	}

	if(trim(document.step4.Expiry_Date_Month.value)=="")
	{
		alert("Please select expiry date month");
		document.step4.Expiry_Date_Month.focus();
		return false;
	}

	if(trim(document.step4.Expiry_Date_Year.value)=="")
	{
		alert("Please select expiry date year");
		document.step4.Expiry_Date_Year.focus();
		return false;
	}


	if(trim(document.step4.Expiry_Date_Year.value)=="")
	{
		alert("Please select expiry date year");
		document.step4.Expiry_Date_Year.focus();
		return false;
	}

	if(trim(document.step4.Card_Type.value)=="")
	{
		alert("Please select card type");
		document.step4.Card_Type.focus();
		return false;
	}

	if(document.step4.Card_Type.value=="MD") 
	{ 		
		if(trim(document.step4.issue_number.value)=="")
		{			
			alert("Please enter issue number");
			document.step4.issue_number.focus();
			return false;
		}		
	}

}


