function validaterequest(form) {
 var name = document.form.name.value;
 var email_id = document.form.email_id.value;
 var contact_no = document.form.contact_no.value;
 //var street_address = document.form.street_address.value;
// var state = document.form.state.value;
 //var business_name =document.form.business_name.value;
 var detail = document.form.detail.value;
// var country=document.form.country.value;
 var service =document.form.service.value;	
 //var start_date = document.form.start_date.value;
 //var min_budget =document.form.min_budget.value;
 var max_budget=document.form.max_budget.value;
 var curr =document.form.curr.value;
 var txtnumber =document.form.txtnumber.value;
 //var random_hidden =document.form.random_hidden.value;
 //var rand =document.form.rand.value;
 
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(name == "")
 {
   
	inlineMsg('name','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!name.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('name','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
 
 if(email_id =="")
 {
	 inlineMsg('email_id','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!email_id.match(emailRegex)) 
  {
    inlineMsg('email_id','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(contact_no=="")
  {
	  inlineMsg('contact_no','<strong>Error!!You must enter the contact number</strong>',2);
	  return false;
  }
  if(isNaN(contact_no))
  {
	   inlineMsg('contact_no','<strong>Error!!Invalid Number</strong>',2);
	   return false;
  }
   if(service == "")
 {
   //  alert('1');
	inlineMsg('service','<strong>Error !!Please select type of service.</strong>',2); 
	 return false;
  }
  if(detail == "&lt;Please Detail Your Project Requirement Here&gt;")
 {
   //  alert('1');
	inlineMsg('detail','<strong>Error !!You must enter description of project.</strong>',2); 
	 return false;
  }

 if(txtnumber == "")
 {
   //  alert('1');
	inlineMsg('txtnumber','<strong>Error !!Please enter the verfication code.</strong>',2); 
	 return false;
  }

 // alert(rand);
 //alert(random_hidden);
  /*if(rand !=txtnumber)
 {
    // alert('1');
	inlineMsg('txtnumber','<strong>Error !!Please enter the correct verfication code.</strong>',2); 
	 return false;
	 
  }*/
  return true;
}


/////////////Start login form validation///
function validate_contact(contact) {

 var fname = document.contact.fname.value;
 var address = document.contact.address.value;
 var Email = document.contact.Email.value;
 //var street_address = document.form.street_address.value;
// var state = document.form.state.value;
 //var business_name =document.form.business_name.value;
 var ph = document.contact.ph.value;
// var country=document.form.country.value;
 var subject =document.contact.subject.value;	
 //var start_date = document.form.start_date.value;
 //var min_budget =document.form.min_budget.value;
 var call_time=document.contact.call_time.value;
 var info =document.contact.info.value;
 var txtnumber =document.contact.txtnumber.value;
 //var random_hidden =document.form.random_hidden.value;
 //var rand =document.form.rand.value;
 
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(fname =="")
 {
   	inlineMsg('fname','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!fname.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('fname','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  if(address =="")
 {
   
	inlineMsg('address','<strong>Error !!You must enter your Address.</strong>',2); 
	 return false;
  }
 
 if(Email =="")
 {
	 inlineMsg('Email','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!Email.match(emailRegex)) 
  {
    inlineMsg('Email','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(ph=="")
  {
	  inlineMsg('ph','<strong>Error!!You must enter the contact number</strong>',2);
	  return false;
  }
  if(isNaN(ph))
  {
	   inlineMsg('ph','<strong>Error!!Invalid Number</strong>',2);
	   return false;
  }
    if(subject=="")
  {
	  inlineMsg('subject','<strong>Error!!You must enter Subject</strong>',2);
	  return false;
  }
  if(info == "")
 {
   //  alert('1');
	inlineMsg('info','<strong>Error !!You must enter description.</strong>',2); 
	 return false;
  }

 if(txtnumber == "")
 {
   //  alert('1');
	inlineMsg('txtnumber','<strong>Error !!Please enter the verfication code.</strong>',2); 
	 return false;
  }

 
  return true;
}


function validate_ref (ref) {

 var fname = document.ref.fname.value;
 var address = document.ref.lname.value;
 var email = document.ref.email.value;
 var subject =document.ref.subject.value;	

 var info =document.ref.info.value;
 
 
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(fname =="" || fname =="First Name")
 {
   	inlineMsg('fname','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!fname.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('fname','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  
 
 if(email =="" || email =="Email")
 {
	 inlineMsg('email','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!email.match(emailRegex)) 
  {
    inlineMsg('email','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
 
    if(subject=="" || subject=="Subject")
  {
	  inlineMsg('subject','<strong>Error!!You must enter Subject</strong>',2);
	  return false;
  }
  if(info == "" || info=="Message")
 {
   //  alert('1');
	inlineMsg('info','<strong>Error !!You must enter description.</strong>',2); 
	 return false;
  }

 
  return true;
}



function validate_feedback(feedback) {

 var name = document.feedback.name.value;
 var detail = document.feedback.detail.value;
 var email_id = document.feedback.email_id.value;
 var txtnumber =document.feedback.txtnumber.value;
 
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(name =="")
 {
   	inlineMsg('name','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!name.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('name','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  
 
 if(email_id =="")
 {
	 inlineMsg('email_id','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!email_id.match(emailRegex)) 
  {
    inlineMsg('email_id','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(detail =="")
 {
   
	inlineMsg('detail','<strong>Error !!You must enter your detail.</strong>',2); 
	 return false;
  }
 
 if(txtnumber == "")
 {
   //  alert('1');
	inlineMsg('txtnumber','<strong>Error !!Please enter the verfication code.</strong>',2); 
	 return false;
  }

 
  return true;
}

function validate_prt_frm1(portfolio_frm1) {

 var name = document.portfolio_frm1.name.value;
 var detail = document.portfolio_frm1.detail.value;
 var email_id = document.portfolio_frm1.email_id.value;
  
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(name =="")
 {
   	inlineMsg('name','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!name.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('name','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  
 
 if(email_id =="")
 {
	 inlineMsg('email_id','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!email_id.match(emailRegex)) 
  {
    inlineMsg('email_id','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(detail =="")
 {
   
	inlineMsg('detail','<strong>Error !!You must enter your detail.</strong>',2); 
	 return false;
  }
 
  return true;
}

function validate_prt_frm2(portfolio_frm2) {

 var name1 = document.portfolio_frm2.name1.value;
 var detail1 = document.portfolio_frm2.detail1.value;
 var email_id1 = document.portfolio_frm2.email_id1.value;
  
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(name1 =="")
 {
   	inlineMsg('name1','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!name1.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('name1','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  
 
 if(email_id1 =="")
 {
	 inlineMsg('email_id1','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!email_id1.match(emailRegex)) 
  {
    inlineMsg('email_id1','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(detail1 =="")
 {
   
	inlineMsg('detail1','<strong>Error !!You must enter your detail.</strong>',2); 
	 return false;
  }
 
  return true;
}

 function validate_career(contact) {

 var name = document.contact.name.value;
 var Email = document.contact.email_id.value;
 var job_typ = document.contact.job_typ.value;
 var contact_no =document.contact.contact_no.value;	
 var detail=document.contact.detail.value;
 var txtnumber =document.contact.txtnumber.value;
 
 
 var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/  ;
 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

 if(name =="")
 {
   	inlineMsg('name','<strong>Error !!You must enter your name.</strong>',2); 
	 return false;
  }
 if(!name.match(nameRegex))
 {
   //  alert('1');
	inlineMsg('name','<strong>Error !!Invalid name.</strong>',2); 
	 return false;
  }
  
 if(Email =="")
 {
	 inlineMsg('email_id','<strong>Error !!You must enter your Email-ID</strong>',2);
	 return false;
 }
  if(!Email.match(emailRegex)) 
  {
    inlineMsg('email_id','<strong>Error !!You have entered an invalid email.</strong>',2);
    return false;
  }
  if(contact_no=="")
  {
	  inlineMsg('contact_no','<strong>Error!!You must enter the contact number</strong>',2);
	  return false;
  }
  if(isNaN(contact_no))
  {
	   inlineMsg('contact_no','<strong>Error!!Invalid Number</strong>',2);
	   return false;
  }
  
   if(job_typ == "")
 {
   //  alert('1');
	inlineMsg('job_typ','<strong>Error !!You must enter job type.</strong>',2); 
	 return false;
  }
  if(detail == "")
 {
   //  alert('1');
	inlineMsg('detail','<strong>Error !!You must enter description.</strong>',2); 
	 return false;
  }

 if(txtnumber == "")
 {
   //  alert('1');
	inlineMsg('txtnumber','<strong>Error !!Please enter the verfication code.</strong>',2); 
	 return false;
  }

 
  return true;
}



// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// 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"; 
}
