// JavaScript Document
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|in)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}


// See if "user" is valid 
if (user.match(userPat)==null) {
// user is not valid
alert("The username doesn't seem to be valid.");
return false;
}


/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}


// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}
/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
// Make sure there's a host name preceding the domain.
if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

/******************************************************************************/

function validaterftu()
{

if(document.formrftu.fname.value=="")
{
alert("Please  Enter Your Name !");
document.formrftu.fname.focus();
return false;
}

if(document.formrftu.org.value=="")
{
alert("Please  Enter Your Organization !");
document.formrftu.org.focus();
return false;
}

if(document.formrftu.comments.value=="")
{
alert("Please  Enter Your Query !");
document.formrftu.comments.focus();
return false;
}

}

/******************************************************************************/

function validategetin()
{
if(document.formgetin.name.value=="")
{
alert("Please  Enter Your Name !");
document.formgetin.name.focus();
return false;
}

if(document.formgetin.email.value=="")
{
alert("Please Enter your Email address!");
document.formgetin.email.focus();
return false;
}
if(emailCheck(document.formgetin.email.value)==false)
{
return false;
}

if(document.formgetin.query.value=="")
{
alert("Please  Enter Your Comments !");
document.formgetin.query.focus();
return false;
}
}

/******************************************************************************/

function validateemail()
{
if(document.emailing.emailer.value=="")
{
alert("Please Enter your Email address!");
document.emailing.emailer.focus();
return false;
}
if(emailCheck(document.emailing.emailer.value)==false)
{
return false;
}
}

/******************************************************************************/


function validatecontact()
{
if(document.formcontact.name.value=="")
{
alert("Please  Enter Your Name !");
document.formcontact.name.focus();
return false;
}

if(document.formcontact.email.value=="")
{
alert("Please Enter your Email address!");
document.formcontact.email.focus();
return false;
}
if(emailCheck(document.formcontact.email.value)==false)
{
return false;
}

if(document.formcontact.city.value=="")
{
alert("Please  Enter Your City Name !");
document.formcontact.city.focus();
return false;
}

if(document.formcontact.comments.value=="")
{
alert("Please  Enter Your comments/query !");
document.formcontact.comments.focus();
return false;
}

}

/******************************************************************************/

function validateemployers()
{

if(document.employers.name.value=="")
{
alert("Please  Enter Your Name !");
document.employers.name.focus();
return false;
}

if(document.employers.company.value=="")
{
alert("Please  Enter Your Company Name !");
document.employers.company.focus();
return false;
}

if(document.employers.designation.value=="")
{
alert("Please  Enter Your Designation !");
document.employers.designation.focus();
return false;
}

if(document.employers.add1.value=="")
{
alert("Please  Enter Your Address !");
document.employers.add1.focus();
return false;
}

if(document.employers.city.value=="")
{
alert("Please  Enter Your City Name !");
document.employers.city.focus();
return false;
}


if(document.employers.email.value=="")
{
alert("Please Enter your Email address!");
document.employers.email.focus();
return false;
}
if(emailCheck(document.employers.email.value)==false)
{
return false;
}

if(document.employers.hquali.value=="")
{
alert("Please Enter Your Highest Required Qualification !");
document.employers.hquali.focus();
return false;
}

if(document.employers.func.value=="")
{
alert("Please  Enter Your Functional Area !");
document.employers.func.focus();
return false;
}

}

/******************************************************************************/

/******************************************************************************/

function validateemployees()
{

if(document.employees.name.value=="")
{
alert("Please Enter Your Name !");
document.employees.name.focus();
return false;
}

if(document.employees.gend.value=="")
{
alert("Please Enter Your Gender !");
document.employees.gend.focus();
return false;
}

if(document.employees.add1.value=="")
{
alert("Please  Enter Your Address !");
document.employees.add1.focus();
return false;
}

if(document.employees.city.value=="")
{
alert("Please  Enter Your City !");
document.employees.city.focus();
return false;
}

if(document.employees.email.value=="")
{
alert("Please Enter your Email address!");
document.employees.email.focus();
return false;
}
if(emailCheck(document.employees.email.value)==false)
{
return false;
}

if(document.employees.hquali.value=="")
{
alert("Please Enter Your Highest Required Qualification !");
document.employees.hquali.focus();
return false;
}

if(document.employees.skills.value=="")
{
alert("Please  Enter Your Main Skils !");
document.employees.skills.focus();
return false;
}

}

/******************************************************************************/

function validatetrain()
{
if(document.formtrainer.name.value=="")
{
alert("Please  Enter Your Name !");
document.formtrainer.name.focus();
return false;
}

if(document.formtrainer.email.value=="")
{
alert("Please Enter your Email address!");
document.formtrainer.email.focus();
return false;
}
if(emailCheck(document.formtrainer.email.value)==false)
{
return false;
}

if(document.formtrainer.org.value=="")
{
alert("Please  Enter Your Organisation name !");
document.formtrainer.org.focus();
return false;
}
}

/******************************************************************************/
