// JavaScript Document
function validate_contactusnew()
{

/*to check the first name*/
if(document.frm_contact_us.name.value=="")
 {
  alert("Please specify your name");
  document.frm_contact_us.name.focus();
  return false;
 }
 
 
var alphaExp = /^[a-zA-Z" "]+$/;
if(document.frm_contact_us.name.value.search(alphaExp)==-1)
{
	alert("Invalid character in name!");
	document.frm_contact_us.name.select();
	return false;
} 


	/*to check the email id*/

	var emailID=document.frm_contact_us.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
	}

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					
	}

 
 /*to check the contact no*/
   var numericExpression = /^[" "0-9+()-]+$/;
	if(document.frm_contact_us.phoneno.value.search(numericExpression)==-1)
	{
		alert("Invalid character in contactno number");
		document.frm_contact_us.phoneno.select();
		return false;
	}

 /*to check the Country */
if(document.frm_contact_us.topic.selectedIndex == 0)
 {
  alert("Please let us know what you are looking for");
  document.frm_contact_us.topic.focus();
  return false;
 }

 /*to check the technology */
 /* disabling this check */
/*if(document.frm_contact.technology.selectedIndex == 0)
 {
  alert("Please specify technology/platform preference");
  document.frm_contact.technology.focus();
  return false;
 }*/


}
function change(obje){
	var val;
		val =obje.options[obje.selectedIndex].value;
	if (val=="Jobs at Xebia"){
document.getElementById("mail").style.display="block";
}
else{
	document.getElementById("mail").style.display="none";
	}		
	}


    var tabLinks = new Array();
    var contentDivs = new Array();

    function init() {

      // Grab the tab links and content divs from the page
      docTab = document.getElementById('tab'); 
      if (!docTab) { return; }     
      var tabListItems = docTab.childNodes;
      for ( var i = 0; i < tabListItems.length; i++ ) {
        if ( tabListItems[i].nodeName == "LI" ) {
          var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
          var id = getHash( tabLink.getAttribute('href') );
          tabLinks[id] = tabLink;
          contentDivs[id] = document.getElementById( id );
        }
      }

      // Assign onclick events to the tab links, and
      // highlight the first tab
      var i = 0;

      for ( var id in tabLinks ) {
        tabLinks[id].onclick = showTab;
        tabLinks[id].onfocus = function() { this.blur() };
        if ( i == 0 ) tabLinks[id].className = 'selected';
        i++;
      }
      
    }

    function showTab() {
      var selectedId = getHash( this.getAttribute('href') );

      // Highlight the selected tab, and dim all others.
      // Also show the selected content div, and hide all others.
      for ( var id in contentDivs ) {
        if ( id == selectedId ) {
          tabLinks[id].className = 'selected';
          contentDivs[id].className = 'tabContent';
        } else {
          tabLinks[id].className = '';
          contentDivs[id].className = 'tabContent hide';
        }
      }

      // Stop the browser following the link
      return false;
    }

    function getFirstChildWithTagName( element, tagName ) {
      for ( var i = 0; i < element.childNodes.length; i++ ) {
        if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
      }
    }

    function getHash( url ) {
      var hashPos = url.lastIndexOf ( '#' );
      return url.substring( hashPos + 1 );
    }

 
 
 
 
 
 
 
 
 /*contact us form validation */
 
/*function disable()
 {
var w = document.frm_contact.skill.selectedIndex;
var a = document.frm_contact.skill.options[w].value;
			
					 if (a==21)
					  { 
					  showhide();
					  return;
					  }
					  else if(a==0)
					  {
						   alert("Please specify your key skills");
						  }
				
 }
 
 function showhide()
 {
	   var state = document.getElementById('showhidetab').style.display;
			if (state == 'block') {
				document.getElementById('showhidetab').style.display = 'none';
					   return false;

			} else {
				document.getElementById('showhidetab').style.display = 'block';
				  document.frm_contact.notech.focus();
				   return false;
				  
  
			}

	 }
 
 */

function validate_contactus()
{

/*to check the first name*/
if(document.frm_contact.fname.value=="")
 {
  alert("Please specify your name");
  document.frm_contact.fname.focus();
  return false;
 }
 
 
var alphaExp = /^[a-zA-Z" "]+$/;
if(document.frm_contact.fname.value.search(alphaExp)==-1)
{
	alert("Invalid character in name!");
	document.frm_contact.fname.select();
	return false;
} 

/*to check the last name*/
if(document.frm_contact.lname.value=="")
 {
  alert("Please specify your last name");
  document.frm_contact.lname.focus();
  return false;
 }
 
var alphaExp = /^[a-zA-Z" "]+$/;
if(document.frm_contact.lname.value.search(alphaExp)==-1)
{
	alert("Invalid character in last name!");
	document.frm_contact.lname.select();
	return false;
} 


/*to check the Company Name*/
if(document.frm_contact.cname.value=="")
 {
  alert("Please specify your company name");
  document.frm_contact.cname.focus();
  return false;
 }

/*to check the Title Name*/
if(document.frm_contact.title.value=="")
 {
  alert("Please specify Title");
  document.frm_contact.title.focus();
  return false;
 }


/*to check the contact no*/
 if(document.frm_contact.contactno.value=="")
 {
  alert("Please specify your contact number!");
  document.frm_contact.contactno.focus();
  return false;
 }
  var numericExpression = /^[" "0-9+()-]+$/;
	if(document.frm_contact.contactno.value.search(numericExpression)==-1)
	{
		alert("Invalid character in contactno number");
		document.frm_contact.contactno.select();
		return false;
	}


	/*to check the email id*/

	var emailID=document.frm_contact.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
	}

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					
	}
 /*to check the Country */
if(document.frm_contact.country.selectedIndex == 0)
 {
  alert("Please specify country");
  document.frm_contact.country.focus();
  return false;
 }

 /*to check the enquiry */
if(document.frm_contact.enquiry.value=="")
 {
  alert("Please let us know what you are looking for");
  document.frm_contact.enquiry.focus();
  return false;
 }

 /*to check the technology */
 /* disabling this check */
/*if(document.frm_contact.technology.selectedIndex == 0)
 {
  alert("Please specify technology/platform preference");
  document.frm_contact.technology.focus();
  return false;
 }*/


}

 /**********validation for new contact us form******************/

 
    
    
 
    
