function searchGoogle(e) {
	var characterCode; //literal character code will be stored in this variable
	var searchString;
	if (document.frmfaq.searchText.value != "")
	{
		searchString = document.frmfaq.searchText.value;

		if(e && e.which){ //if which property of event object is supported (NN4)
			e = e;
			characterCode = e.which; //character code is contained in NN4's which property
		}
		else{
			e = event;
			characterCode = e.keyCode; //character code is contained in IE's keyCode property
		}

		if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)

			var startAt = 1;
			document.frmfaq.action = "search.html?searchText="+searchString+"&p="+startAt;
			location.replace("search.html?searchText="+searchString+"&p="+startAt)

			return false;
		}
		else{
			return true;
		}
	}
}


window.onload = function () {

  if(document.getElementById('iq-name')==null){
    return;
  }
  var iq_name        = document.getElementById('iq-name');
  var iq_email       = document.getElementById('iq-email');
  var iq_phone       = document.getElementById('iq-phone');
  var iq_services    = document.getElementById('iq-services');
  var iq_comments    = document.getElementById('iq-comments');
  var iq_submit      = document.getElementById('iq-submit');
  var iq_sum         = document.getElementById('iq-sum');
  var iq_loading_img = document.getElementById('iq-loading-img');
  var iq_total       = parseInt(document.getElementById('iq_random1').value) + parseInt(document.getElementById('iq_random2').value);

  iq_name.addEventListener('keydown',function(){
        this.className='';
  },false);
  iq_email.addEventListener('keydown',function(){
        this.className='';
  },false);
  iq_phone.addEventListener('keydown',function(){
        this.className='';
  },false);
  iq_comments.addEventListener('keydown',function(){
        this.className='';
  },false);
  iq_sum.addEventListener('keydown',function(){
        this.className='ip-small';
  },false);
  iq_services.addEventListener('change',function(){
        this.className='';
  },false);


  iq_sum.addEventListener('focus',function(){
      this.value='';
      this.className='ip-small';
  },false);
  iq_sum.addEventListener('blur',function(){
      this.className='ip-small';
  },false);
  
  
  iq_name.addEventListener('focus',function(){
    if(this.value=='name*'){
      this.value='';
      this.className='';
    }
  },false);
  iq_name.addEventListener('blur',function(){
    if(this.value==''){
      this.value='name*';
      this.className='default';
    }
  },false);
   
  
  iq_email.addEventListener('focus',function(){
    if(this.value=='email*'){
      this.value='';
      this.className='';
    }
  },false);
  iq_email.addEventListener('blur',function(){
    if(this.value==''){
      this.value='email*';
      this.className='default';
    }
  },false);
  
  
  iq_phone.addEventListener('focus',function(){
    if(this.value=='phone*'){
      this.value='';
      this.className='';
    }
  },false);
  iq_phone.addEventListener('blur',function(){
    if(this.value==''){
      this.value='phone*';
      this.className='default';
    }
  },false);
  
  
  iq_comments.addEventListener('focus',function(){
    if(this.value=='additional comments*'){
      this.value='';
      this.className='';
    }
  },false);
  iq_comments.addEventListener('blur',function(){
    if(this.value==''){
      this.value='additional comments*';
      this.className='default';
    }
  },false);

  getHTTPObject = function(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
    }
    @else
      xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
      try {
        xmlhttp = new XMLHttpRequest();
      } catch (e) {
        xmlhttp = false;
      }
    }
    return xmlhttp;
  }



  validateIQForm = function(){
    var error = false;
    if (iq_comments.value=='' || iq_comments.value.match(/^ *$/) || iq_comments.value=='additional comments*'|| iq_comments.value=='additional comments') {
      iq_comments.className = 'error';
      error = true;
    } else {
      iq_comments.className = '';
    }
  

    if (parseInt(iq_sum.value)!=iq_total) {
      iq_sum.className += ' error';  
      error = true;
    } else {
      iq_sum.className = 'ip-small';
    }
   
    if (iq_services.value==0) {
      iq_services.className = 'error';  
      error = true;
    } else {
      iq_services.className = '';
    }
    
    if (iq_phone.value=='' || iq_phone.value.match(/^ *$/) || iq_phone.value=='phone*') {
      iq_phone.className = 'error';  
      error = true;
    } else {
      iq_phone.className = '';
    }

    if (iq_email.value=='' || iq_email.value.match(/^ *$/) || iq_email.value=='email*' || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/.test(iq_email.value))) {
      iq_email.className = 'error'; 
      error = true;
    } else {
      iq_email.className = '';
    }

    if (iq_name.value=='' || iq_name.value.match(/^ *$/) || iq_name.value=='name*') {
      iq_name.className = 'error';
      error = true;
    } else {
      iq_name.className = '';
    }
    return error;
  }
  
  
  iq_submit.addEventListener('click',function(){
   
    if(validateIQForm()){
      return;
    } else {
      http = getHTTPObject();
      http.open("POST", './amt/php/sendIqMail.php', true);

      params="iq_name="+escape(iq_name.value)+"&";
      params += "iq_email="+escape(iq_email.value)+"&";
      params += "iq_phone="+escape(iq_phone.value)+"&";
      params += "iq_services="+escape(iq_services.value)+"&";
      params += "iq_comments="+escape(iq_comments.value)+"&";

      iq_submit.disabled=true;
      iq_loading_img.style.visibility = 'visible';

      http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http.setRequestHeader("Content-length", params.length);
      http.setRequestHeader("Connection", "close");
      http.onreadystatechange=function(){
        if(http.readyState==4){
          document.getElementById('iq-msg').innerHTML ='Thank you for your interest in AMT';
          iq_name.value='name*';
          iq_name.className = 'default';
          iq_email.value='email*';
          iq_email.className = 'default';
          iq_phone.value='phone*';
          iq_phone.className = 'default';
          iq_services.value=0;
          iq_comments.value='additional comments*';
          iq_comments.className = 'default';
          iq_sum.value='';
          iq_submit.disabled=false;
          iq_loading_img.style.visibility = 'hidden';
        }
      }
      http.send(params);
    }
   
 








  },false);
}
/**
******************************************************************************
*
* (c) Segger CMS 2008-2009 by Advanced Millennium Technologies Pvt Ltd.
* 
****************************************************************************** 
*/
