function checkEmail(e) {
  ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

  for(i=0; i < e.length ;i++){
    if(ok.indexOf(e.charAt(i))<0){ 
	  //found character not in OK string
      return -1;
      }	
    } 
  
  // Note {2, 4} indicates the length of domain from 2 to 4 characters. For example .com, .tv, .us
  if (document.images) {
   re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
   re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
   if (!e.match(re) && e.match(re_two)) {
     //Everything is OK
     return 1;		
     } 
   }
  
  //Bad by Default
  return -1;
  }
  

function clearFields(){
		document.getElementById("lblFirstName").style.color = "white";
		document.getElementById("txtFirstName").style.backgroundColor = "#fff";	
		document.getElementById("lblLastName").style.color = "white";
		document.getElementById("txtLastName").style.backgroundColor = "#fff";
		document.getElementById("lblEmail").style.color = "white";
		document.getElementById("txtEmail").style.backgroundColor = "white";
		document.getElementById("lblDisclaimer").style.color = "white";
}


function validateForm(){
	clearFields()
  if (window.document.chatForm.firstname.value == ""){
		document.getElementById("lblFirstName").style.color = "yellow";
		document.getElementById("txtFirstName").style.backgroundColor = "#ffff99";
	return false;
	}
  if (window.document.chatForm.lastname.value == ""){
		document.getElementById("lblLastName").style.color = "yellow";
		document.getElementById("txtLastName").style.backgroundColor = "#ffff99";
	return false;
	}
  if (window.document.chatForm.email.value == ""){
		document.getElementById("lblEmail").style.color = "yellow";
		document.getElementById("txtEmail").style.backgroundColor = "#ffff99";
	return false;
	}
  
  if (checkEmail(window.document.chatForm.email.value) < 0){
		document.getElementById("lblEmail").innerHTML = "Enter a Valid Email";
		document.getElementById("lblEmail").style.color = "yellow";
		document.getElementById("txtEmail").style.backgroundColor = "#ffff99";
	return false;
	}

  if(!window.document.chatForm.accept.checked) {
		document.getElementById("lblDisclaimer").style.color = "yellow";
	return false;
	}	
	
  newwin = window.open('', 'chat_window', 'screenX=10,screenY=25,top=25,left=10,width=500,height=320,scrollbars=no,menubar=no,resizable=yes,status=no,toolbar=no');
  
	  return submitRequest();
    }	
	
	var requestSubmitted = false;
	var ms = (new Date().getTime()/1000); //milliseconds since 1970-01-01
    function submitRequest() {
              if (!requestSubmitted || ((new Date().getTime()/1000) - ms) > 2) // time interval between two click is greater than 2 seconds
			  {
                     requestSubmitted  = true;
					 ms = new Date().getTime()/1000;
                     return true;
              }
			  else 
			  {
				  //alert('dbl click1!');
				  window.location.reload(false);
				  return false;
			  }
       }


