function validate(msgform) 
{
	
  var name = msgform.name.value; 
  var place = msgform.place.value;
  var email = msgform.email.value;
  var feedback = msgform.feedback.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
 
  if(name == "") {
		
    inlineMsg('name','You must Enter Name',4);
    return false;
  }
 
 if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered an invalid name.',2);
    return false;
  }
  if(place == "") {
		
    inlineMsg('place','You must Enter place',4);
    return false;
  }

   if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
  if(feedback == "") {
		
    inlineMsg('feedback','You must Enter feedback',4);
    return false;
  }
  
  
  return true;
}





function validate1(msgform) 
{
	
  var name = msgform.name.value; 
  var contact = msgform.contact.value;
  var email = msgform.email.value;
  var enquiry = msgform.enquiry.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var numRegex = /^[0-9]/;
  
   if(name == "") {
		
    inlineMsg('name','You must Enter Name',4);
    return false;
  }
   if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered an invalid name.',2);
    return false;
  }
   if(contact == "") {
		
    inlineMsg('contact','You must Enter contact Number',4);
    return false;
  }
   if(!contact.match(numRegex)) {
    inlineMsg('contact','You have entered an invalid contact no.',2);
    return false;
  }
   if(contact.length<10) {
    inlineMsg('contact','You have entered an invalid contact no.',2);
    return false;
  }
   if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
	 if(enquiry == "") {
		
    inlineMsg('enquiry','You must Enter enquiry',4);
    return false;
  }
  
    return true;
}







function validate_training(msgform) 
{
	
  var name = msgform.name.value; 
  var phone = msgform.phone.value;
  var email = msgform.email.value;
  var course = msgform.course.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var numRegex = /^[0-9]/;
  
   if(name == "") {
		
    inlineMsg('name','You must Enter Name',4);
    return false;
  }
   if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered an invalid name.',2);
    return false;
  }
     if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
   if(phone == "") {
		
    inlineMsg('phone','You must Enter phone Number',4);
    return false;
  }
   if(!phone.match(numRegex)) {
    inlineMsg('phone','You have entered an invalid phone no.',2);
    return false;
  }
   if(phone.length<10) {
    inlineMsg('phone','You have entered an invalid phone no.',2);
    return false;
  }

	 if(course == "") {
		
    inlineMsg('course','You must Select Course',4);
    return false;
  }
  
    return true;
}









function validate_projects(msgform) 
{
	
  var name = msgform.name.value; 
  var phone = msgform.phone.value;
  var email = msgform.email.value;
  var project = msgform.project.value;
  var institute = msgform.institute.value;
  var location = msgform.location.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var numRegex = /^[0-9]/;
  
   if(name == "") {
		
    inlineMsg('name','You must Enter Name',4);
    return false;
  }
   if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered an invalid name.',2);
    return false;
  }
     if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
   if(phone == "") {
		
    inlineMsg('phone','You must Enter phone Number',4);
    return false;
  }
   if(!phone.match(numRegex)) {
    inlineMsg('phone','You have entered an invalid phone no.',2);
    return false;
  }
   if(phone.length<10) {
    inlineMsg('phone','You have entered an invalid phone no.',2);
    return false;
  }

	 if(project == "") {
		
    inlineMsg('project','Select your Interested Project',4);
    return false;
  }
   if(institute == "") {
		
    inlineMsg('institute','Please enter your Institute',4);
    return false;
  }
     if(location == "") {
		
    inlineMsg('location','Please enter your Location',4);
    return false;
  }
  
    return true;
}









function validate_job(msgform) 
{
	
  var name = msgform.name.value;
  var last_name = msgform.last_name.value;
  var sex = msgform.sex.value;
  var marital_status = msgform.marital_status.value;
  var date_birth = msgform.date_birth.value;
  var month_birth = msgform.month_birth.value;
  var year = msgform.year.value;
  var email = msgform.email.value;
  var phone = msgform.phone.value;
  var nationality = msgform.nationality.value;
  var address = msgform.address.value;
  var qualification = msgform.qualification.value;
  var year_passing = msgform.year_passing.value;
  var institute = msgform.institute.value;
  var university = msgform.university.value;
  var job_category = msgform.job_category.value;
  var experience = msgform.experience.value;
  var key_skills = msgform.key_skills.value;
  var company = msgform.company.value;
  var location = msgform.location.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var numRegex = /^[0-9]/;


  
    if(name == "") {
		
    inlineMsg('name','You must Enter First Name',4);
    return false;
  }
   if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered invalid.',2);
    return false;
  }
  if(last_name == "") {
		
    inlineMsg('last_name','You must Enter Last Name',4);
    return false;
  }
   if(!last_name.match(nameRegex)) {
    inlineMsg('last_name','You have entered invalid.',2);
    return false;
  }
  if(sex == "") {
		
    inlineMsg('sex','You must Enter Your Sex',4);
    return false;
  }
    if(marital_status == "") {
		
    inlineMsg('marital_status','You must Enter Marital Status',4);
    return false;
  }
      if(date_birth == "") {
		
    inlineMsg('date_birth','You must Enter Date',4);
    return false;
  }
       if(month_birth == "") {
		
    inlineMsg('month_birth','You must Enter Month',4);
    return false;
  }
      if(year == "") {
		
    inlineMsg('year','You must Enter Year',4);
    return false;
  }
    if(!year.match(numRegex)) {
    inlineMsg('year','You have entered an invalid year.',2);
    return false;
  }
   if(year.length<4) {
    inlineMsg('year','You have entered an invalid year.',2);
    return false;
  }
  if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
	 if(phone == "") {
		
    inlineMsg('phone','You must Enter Phone Number',4);
    return false;
  }
   if(!phone.match(numRegex)) {
    inlineMsg('phone','You have entered an invalid Phone no.',2);
    return false;
  }
   if(phone.length<10) {
    inlineMsg('phone','Phone no must be 10 digits.',2);
    return false;
  }
    if(nationality == "") {
		
    inlineMsg('nationality','You must Enter Nationality',4);
    return false;
  }
   if(!nationality.match(nameRegex)) {
    inlineMsg('nationality','You have entered invalid.',2);
    return false;
  }
    if(address == "") {
		
    inlineMsg('address','You must Enter Address',4);
    return false;
  }
     if(qualification == "") {
		
    inlineMsg('qualification','You must Enter Qualification',4);
    return false;
  }
      if(year_passing == "") {
		
    inlineMsg('year_passing','You must Enter Year of Passout',4);
    return false;
  }
     if(!year_passing.match(numRegex)) {
    inlineMsg('year_passing','You have entered an invalid year.',2);
    return false;
  }
   if(year_passing.length<4) {
    inlineMsg('year_passing','Year must be 4 digit.',2);
    return false;
  }
  
       if(institute == "") {
		
    inlineMsg('institute','You must Enter Institute',4);
    return false;
  }
         if(university == "") {
		
    inlineMsg('university','You must Enter University',4);
    return false;
  }
       if(job_category == "") {
		
    inlineMsg('job_category','You must Enter Job Category',4);
    return false;
  }
         if(experience == "") {
		
    inlineMsg('experience','You must Enter Experience',4);
    return false;
  }
        if(key_skills == "") {
		
    inlineMsg('key_skills','You must Enter Your Key Skills',4);
    return false;
  }
        if(company == "") {
		
    inlineMsg('company','You must Enter Company Name',4);
    return false;
  }
       if(location == "") {
		
    inlineMsg('location','You must Enter Company Location',4);
    return false;
  }
  
  
  return true;
}








function validate_quote(msgform) 
{
	
  var project_info = msgform.project_info.value;
  var name = msgform.name.value;
  var email = msgform.email.value;
  var phone = msgform.phone.value;
  var city_state = msgform.city_state.value;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var numRegex = /^[0-9]/;


  
    if(project_info == "") {
		
    inlineMsg('project_info','You must Enter Project Details',4);
    return false;
  }
     if(name == "") {
		
    inlineMsg('name','You must Enter First Name',4);
    return false;
  }
   if(!name.match(nameRegex)) {
    inlineMsg('name','You have entered invalid.',2);
    return false;
  }
 
  if(email == "") {
		
    inlineMsg('email','You must Enter email',4);
    return false;
  }
   if(!email.match(emailRegex)) {
    inlineMsg('email','You have entered an invalid email.',4);
    return false;
     }
	 if(phone == "") {
		
    inlineMsg('phone','You must Enter Phone Number',4);
    return false;
  }
   if(!phone.match(numRegex)) {
    inlineMsg('phone','You have entered an invalid Phone no.',2);
    return false;
  }
   if(phone.length<10) {
    inlineMsg('phone','You have entered an invalid Phone no.',2);
    return false;
  }
    if(city_state == "") {
		
    inlineMsg('city_state','You must Enter City/State',4);
    return false;
  }
   if(!city_state.match(nameRegex)) {
    inlineMsg('city_state','You have entered invalid Entry.',2);
    return false;
  }

  return true;
}






// START OF MESSAGE SCRIPT //


var MSGTIMER = 20;
var MSGSPEED = 10;
var MSGOFFSET = 10;
var MSGHIDE = 100;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) 
{
  arrow = new Image(7,80); 
  arrow.src = "images/msg_arrow.gif"; 
}

