function RefemailExists()
		 	{
				
				email=document.getElementById("refemailid").value;
				ajaxEngine.registerRequest('addAction', "actions/registerAction.asp");
	  			ajaxEngine.sendRequest('addAction', "email="+email,"id=refForm");
				return false;
			}
function roundNumber(number,decimal_points) {
	if(!decimal_points) return Math.round(number);
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}

	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
}


function redPage()
		 	{
					
				if(document.getElementById("msgId").innerHTML=="refForm")  // Refferal email check
					{	
					//	loading.style.display="none";						
						if(document.getElementById("msg").innerHTML!="1")
						{
														//alert("Refferal Email ID Doesn't Exists");
							if(confirm('Refferal Email ID do not exists!!!!Do you want to continue with this refferal email id'))
 								{	
									document.getElementById("ref").value=1;
									//alert(document.getElementById("ref").value);
									document.regForm.submit();
									document.getElementById("loadinghl").style.display="none";
								}
						}
						else
						{
							document.getElementById("ref").value=2;
							//alert(document.getElementById("ref").value);
							document.regForm.submit();
						}
					}
				else if(document.getElementById("msgId").innerHTML=="regForm")  // registation of customer
					{	
						if(document.getElementById("msg").innerHTML=="1")
						{alert("EmailID already Exists, Plz enter email ID");}
						else
						{
							if (document.getElementById("refemailid").value!="" && myArray[0]==1)
								{
								RefemailExists();}
							else if(document.getElementById("refemailid").value!="" && myArray[0]==2)
								{
									if(document.getElementById("refemailid").value!="AG350681")
									{
										if(confirm('Agent Refferal  ID do not exists!!!!Do you want to continue with this Agent refferal  id'))
										{	
											document.getElementById("ref").value=1;
											document.regForm.submit();
										}
									
									}
									else
									{
										document.getElementById("ref").value=1;
										document.regForm.submit();
									}
								}
							else
								{								
								document.getElementById("ref").value=1;
								//alert(document.getElementById("ref").value);
								document.regForm.submit();	
								document.getElementById("loadinghl").style.display="none";
								}
															
							}
						}
				else if(document.getElementById("msgId").innerHTML=="busRegForm")  // registation of customer
					{	
					
						if(document.getElementById("msg").innerHTML=="1")
						{alert("EmailID already Exists, Plz enter email ID");}
						else
						{
							document.bcustadd.submit();										
															
							}
						}				
				else if(document.getElementById("msgId").innerHTML=="loginForm") //login of customer
					{
						//loading.style.display="none";
						if(document.getElementById("msg").innerHTML=="1")
							alert("Invalid Email/userName");
							
						else if(document.getElementById("msg").innerHTML=="2") 
							alert("Invalid Password");
						else
							document.loginForm.submit();
							document.getElementById("loadinghl").style.display="none";
					}
				else if(document.getElementById("msgId").innerHTML=="ecchkemail") //check email existance
					{
						//loading.style.display="none";
						if(document.getElementById("msg").innerHTML=="1")
							alert("emailID already Exists, Please enter another Email ID");
						else
						{
							document.editinfo.hiUpdate.value="Update";
							document.editinfo.submit();	
							document.getElementById("loadinghl").style.display="none";
						}	
					}
				else if(document.getElementById("msgId").innerHTML=="hloginForm") //login of customer from Header
					{
						//loadinghl.style.display="none";
						if(document.getElementById("msg").innerHTML=="1")
							alert("Invalid Email/userName");
							
						else if(document.getElementById("msg").innerHTML=="2") 
							alert("Invalid Password");
						else
							document.hlogin.submit();
							document.getElementById("loadinghl").style.display="none";
					}
				else if(document.getElementById("msgId").innerHTML=="chngpwd") //check email for change pwd
					{ 
						//loading.style.display="none";
						if(document.getElementById("msg").innerHTML=="1")
							alert("Invalid Email/userName");
						else if(document.getElementById("msg").innerHTML=="2") 
							alert("Invalid Password !! Please Enter correct Password..");
						else	
							document.chgpwd.submit();
							document.getElementById("loadinghl").style.display="none";
					}
					
					
					else if(document.getElementById("msgId").innerHTML=="checkCaptcha") 
					{ 
						//loading.style.display="none";
						if(document.getElementById("msg").innerHTML=="2")
						{
							alert("Please Enter Correct Code");
							document.getElementById("caimage").src='blog/aspcaptcha.asp';
						}
						else
						  emailExists();
							
						 
					}
					
					
	
				else if(document.getElementById("msgId").innerHTML=="promoForm") //check email for change pwd
					{ 
						
						if(document.getElementById("msg").innerHTML=="1")
							alert("Invalid PromoCode");
						if(document.getElementById("msg").innerHTML=="2")
							alert("This PromoCode already used");
						if(document.getElementById("msg").innerHTML=="4")
							alert("This PromoCode Valid for 20kgs and above");
						if(document.getElementById("msg").innerHTML=="3")
						{
							disc=discSpan.innerHTML;
							discType=discTypeSpan.innerHTML;
							totPrice.innerHTML=totSpan.innerHTML;
							document.getElementById("promoTr").style.display = "none";
							document.getElementById("discountTr").style.display = "";
							document.getElementById("hidPromo").value = promo.innerHTML;							
						}
						//loading.style.display="none";
						document.getElementById("loadinghl").style.display="none";
					}	
				else if(document.getElementById("msgId").innerHTML=="tocountry") // destinations from coun
				{	
					
					var quoteString=document.getElementById("msg").innerHTML;
					var mytool_array=quoteString.split("$");
					var part_num=0;
					var part_num1=1;
					var part_num2=0;
					totOpt=document.forms['quote'].dest.options.length;
					 while (part_num1 < totOpt )
					{
						document.forms['quote'].dest.options[part_num2]=null;
						part_num1=part_num1+1;
					}
					document.forms['quote'].dest.options[0]=new Option("Select ","0");
					while (part_num < mytool_array.length)
					 {
						var mytool_array1=mytool_array[part_num].split("#");
						part_num+=1;
						document.forms['quote'].dest.options[part_num]=new Option(mytool_array1[1],mytool_array1[0]);
					 }
					 document.getElementById("loadinghc").style.display="none";
					
					//loadinghc.style.display="none";
						//document.quote.dest.value=destVal;
						
				}
			else if(document.getElementById("msgId").innerHTML=="toDest") // destinations from coun
				{	
					
					var quoteString=document.getElementById("msg").innerHTML;
					var mytool_array=quoteString.split("$");
					var part_num=0;
					var part_num1=1;
					var part_num2=0;
					totOpt=document.forms['booking'].destination.options.length;
					
					 while (part_num1 < totOpt )
					{
						document.forms['booking'].destination.options[part_num2]=null;
						part_num1=part_num1+1;
					}
					
					while (part_num < mytool_array.length)
					 {
						if (part_num==1)
							document.forms['booking'].destination.options[0]=new Option("Choose one","");
						var mytool_array1=mytool_array[part_num].split("#");
						part_num+=1;
						document.forms['booking'].destination.options[part_num]=new Option(mytool_array1[1],mytool_array1[0]);
					 }
					
					//loadinghc.style.display="none";
					if(dId!="")
						document.booking.destination.value=dId;
					else
						document.booking.destination.value="";
						document.getElementById("loadinghl").style.display="none";
						
				}	
			else if(document.getElementById("msgId").innerHTML=="toSplcountry") // destinations from coun
				{	
					
					var quoteString=document.getElementById("msg").innerHTML;
					var mytool_array=quoteString.split("$");
					var part_num=0;
					var part_num1=1;
					var part_num2=1;
					totOpt=document.forms['splQuote'].destination.options.length;
					 while (part_num1 < totOpt )
					{
						document.forms['splQuote'].destination.options[part_num2]=null;
						part_num1=part_num1+1;
					}
					
					while (part_num < mytool_array.length)
					 {
						var mytool_array1=mytool_array[part_num].split("#");
						part_num+=1;
						document.forms['splQuote'].destination.options[part_num]=new Option(mytool_array1[1],mytool_array1[0]);
					 }
					
					//loading.style.display="none";
					if(fromId==1)
						assignSplVals();
						//document.quote.destination.value=destVal;
						document.getElementById("loadinghl").style.display="none";
						
				}
			 else if(document.getElementById("msgId").innerHTML=="toAdcountry") // destinations from coun
				{	
					
					var quoteString=document.getElementById("msg").innerHTML;
					var mytool_array=quoteString.split("$");
					var part_num=0;
					var part_num1=1;
					var part_num2=1;
					totOpt=document.forms['booking'].dest.options.length;
				
					 while (part_num1 < totOpt )
					{
						document.forms['booking'].dest.options[part_num2]=null;
						part_num1=part_num1+1;
					}
					
					while (part_num < mytool_array.length)
					 {
						var mytool_array1=mytool_array[part_num].split("#");
						part_num+=1;
						document.forms['booking'].dest.options[part_num]=new Option(mytool_array1[1],mytool_array1[0]);
					 }
					// loading.style.display="none";
					assinVals();
					
						//document.booking.dest.value=destVal;
						document.getElementById("loadinghl").style.display="none";
						
				}
			  else if(document.getElementById("msgId").innerHTML=="agentPrice") // agent price
				{
					//loading.style.display="none";
					assignBalVals();
						
				}
			else if(document.getElementById("msgId").innerHTML=="sameday") // agent price
				{
					//loading.style.display="none";
					if(document.getElementById("msg").innerHTML=="flg1")
						alert("Enter the Correct From PostCode");
					else if(document.getElementById("msg").innerHTML=="flg2")
						alert("Enter the Correct To PostCode");
					else
						document.sameday.submit();
						document.getElementById("loadinghs").style.display="none";
				}
			  else if(document.getElementById("msgId").innerHTML=="postcode") // agent price
				{
					//loading.style.display="none";
					if(document.getElementById("msg").innerHTML=="flg1")
						alert("Enter the Correct From PostCode");
					else if(document.getElementById("msg").innerHTML=="flg2")
						alert("Enter the Correct To PostCode");
					else
					{
						document.getElementById("postVals").style.display="";
						vat="";
						if(document.getElementById("hidVat").value!=0)
							vat="+VAT";
						kms=document.getElementById("msg").innerHTML.split(".");
						if(kms[1]!=undefined)
							miles=parseInt(kms[0])+1;
						
						//alert(document.getElementById("hidStartBike").value);
						if(miles<=2)
						{
							bikVal=roundNumber((parseFloat(document.getElementById("hidStartBike").value)),2);
							smlVanVal=roundNumber((parseFloat(document.getElementById("hidStartSVan").value)),2);
							larVanVal=roundNumber((parseFloat(document.getElementById("hidStartLVan").value)),2);
						}
						else
						{
							bikVal=parseFloat(document.getElementById("hidStartBike").value);
							smlVanVal=parseFloat(document.getElementById("hidStartSVan").value);
							larVanVal=parseFloat(document.getElementById("hidStartLVan").value);
							//alert(bikVal);
							bikVal=roundNumber(bikVal+(parseFloat(document.getElementById("hidAddBike").value)*(miles-2)),2);
							smlVanVal=roundNumber(smlVanVal+(parseFloat(document.getElementById("hidAddSVan").value)*(miles-2)),2);
							larVanVal=roundNumber(larVanVal+(parseFloat(document.getElementById("hidAddLVan").value)*(miles-2)),2);
							//alert(bikVal);
						}
						document.getElementById("spanMotor").innerHTML="£"+bikVal+vat;
						document.getElementById("radioBike").value=document.getElementById("radioBike").value + "$"+bikVal;
						document.getElementById("spanSmlVan").innerHTML="£"+smlVanVal+vat;
						document.getElementById("radioSmlVan").value=document.getElementById("radioSmlVan").value + "$"+smlVanVal;
						document.getElementById("spanLarVan").innerHTML="£"+larVanVal+vat;
						document.getElementById("radioBigVan").value=document.getElementById("radioBigVan").value + "$"+larVanVal;
						//alert(radioVal);
					 if(radioVal==1)
					 	document.getElementById("radioBike").checked =true; 
					 else if(radioVal==2)
					 	document.getElementById("radioSmlVan").checked=true;
					 else if(radioVal==3)
					 	document.getElementById("radioBigVan").checked=true;
					}
					document.getElementById("loadinghl").style.display="none";	
				}
			 else if(document.getElementById("msgId").innerHTML=="priceList") // Prices for diffrent supliers
				{
						var part_num=1;
						var part_num2=0;
						var suplid_array=suplList.innerHTML.split("#");
						var bookPrices_array=bookPrices.innerHTML.split("#");
						var dDays_array=dDays.innerHTML.split("#");
						bookPrice.innerHTML="<TABLE width='80%'><TR><TD class='h2'>Choose the Courier Service</TD></TR></TABLE>"
						
						while (part_num < suplid_array.length)
					 	{
							var part_num1=0;
							
							while (part_num1 < suplAr.length)
							{
								if(suplid_array[part_num]==suplAr[part_num1])
								{
									
									funVal='<A href="javascript:;"  class="a1"  >';
									listSuplAr[part_num2]=suplid_array[part_num];
									//alert(funVal);
									bookPrice.innerHTML=bookPrice.innerHTML+'<TABLE width="80%"><TR><TD width="60%" align="left" nowrap><input type="radio" name="bPrice" id="radio'+suplid_array[part_num]+'" value="'+suplid_array[part_num]+'" onClick="javascript:asgPrice('+bookPrices_array[part_num]+','+dDays_array[part_num]+','+suplid_array[part_num]+');">'+funVal+'<img src="'+imgAr[suplid_array[part_num]]+'" border="0"> </a></TD><TD width="40%" align="left" class="textgreenbold">£ '+roundNumber(parseFloat(bookPrices_array[part_num]),2)+'</TD></TR></TABLE>' ;
									//alert(bookPrice.innerHTML);
									part_num2+=1;
								}
								
								if(suplId==suplid_array[part_num])
									bookingPrice=bookPrices_array[part_num];
								part_num1+=1;
							}
							part_num+=1;
						}
						document.getElementById("loadinghl").style.display="none";
						
						//loading.style.display="none";
						if(suplId!=0)
						{
							document.getElementById("radio"+suplId).checked=true;
							asgPrice(bookingPrice,delDays,suplId);
							
						}
						
				}
			else if(document.getElementById("msgId").innerHTML=="splPriceList") // Prices for diffrent supliers
				{
						var part_num=1;
						var part_num2=0;
						var suplid_array=suplList.innerHTML.split("#");
						var bookPrices_array=bookPrices.innerHTML.split("#");
						var dDays_array=dDays.innerHTML.split("#");
						bookPrice.innerHTML="<TABLE width='80%'><TR><TD class='h2'>Choose the Courier Service</TD></TR></TABLE>"
						while (part_num < suplid_array.length)
					 	{
							var part_num1=0;
							
							while (part_num1 < suplAr.length)
							{
								if(suplid_array[part_num]==suplAr[part_num1])
								{
									
									//funVal='<A href="javascript:;"  class="a1"  onMouseover="ddrivetip(\''+descAr[suplid_array[part_num]]+'\',\'#E6FFCC\',\'400\')" onMouseout="hideddrivetip()">';
									listSuplAr[part_num2]=suplid_array[part_num];
									//alert(funVal);
									bookPrice.innerHTML=bookPrice.innerHTML+'<TABLE width="80%"><TR><TD width="70%" align="left"><input type="radio" name="bPrice" id="radio'+suplid_array[part_num]+'" value="'+suplid_array[part_num]+'" onClick="javascript:asgPrice('+bookPrices_array[part_num]+','+dDays_array[part_num]+','+suplid_array[part_num]+');"><img src="'+imgAr[suplid_array[part_num]]+'" border="0"> </a></TD><TD width="30%" align="left" class="textgreenbold">£ '+roundNumber(parseFloat(bookPrices_array[part_num]),2)+'</TD></TR></TABLE>' ;
									//alert(bookPrice.innerHTML);
									part_num2+=1;
								}
								
								if(suplId==suplid_array[part_num])
									bookingPrice=bookPrices_array[part_num];
								part_num1+=1;
							}
							part_num+=1;
						}
						
						//loading.style.display="none";
						if(suplId!=0)
						{
							document.getElementById("radio"+suplId).checked=true;
							asgPrice(bookingPrice,delDays,suplId);
							
							document.getElementById("loadinghl").style.display="none";
						}
				}
			else if(document.getElementById("msgId").innerHTML=="mobPriceList") // Prices for diffrent supliers
				{
						var part_num=1;
						var part_num2=0;
						var suplid_array=suplList.innerHTML.split("#");
						var bookPrices_array=bookPrices.innerHTML.split("#");
						bookPrice.innerHTML="<TABLE width='80%'><TR><TD class='h2'>Choose the Courier Service</TD></TR></TABLE>"
						while (part_num < suplid_array.length)
					 	{
							var part_num1=0;
							
							while (part_num1 < suplAr.length)
							{
								if(suplid_array[part_num]==suplAr[part_num1])
								{
									
									funVal='<A href="javascript:;"  class="a1"  >';
									listSuplAr[part_num2]=suplid_array[part_num];
									//alert(funVal);
									bookPrice.innerHTML=bookPrice.innerHTML+'<TABLE width="80%"><TR><TD width="40%" align="left"><input type="radio" name="bPrice" id="radio'+suplid_array[part_num]+'" value="'+suplid_array[part_num]+'" onClick="javascript:asgPrice('+bookPrices_array[part_num]+','+suplid_array[part_num]+');"><img src="'+imgAr[suplid_array[part_num]]+'" border="0"> </a></TD><TD width="60%" align="left" class="textgreenbold">£ '+roundNumber(parseFloat(bookPrices_array[part_num]),2)+'</TD></TR></TABLE>' ;
									//alert(bookPrice.innerHTML);
									part_num2+=1;
								}
								
								if(suplId==suplid_array[part_num])
									bookingPrice=bookPrices_array[part_num];
								part_num1+=1;
							}
							part_num+=1;
						}
						document.getElementById("loadinghl").style.display="none";
						//loading.style.display="none";
						if(suplId!=0)
						{
							document.getElementById("radio"+suplId).checked=true;
							asgPrice(bookingPrice,suplId);
							
						}
				}
						
			}	 
