function getHomeCareDetails1(){

var postCode=null;

var prodName=null;



if(document.getElementById('postcode').value!=null)
  {

    postCode= document.getElementById('postcode').value;

   }



if(document.getElementById('fProductname').value !='' || document.getElementById('fProductname').value !=null)
{

  prodValue= document.getElementById('fProductname').value;
  
  if(prodValue == 0){
  prodName="HomeCare 100";
  }
  else if(prodValue == 1){
  prodName="HomeCare 200";
  }
  else if(prodValue == 2){
  prodName="HomeCare 300";
  }
  else if(prodValue == 3){
  prodName="HomeCare 400";
  }
  else{  
  prodName ='select';
  }
}
  
var fromHomeCareQ4Campaign="Y";
var baseURL = "/HomecareCampaign/"+postCode+"/"+prodName+"/"+fromHomeCareQ4Campaign;

var postCodeCount=getHomeCarePostCodeCount();

if(postCode!=null &&postCode!='' && prodName!='select'&& postCodeCount!=0 && alphanumeric(postCode) == true){

document.getElementById("quotePriceDetails").innerHTML="<img align='middle' src='/images/loading.gif' alt='Loading' style='padding:20px 0px 20px 350px;'/>";

document.getElementById("quotePriceDetails").style.display="block";

document.getElementById("errorCoverProduct").style.display="none";

document.getElementById("errorCoverPostCode").style.display="none";

getQuotePriceForHomeCare(baseURL);



}else{

document.getElementById("quotePriceDetails").style.display="none";

if(postCode==null || postCode==''|| postCodeCount==0 || alphanumeric(postCode) == false){

if(prodName!='select'){


document.getElementById("errorCoverProduct").style.display="none";

}



document.getElementById("errorCoverPostCode").style.display="";



document.getElementById("errorCoverPostCode").innerHTML="Please enter a valid UK postcode (E.G. W14 8TS)";



}if(prodName=='select'){



if(postCode!=null && postCode!='' && postCodeCount!=0 && alphanumeric(postCode) == true){



document.getElementById("errorCoverPostCode").style.display="none";



}



document.getElementById("errorCoverProduct").style.display="";

document.getElementById("errorCoverProduct").innerHTML="Please select which product you wish to get a quote for.";



}



}



}



function getQuotePriceForHomeCare(CompleteURL){







xmlHttpNew=GetXmlHttpObject();



		if (xmlHttpNew==null)



  		{



  			alert ("Your browser does not support AJAX!");



  			return;



  		} 



  		


		var url=CompleteURL;



		xmlHttpNew.onreadystatechange=stateChangedforHomeCare;



		xmlHttpNew.open("POST",url,true);



		xmlHttpNew.send(null);



	



}



function GetXmlHttpObject()



	{



			var xmlHttp=null;



		try



			{



				// Firefox, Opera 8.0+, Safari



				xmlHttp=new XMLHttpRequest();



				



				



			}



		catch (e)



  		{



  			// Internet Explorer



  			try



			{



				    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");



		 	}



  			catch (e)



			{



				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");



			}



  		}



  		



		return xmlHttp;



	}



function stateChangedforHomeCare(){



if (xmlHttpNew.readyState==4)



		{ 



		if(xmlHttpNew.responseText=='' || xmlHttpNew.responseText==null){



		document.getElementById("errorCoverPostCode").style.display="";

		document.getElementById("errorCoverProduct").style.display="none";

		document.getElementById("errorCoverPostCode").innerHTML="Please enter a valid UK postcode (E.G. W14 8TS)";



		document.getElementById("quotePriceDetails").style.display="none";	



		}



		else{



		document.getElementById("quotePriceDetails").style.display="block";



		document.getElementById("errorCoverPostCode").style.display="none";



		document.getElementById("errorCoverProduct").style.display="none";



		document.getElementById("quotePriceDetails").innerHTML=xmlHttpNew.responseText;



		}



		}



		}



		



		function productSubmit(){ 


	document.HomeCarePriceDetails.method = 'post';

	document.HomeCarePriceDetails.action = '/HomecareCampaignOrderPage/Apply-Now/';

	document.HomeCarePriceDetails.submit();



}











function validatePostCode(){



var postCodeCount=getHomeCarePostCodeCount();



if(postCodeCount==0){

document.getElementById("quotePriceDetails").style.display="none";

document.getElementById("errorCoverPostCode").style.display="";



document.getElementById("errorCoverPostCode").innerHTML="Please enter a valid UK postcode (E.G. W14 8TS)";



}



}







function getHomeCarePostCodeCount(){



 	var count=0;



 	var postCode=document.getElementById('postcode').value;



 	postCode=postCode.replace(/^\s+|\s+$/g, '') ;



 	if(postCode!=''){
 	
		count= count+1;

 	}



  return count;


 }
 

  function checkForOfferEnter(event){

  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;  

     if (keyCode == 13)

 	{	

 			if (window.event){ //IE

 				event.returnValue=false;

 			        event.cancel = true;

 		         }

 		         else {

 		   	        event.preventDefault();

 		         }

 	   

 	    getHomeCareDetails1();

 	}

 

}

function alphanumeric(postCode)
{
var postCodeTemp=postCode.replace(/\s/g, "");
	var numaric = postCodeTemp;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{                       
			 return false;
		  }
 		} 
 return true;
}

