	function CheckPhone(tel)
	{
		allowed="1234567890.-/";
		for (i = 0; i < tel.length; i++)
		{
			var c=tel.charAt(i);
			// test for spaces
			if(c != " ")
			{
				if(allowed.indexOf(c)==-1)
					return false;
			}		
		}
		return true;
	}

	function validare_contact()
	{
	    var M_firstname,M_lastname,M_email,M_city,M_country,M_phone,M_comments,project_brief;
	    M_firstname=document.contactfrm.M_firstname;
	    M_lastname=document.contactfrm.M_lastname;
	    M_email=document.contactfrm.M_email;
	    M_city=document.contactfrm.M_city;		
	    M_country=document.contactfrm.M_country;		
	    M_phone=document.contactfrm.M_phone;		
	    M_comments=document.contactfrm.M_comments;				
	    project_brief=document.contactfrm.project_brief;				
		
  	    if (M_firstname.value.length==0)
  	    {
   	    	alert ("Please insert your 'First name'!");
			M_firstname.focus();
    		M_firstname.select();
    		return false;
   	    }
  	    if (M_lastname.value.length==0)
  	    {
   	    	alert ("Please insert your 'Last name'!");
			M_lastname.focus();
    		M_lastname.select();
    		return false;
   	    }		
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(M_email.value)))
	    {
	    	alert('Incorrect email address!');
			M_email.focus();
			M_email.select();
			return false;
	    }
  	    if (M_city.value.length==0)
  	    {
   	    	alert ("Please insert 'City'!");
			M_city.focus();
    		M_city.select();
    		return false;
   	    }				
	    if(document.forms['contactfrm'].elements['M_country'].value==0)
	    {
			alert('Please select your country!');
			return false;
	    }
		if(M_phone.value.length!=0) 
		{
			if(!CheckPhone(M_phone.value))
			{			
				alert ('Please insert a correct phone number!');
				M_phone.focus();
				M_phone.select();
				return false;
			}	
	    }
  	    if(project_brief.value!='')
		{
			var file;
			file = project_brief.value;
			extArray = new Array(".doc", ".pdf");
			allowSubmit = false;

			while (file.indexOf("\\") != -1)
				file = file.slice(file.indexOf("\\") + 1);
			ext = file.slice(file.indexOf(".")).toLowerCase();
			for (var i = 0; i < extArray.length; i++)
			{
				if (extArray[i] == ext) { allowSubmit = true; break; }
			}

			if(!allowSubmit)
			{
	   	    	alert ("Please choose a DOC or PDF file!");
				project_brief.focus();
    			project_brief.select();
    			return false;
			}
		}
		if (M_comments.value.length==0)
  	    {
   	    	alert ("Please type your comments!");
			M_comments.focus();
    		M_comments.select();
    		return false;
   	    }
   	}

	function validare_join()
	{
	    var M_firstname,M_lastname,M_bd,M_bm,M_by;
		var M_phone,M_mphone,M_email,M_url;
		var M_goals,M_colab1,M_colab2,M_colab3;
		var M_studies,M_experience,M_flanguages,M_referrers,M_other,M_comments;

		M_firstname=document.joinfrm.M_firstname;
	    M_lastname=document.joinfrm.M_lastname;
		M_bd=document.joinfrm.M_bd;
		M_bm=document.joinfrm.M_bm;
		M_by=document.joinfrm.M_by;
	    M_phone=document.joinfrm.M_phone;		
	    M_mphone=document.joinfrm.M_mphone;		
	    M_email=document.joinfrm.M_email;
	    M_url=document.joinfrm.M_url;		
	    M_goals=document.joinfrm.M_goals;		
	    M_colab1=document.joinfrm.M_colab1;		
	    M_colab2=document.joinfrm.M_colab2;		
	    M_colab3=document.joinfrm.M_colab3;		
	    M_studies=document.joinfrm.M_studies;		
	    M_experience=document.joinfrm.M_experience;		
	    M_flanguages=document.joinfrm.M_flanguages;		
	    M_referrers=document.joinfrm.M_referrers;		
	    M_other=document.joinfrm.M_other;		
	    M_comments=document.joinfrm.M_comments;				
 		
  	    if (M_firstname.value.length==0)
  	    {
   	    	alert ("Please insert your 'First name'!");
			M_firstname.focus();
    		M_firstname.select();
    		return false;
   	    }
  	    if (M_lastname.value.length==0)
  	    {
   	    	alert ("Please insert your 'Last name'!");
			M_lastname.focus();
    		M_lastname.select();
    		return false;
   	    }		
  	    if (M_bd.value.length==0 || M_bm.value.length==0 || M_by.value.length==0)
  	    {
   	    	alert ("Please insert your 'Birthday'!");
			M_bd.focus();
    		M_bd.select();
    		return false;
   	    }		
		if(M_phone.value.length==0 || !CheckPhone(M_phone.value))
		{			
			alert ('Please insert a correct phone number!');
			M_phone.focus();
			M_phone.select();
			return false;
		}	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(M_email.value)))
	    {
	    	alert('Incorrect email address!');
			M_email.focus();
			M_email.select();
			return false;
	    }
  	    if (M_goals.value.length==0)
  	    {
   	    	alert ("Please insert your 'Professional goals'!");
			M_goals.focus();
    		M_goals.select();
    		return false;
   	    }	
		if (!M_colab1.checked && !M_colab2.checked && !M_colab3.checked)
  	    {
   	    	alert ("Please choose at least one collaboration type.");
    		return false;
   	    }		
  	    if (M_studies.value.length==0)
  	    {
   	    	alert ("Please insert your 'Studies'!");
			M_studies.focus();
    		M_studies.select();
    		return false;
   	    }		
  	    if (M_experience.value.length==0)
  	    {
   	    	alert ("Please insert your 'Professional experience'!");
			M_experience.focus();
    		M_experience.select();
    		return false;
   	    }		
  	    if (M_flanguages.value.length==0)
  	    {
   	    	alert ("Please insert your 'Foreign languages'!");
			M_flanguages.focus();
    		M_flanguages.select();
    		return false;
   	    }		
		if (M_referrers.value.length==0)
  	    {
   	    	alert ("Please type your refererrs!");
			M_referrers.focus();
    		M_referrers.select();
    		return false;
   	    }
   	}

	function SearchSubmit(forma)
	{
      var srh_field;
	  var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\<\>]/;

	  sh=forma.srh_field;
	  if(sh.value.length == 0 || sh.value=="your keyword here")
	  {
			alert("Please enter a keyword.");		  
			sh.focus();
    		sh.select();
			return false;
	  }

	  if(sh.value.length >= 20){
			alert("String is to big! Maximum 20 characters is possible!");		  
			sh.focus();
    		sh.select();
			return false;
	  } 

	  if(sh.value.length <= 2) {
			alert("Minimum 3 characters required.");		  
			sh.focus();
    		sh.select();
			return false;
	  } else {
		  if(sh.value.search(mikExp) != -1) {
				alert("Sorry, but the following characters\n\r\n\r < > @ $ % ^ & * # ( ) [ ] \\ { + } ` ~ =  | \n\r\n\rare not allowed!\n");
				sh.focus();
				sh.select();
				return false;
			}
	  }
	  return;
}
