// JavaScript Document
function checkInput()
{
	var name 	= document.getElementById('first_name').value;
	var lname 	= document.getElementById('last_name').value;
	var country = document.getElementById('country').value;
	var phone 	= document.getElementById('phone').value;
	var email 	= document.getElementById('email').value;
	var subject	= document.getElementById('subject').value;
	var comment	= document.getElementById('comment').value;

	if (name.length < 1) {
		alert("Please enter your name.");
		document.getElementById('first_name').focus();
	} else if (lname.length < 1) {
		alert("Please enter your last name.");
		document.getElementById('last_name').focus();
	} else if (country.length < 1) {
		alert("Please enter your country.");
		document.getElementById('country').focus();
	} else if (phone.length < 5) {
		alert("Please enter your phone number.");
		document.getElementById('phone').focus();
	} else if (!echeck(email)) {
		alert("Please enter your email address.");
		document.getElementById('email').focus();
	} else if (subject.length < 1) {
		alert("Please enter a subject.");
		document.getElementById('subject').focus();
	} else if (comment.length < 5) {
		alert("Please enter your comment.");
		document.getElementById('comment').focus();
	} else {
		document.frm_contact.submit();
	}

	//alert(comment);
  	//document.myform.submit();
}

function echeck(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(" ")!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 return true
}