//send request to server
function startRequest(){
   $('contactForm').set('send', {url:'52?option=record', method:'post', onSuccess:parseResults});
   $('contactForm').send();
}                      

   ////print results
   
function parseResults(responseText){
	document.getElementById("serverResponse").innerHTML=responseText;//alert(responseText);
	document.body.style.cursor='default';//set to default cursor
	window.location.href = '/411';
	try{
		pageTracker._trackPageview("/step2");
	} catch(err) {}
	
	var google_conversion_id = 1071632476;
    var google_conversion_language = "en_GB";
    var google_conversion_format = "1";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "jaLbCM7sPRDcoP_-Aw";
	
	(function(){
var d=null;function g(a){if(a!=d)return escape(a.toString());return""}function h(a,c){var e=g(c);if(e!=""){var b=g(a);if(b!="")return"&".concat(b,"=",e)}return""}function i(a){if(a!=d){var c=a.toString();if(2==c.length)return h("hl",c);if(5==c.length)return h("hl",c.substring(0,2))+h("gl",c.substring(3,5))}return""}
function j(a,c,e){var b="";if(a){var f=a.screen;if(f){b+=h("u_h",f.height);b+=h("u_w",f.width);b+=h("u_ah",f.availHeight);b+=h("u_aw",f.availWidth);b+=h("u_cd",f.colorDepth)}if(a.history)b+=h("u_his",a.history.length)}if(e&&typeof e.getTimezoneOffset=="function")b+=h("u_tz",-e.getTimezoneOffset());if(c){if(typeof c.javaEnabled=="function")b+=h("u_java",c.javaEnabled());if(c.plugins)b+=h("u_nplug",c.plugins.length);if(c.mimeTypes)b+=h("u_nmime",c.mimeTypes.length)}return b}
function k(a,c){var e="";if(c){var b=c.referrer;if(a&&a.top&&c.location&&a.top.location==c.location){e+=h("ref",b);b=c.location}e+=h("url",b)}return e}
function l(a,c,e){var b="";b+=h("cv",a.google_conversion_js_version);b+=h("fst",a.google_conversion_first_time);b+=h("num",a.google_conversion_snippets);b+=h("fmt",a.google_conversion_format);b+=h("value",a.google_conversion_value);b+=h("label",a.google_conversion_label);b+=h("bg",a.google_conversion_color);b+=i(a.google_conversion_language);b+=j(a,c,a.google_conversion_date);b+=k(a,e);return b}
function m(a){if(a&&a.location&&a.location.protocol&&a.location.protocol.toString().toLowerCase()=="https:")return"https:";return"http:"}function n(a,c,e){var b="/?";if(a.google_conversion_type=="landing")b="/extclk?";var f=m(a)+"//www.googleadservices.com/pagead/conversion/"+g(a.google_conversion_id)+b+"random="+g(a.google_conversion_time);f+=l(a,c,e);return f.substring(0,1953)}
function o(a){var c={da:1,de:1,en_AU:1,en_US:1,en_GB:1,es:1,fi:1,fr:1,it:1,iw:1,ja:1,ko:1,nl:1,no:1,pl:1,pt_BR:1,pt_PT:1,ru:1,sv:1,tr:1,zh_CN:1,zh_TW:1};if(c[a])return a+".html";return"en_US.html"}
function p(a,c,e){var b=n(a,c,e),f=function(q,r,s){return'<img height="'+s+'" width="'+r+'" border="0" src="'+q+'" />'};if(a.google_conversion_format==0){var t=m(a)+"//services.google.com/sitestats/"+o(a.google_conversion_language)+"?cid="+g(a.google_conversion_id);return'<a href="'+t+'" target="_blank">'+f(b,135,27)+"</a>"}else return a.google_conversion_snippets>1||a.google_conversion_format==3?f(b,1,1):'<iframe name="google_conversion_frame" width="'+(a.google_conversion_format==2?200:300)+'" height="'+
(a.google_conversion_format==2?26:13)+'" src="'+b+'" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">'+f(b.replace(/\?random=/,"?frame=0&random="),1,1)+"</iframe>"}
function u(a){if(a.google_conversion_type=="landing"||!a.google_conversion_id)return false;a.google_conversion_date=new Date;a.google_conversion_time=a.google_conversion_date.getTime();if(typeof a.google_conversion_snippets=="number"&&a.google_conversion_snippets>0)a.google_conversion_snippets+=1;else a.google_conversion_snippets=1;if(typeof a.google_conversion_first_time!="number")a.google_conversion_first_time=a.google_conversion_time;a.google_conversion_js_version="2";if(a.google_conversion_format!=
0&&a.google_conversion_format!=1&&a.google_conversion_format!=2&&a.google_conversion_format!=3)a.google_conversion_format=1;return true}function v(a){a.google_conversion_date=d;a.google_conversion_time=d;a.google_conversion_js_version=d;a.google_conversion_id=d;a.google_conversion_value=d;a.google_conversion_label=d;a.google_conversion_language=d;a.google_conversion_format=d;a.google_conversion_color=d;a.google_conversion_type=d}function w(a,c,e){if(a)try{u(a)&&e.write(p(a,c,e))}finally{v(a)}}
w(window,navigator,document);
})()


	}
	
	
	function cl_text(){
	var t=document.getElementById("enquiry_text");
	  if(t.value=='Type your enquiry here. We will aim to answer within 15 minutes...'){t.innerHTML="";}
	}
	
   function text_v(){
   var p=document.getElementById("enquiry_text");
    if(Rtrim(p.value)==""){p.innerHTML="Type your enquiry here. We will aim to answer within 15 minutes...";}
   }
   
   
  function Rtrim(t){
         var str=t.replace(/\r\n|\n/g,"");
         var i;
        //alert(str.length);
    for(i=str.length-1;i>=0;i--){
       if(str.charAt(i)!=" "&&str.charAt(i)!="  ") break;
     }
          str = str.substring(0,i+1);
           return str;
  }
  
  function in_array(stringToSearch, arrayToSearch) {
    for (s = 0; s <arrayToSearch.length; s++) {
        thisEntry = arrayToSearch[s].toString();
        if (stringToSearch.search(thisEntry)>-1) {
            return true;
        }
    }
    return false;
} 

  function capitalize(f,m) {

if (m) /*cap words*/ {
	var temp, tempC, pre, post, strlen;
	temp = f.value.toLowerCase();
	stringLen = temp.length;
	  if (stringLen > 0) {
		for (i = 0; i < stringLen; i++) {
		  if (i == 0) {
			tempC = temp.substring(0,1).toUpperCase();
			post = temp.substring(1,stringLen);
			temp = tempC + post;
		  } else {
			tempC = temp.substring(i,i+1);
			if (tempC == " " && i < (stringLen-1)) {
			tempC = temp.substring(i+1,i+2).toUpperCase();
			pre = temp.substring(0,i+1);
			post = temp.substring(i+2,stringLen);
			temp = pre + tempC + post;
		  }
		}
	  }
	}
  } else /*cap all*/ {
    var temp = f.value.toUpperCase();
  }
  f.value = temp;
}


  function trim(p){
  
  var t=document.getElementById(p).value;
         var str=t.replace(/\r\n|\n/g,"");
         var i;
        //alert(str.length);
    for(i=str.length-1;i>=0;i--){
       if(str.charAt(i)!=" "&&str.charAt(i)!="  ") break;
     }
          str = str.substring(0,i+1);
		  
	for(i=0;i<=str.length-1;i++){
       if(str.charAt(i)!=" "&&str.charAt(i)!="  ") break;
     }
          str = str.substring(i,str.length);
           return str.length;
  }
  
   function find_dot(n){
  
    var str=document.getElementById(n).value;
      if(str.search(/@/)==-1){return true;}else{
	      var i=str.search(/@/);
	      var sub_str=str.substring(i+1,str.length);//alert(sub_str);
	      if(sub_str.search(/\./)==-1){return true;}else{return false;}
	  }
     
  }
  
  function checkform(){
  var phone_arr=Array("111111","222222","333333","444444","555555","666666","777777","888888","999999","000000","123456");
  if(trim("company_name")<2){alert("Please type in a valid company name .");return false;}
  if(trim("first_name")<2){alert("Please type in a valid first name.");return false;}
  if(trim("last_name")<2){alert("Please type in a valid last name .");return false;}
  if(trim("phone")<6||in_array(document.getElementById("phone").value,phone_arr)){alert("Please type in a valid phone number ");return false;}      
   if(trim("email")<2||find_dot("email")){alert("Please type in a valid email address . ");return false;}
   if(trim("enquiry_text")<2||document.getElementById("enquiry_text").value=="Type your enquiry here. We will aim to answer within 15 minutes..."){alert("Please enter valid enquiry.");return false;} 
   startRequest(); 
   document.getElementById("process_status").style.display="block";
		 document.body.style.cursor='wait';
  }
	
