function validateSearch(){
	if(document.users_s.operAge[document.users_s.operAge.selectedIndex].value != ''){
		if(document.users_s.age.value == ''){
			alert('Please Choose Age');
			document.users_s.age.focus();
			return false;
		}
	}
	if(document.users_s.operExp.value != ''){
		if(document.users_s.experience.value == ''){
			alert('Please Choose Expirience');
			document.users_s.experience.focus();
			return false;
		}
	}
	
	
	
	var search = document.users_s.length;
	search = search -2;
	c = 0;
	for(i=0;i<=search;i++){
		if(document.users_s.elements[i].value == ''){
			c++;
		}
	}

	if(c == search){
		alert('Please insert a keyword or select an option.');
		document.users_s.keyword.focus();
		return false;
	}
	
}



function validateLogin(){
	var root = document.login;
	if(root.username.value==''){
		alert('Please Insert Your Username');
		root.username.focus();
		return false;
	}
	if(root.password.value==''){
		alert('Please Insert Your Password');
		root.password.focus();
		return false;
	}
	return true;	
}

function validateContact(){
	var root = document.contact;
	var fullName = root.name.value;
	if(fullName == ''){
		alert('Please Insert Full Name');
		root.name.focus();
		return false;
	}
	var country = root.country[root.country.selectedIndex].value;
	if(country == ''){
		alert('Please Choose Your Country');
		root.country.focus();
		return false; 
	}
	var phone = root.phone.value;
	if(phone == ''){
		alert('Please Insert Your Phone');
		root.phone.focus();
		return false;
	}
	var email=root.email.value;
	if(email==''){
		alert("Please specify an email address.");
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	var subject = root.subject.value;
	if(subject == ''){
		alert('Please Insert Your Subject');
		root.subject.focus();
		return false;
	}
	
	var mess = root.message.value;
	if(mess == ''){
		alert('Please Insert Your Message');
		root.message.focus();
		return false;
	}
}


function addEvent(){
	
	var ni = document.getElementById('myDiv');
	var numi = document.getElementById('theValue');
	var num = (document.getElementById("theValue").value -1)+ 2;
	if(num > 5){
		alert('Maximum 5 Languages');
		return false;	
	}
	numi.value = num;
	var divIdName = "my"+num+"Div";
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	newdiv.innerHTML = "<table width='240' cellpadding='0' cellspacing='0' border='0'><tr><td><select name='language"+num+"a' class='blueField' style='width:95px;'><option value='english'>English</option><option value='arabic' selected>Arabic</option><option value='chinese'>Chinese</option><option value='french'>French</option><option value='german'>German</option><option value='italian'>Italian</option><option value='japanese'>Japanese</option><option value='russian'>Russian</option><option value='spanish'>Spanish</option></select></td><td><select name='level"+num+"a' class='blueField' style='width:95px;'><option value='fuent1'>Fluent (Read / Write / Speak) </option><option value='fuent2'>Fluent (Speak) </option><option value='intermidiate'>Intermidiate (Speak) </option><option value='basic'>Basic (Speak) </option>	</select></td></tr></table>";
	
	ni.appendChild(newdiv);
}



function submitThisPage(){
	var ni = document.getElementById('myDiv2');
	var sectorId = document.myform.sector[document.myform.sector.selectedIndex].value;
	if(sectorId == ''){
		var stringSelect = 'Select the sector from above';
	}else{
		var stringSelect  = getSelect(sectorId);
	}
	ni.innerHTML = stringSelect;
}

function validateAddApplication(){
	
	var root = document.myform;
	var fname = root.first_name.value;
	if(fname == ''){
		alert('please insert first name');
		root.first_name.focus();
		return false;
	}
	var lname = root.last_name.value;
	if(lname == ''){
		alert('please insert last name');
		root.last_name.focus();
		return false;
	}
	var email=root.email.value;
	if(email==''){
		alert("Please specify an email address.");
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	var coResidence = root.country[root.country.selectedIndex].value;
	if(coResidence == ''){
		alert('Please select Country of residence.');
		root.country.focus();
		return false;
	}
	var address = root.address.value;
	if(address == ''){
		alert('Please insert address.');
		root.address.focus();
		return false;
	}
	var phoneN = root.phone.value;
	if(phoneN == ''){
		alert('Please insert the phone number.');
		root.phone.focus();
		return false;
	}
	var coBirth = root.Bcountry[root.Bcountry.selectedIndex].value;
	if(coBirth == ''){
		alert('Please select Country of birth.');
		root.Bcountry.focus();
		return false;
	}	
	var nationality = root.nationality[root.nationality.selectedIndex].value;
	if(nationality == ''){
		alert('Please select nationality.');
		root.nationality.focus();
		return false;
	}
	var age = root.age.value;
	if(isNaN(age) || age == ''){
		alert('Age must be numeric');
		root.age.focus();
		return false;
	}
	var quest = root.secret_question.value;
	if(quest == ''){
		alert('Insert Your Secret question.');
		root.secret_question.focus();
		return false;
	}
	
	var ans = root.secret_answer.value;
	if(ans == ''){
		alert('Insert Your Secret answer.');
		root.secret_answer.focus();
		return false;
	}
	
	var sector = root.sector[root.sector.selectedIndex].value;
	if(sector == ''){
		alert('Please select sector.');
		root.sector.focus();
		return false;
	}
	
	var subsector = root.subsector[root.subsector.selectedIndex].value;
	if(subsector == ''){
		alert('Please select subsector.');
		root.subsector.focus();
		return false;
	}
	var educationdegree = root.education_degree.value;
	if(educationdegree == ''){
		alert('Please select education degree.');
		root.education_degree.focus();
		return false;
	}
	var academic = root.academic[root.academic.selectedIndex].value;
	if(academic == ''){
		alert('Please select Academic Qualification.');
		root.academic.focus();
		return false;
	}
	var YoE = root.yearsExpirience.value;
	if(isNaN(YoE) || YoE == ''){
		alert('Years of Experience must be numeric');
		root.yearsExpirience.focus();
		return false;
	}
	var cv = root.cv.value;
	if(cv == ''){
		alert('Please Browse your CV.');
		root.cv.focus();
		return false;
	}

}


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");