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;
}

/*
function validate_form()
{
	if (document.ContactForm.dep_name.value=="")
	{
		alert("Please choose a Department");
		document.ContactForm.name.focus();
		return false;
	}

	if (document.ContactForm.name.value=="")
	{
		alert("Please enter your Name");
		document.ContactForm.name.focus();
		return false;
	}


	if (document.ContactForm.title.value=="")
	{
		alert("Please enter your Title");
		document.ContactForm.title.focus();
		return false;
	}

	if(document.ContactForm.phone.value=="")
	{
		alert("Please enter your Phone Number");
		document.formular.phone.focus();
		return false;
	}

	var emailID=document.ContactForm.email
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}

	if (echeck(emailID.value)==false)
	{
		emailID.value="";
		emailID.focus();
		return false;
	}

	

	if(document.ContactForm.comments.value=="")
	{
		alert("Please enter your Comments");
		document.ContactForm.comments.focus();
		return false;
	}
	return true;
}

*/

function validate_form()
{
	var err = '';
	if (document.getElementById('comments').value == '')
		err += 'Please enter your Comments. \n';

	if (document.getElementById('name').value == '')
			err += 'Please enter your Name. \n';

	if (document.getElementById('title').value == '')
			err += 'Please enter your Title. \n';

	if (document.getElementById('phone').value == '')
			err += 'Please enter your Phone Number. \n';

	if (document.getElementById('email').value == '')
			err += 'Please enter your Email. \n';

	if (document.getElementById('dep_name').value == '')
			err += 'Please choose a Department. \n';
			
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(document.getElementById('email').value) == false)
	{
		err +='Invalid Email Address';
	}

	if (err !='')
	{
		alert(err);
		return false;
	}

	return true;
}


function validate_form_fraud_trial_request()
{
	var err = '';
	
	if (document.getElementById('name').value == '')
			err += 'Please enter your Name. \n';

	if (document.getElementById('company').value == '')
			err += 'Please enter your Company Name. \n';
    
    if (document.getElementById('function').value == '')
	       err += 'Please enter your Job Function. \n';
			
	if (document.getElementById('phone').value == '')
			err += 'Please enter your Phone Number. \n';

	if (document.getElementById('email').value == '')
			err += 'Please enter your Email. \n';

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(document.getElementById('email').value) == false)
	{
		err +='Invalid Email Address';
	}

	if (err !='')
	{
		alert(err);
		return false;
	}

	return true;
}

