// JavaScript Document 
//N.B. Currently within the Pure360 Final design
	$(document).ready(function(){
	
	var badDomains = ["Hotmail","Yahoo","Gmail","Googlemail","Aol","Lycos","msn","wanadoo","blueyonder","virgin","freeserve","go2","o2","freemail","wp","tlen","btinternet","ntlworld","webmail","btconnect","rediffmail","mail2hungary","mail2world","caramail","bermuda","pookmail","inbox","yandex","narod","viszme","xglxpg"];
	
	function decode(obj) {
	        return decodeURIComponent(obj.replace(/\+/g,  " "));
        }

        function trim(str, chars) {
	        return ltrim(rtrim(str, chars), chars);
        }


        //Pre-populate email address
	if(getParameterByName("e") !="")
	{
		$("#email").val( getParameterByName("e") );
		$("#q2028_q6").val( getParameterByName("e") );
		$("#q2646_q6").val( getParameterByName("e") );
	}
	
	//Pre-populate email address
	if(getParameterByName("p") !="")
	{
		$("#phoneWork").val( decode( getParameterByName("p") ) );
	}

	//Pre-populate name
	if(getParameterByName("n") !="")
	{
		$("#name").val( decode( getParameterByName("n") ) );
	}

	//'Other' field on the leadsource 
        $("#leadSource").change(function(){ 
	    if($("#leadSource").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });

        //AdWords Landing
        $("#q2028_q8").change(function(){ 
	    if($("#q2028_q8").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });
      
        //Request-pricelist
        $("#q2646_q8").change(function(){ 
	    if($("#q2646_q8").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });
      
        //Timings Guide
        $("#q2820_q8").change(function(){ 
	    if($("#q2820_q8").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });
      
        //Prebook Automations
        $("#q2861_q8").change(function(){ 
	    if($("#q2861_q8").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });
      
        //10 things guide
        $("#q3627_q8").change(function(){ 
	    if($("#q3627_q8").val() == "AM to amend")
	    {
               $("#leadSourceField").css("display", "block"); 
	    }
	    else
	    {
	       $("#leadSourceField").css("display", "none"); 
	    }
        });
      
      //Manual Lead Allocation Form
	$("#submit-manual-lead").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmBusinessTypeVal = $("#emailVolume").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}

                switch(frmBusinessTypeVal ) {
                 case('up to 10,000'):
                   $("#bandC").val('C');
                   $("#businessType").val('groupc');
                   break;
                 case('11,000 to 100,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('101,000 to 199,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('200,000 to 500,000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 500000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 3m'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                }
                
                var frmIsAgency = $("#pureFldMarketingCodeC").val();
		if(frmIsAgency == 1) {
                   $("#businessType").val('agency');                  
                }
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});


	//Standard Submit Form (used on newsletter and elsewhere)
	$("#submit-standard").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#name").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		} else {
                        //split the name in two
                        $("#firstName").val(frmNameVal.substr(0,frmNameVal.lastIndexOf(' ')));
                        $("#lastName").val(frmNameVal.substr(frmNameVal.lastIndexOf(' ') + 1));
                }
		
                var frmOrganisationVal = $("#accountName").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#email").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		var frmPhoneVal = $("#phoneWork").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#emailVolume").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}

                switch(frmBusinessTypeVal ) {
                 case('up to 10,000'):
                   $("#bandC").val('C');
                   $("#businessType").val('groupc');
                   break;
                 case('11,000 to 100,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('101,000 to 199,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('200,000 to 500,000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 500000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 3m'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                }
                
                var frmIsAgency = $("#pureFldMarketingCodeC").val();
		if(frmIsAgency == 1) {
                   $("#businessType").val('agency');                  
                }
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});
	
	//Free Trial Submit Form (checks email)
	$("#submit-validate-email").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#name").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		} else {
                        //split the name in two
                        $("#firstName").val(frmNameVal.substr(0,frmNameVal.lastIndexOf(' ')));
                        $("#lastName").val(frmNameVal.substr(frmNameVal.lastIndexOf(' ') + 1));
                }
		
                var frmOrganisationVal = $("#accountName").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#email").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		for(var x = 0;x < badDomains.length;x++)
		{
			if(frmEmailVal.indexOf('@' + badDomains[x]) > 0)
			{
				errorMsg+=' - Sorry, we can\'t accept submissions that use an email address supplied by an ISP.\n';
				hasError = true;					
			}
		}

                var frmPhoneVal = $("#phoneWork").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#emailVolume").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}

                switch(frmBusinessTypeVal ) {
                 case('up to 10,000'):
                   $("#bandC").val('C');
                   $("#businessType").val('groupc');
                   break;
                 case('11,000 to 100,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('101,000 to 199,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('200,000 to 500,000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 500000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 3m'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                }
                
                var frmIsAgency = $("#pureFldMarketingCodeC").val();
		if(frmIsAgency == 1) {
                   $("#businessType").val('agency');                  
                }
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});
	
	//Free Trial AdWords Form - validate domain
	$("#form_email_2028_submit").click(function(){
                var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#q2028_q1").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		}

		var frmOrganisationVal = $("#q2028_q1").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#q2028_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		for(var x = 0;x < badDomains.length;x++)
		{
			if(frmEmailVal.indexOf('@' + badDomains[x]) > 0)
			{
				errorMsg+=' - Sorry, we can\'t accept submissions that use an email address supplied by an ISP.\n';
				hasError = true;					
			}
		}
		
		var frmPhoneVal = $("#q2028_q4").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#q2028_q5").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});


	//Request Pricelist Form
	$("#form_email_2646_submit").click(function(){
                var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#q2646_q1").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		}

		var frmOrganisationVal = $("#q2646_q1").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#q2646_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
				
		var frmPhoneVal = $("#q2646_q4").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#q2646_q5").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});


//Download timings guide Form
	$("#form_email_2820_submit").click(function(){
                var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#q2820_q1").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		}

		var frmOrganisationVal = $("#q2820_q1").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#q2820_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
				
		var frmPhoneVal = $("#q2820_q4").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#q2820_q5").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

//Prebook Automations Form
	$("#form_email_2861_submit").click(function(){
                var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#q2861_q1").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		}

		var frmOrganisationVal = $("#q2861_q1").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#q2861_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
				
		var frmPhoneVal = $("#q2861_q4").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#q2861_q5").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

//Download 10 Things Form
	$("#form_email_3627_submit").click(function(){
                var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#q3627_q1").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		}

		var frmOrganisationVal = $("#q3627_q1").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#q3627_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
				
		var frmPhoneVal = $("#q3627_q4").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#q3627_q5").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

        /* HomepageNewsletter */
	$("#form_email_4155_submit").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmEmailVal = $("#q4155_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

        /* CTA Newsletter */
	$("#form_email_2685_submit").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmEmailVal = $("#q2685_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

/* CTA Call */
	$("#form_email_2727_submit").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmPhoneVal = $("#q2727_q6").val();
		if(frmPhoneVal == '' || frmPhoneVal == 'your phone number...' ) {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});

/* CTA Trial*/
	$("#form_email_2700_submit").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmEmailVal = $("#q2700_q6").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		for(var x = 0;x < badDomains.length;x++)
		{
			if(frmEmailVal.indexOf('@' + badDomains[x]) > 0)
			{
				errorMsg+=' - Sorry, we can\'t accept submissions that use an email address supplied by an ISP.\n';
				hasError = true;					
			}
		}

                //Submit the form
		if(hasError == true) {
			alert(errorMsg);			
			return false;
		} else {
			return true;
		}
	});


$("#submit-call-me").click(function(){
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var errorMsg = "Your form contained the following errors:\n"

		var frmNameVal = $("#name").val();
		if(frmNameVal == '') {
			errorMsg+=' - You forgot to enter your name.\n';
			hasError = true;
		} else {
                        //split the name in two
                        $("#firstName").val(frmNameVal.substr(0,frmNameVal.lastIndexOf(' ')));
                        $("#lastName").val(frmNameVal.substr(frmNameVal.lastIndexOf(' ') + 1));
                }

		var frmOrganisationVal = $("#accountName").val();
		if(frmOrganisationVal == '') {
			errorMsg+=' - You forgot to enter the name of your organisation.\n';
			hasError = true;
		}

		var frmEmailVal = $("#email").val();
		frmEmailVal = jQuery.trim(frmEmailVal);
		if(frmEmailVal == '') {
			errorMsg+=' - You forgot to enter your email address.\n';
			hasError = true;
		} else if(!emailReg.test(frmEmailVal)) {	
			errorMsg+=' - You didn\'t enter a valid email address.\n';
			hasError = true;
		}
		
		var frmPhoneVal = $("#phoneWork").val();
		if(frmPhoneVal == '') {
			errorMsg+=' - You forgot to enter your phone number.\n';
			hasError = true;
		}

		var frmBusinessTypeVal = $("#emailVolume").val();
		if(frmBusinessTypeVal == '- please select -') {
			errorMsg+=' - You forgot to tell us how many emails you send each month.\n';
			hasError = true;
		}

                switch(frmBusinessTypeVal ) {
                 case('up to 10,000'):
                   $("#bandC").val('C');
                   $("#businessType").val('groupc');
                   break;
                 case('11,000 to 100,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('101,000 to 199,000'):
                   $("#bandC").val('B');
                   $("#businessType").val('groupb');
                   break;
                 case('200,000 to 500,000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 500000'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                 case('over 3m'):
                   $("#bandC").val('A');
                   $("#businessType").val('groupa');
                   break;
                }
                
                var frmIsAgency = $("#pureFldMarketingCodeC").val();
		if(frmIsAgency == 1) {
                   $("#businessType").val('agency');                  
                }
		
		//Submit the form
		if(hasError == true) {
			alert(errorMsg);			
		} else {
			$("#display-form").hide();
			$("#display-message").show();
			$("#formcontent").load("http://forms.pure360.com/_act/web_capture_call_me.php", {errorPage:'redirect: http://www.pure360.com?call-me-error', sequenceNum: '1', captureSourceDesc: 'call me / quote me form', name: frmNameVal, organisation: frmOrganisationVal, email: frmEmailVal, phone: frmPhoneVal, businessType: frmBusinessTypeVal}, function(){
    		alert($("#formcontent").html().length);
			if($("#formcontent").html().length == 0)
			{
				//Something went wrong, redirect
				window.location.replace("http://www.pure360.com/call-me-error");
			} else {
				//All good, redirect
				window.location.replace("http://www.pure360.com/call-me-thanks");
			}
			
	    	});		
		}
	});
  });
	
function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
