var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            xmlhttp.overrideMimeType('text/html');
         }
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

///// For Search ///////////
var link1 = new Image();
var link2 = new Image();
var link3 = new Image();
var link4 = new Image();
////////////////////////////
/// about us ///
var link24 = new Image();
var link25 = new Image();
var link26 = new Image();
var link27 = new Image();
var link28 = new Image();
var link29 = new Image();
var link30 = new Image();
var link31 = new Image();
///////////////////////////

//////// For Search ////////
link1.src = "/images/search/search_form_cv_search.gif";
link2.src = "/images/search/search_form_cv_search_v.gif";
link3.src = "/images/search/search_form_job_search.gif";
link4.src = "/images/search/search_form_job_search_v.gif";
////////////////////////////
/// about us ///
link24.src = "/images/about_us/about_talent.gif";
link25.src = "/images/about_us/about_talent_v.gif";
link26.src = "/images/about_us/our_mission.gif";
link27.src = "/images/about_us/our_mission_v.gif";
link28.src = "/images/about_us/our_vision.gif";
link29.src = "/images/about_us/our_vision_v.gif";
link30.src = "/images/about_us/our_prayer.gif";
link31.src = "/images/about_us/our_prayer_v.gif";
///////////////////////////////////////////////

/////For LogIn Area///////
function check_login()
{
	var root = document.login;
	var username = root.username;
	var password = root.password;
	if(username.value == '' || username.value == 'Username')
	{
		alert('Please insert your username');
		username.focus();
		return false;
	}
	if(password.value == '' || password.value == 'Password')
	{
		alert('Please insert your password');
		password.focus();
		return false;
	}
	return true;
}
//////////////////////////
/////To check Username Availability///////
function checkUsername(){
	
	var username2 = document.employer_register.username;
	var username = document.employer_register.username.value;
	
	if(username ==''){
		alert("Please type a Username first.");
		username2.focus();
		return false;
	}
	window.open("/members/check.php?username="+username,"Check","width=200,height=100,top=400,left=400,scrollbars=no,toolbar=no,resizable=no,statusbar=no");

	return false;

}
//////////////////////////
/////To check Employer Registration///////
function validateEmployerRegister(){

	
	var root = document.employer_register;
	var username = root.username;
	var password = root.password;
	var confirm_password = root.confirm_password;
	var company_type = root.company_type;
	var company_logo = root.company_logo;
	var company_name = root.company_name;
	var company_industry = root.company_industry;
	var num_employee = root.num_employee;
	var profile_company_text = root.profile_company_text;
	var company_street_address = root.company_street_address;
	var company_city = root.company_city;
	//var company_state_province_emirate = root.company_state_province_emirate;
	//var company_zip = root.company_zip;
	//var company_postal_code = root.company_postal_code;
	var company_country = root.company_country;
	//var company_website_address = root.company_website_address;
	var first_name = root.first_name;
	var last_name = root.last_name;
	var job_title = root.job_title;
	var phone_number = root.phone_number;
	//var fax_number = root.fax_number;
	var employer_country = root.employer_country;
	var email = root.email;
	var confirm_email = root.confirm_email;
	var hiring_num_plan = root.hiring_num_plan;
	var hear_about_us = root.hear_about_us;
	var vcode = root.vcode;
	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	//var link_pattern = /^\w+([a-zA-Z0-9_-])+(\.[a-zA-ZZ0-9_-]+)+([a-zA-ZZ0-9\/_-]+)*$/;
	//var link_pattern = /^^(www\.)?.+\.[a-z]{2,}(/.+\..+\??.*=?.*&?)*$$/;
	var flag1 = email.value.match(email_pattern);
	var flag2 = confirm_email.value.match(email_pattern);
	//var flag3 = company_website_address.value.match(link_pattern);
	

	if(username.value ==''){
		alert("Please enter the username.");
		username.select();
		return false;
	}
	if(password.value ==''){
		alert("Please enter the password.");
		password.select();
		return false;
	}
	if(confirm_password.value ==''){
		alert("Please enter the password confirmation.");
		confirm_password.select();
		return false;
	}
	if(confirm_password.value != password.value){
		alert("The password and its confirmation do not match.");
		return false;
	}
	
	if(password.value.length<6){
		alert("The password should be more than 6 characters long.");
		return false;
	}
	if(company_type.value ==0){
		alert("Please select the company type.");
		company_type.focus();
		return false;
	}
//	if(company_logo.value ==''){
//		alert("Please browse for a company logo.");
//		company_logo.select();
//		return false;
//	}
	if(company_name.value ==''){
		alert("Please enter the company name.");
		company_name.select();
		return false;
	}
	if(company_industry.value ==''){
		alert("Please select the company industry.");
		company_industry.focus();
		return false;
	}
	if(num_employee.value ==''){
		alert("Please enter the number of employees.");
		num_employee.select();
		return false;
	}
	if(profile_company_text.value ==''){
		alert("Please enter the company profile text.");
		profile_company_text.select();
		return false;
	}
	if(company_street_address.value ==''){
		alert("Please enter the company street address.");
		company_street_address.select();
		return false;
	}
	if(company_city.value ==''){
		alert("Please enter the company city.");
		company_city.select();
		return false;
	}
	/*if(company_state_province_emirate.value ==''){
		alert("Please enter the company state/province/emirate.");
		company_state_province_emirate.select();
		return false;
	}
	if(company_zip.value ==''){
		alert("Please enter a zip code.");
		company_zip.select();
		return false;
	}
	if(company_postal_code.value ==''){
		alert("Please enter a postal code.");
		company_postal_code.select();
		return false;
	}*/
	if(company_country.value ==''){
		alert("Please select a country.");
		company_country.focus();
		return false;
	}
	/*if(company_website_address.value ==''){
		alert("Please enter the company website address.");
		company_website_address.select();
		return false;
	}
	if(!flag3){
		alert("Please enter a valid url link");
		email.focus();
		return false;
	}*/
	if(first_name.value ==''){
		alert("Please enter your first name.");
		first_name.select();
		return false;
	}
	if(last_name.value ==''){
		alert("Please enter your last name.");
		last_name.select();
		return false;
	}
	if(job_title.value ==''){
		alert("Please enter your job designation/title.");
		job_title.select();
		return false;
	}
	if(phone_number.value ==''){
		alert("Please enter the phone number.");
		phone_number.select();
		return false;
	}
	/*if(fax_number.value ==''){
		alert("Please enter the fax number.");
		fax_number.select();
		return false;
	}*/
	if(employer_country.value ==''){
		alert("Please select your country.");
		employer_country.focus();
		return false;
	}
	if(email.value ==''){
		alert("Please enter your email.");
		email.select();
		return false;
	}
	if(!flag1){
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	if(confirm_email.value ==''){
		alert("Please enter the email confirmation.");
		confirm_email.select();
		return false;
	}
	if(!flag2){
		alert("Please enter a valid email address");
		confirm_email.select();
		return false;
	}
	if(confirm_email.value != email.value){
		alert("The email and its confirmation do not match.");
		return false;
	}
	if(vcode.value ==''){
		alert("Please enter the visual code.");
		vcode.select();
		return false;
	}

	return true;

}
//////////////////////////
/////To prevent entering characters///////
function validChars(e,goods,typeId) {

	var key, keychar;

	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if(key==48){

	}
	if (key == null) return true;



	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
	return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27){
		return true;
	}

	return false;

}
////////////////Candidate Checking///////////
function validateAddProfile(){
	var root = document.add_profile;
	var first_name = root.first_name.value;
	if (first_name == ''){
		alert('Please enter your First Name');
		root.first_name.focus();
		return false;
	}
	var last_name = root.last_name.value;
	if (last_name == ''){
		alert('Please enter your Last Name');
		root.last_name.focus();
		return false;
	}
	var father_name = root.father_name.value;
	if (father_name == ''){
		alert('Please enter your Father\'s Name');
		root.father_name.focus();
		return false;
	}
	var year = root.year.value;
	var month = root.month.value;
	var day = root.day.value;
	if (year == '' || month == '' || day == ''){
		alert('Please select your Birth Date');
		return false;
	}
	var nationality = root.nationality.value;
	if (nationality == ''){
		alert('Please enter your Nationality');
		root.nationality.focus();
		return false;
	}
	var gender = root.gender.value;
	if (gender == ''){
		alert('Please select your Gender');
		root.gender.focus();
		return false;
	}
	var home_address_1 = root.home_address_1.value;
	if (home_address_1 == ''){
		alert('Please enter your Mailing Address');
		root.home_address_1.focus();
		return false;
	}
	var city = root.city.value;
	if (city == ''){
		alert('Please enter your City');
		root.city.focus();
		return false;
	}
	var country_id = root.country_id.value;
	if (country_id == ''){
		alert('Please select your Country');
		root.country_id.focus();
		return false;
	}
	var contact_preference_id = root.contact_preferences.value;
	if (contact_preference_id == ''){
		alert('Please select your prefered Contact Mode');
		root.contact_preferences.focus();
		return false;
	}
	if(contact_preference_id==1){
		var mobile_phone = root.mobile_phone.value;
	if (mobile_phone == ''){
		alert('Please enter your Mobile Phone');
		root.mobile_phone.focus();
		return false;
	}
	}
	var home_phone = root.home_phone.value;
	if (home_phone == ''){
		alert('Please enter your Home Phone');
		root.home_phone.focus();
		return false;
	}
	var personal_email = root.personal_email.value;
	if (personal_email == ''){
		alert('Please enter your Personal Email');
		root.personal_email.focus();
		return false;
	}
	var email_format_html = root.email_format_html.value;
	if (email_format_html == ''){
		alert('Please choose your prefered Email Format');
		root.email_format_html.focus();
		return false;
	}
	var username = root.username.value;
	if (username == ''){
		alert('Please choose a Username');
		root.username.focus();
		return false;
	}
	var password = root.password.value;
	if (password == ''){
		alert('Please enter a Password');
		root.password.focus();
		return false;
	}
	var confpassword = root.conf_password.value;
	if (confpassword == ''){
		alert('Please enter a Password Confirmation');
		root.conf_password.focus();
		return false;
	}
	if (!isNaN(password)) {
		alert('Please choose a password that contains characters.');
		root.password.select();
		return false;
	}
	if (password != confpassword) {
		alert('The password and its confirmation do not match.');
		return false;
	}
	var secretQuestionId = root.secret_questions.value;
	var secretQuestion = root.secret_question.value;
	if (secretQuestionId == '' && secretQuestion == '') {
		alert('Please either select a Secret Question or Enter your own');
		return false;
	}
	var secret_answer = root.secret_answer.value;
	if (secret_answer == ''){
		alert('Please enter an answer to your Secret Question');
		root.secret_answer.focus();
		return false;
	}
	var resume_type1 = root.resume_type[0].checked;
	var resume_type2 = root.resume_type[1].checked;
	var resume_type3 = root.resume_type[2].checked;
	if (!resume_type1 && !resume_type2 && !resume_type3){
		alert('Please select a Resume Type from "What Do You Want To Do Now" section');
		return false;
	}
	
	var thisnewpassword = hex_md5(password);
	root.password.value = thisnewpassword;
	root.conf_password.value = thisnewpassword;
	root.hashed.value = 'yes';
	
	return true;
}
////////////--------////////////////
function openCheckingValidity(){
	var root = document.add_profile;
	var username2 = root.username;
	var username = root.username.value;
	if(username2.value ==''){
		alert("Please type a Username first.");
		username2.focus();
		return false;
	}
	window.open("/users/check_username_validity.php?username="+username, "username", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=240,height=70,top=200,left=300");
	return false;
}
///////////-------------///////////////
function clearProfileForm() {
	var test = confirm('Are you sure you want to clear the whole form?');
	if (!test) return false;
	else {
		var root = document.add_profile;
		
		root.first_name.value = '';
		root.last_name.value = '';
		root.father_name.value = '';
		root.nationality.value = '';
		root.other_nationality.value = '';
		root.gender.value = '';
		root.home_address_1.value = '';
		root.home_address_2.value = '';
		root.city.value = '';
		root.state.value = '';
		root.zip_code.value = '';
		root.country_id.value = '';
		root.contact_preferences.value = '';
		root.mobile_phone.value = '';
		root.home_phone.value = '';
		root.work_phone.value = '';
		root.work_ext.value = '';
		root.work_email.value = '';
		root.personal_email.value = '';
		root.username.value = '';
		root.password.value = '';
		root.conf_password.value = '';
		root.secret_questions.value = '';
		root.secret_question.value = '';
		root.secret_answer.value = '';
		root.target_job_title.value = '';
		root.relevant_work_experience.value = '';
		root.career_level.value = '';
		root.military_required.checked = false;
		root.military_completed.checked = false;
		root.recieve_occasional_career.checked = false;
		root.resume_type[0].checked = false;
		root.resume_type[1].checked = false;
		root.resume_type[2].checked = false;
		
		root.n_candidates.checked = false;
		root.n_employers.checked = false;
		
		root.n_exclusive.checked = false;
		root.n_press.checked = false;
		root.n_special.checked = false;
		
		root.n_third.checked = false;
		root.n_sponsored.checked = false;
		//root.first_name.focus();
		return false;
	}
}
////////----------/////////////////////////
function passValidation(){
	var root = document.change_password;
	var oldp = root.old.value;
	var newp = root.newp.value;
	var confnew = root.confnew.value;
	
	if (oldp == '' || newp == '' || confnew == ''){
		alert('Please fill up all the fields');
		return false;
	}
	if (!isNaN(newp)){
		alert('Please insert a password that contains characters.');
		root.newp.focus();
		return false;
	}
	
	if (newp != confnew){
		alert('The password and it\'s confirmation do not match');
		root.confnew.focus();
		return false;
	}
	
	oldp = hex_md5(oldp);
	newp = hex_md5(newp);
	confnew = hex_md5(confnew);
	
	root.old.value = oldp;
	root.newp.value = newp;
	root.confnew.value = confnew;
	
	return true;
}
/////////--------------///////////////////
function validateEditProfile(){
	var root = document.add_profile;
	var first_name = root.first_name.value;
	if (first_name == ''){
		alert('Please enter your First Name');
		root.first_name.focus();
		return false;
	}
	var last_name = root.last_name.value;
	if (last_name == ''){
		alert('Please enter your Last Name');
		root.last_name.focus();
		return false;
	}
	var father_name = root.father_name.value;
	if (father_name == ''){
		alert('Please enter your Father\'s Name');
		root.father_name.focus();
		return false;
	}
	var year = root.year.value;
	var month = root.month.value;
	var day = root.day.value;
	if (year == '' || month == '' || day == ''){
		alert('Please select your Birth Date');
		return false;
	}
	var nationality = root.nationality.value;
	if (nationality == ''){
		alert('Please enter your Nationality');
		root.nationality.focus();
		return false;
	}
	var gender = root.gender.value;
	if (gender == ''){
		alert('Please select your Gender');
		root.gender.focus();
		return false;
	}
	var home_address_1 = root.home_address_1.value;
	if (home_address_1 == ''){
		alert('Please enter your Mailing Address');
		root.home_address_1.focus();
		return false;
	}
	var city = root.city.value;
	if (city == ''){
		alert('Please enter your City');
		root.city.focus();
		return false;
	}
	var country_id = root.country_id.value;
	if (country_id == ''){
		alert('Please select your Country');
		root.country_id.focus();
		return false;
	}
	var contact_preference_id = root.contact_preferences.value;
	if (contact_preference_id == ''){
		alert('Please select your prefered Contact Mode');
		root.contact_preferences.focus();
		return false;
	}
	var home_phone = root.home_phone.value;
	if (home_phone == ''){
		alert('Please enter your Home Phone');
		root.home_phone.focus();
		return false;
	}
	var personal_email = root.personal_email.value;
	if (personal_email == ''){
		alert('Please enter your Personal Email');
		root.personal_email.focus();
		return false;
	}
	var email_format_html = root.email_format_html.value;
	if (email_format_html == ''){
		alert('Please choose your prefered Email Format');
		root.email_format_html.focus();
		return false;
	}
	var secretQuestionId = root.secret_questions.value;
	var secretQuestion = root.secret_question.value;
	if (secretQuestionId == '' && secretQuestion == '') {
		alert('Please either select a Secret Question or Enter your own');
		return false;
	}
	var secret_answer = root.secret_answer.value;
	if (secret_answer == ''){
		alert('Please fill up the secret answer field');
		root.secret_answer.focus();
		return false;
	}
	return true;
}
///////////-------------------///////////////
function validateAddLanguageSkill(){
	var root = document.add_languageskill;
	var spoken_language_id = root.language_id.value;
	if (spoken_language_id == ''){
		alert('Please select a Spoken Language , or Click on "Skip" to go to the next item.');
		root.language_id.focus();
		return false;
	}
	var language_skills_proficiency_id = root.language_skill_proficiency_id.value;
	if (language_skills_proficiency_id == ''){
		alert('Please select a Language Proficiency');
		root.language_skill_proficiency_id.focus();
		return false;
	}
	return true;
}

function validateAddProfessionalSkill(){
	var root = document.add_professionalskill;
	var skill_name = root.skill_name.value;
	if (skill_name == ''){
		alert('Please enter a Skill Name, Or click "Skip to go to the next item.');
		root.skill_name.focus();
		return false;
	}
	var professional_skills_last_used_id = root.professional_skills_last_used_id.value;
	if (professional_skills_last_used_id == ''){
		alert('Please mention when did you last use this skill.');
		root.professional_skills_last_used_id.focus();
		return false;
	}
	var professional_skill_level_id = root.professional_skills_levels_id.value;
	if (professional_skill_level_id == ''){
		alert('Please specify your level in this skill');
		root.professional_skills_levels_id.focus();
		return false;
	}
	var years_of_experience = root.years_of_experience.value;
	if (isNaN(years_of_experience) || years_of_experience == ''){
		alert('Please specify your years of experience with this skill.');
		root.years_of_experience.select();
		return false;
	}
	return true;
}

function validateAddWorkExperience(){
	var root = document.add_workexperience;
	if (root.elements.length == 20) {
		var none = root.none.checked;
		if (none){
			return true;
		}
	}
	var company_name = root.company_name.value;
	if (company_name == ''){
		alert('Please enter a Company Name, Or click "Skip to go to the next item.');
		root.company_name.focus();
		return false;
	}
	var country_id = root.country_id.value;
	if (country_id == ''){
		alert('Please select a Country');
		root.country_id.focus();
		return false;
	}
	var job_title_id = root.job_title_id.value;
	if (job_title_id == ''){
		alert('Please select a Job Title');
		root.job_title_id.focus();
		return false;
	}
	var industry_id = root.industry_id.value;
	if (industry_id == ''){
		alert('Please select an Industry');
		root.industry_id.focus();
		return false;
	}
	var start_month = root.month.value;
	if (start_month == ''){
		alert('Please select a Start Month');
		root.month.focus();
		return false;
	}
	var start_year = root.year.value;
	if (start_year == ''){
		alert('Please select a Start Year');
		root.year.focus();
		return false;
	}
	var end_year = root.year2.value;
	if (end_year == ''){
		alert('Please select an End Year');
		root.end_year.focus();
		return false;
	}
	if (end_year != 0) {
		var end_month = root.month2.value;
		if (end_month == ''){
			alert('Please select an End Month');
			root.month2.focus();
			return false;
		}
	}
	var department = root.department.value;
	if (department == ''){
		alert('Please enter a Department');
		root.department.focus();
		return false;
	}
	var main_responsibilities = root.main_responsibilities.value;
	if (main_responsibilities == ''){
		alert('Please enter a Main Responsibility at least');
		root.main_responsibilities.focus();
		return false;
	}
	return true;
}
////////////////////////////////////////////
/////////////////////////////////////////////

//////////////////For Resume////////////////
function validateSendResume(){
	var root = document.send_resume;
	
	var to = root.to.value;
	var email = root.email.value;
	var from = root.from.value;
	if (to == '' || from == '' || email == '') {
		alert('Please fill up the obligatory fields.');
		return false;
	}
	return true;
}


function validateAddHeadline(){
	var root = document.add_headline;
	var title = root.title.value;
	if (title == ''){
		alert('Please enter a Headline for your resume.');
		root.title.focus();
		return false;
	}
	var headline_status_id1 = root.headline_status_id[0].checked;
	var headline_status_id2 = root.headline_status_id[1].checked;
	var headline_status_id3 = root.headline_status_id[2].checked;
	
	if (!headline_status_id1 && !headline_status_id2 && !headline_status_id3){
		alert('Please choose a status for your resume.');
		return false;
	}
	
	var headline_start_id = root.headline_start_id.value;
	var year = root.year.value;
	var month = root.month.value;
	var day = root.day.value;
	if (headline_start_id == '' && (year == ''||month == ''||day == '')) {
		alert('Please select an option or select a date for starting your job');
		return false;
	}
	
	if (headline_start_id != '' && (year != ''|| month != '' || day != '')) {
		return confirm('The option that you have selected for the date to start with your new job will be chosen. \n Do you want to continue?');
	}
	
	return true;
}


function validateAddHeadlineBeforePreview(id){
	var root = document.add_headline;
	var title = root.title.value;
	if (title == ''){
		alert('Please enter a Headline for your resume.');
		root.title.focus();
		return false;
	}
	var headline_status_id1 = root.headline_status_id[0].checked;
	var headline_status_id2 = root.headline_status_id[1].checked;
	var headline_status_id3 = root.headline_status_id[2].checked;
	
	if (!headline_status_id1 && !headline_status_id2 && !headline_status_id3){
		alert('Please choose a status for your resume.');
		return false;
	}
	
	var headline_start_id = root.headline_start_id.value;
	var year = root.year.value;
	var month = root.month.value;
	var day = root.day.value;
	if (headline_start_id == '' && (year == ''||month == ''||day == '')) {
		alert('Please select an option or select a date for starting your job');
		return false;
	}
	
	if (headline_start_id != '' && (year != ''|| month != '' || day != '')) {
		c = confirm('The option that you have selected for the date to start with your new job will be chosen. \n Do you want to continue?');
	}
	if (c==true)
	{	
		document.add_headline.action = "insert_headline.php";
		document.add_headline.target="_new";
		document.add_headline.submit();
	}
	
	return true;
}



////////////////----------------///////////
function openFullResume(id){
	window.open("/resume/display_full_resume.php?headline_id="+id, "resume", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=600,top=50,left=150");
	return false;
}
////////////----------------/////////////////
function validateAddEducation(){
	var root = document.add_education;
	
	if (root.length == 15) {
		var none = root.none.checked;
		if (none){
			return true;
		}
	}
	
	var college_uni_name = root.college_uni_name.value;
	if (college_uni_name == ''){
		alert('Please enter your School/College/University Name, Or click "Skip to go to the next item."');
		root.college_uni_name.focus();
		return false;
	}
	var country_id = root.country_id.value;
	if (country_id == ''){
		alert('Please select the country of your School/College/University Name.');
		root.country_id.focus();
		return false;
	}
	var educations_degree_level_id = root.degree_level_id.value;
	if (educations_degree_level_id == ''){
		alert('Please select a Degree Level');
		root.degree_level_id.focus();
		return false;
	}
	var end_year = root.year.value;
	if (end_year == ''){
		alert('Please select a Year');
		root.year.focus();
		return false;
	}
	if (end_year != 0) {
		var end_month = root.month.value;
		if (end_month == ''){
			alert('Please select a Month');
			root.month.focus();
			return false;
		}
	}
	return true;
}
////////////////////////////////////////////
///////////-------------//////////////////
function validateAddReference(){
	var root = document.add_reference;
	var name = root.name.value;
	if (name == ''){
		alert('Please enter a Name, Or click "Skip to go to the next item.');
		root.name.focus();
		return false;
	}
	var company = root.company.value;
	if (company == ''){
		alert('Please enter a Company');
		root.company.focus();
		return false;
	}
	var title = root.title.value;
	if (title == ''){
		alert('Please enter a Title');
		root.title.focus();
		return false;
	}
	var phone = root.phone.value;
	if (phone == ''){
		alert('Please enter a Phone');
		root.phone.focus();
		return false;
	}
	var email = root.email.value;
	if (email == ''){
		alert('Please enter an Email');
		root.email.focus();
		return false;
	}
	var reference_type_id1 = root.reference_type_id[0].checked;
	var reference_type_id2 = root.reference_type_id[1].checked;
	if (!reference_type_id1 && !reference_type_id2){
		alert('Please select a Reference Type');
		return false;
	}
	return true;
}

function validateAddAffiliationAndMembership(){
	var root = document.add_affiliationandmembership;
	var name = root.name.value;
	if (name == ''){
		alert('Please enter the Organization Name, Or click "Skip to go to the next item.');
		root.name.focus();
		return false;
	}
	var phone = root.phone.value;
	if (phone == ''){
		alert('Please enter the Organisation Phone');
		root.phone.focus();
		return false;
	}
	var affiliation = root.affiliation.value;
	if (affiliation == ''){
		alert('Please enter the Affiliation or Role');
		root.affiliation.focus();
		return false;
	}

	var start_month = root.month.value;
	
	if (start_month == ''){
		alert('Please  select a Start Month');
		root.month.focus();
		return false;
	}
	var start_year = root.year.value;
	if (start_year == ''){
		alert('Please select a Start Year');
		root.year.focus();
		return false;
	}
	
	var end_year = root.year2.value;
	if (end_year == ''){
		alert('Please select an End Year');
		root.year2.focus();
		return false;
	}
	if (end_year != 0) {
		var end_month = root.month2.value;
		if (end_month == '' || end_month == 0){
			alert('Please select an End Month');
			root.month2.focus();
			return false;
		}
	}
	if(end_year != 0){
		if(start_year>end_year)
		{
			alert('Please select a start date that is smaller than the end date');
			root.year.focus();
			return false;
		}
		if(start_year==end_year){
			if(start_month>end_month){
				alert('Please select a start date that is smaller than the end date');
				root.month.focus();
				return false;
			}
		}
	}
	return true;
}
function validateAddProfessionalTrainings(){
	var root = document.add_professionaltrainings;
	var none = root.none.checked;
	if (none){
		return true;
	}
	var training_institution = root.training_institution.value;
	if (training_institution == ''){
		alert('Please enter a name of the Training Institution, Or click "Skip to go to the next item.');
		root.training_institution.focus();
		return false;
	}
	var country_id = root.country_id.value;
	if (country_id == '' ){
		alert('Please select a Country');
		root.country_id.focus();
		return false;
	}
	var seminar = root.seminar.value;
	if (seminar == ''){
		alert('Please enter a Name of Seminar, Workshop or Program');
		root.seminar.focus();
		return false;
	}
	return true;
}
function professionalTrainingOnOff(){
	var root = document.add_professionaltrainings;
	
	var currentStatus = root.checkbox_status.value;
	
	if (currentStatus == 'on'){
		root.training_institution.style.backgroundColor='#D8D8D8';
		root.training_institution.disabled=true;

		root.city.style.backgroundColor='#D8D8D8';
		root.city.disabled=true;

		root.state.style.backgroundColor='#D8D8D8';
		root.state.disabled=true;

		root.country_id.style.backgroundColor='#D8D8D8';
		root.country_id.disabled=true;

		root.seminar.style.backgroundColor='#D8D8D8';
		root.seminar.disabled=true;

		root.year.style.backgroundColor='#D8D8D8';
		root.year.disabled=true;

		root.month.style.backgroundColor='#D8D8D8';
		root.month.disabled=true;
		
		root.completion_proof.style.backgroundColor='#FFFFFF';
		root.completion_proof.disabled=true;

		root.related_info.style.backgroundColor='#D8D8D8';
		root.related_info.disabled=true;
		
		root.checkbox_status.value = 'off';
	}
	
	else {
		root.training_institution.style.backgroundColor='#FFFFFF';
		root.training_institution.disabled=false;

		root.city.style.backgroundColor='#FFFFFF';
		root.city.disabled=false;

		root.state.style.backgroundColor='#FFFFFF';
		root.state.disabled=false;

		root.country_id.style.backgroundColor='#FFFFFF';
		root.country_id.disabled=false;

		root.seminar.style.backgroundColor='#FFFFFF';
		root.seminar.disabled=false;

		root.year.style.backgroundColor='#FFFFFF';
		root.year.disabled=false;

		root.month.style.backgroundColor='#FFFFFF';
		root.month.disabled=false;

		root.completion_proof.style.backgroundColor='#D8D8D8';
		root.completion_proof.disabled=false;
		
		root.related_info.style.backgroundColor='#FFFFFF';
		root.related_info.disabled=false;
		
		root.checkbox_status.value = 'on';
	}
}

function validateAddTargetJob(){
	var root = document.add_targetjob;
	
	var addedit =root.addedit.value;
	
	if (addedit=='edit'){
		var jobTypeSet = 0;
		for (var i = 1; i <= 5; i++) {
				temp = eval('root.job_type_'+i+'.checked');
				
				if (temp) jobTypeSet = 1;
			
			if (jobTypeSet == 0) {
				alert('Please check at least one Job Type');
				return false;
			}
			var jobStatusSet = 0;
			for (var j = 1; j <= 3; j++) {
				temp = eval('root.job_status_'+j+'.checked');
				if (temp) jobStatusSet = 1;
			}
			if (jobStatusSet == 0) {
				alert('Please check at least one Job Status ');
				return false;
			}
		}
		
		
		var salary = root.salary.value;
		
		if (isNaN(salary) && salary != '') {
			alert('Please enter a numeric Desired Salary/Wage');
			root.salary.select();
			return false;
		}
		var currency = root.currency_id.value;
		
		if (currency == '') {
			alert('Please select a currency');
			root.currency_id.focus();
			return false;
		}
		var per = root.per_id.value;
		if (per == '') {
			alert('Please select a Per value');
			root.per_id.focus();
			return false;
		}
		
		var relocate1 = root.relocate[0].checked;
		var relocate2 = root.relocate[1].checked;
		if (!relocate1 && !relocate2){
			alert('Please specify whether you would like to relocate or not');
			return false;
		}
		var travel_id = root.travel_id.value;
		if (travel_id == ''){
			alert('Please select whether you are willing to travel or not');
			root.travel_id.focus();
			return false;
		}
		
	/*	var industryCount = 0;
		
		for (var k = 0; k<root.elements[6].length; k++) {
				if (root.elements[6][k].selected) {
				industryCount++;
			}
		}
		if (industryCount < 1) {
			alert('Please select at least one industry');
			return false;
		}
		else if (industryCount > 5) {
			alert('A maximum of five industries is allowed.');
			return false;
		}
		var countryCount = 0;
		for (var l = 0; l<root.elements[7].length; l++) {
			if (root.elements[7][l].selected) 
			{
				countryCount++;
			}
		}
		if (countryCount < 1) {
			alert('Please select at least one country');
			return false;
		}
		else if (countryCount > 20) {
			alert('A maximum of twenty countries is allowed.');
			return false;
		}*/
	
	/*	var number =root.j.value;
		for(var k=0;k<number;k++){
			var name = eval('root.name'+k+'.value');
			if (name == '') {
				alert('Please specify a Target Job Name');
				return false;
			}		
			for (var i = 1; i <= 5; i++) {
				temp = eval('root.job_type_'+i+''+k+'.checked');
				if (temp) jobTypeSet = 1;
			}
			if (jobTypeSet == 0) {
				alert('Please check at least one Job Type');
				return false;
			}
			var jobStatusSet = 0;
			for (var j = 1; j <= 3; j++) {
				temp = eval('root.job_status_'+j+''+k+'.checked');
				if (temp) jobStatusSet = 1;
			}
			if (jobStatusSet == 0) {
				alert('Please check at least one Job Status ');
				return false;
			}
			var job_title_id = eval('root.job_title_id_'+k+'.value');
			if (job_title_id == ''){
				alert('Please select a Desired Job Title');
				return false;
			}
		}*/
			
	}
	else{
		
	var addanother= root.addanother.value;
	if(addanother=='no'){
		
		var temp;
		var jobTypeSet = 0;
		for (var i = 1; i <= 5; i++) {
		temp = eval('root.job_type_'+i+'.checked');
		if (temp) jobTypeSet = 1;
	}
	if (jobTypeSet == 0) {
		alert('Please check at least one Job Type');
		return false;
	}
	var jobStatusSet = 0;
	for (var j = 1; j <= 3; j++) {
		temp = eval('root.job_status_'+j+'.checked');
		if (temp) jobStatusSet = 1;
	}
	if (jobStatusSet == 0) {
		alert('Please check at least one Job Status ');
		return false;
	}
			
	var salary = root.salary.value;
	if (isNaN(salary) && salary != '') {
		alert('Please enter a numeric Desired Salary/Wage');
		root.salary.select();
		return false;
	}
	var currency = root.currency_id.value;
	if (currency == '') {
		alert('Please select a currency');
		root.currency_id.focus();
		return false;
	}
	var per = root.per_id.value;
	if (per == '') {
		alert('Please select a Per value');
		root.per_id.focus();
		return false;
	}
	
	/*var industryCount = 0;
	
	for (var k = 0; k<root.elements[5].length; k++) {
			if (root.elements[5][k].selected) {
			industryCount++;
		}
	}
	if (industryCount < 1) {
		alert('Please select at least one industry');
		return false;
	}
	else if (industryCount > 5) {
		alert('A maximum of five industries is allowed.');
		return false;
	}
	var countryCount = 0;
	for (var l = 0; l<root.elements[6].length; l++) {
		if (root.elements[6][l].selected) 
		{
			countryCount++;
		}
	}
	if (countryCount < 1) {
		alert('Please select at least one country');
		return false;
	}
	else if (countryCount > 20) {
		alert('A maximum of twenty countries is allowed.');
		return false;
	}*/
	var relocate1 = root.relocate[0].checked;
	var relocate2 = root.relocate[1].checked;
	if (!relocate1 && !relocate2){
		alert('Please specify whether you would like to relocate or not');
		return false;
	}
	var travel_id = root.travel_id.value;
	if (travel_id == ''){
		alert('Please select whether you are willing to travel or not');
		root.travel_id.focus();
		return false;
	}
	}
		
	

	}
		
	return true;
}

function validateAddTargetJobDetails(){
	var root = document.add_targetjob_details;
	
	var name=root.name.value;
	if(name==''){
		alert('Please specify a target job name, Or click "Skip to go to the next item.');
		root.name.focus();
		return false;
	}
	
	var job_title_id=root.job_title_id.value;
	if(job_title_id==''){
		alert('Please select a desired job title');
		root.job_title_id.focus();
		return false;
	}
	
	var industryCount = 0;
	
	for (var k = 0; k<root.elements[3].length; k++) {
			if (root.elements[3][k].selected) {
			industryCount++;
		}
	}
	if (industryCount < 1) {
		alert('Please select at least one industry');
		return false;
	}
	else if (industryCount > 5) {
		alert('A maximum of five industries is allowed.');
		return false;
	}
	var countryCount = 0;
	for (var l = 0; l<root.elements[4].length; l++) {
		if (root.elements[4][l].selected) 
		{
			countryCount++;
		}
	}
	if (countryCount < 1) {
		alert('Please select at least one country');
		return false;
	}
	else if (countryCount > 20) {
		alert('A maximum of twenty countries is allowed.');
		return false;
	}
	
}

function validateAddAdditionalInfo(){
	var root = document.add_additionalinfo;
	var subject = root.subject.value;
	if (subject == ''){
		alert('Please enter a Subject');
		root.subject.focus();
		return false;
	}
	var text = root.text.value;
	if (text == ''){
		alert('Please enter a Text');
		root.text.focus();
		return false;
	}
	return true;
}
////////////////////////////////////////////
////////////////For Updating Number of Questionnaire Answers/////////////////////
////////////////////////////////////////////
var last_chosen_answer=2;
function updateAnswersNumber(flag,flag2)
{

	
	last_chosen_answer2=1+ Number(last_chosen_answer);
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
		
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	last_chosen_answer=root.num_of_answers.value;
	
	
	if (flag2==1)
	{
	document.getElementById('div_answer_row2').innerHTML='';
	var answer_row = document.getElementById('answer_row');
	}
	else {
		var answer_row = document.getElementById('answer_row2');
	}
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	//var answer_row=document.getElementById('answer_row');
//	alert(last_chosen_answer2);
//	for(var i = last_chosen_answer2; i <= num_of_answers; i++){	
	for(var i = 3; i <= num_of_answers; i++){	
		 var z = i - 3; 		
		 
		 var row = answer_row.insertRow(z);
		 var a=row.insertCell(0);
		 var b=row.insertCell(1);
		 var c=row.insertCell(2);
		 a.width="15px";
		 b.width="140px";
		 c.width="415px";
		 c.style.height="27px";
		 c.valign ="top";
		 a.innerHTML="&nbsp;";
		 b.innerHTML="<span class=\"register_today_content_text\" id=\"answer_"+ i +"_title\">Answer "+i+"</span>";		
		 c.innerHTML="<input type=\"text\" name=\"answer_"+ i +"\" id=\"answer_"+ i +"\" size=\"35\" class=\"input_class\"/>";
		
	}	
}

function updateAnswersNumberForEdit(flag,counter)
{

	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
		
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	var answer_row = document.getElementById('answer_row');
	var answer_row2 = document.getElementById('answer_row2');
	var answer_row_length = answer_row.rows.length;
	var answer_row_length2 = answer_row2.rows.length;
//alert(answer_row_length);

//answer_row2.deleteRow(2);
//if (num_of_answers<counter)
//
//{
//	alert("here");
//	for (var i=counter;i >= num_of_answers;i--)
//	{
//	answer_row.deleteRow(i);	
//	}
//}
	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	if (counter!='')
	{
		
		var answer_row=document.getElementById('answer_row');
		if (parseInt(num_of_answers)<parseInt(counter))
		{
		
			counter=1;
			answer_row2.innerHTML = '&nbsp;';
			
		}else counter =answer_row_length2+1;
	}  
	
	for(var i = counter; i <= num_of_answers; i++){	
	
		 var z = i - counter; 		
		 var row = answer_row.insertRow(z);
		 var a=row.insertCell(0);
		 var b=row.insertCell(1);
		 var c=row.insertCell(2);
		 a.width="15px";
		 b.width="140px";
		 c.width="415px";
		 c.style.height="27px";
		 c.valign ="top";
		 a.innerHTML="&nbsp;";
		 b.innerHTML="<span class=\"register_today_content_text\">Answer "+i+"</span>";		
		 c.innerHTML="<input type=\"text\" name=\"answer_"+ i +"\" id=\"answer_"+ i +"\" size=\"35\" class=\"input_class\"/>";
		
	}	
}


function updateAnswersNumberForEditYesNo(flag,counter)
{
	//alert(counter);
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
		
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	var answer_row = document.getElementById('answer_row');
	var answer_row2 = document.getElementById('answer_row2');
	var answer_row_length = answer_row.rows.length;
	var answer_row_length2 = answer_row2.rows.length;
//alert(answer_row_length);

//answer_row2.deleteRow(2);
//if (num_of_answers<counter)
//
//{
//	alert("here");
//	for (var i=counter;i >= num_of_answers;i--)
//	{
//	answer_row.deleteRow(i);	
//	}
//}
	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	if (counter!='')
	{
	
		if (num_of_answers<counter)
		{
			counter=1;
			answer_row2.innerHTML = '';
			
		}else counter =answer_row_length2+1;
	} 
	var answer_row=document.getElementById('answer_row');
	for(var i = counter; i <= num_of_answers; i++){	
		 var z = i - counter; 		
		 var row = answer_row.insertRow(z);
		 var a=row.insertCell(0);
		 var b=row.insertCell(1);
		 var c=row.insertCell(2);
		 a.width="15px";
		 b.width="140px";
		 c.width="415px";
		 c.style.height="27px";
		 c.valign ="top";
		 a.innerHTML="&nbsp;";
		 b.innerHTML="<span class=\"register_today_content_text\">Answer "+i+"</span>";		
		 c.innerHTML="<input type=\"text\" name=\"answer_"+ i +"\" id=\"answer_"+ i +"\" size=\"35\" class=\"input_class\"/>";
		
	}	
}


function updateAnswersNumber2(flag)
{
	var answer_row_edit = document.getElementById('answer_row_edit');
	answer_row_edit.innerHTML='<tr><td></td></tr>';
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
		
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	var answer_row = document.getElementById('answer_row_edit');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	var answer_row=document.getElementById('answer_row_edit');
	for(var i = 3; i <= num_of_answers; i++){	
		 var z = i - 3; 		
		 var row = answer_row.insertRow(z);
		 var a=row.insertCell(0);
		 var b=row.insertCell(1);
		 var c=row.insertCell(2);
		 a.width="15px";
		 b.width="140px";
		 c.width="415px";
		 c.style.height="27px";
		 c.valign ="top";
		 a.innerHTML="&nbsp;";
		 b.innerHTML="<span class=\"register_today_content_text\">Answer "+i+"</span>";		
		 c.innerHTML="<input type=\"text\" name=\"answer_"+ i +"\" id=\"answer_"+ i +"\" size=\"35\" class=\"input_class\"/>";
		
	}	
}


function updateForYesNo(flag)
{
			var answers_num_title = document.getElementById('answers_num_title');
	var select_answers_num = document.getElementById('select_answers_num');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_2_title = document.getElementById('answer_2_title');
	select_answers_num.style.visibility='hidden';
	answers_num_title.style.visibility='hidden';
	answer_1_title.style.visibility='visible';
	answer_1_input.style.visibility='visible';
	answer_2_input.style.visibility='visible';
	answer_2_title.style.visibility='visible';
	
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
	
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	
	select_answers_num.innerHTML ="&nbsp;";
	answers_num_title.innerHTML ="&nbsp;";
	answer_1_title.innerHTML ="Answer 1";
	answer_2_title.innerHTML ="Answer 2";
	answer_1_input.innerHTML ="<input type=\"text\" name=\"answer_1\" size=\"35\" class=\"input_class\" />";
	answer_2_input.innerHTML ="<input type=\"text\" name=\"answer_2\" size=\"35\" class=\"input_class\" />";
	root.answer_1.readOnly = true;
	root.answer_2.readOnly = true;
	root.answer_1.value = 'Yes';
	root.answer_2.value = 'No';
}



function updateForYesNoEdit(flag)
{
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var yesno_table = document.getElementById('inputs_table');
	inputs_table.style.display="none";
//	var answer_1_title = document.getElementById('answer_1_title');
//	var answer_2_title = document.getElementById('answer_2_title');
//	var answer_1_input = document.getElementById('answer_1_input');
//	var answer_2_input = document.getElementById('answer_2_input');
	var answer_row = document.getElementById('answer_row');
	var answer_row2 = document.getElementById('div_answer_row2');
	answer_row.innerHTML = "";
	answer_row2.innerHTML = "";
	//answer_row2.innerHTML = "&nbsp;";
	var answer_row_length = answer_row.rows.length;
	//var answer_row_length2 = answer_row2.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	
//	if(answer_row_length2 != 0)
//	{
//		answer_row_length2--;
//		for(var i = answer_row_length2; i >= 0; i--){	
//			answer_row2.deleteRow(i);	
//		}
//	}
	
	select_answers_num.innerHTML ="&nbsp;";
	answers_num_title.innerHTML ="&nbsp;";

//	answer_1_title.innerHTML ="Answer 1";
//	answer_2_title.innerHTML ="Answer 2";
//	answer_1_input.innerHTML ="<input type=\"text\" name=\"answer_1\" size=\"35\" class=\"input_class\" />";
//	answer_2_input.innerHTML ="<input type=\"text\" name=\"answer_2\" size=\"35\" class=\"input_class\" />";
//	root.answer_1.readOnly = true;
//	root.answer_2.readOnly = true;
//	root.answer_1.value = 'Yes';
//	root.answer_2.value = 'No';
}






function updateForMultiple(flag)
{
	if(flag == '0'){	
		//alert('hi');	
		var root = document.insert_question;
	}
	else{
		//alert('hiii');
		var root = document.update_question;
	}
	
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	
	select_answers_num.innerHTML ="<select name=\"num_of_answers\" class=\"input_class\" onChange=\"updateAnswersNumber("+flag+");\"/><option value=\"2\" selected>2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select>";
	answers_num_title.innerHTML ="Number of Answers";
	answer_1_title.innerHTML ="Answer 1";
	answer_2_title.innerHTML ="Answer 2";
	answer_1_input.innerHTML ="<input type=\"text\" name=\"answer_1\" size=\"35\" class=\"input_class\" />";
	answer_2_input.innerHTML ="<input type=\"text\" name=\"answer_2\" size=\"35\" class=\"input_class\" />";
}


function updateForMultiple(flag)
{
	
		var answers_num_title = document.getElementById('answers_num_title');
	var select_answers_num = document.getElementById('select_answers_num');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_2_title = document.getElementById('answer_2_title');
	select_answers_num.style.visibility='visible';
	answers_num_title.style.visibility='visible';
	answer_1_title.style.visibility='visible';
	answer_1_input.style.visibility='visible';
	answer_2_input.style.visibility='visible';
	answer_2_title.style.visibility='visible';
	if(flag == '0'){	
		//alert('hi');	
		var root = document.insert_question;
	}
	else{
		//alert('hiii');
		var root = document.update_question;
	}
	
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	
	select_answers_num.innerHTML ="<select name=\"num_of_answers\" class=\"input_class\" onChange=\"updateAnswersNumber("+flag+");\"/><option value=\"2\" selected>2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select>";
	answers_num_title.innerHTML ="Number of Answers";
	answer_1_title.innerHTML ="Answer 1";
	answer_2_title.innerHTML ="Answer 2";
	answer_1_input.innerHTML ="<input type=\"text\" name=\"answer_1\" size=\"35\" class=\"input_class\" />";
	answer_2_input.innerHTML ="<input type=\"text\" name=\"answer_2\" size=\"35\" class=\"input_class\" />";
}



function updateForMultipleUnique(flag)
{


	if(flag == '0'){	
		//alert('hi');	
		var root = document.insert_question;
	}
	else{
		//alert('hiii');
		var root = document.update_question;
	}
	var answer_row2 = document.getElementById('div_answer_row2');
	answer_row2.innerHTML = "&nbsp";
	var inputs_table = document.getElementById('inputs_table');
	inputs_table.style.display = 'block';
	var select_answers_num = document.getElementById('select_answers_num');
	select_answers_num.style.visibility='visible';
	var answers_num_title = document.getElementById('answers_num_title');
	answers_num_title.style.visibility='visible';
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;

	if(answer_row_length != 0)
	{
		answer_row_length--;
		for(var i = answer_row_length; i >= 0; i--){	
			answer_row.deleteRow(i);	
		}
	}
	
	select_answers_num.innerHTML ="<select id=select_answers_num name=\"num_of_answers\" class=\"input_class\" onChange=\"updateAnswersNumber("+flag+",1);\"/><option value=\"2\" selected>2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option></select>";
	answers_num_title.innerHTML ="Number of Answers";
	answer_1_title.innerHTML ="Answer 1";
	answer_2_title.innerHTML ="Answer 2";
	answer_1_input.innerHTML ="<input type=\"text\" name=\"answer_1\" size=\"35\" class=\"input_class\" />";
	answer_2_input.innerHTML ="<input type=\"text\" name=\"answer_2\" size=\"35\" class=\"input_class\" />";
}


function updateForText(flag)
{
	if(document.getElementById('answer_row')){
		var answer_row = document.getElementById('answer_row');
		var answer_row_length = answer_row.rows.length;
		for(var i = answer_row_length-1; i >= 0; i--){
			answer_row.deleteRow(i);
		}
		
	}
	
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
	
	var answers_num_title = document.getElementById('answers_num_title');
	var select_answers_num = document.getElementById('select_answers_num');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_input = document.getElementById('answer_2_input');
	var answer_2_title = document.getElementById('answer_2_title');
	
	select_answers_num.style.visibility='hidden';
	answers_num_title.style.visibility='hidden';
	answer_1_title.style.visibility='hidden';
	answer_1_input.style.visibility='hidden';
	answer_2_input.style.visibility='hidden';
	answer_2_title.style.visibility='hidden';
}

function updateForTextEdit(flag)
{
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
	var answer_row = document.getElementById('answer_row');
	answer_row.innerHTML = "&nbsp;";
	
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	
	select_answers_num.innerHTML ="&nbsp;";
	answers_num_title.innerHTML ="&nbsp;";
	answer_1_title.innerHTML ="&nbsp;";
	answer_2_title.innerHTML ="&nbsp;";
	answer_1_input.innerHTML ="&nbsp;";
	answer_2_input.innerHTML ="&nbsp;";
}


function updateForTextUnique(flag)
{
	if(flag == '0'){	
		var root = document.insert_question;
	}
	else{
		var root = document.update_question;
	}
	var answer_row = document.getElementById('answer_row');
	answer_row.innerHTML = "&nbsp;"
	var answer_row2 = document.getElementById('answer_row2');
	answer_row2.innerHTML = "&nbsp;"
	
	var select_answers_num = document.getElementById('select_answers_num');
	var answers_num_title = document.getElementById('answers_num_title');
	var answer_1_title = document.getElementById('answer_1_title');
	var answer_2_title = document.getElementById('answer_2_title');
	var answer_1_input = document.getElementById('answer_1_input');
	var answer_2_input = document.getElementById('answer_2_input');
	
	select_answers_num.innerHTML ="&nbsp;";
	answers_num_title.innerHTML ="&nbsp;";
	answer_1_title.innerHTML ="&nbsp;";
	answer_2_title.innerHTML ="&nbsp;";
	answer_1_input.innerHTML ="&nbsp;";
	answer_2_input.innerHTML ="&nbsp;";
}


function validateAddQuestionnaireAndQuestion(flag)
{
	var root = document.insert_question;
	var question = root.question;
	var answer_1 = root.answer_1;
	var answer_2 = root.answer_2;
	
	if(flag == 0)
	{
		var questionnaire_title = root.questionnaire_title;
		if(questionnaire_title.value =='')
		{
			alert("Please enter the quesitonnaire title.");
			questionnaire_title.select();
			return false;
		}
	}
	if(question.value =='')
	{
		alert("Please enter the question.");
		question.select();
		return false;
	}
	//var root = document.insert_question;
	var multi_unique_radio = document.getElementById('multi_unique_radio');
	var multi_many_radio = document.getElementById('multi_many_radio');
	var multi_yes_no_radio = document.getElementById('multi_yes_no_radio');
	var text_field_radio = document.getElementById('text_field_radio');
	var multi_text_field_radio = document.getElementById('multi_text_field_radio');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	var valid =0;
	
	if(multi_unique_radio.checked == true || multi_many_radio.checked == true)
	{
		if(answer_1.value =='')
		{
			alert("Please fill all the answers.");
			answer_1.select();
			return false;
		}
		if(answer_2.value =='')
		{
			alert("Please fill all the answers.");
			answer_2.select();
			return false;
		}
		
		var answer_array = new Array();
		for(var i=3;i<=num_of_answers;i++)
		{
			z = i-3;
			answer_array[z] = eval("document.getElementById('answer_"+i+"').value;");
		}
		
		var a = 3;
		for(var i=0; i<=answer_array.length;i++){
			if(answer_array[i]=='')
			{
				
				alert("Please fill all the answers");
				return false;
				a++;
				valid=1;
				break;
			}
		}
		if(valid == 1){
			return false;
		}
	}		
}

function validateAddQuestionnaireAndQuestionForEdit()
{
	var root = document.update_question;
	var question = root.question;
	var answer_1 = root.answer_1;
	var answer_2 = root.answer_2;
	
	
	if(question.value =='')
	{
		alert("Please enter the question.");
		question.select();
		return false;
	}
	//var root = document.insert_question;
	var multi_unique_radio = document.getElementById('multi_unique_radio');
	var multi_many_radio = document.getElementById('multi_many_radio');
	var multi_yes_no_radio = document.getElementById('multi_yes_no_radio');
	var text_field_radio = document.getElementById('text_field_radio');
	var multi_text_field_radio = document.getElementById('multi_text_field_radio');
	var answer_row = document.getElementById('answer_row');
	var answer_row_length = answer_row.rows.length;
	var num_of_answers = root.num_of_answers[root.num_of_answers.selectedIndex].value;
	var valid =0;
	
	if(multi_unique_radio.checked == true || multi_many_radio.checked == true)
	{
		if(answer_1.value =='')
		{
			alert("Please fill all the answers.");
			answer_1.select();
			return false;
		}
		if(answer_2.value =='')
		{
			alert("Please fill all the answers.");
			answer_2.select();
			return false;
		}
		
		var answer_array = new Array();
		for(var i=3;i<=num_of_answers;i++)
		{
			z = i-3;
			answer_array[z] = eval("document.getElementById('answer_"+i+"').value;");
		}
		
		var a = 3;
		for(var i=0; i<=answer_array.length;i++){
			if(answer_array[i]=='')
			{
				
				alert("Please fill all the answers");
				return false;
				a++;
				valid=1;
				break;
			}
		}
		if(valid == 1){
			return false;
		}
	}		
}

////////////////////////////////////////////
////////////////////////////////////////////

function validateAddProject(){
	var root = document.add_project;
	var project_title = root.project_title.value;
	if (project_title == ''){
		alert('Please enter a Project Title, Or click "Skip to go to the next item.');
		root.project_title.focus();
		return false;
	}
	var project_type = root.project_type.value;
	if (project_type == ''){
		alert('Please enter a Project Type');
		root.project_type.focus();
		return false;
	}
	var project_description = root.project_description.value;
	if (project_description == ''){
		alert('Please enter a Project Description');
		root.project_description.focus();
		return false;
	}
	var year = root.year.value;
	var month = root.month.value;
	var day = root.day.value;
	if (year == ''||month==''||day==''){
		alert('Please select a Begin Date');
		return false;
	}
	var year = root.year2.value;
	var month = root.month2.value;
	var day = root.day2.value;
	if (year != '0') {
		if (year == ''||month==''||day==''){
			alert('Please select an End Date');
			return false;
		}
	}
	var purpose_id1 = root.purpose_id[0].checked;
	var purpose_id2 = root.purpose_id[1].checked;
	var purpose_id3 = root.purpose_id[2].checked;
	if (!purpose_id1 && !purpose_id2  && !purpose_id3){
		alert('Please select a Purpose');
		return false;
	}
	var sold1 = root.sold[0].checked;
	var sold2 = root.sold[1].checked;
	if (!sold1 && !sold2){
		alert('Please specify whether the project has been Sold or Not');

		return false;
	}
	
	
	return true;
}


////////////////////////////////////////////
//////Job Post Form
///////////////////////////////////////////
function validateAddJobPost()
{

	var root = document.add_job_post;
	var title = root.title;
	var industry = document.getElementById("industry");
	var job_location = document.getElementById("job_location");
	var description = root.description;
//	var employment_type_employee = root.employment_type_employee;
//	var employment_type_project = root.employment_type_project;
//	var employment_type_temporary = root.employment_type_temporary;
//	var employment_type_seasonal = root.employment_type_seasonal;
//	var employment_type_contract = root.employment_type_contract;
//	var employment_type_no_preference = root.employment_type_no_preference;	
//	var minimum_salary = root.minimum_salary;
//	var currency = root.currency;
//	var hire_year = root.hire_year;
//	var hire_month = root.hire_month;
//	var career_level = root.career_level;
//	var relevant_work_experience = root.relevant_work_experience;
//	var residence = root.residence;
//	var gender = root.gender;
//	var degree = root.degree;
//	var skills = root.skills;
//	var first_name = root.first_name;
//	var last_name = root.last_name;
//	var job_title = root.job_title;
//	var phone_number = root.phone_number;
//	var fax_number = root.fax_number;
//	var employer_country = root.employer_country;
//	var email = root.email;
//	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
//	var flag1 = email.value.match(email_pattern);
	var vcode = root.vcode;
	
	if(title.value ==''){
		alert("Please enter the job title.");
		title.select();
		return false;
	}
	if(industry.value ==''){
		alert("Please select the job industry.");
		industry.focus();
		return false;
	}
	if(job_location.value ==''){
		alert("Please select the job location.");
		job_location.focus();
		return false;
	}
//	if(description.value ==''){
//		alert("Please enter the job description.");
//		description.select();
//		return false;
//	}
	if (vcode.value=='')
	{
		alert("Please enter the visual code.");
		vcode.focus();
		return false;
	}
	
//	if(employment_type_employee.checked == false && employment_type_project.checked == false && employment_type_temporary.checked == false && employment_type_seasonal.checked == false && employment_type_contract.checked == false && employment_type_no_preference.checked == false){
//		alert("Please fdfdcription.");
//		description.select();
//		return false;
//	}	
//	if(minimum_salary.value ==''){
//		alert("Please select the minimum salary");
//		minimum_salary.focus();
//		return false;
//	}
//	if(currency.value ==''){
//		alert("Please select the currency.");
//		currency.focus();
//		return false;
//	}
//	if(hire_year.value ==''){
//		alert("Please enter the target start year.");
//		hire_year.focus();
//		return false;
//	}
//	if(hire_month.value ==''){
//		alert("Please enter the target start month.");
//		hire_month.focus();
//		return false;
//	}
//	if(career_level.value ==''){
//		alert("Please select the career level.");
//		career_level.focus();
//		return false;
//	}
//	if(relevant_work_experience.value ==''){
//		alert("Please select the years of experience.");
//		relevant_work_experience.focus();
//		return false;
//	}
//	if(residence.value ==''){
//		alert("Please select the residence location.");
//		residence.focus();
//		return false;
//	}
//	if(gender.value ==''){
//		alert("Please select a gender.");
//		gender.select();
//		return false;
//	}
//	if(degree.value ==''){
//		alert("Please select a degree.");
//		degree.focus();
//		return false;
//	}
//	if(skills.value ==''){
//		alert("Please enter the skills required.");
//		skills.select();
//		return false;
//	}
//	if(first_name.value ==''){
//		alert("Please enter your first name.");
//		first_name.select();
//		return false;
//	}
//	if(last_name.value ==''){
//		alert("Please enter your last name.");
//		last_name.select();
//		return false;
//	}
//	if(job_title.value ==''){
//		alert("Please enter your job title/designation.");
//		job_title.select();
//		return false;
//	}
//	if(phone_number.value ==''){
//		alert("Please enter the phone number.");
//		phone_number.select();
//		return false;
//	}
//	if(fax_number.value ==''){
//		alert("Please enter the fax number.");
//		fax_number.select();
//		return false;
//	}
//	if(employer_country.value ==''){
//		alert("Please select your country.");
//		employer_country.focus();
//		return false;
//	}
//	if(email.value ==''){
//		alert("Please enter your email.");
//		email.select();
//		return false;
//	}
//	if(!flag1){
//		alert("Please enter a valid email address");
//		email.focus();
//		return false;
//	}
//	if(confirm_email.value ==''){
//		alert("Please enter the email confirmation.");
//		confirm_email.select();
//		return false;
//	}
	//document.add_job_post.go_x.value='1';

	return true;
}
////////////////////////////////////////////
//////Validate Password Recovery
///////////////////////////////////////////
function  validateRecovery(){
	
	var root = document.password_rec;
	var email = root.email;
	var username = root.username;
	
	if(username.value ==''){
		alert("Please enter your username.");
		username.focus();
		return false;
	}
	if(email.value ==''){
		alert("Please enter your email.");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2)
	{
		alert("Please enter a valid E-mail address.");
		email.focus();
		return false;
	}
	return true;
}
////////////////////////////////////////////
//////Validate Advanced Job Search
///////////////////////////////////////////
function validateAdvancedJobSearch()
{
	var root = document.adv_job_search;
	var keyword = root.keyword;
	
	if(keyword.value == "")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	return true;
}
function check_quick_job_search()
{
	var root = document.quick_job_search;
	var keyword = root.keyword;
	
	if(keyword.value == "")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	return true;
}
function check_quick_search()
{
	var root = document.quick_search;
	var keyword = root.keyword;
	
	if(keyword.value == "" || keyword.value == "Search")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	return true;
}

function validateJobAgent()
{
	var root = document.job_agent;
	var keyword = root.keyword;
	var job_agent_name = root.job_agent_name;
	var minimum_salary = root.minimum_salary;
	var currency = root.currency;
	
	if(job_agent_name.value == "")
	{
		alert('Please enter a name for the job agent.');
		return false;
	}
	if(keyword.value == "")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	if(minimum_salary.value != '' && currency.value == '')
	{
		alert('Please specify the minimum salary with its currency.');
		minimum_salary.focus();
		return false;
	}
	if(minimum_salary.value == '' && currency.value != '')
	{
		alert('Please specify the minimum salary with its currency.');
		minimum_salary.focus();
		return false;
	}
	return true;
}


function validateAdvancedResumeSearch()
{
	var root = document.advanced_resume;
	var keyword = root.keyword;
	var residence = root.elements[4];
	var job_location = root.elements[16];
	var industry = root.elements[17];
	var experience_location = root.elements[34];
	var languages = root.elements[40];
	var education_location = root.elements[42];
	var minimum_salary = root.minimum_salary;
	var maximum_salary = root.maximum_salary;
	var currency = root.currency;
	var pers = root.pers;
	
	if(keyword.value == "")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	
	var a = 0;
	var residence_num = residence.length;
	for(var i=0;i<residence_num;i++)
	{
		if(residence[i].selected == true){
			a++;
		}
	}
	//alert(a);return false;
	if(a > 10){
		alert("You can choose up to 10 residence locations.");
		residence.focus();
		return false;	
	}
	var b = 0;
	var job_location_num = job_location.length;
	for(var i=0;i<job_location_num;i++)
	{
		if(job_location[i].selected == true){
			b++;
		}
	}
	//alert(c);return false;
	if(b > 10){
		alert("You can choose up to 10 job locations.");
		job_location.focus();
		return false;	
	}
	var c = 0;
	var industry_num = industry.length;
	for(var i=0;i<industry_num;i++)
	{
		if(industry[i].selected == true){
			c++;
		}
	}
	
	var salary_counter = 0;
	
	if(minimum_salary.value != '')
		salary_counter++;
	if(maximum_salary.value != '')
		salary_counter++;
	if(currency.value != '')
		salary_counter++;
	if(pers.value != '')
		salary_counter++;
		
	if(salary_counter > 0 && salary_counter < 4)
	{
		alert("You need to specify all the salary requirements.");
		minimum_salary.focus();
		return false;	
	}
	if(minimum_salary.value != '' && maximum_salary.value != '')
	{
		//alert(minimum_salary.value);return false;
		//alert(maximum_salary.value);return false;
		var min = parseInt(minimum_salary.value); 
		var max = parseInt(maximum_salary.value);
		//alert(''+min+''+max);return false; 
		if(min >= max){
			alert("The minimum salary must be less than the maximum one.");
			//minimum_salary.focus();
			return false;
		}
	}

	//alert(c);return false;
	if(c > 10){
		alert("You can choose up to 10 industries.");
		industry.focus();
		return false;	
	}
	var d = 0;
	var experience_location_num = experience_location.length;
	for(var i=0;i<experience_location_num;i++)
	{
		if(experience_location[i].selected == true){
			d++;
		}
	}
	//alert(d);return false;
	if(d > 10){
		alert("You can choose up to 10 experience locations.");
		experience_location.focus();
		return false;	
	}
	
	var e = 0;
	var languages_num = languages.length;
	for(var i=0;i<languages_num;i++)
	{
		if(languages[i].selected == true){
			e++;
		}
	}
	//alert(e);return false;
	if(e > 10){
		alert("You can choose up to 10 languages.");
		languages.focus();
		return false;	
	}
	
	var f = 0;
	var education_location_num = education_location.length;
	for(var i=0;i<education_location_num;i++)
	{
		if(education_location[i].selected == true){
			f++;
		}
	}
	//alert(c);return false;
	if(f > 10){
		alert("You can choose up to 10 education locations.");
		education_location.focus();
		return false;	
	}
	
	
	return true;
}

function validateResumeFilter()
{
	var root = document.resume_filter;
	var minimum_salary = root.minimum_salary;
	var maximum_salary = root.maximum_salary;
	var currency = root.currency;
	var pers = root.pers;
	var job_location = root.job_location;
	var age_range = root.age_range;
	var gender = root.gender;
	var industry = root.industry;
	
	if(minimum_salary.value == "" && maximum_salary.value == "" && currency.value == "" && pers.value == "" && job_location.value == "" && age_range.value == "" && gender.value == "" && industry.value == "")
	{
		alert("Please specify at least one criteria to filter with.");
		return false;	
	}
	

	var salary_counter = 0;
	
	if(minimum_salary.value != '')
		salary_counter++;
	if(maximum_salary.value != '')
		salary_counter++;
	if(currency.value != '')
		salary_counter++;
	if(pers.value != '')
		salary_counter++;
		
	if(salary_counter > 0 && salary_counter < 4)
	{
		alert("You need to specify all the salary requirements.");
		minimum_salary.focus();
		return false;	
	}
	if(minimum_salary.value != '' && maximum_salary.value != '')
	{
		var min = parseInt(minimum_salary.value); 
		var max = parseInt(maximum_salary.value);
	
		if(min >= max){
			alert("The minimum salary must be less than the maximum one.");
			return false;
		}
	}

	return true;
}






function check_quick_cv_search()
{
	var root = document.quick_cv_search;
	var keyword = root.keyword;
	
	if(keyword.value == "")
	{
		alert('Please enter a keyword.');
		keyword.select();
		return false;
	}
	if(keyword.value.length < 3)
	{
		alert('The keyword provided must be more than 3 characters.');
		keyword.select();
		return false;
	}
	
	
}
//////contact form//////////////
function validateContactForm(){
	var first = document.contact;
	var firstName = first.firstName;
	var lastName = first.lastName;
	var comp = first.Company;
	var country = first.country_id[first.country_id.selectedIndex].value;
	var mobile = first.mobile;
	var mail = first.email;
	//var servic = first.service[first.service.selectedIndex].value;
	var desc = first.desc;
	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	
	if(firstName.value == ''){
		alert("Please insert first name.");
		firstName.focus();
		return false;
	}
	if(lastName.value == ""){
		alert("Please insert last name.");
		lastName.focus();
		return false;
	}
	if(comp.value == ""){
		alert("Please insert your company name.");
		comp.focus();
		return false;
	}
	if(country == ""){
		alert("please select your country");
		first.country_id.focus();	
		return false;
	}
	if(mobile.value == ""){
		alert("please insert your mobile number");
		mobile.focus();	
		return false;
	}
	if(mail.value == ""){
		alert("please insert your email address");
		mail.focus();	
		return false;
	}
	var flag1 = mail.value.match(email_pattern);
	if(!flag1){
		alert("Please enter a valid email address");
		mail.focus();
		return false;
	}
	if(desc.value == ""){
		alert("Please indicate how can we be of service Or what info you require");
		desc.focus();
		return false;	
	}	
}
function clearContactForm() {
	var test = confirm('Are you sure you want to empty the fields above?');
	if (!test) return false;
	
	var root = document.contact;
	
	root.firstName.value = '';
	root.lastName.value = '';
	root.Company.value = '';
	root.Street.value = '';
	root.city.value = '';
	root.country_id.value = '';
	root.mobile.value = '';
	root.office_phone.value = '';
	root.ext.value = '';
	root.email.value = '';
	//root.service.value = '';
	root.desc.value = '';
	return false;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////
//////For Employer////////////////////
///////////////////////////////////////
function changejobpostingbgcolor(td_id,href_id,flag)
{
	var td_id_2 = document.getElementById(td_id);
	var href_id_2 = document.getElementById(href_id);
	if(flag == 1)
	{
		td_id_2.style.backgroundColor = '#FF7700';
		href_id_2.style.backgroundColor = '#FF7700';
	}
	else
	{
		td_id_2.style.backgroundColor = '#FFA101';
		href_id_2.style.backgroundColor = '#FFA101';
	}
}
function check_edit_employer(flag)
{
	switch (flag)
	{
		case 1:
		var return_value = check_edit_employer_profile();
		return return_value;
		break;
		case 2:
		var return_value = check_edit_employer_password();
		return return_value;
		break;
		case 3:
		var return_value = check_edit_employer_company_profile();
		return return_value;
		break;
		case 4:
		var return_value = check_edit_employer_company_logo();
		return return_value;
		break;
	}
}
function check_edit_employer_profile()
{
	var root = document.edit_employer;
	var username = root.username;
	var first_name = root.first_name;
	var last_name = root.last_name;
	var job_title = root.job_title;
	//var phone = root.phone;
	//var fax = root.fax;
	var mail = root.email;
	var employer_country = root.employer_country;
	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	
	if(username.value == ""){
		alert("please insert a username");
		username.focus();	
		return false;
	}
	if(first_name.value == ""){
		alert("please insert your First Name");
		first_name.focus();	
		return false;
	}
	if(last_name.value == ""){
		alert("please insert your Last Name");
		last_name.focus();	
		return false;
	}
	if(job_title.value == ""){
		alert("please insert your Job Title");
		job_title.focus();	
		return false;
	}
	/*if(phone.value == ""){
		alert("please insert your Phone Number");
		phone.focus();	
		return false;
	}*/
	/*if(fax.value == ""){
		alert("please insert your Fax Number");
		fax.focus();	
		return false;
	}*/
	if(employer_country.value == ""){
		alert("please select your Country");
		employer_country.focus();	
		return false;
	}
	if(mail.value == ""){
		alert("please insert your email address");
		mail.focus();	
		return false;
	}
	var flag1 = mail.value.match(email_pattern);
	if(!flag1){
		alert("Please enter a valid email address");
		mail.select();
		return false;
	}
	return true;
}
function check_edit_employer_password()
{

	var root = document.edit_employer;
	var old_pass = root.old_pass;
	var new_pass = root.new_pass;
	var confirm_pass = root.confirm_pass;
	
	if(old_pass.value == ""){
		alert("please insert your old password");
		old_pass.focus();	
		return false;
	}
	if(new_pass.value == ""){
		alert("please insert your new password");
		new_pass.focus();	
		return false;
	}
	if(new_pass.value.length < 6){
		alert("The password should be more than 6 characters long.");
		new_pass.focus();	
		return false;
	}
	if(confirm_pass.value == ""){
		alert("please insert your confirmation password");
		confirm_pass.focus();	
		return false;
	}
	if(new_pass.value != confirm_pass.value){
		alert("the new password and its confirmation does not match");
		confirm_pass.select();	
		return false;
	}
	
	return true;
}
function check_edit_employer_company_profile()
{
	var root = document.edit_employer;
	var company_profile = root.company_profile;
	
	if(company_profile.value == ""){
		alert("please insert your company profile");
		company_profile.focus();	
		return false;
	}
	return true;
}
function check_edit_employer_company_logo()
{
	var root = document.edit_employer;
	var company_logo = root.company_logo;
	
	if(company_logo.value == ""){
		alert("please browse your company logo");
		company_logo.focus();	
		return false;
	}
	return true;
}
function checkUsernameForUpdate(id){
	
	var username = document.edit_employer.username;
	
	if(username.value ==''){
		alert("Please type a Username first.");
		username.focus();
		return false;
	}
	window.open("/members/check.php?id="+id+"&username="+username.value,"Check","width=200,height=100,top=400,left=400,scrollbars=no,toolbar=no,resizable=no,statusbar=no");

	return false;

}
function letter_form_check()
{
	var root = document.letter_form;
	var title = root.title;
	var letter = root.letter;
	
	if(title.value == ""){
		alert("please insert a title");
		title.focus();	
		return false;
	}
//	if(letter.value == ""){
//		alert("please insert your letter");
//		letter.focus();	
//		return false;
//	}
	return true;
}
function openFullResumeForEmployer(id){
	window.open("/search/employer_saved_resume/display_full_resume.php?headline_id="+id, "resume", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=900,height=700,top=0,left=0");
	return false;
}
function openFullResumeForEmployerJustToView(id){
	window.open("/search/employer_saved_resume/display_full_resume.php?headline_id="+id+"&view=1", "resume", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=900,height=700,top=0,left=0");
	return false;
}
function openFullResumeForEmployerForApplier(id){
	window.open("/search/employer_saved_resume/display_full_resume_applicant.php?headline_id="+id, "resume", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=800,top=0,left=0");
	return false;
}
function openFullAnswersForEmployerForApplier(cand_id,job_id){
	
	window.open("/search/employer_saved_resume/display_full_answers_applicant.php?candidate="+cand_id+"&job="+job_id, "resume", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=800,top=0,left=0");
	return false;
}
//////////Tell A Friend/////////////

function validateTellAFriend(e){
	var root = document.tell_a_friend;
	var name = root.name.value;
	if (name==''){
		alert('Please fill up your name');
		root.name.select();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		alert('Please fill up your email');
		root.email.select();
		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.select();
		return false;
	}
	var count=0;
	for(var i=0;i<e;i++){
		var f_name= eval('root.f_name'+i+'.value');
		var f_email= eval('root.f_email'+i+'.value');
		if(f_name==''&&f_email==''){
			count++;
		}
		if(f_name==''&&f_email!=''){
			alert('Please fill up your friends name');
			eval('root.f_name'+i+'.focus()');
			return false;
		}
		if(f_name!=''&&f_email==''){
			alert('Please fill up your friends email');
			eval('root.f_email'+i+'.focus()');
			return false;
		}
		var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(f_name!=''){
			flag=f_email.match(pattern);
			if(!flag){
				alert('Please insert a valid email address.');
				eval('root.f_email'+i+'.select()');
				return false;
			}
		}
	}
	if(count==e){
		alert('Please provide at least one friend email');
		root.f_name0.select();
		return false;
	}
	
	var vcode = root.vcode.value;
	if (vcode==''){
		alert('Please provide the visual code.');
		root.vcode.select();
		return false;
	}
	
	return true;
}
function reloadPage3(url)
{
	var cat_id = document.tell_a_friend.subject[document.tell_a_friend.subject.selectedIndex].value;
	location.href=url+'/tell_a_friend/index.php?cat_id='+ cat_id;
}
////////////////////////////////

function getSubject(){
	
	var message = document.getElementById('message');
	var id = document.tell_a_friend.subject[document.tell_a_friend.subject.selectedIndex].value;
	xmlhttp.open("GET", "/tell_a_friend/get_subject.php?id="+id);

	//Send the proper header information along with the request
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//xmlhttp.setRequestHeader("Content-length");
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange=function() {
		
  		if(xmlhttp.readyState==4) {
  			if(xmlhttp.status ==200){
  				var response = xmlhttp.responseText;
  				message.innerHTML = ""+response;
  			}
 		 }
 	}
 	xmlhttp.send(null);
}
////////Success Story//////////////
function limitText(limitField, limitCount, limitNum) 
{
	if (limitField.value.length > limitNum) 
	{
		limitField.value = limitField.value.substring(0, limitNum);
	} 
	else 
	{
		limitCount.value = limitNum - limitField.value.length;
	}
}

function validateAddSuccessStory()
{
	
	var root = document.add_success;
	var short_desc = root.short_desc;
	if (short_desc.value==''){
		alert('Please provide a short description');
		return false;
	}
	return true;
}
///////////////////////////////
//////Help Categories///////
function toggle(obj) {
	// Moz. or IE
	var sibling=(obj.nextSibling.nodeType==3)? obj.nextSibling.nextSibling : obj.nextSibling;
	// hide or show
	if(sibling.style.display=='' || sibling.style.display=='block') {
		sibling.style.display='none';
		obj.firstChild.firstChild.data='+';
	}
	else {
		sibling.style.display='block';
		obj.firstChild.firstChild.data='-';
	}
}

function initCollapse() {

	var oDT=document.getElementById('version').getElementsByTagName('dt');
	for (var i=0; i < oDT.length; i++) {
		oDT[i].onclick=function() {toggle(this)};
		var oSpan=document.createElement('span');
		var sign=document.createTextNode('-');
		oSpan.appendChild(sign);
		oDT[i].insertBefore(oSpan, oDT[i].firstChild);
		oSpan.style.fontFamily='tahoma';
		oSpan.style.paddingRight='10px';
		oDT[i].style.cursor='pointer';
		toggle(oDT[i]);
	}
	oDT=null;
}

////////////////////////////////////////////
////////////////////////////////////////////
//////////////// BANNERS CHANGE/////////////
////////////////////////////////////////////

var urlArray = new Array; //for URL's, increase size as necessary
var banArray = new Array; //for banners, increase size as necessary
var typeArray = new Array; //for banners types, internal or external
var counter = 0;
var count = 0;
//calls the changeBanner() function every 10 seconds
//change the timer as necessary (minutes * 60000) or (seconds * 1000)
var timer = window.setInterval("changeBanner()", 7000);

var urlArray2 = new Array; //for URL's, increase size as necessary
var banArray2 = new Array; //for banners, increase size as necessary
var typeArray2 = new Array; //for banners types, internal or external
var counter2 = 0;
var count2 = 0;

var timer2 = window.setInterval("changeBanner2()", 11000);

function changeBanner() //banner changer function
{
	//alert(new_flag);
	//alert('serge');
	  /*for(var i=1;i<=3;i++)
	  {*/
	   	var i=1;
	  	if(counter >= count)
	  	{
	   		counter = 0;
	  	}
  	 if(count != 0)
  	 {
  	 	//alert('100');
		  var bannertd_id = 'bannerTd'+i;
	  	  document.getElementById(bannertd_id).innerHTML='';
	  	  var temp = new Image();
		  //alert('101');
		  temp.src = banArray[counter].src;
		  //alert(typeArray[counter]);
		  if(urlArray[counter] == "")
		  {
		  	url_image = "";
		  }
		  else
		  {
		  	url_image = "http://"+urlArray[counter];
		  }
		  //alert('102');
		  //alert(typeArray[counter]);
		  if(typeArray[counter]=='i')
		  {
		  	if(url_image == "")
		  	{
		  		document.getElementById(bannertd_id).innerHTML= "<img src="+temp.src+" border='0'>"; //sets a new banner
		  	}
		  	else
		  	{
		  		document.getElementById(bannertd_id).innerHTML= "<a href="+url_image+" target='_blank'><img src="+temp.src+" border='0'></a>"; //sets a new banner
		  	}
		  }else
		  {
		  		document.getElementById(bannertd_id).innerHTML="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='header' ALIGN='middle'><PARAM NAME='movie' VALUE="+temp.src+"><PARAM NAME='quality' VALUE='high'><param name='wmode' value='transparent'><EMBED src="+temp.src+" wmode='transparent' quality='high' bgcolor='#000000' NAME='header' ALIGN='middle' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>";
		  }
  	 }
	 counter++; //increase the counter for the next banner
}

function changeBanner2() //banner changer function
{
	//alert('serge');
	  /*for(var i=1;i<=3;i++)
	  {*/
	   	var i=2;
	  	if(counter2 >= count2)
	  	{
	   		counter2 = 0;
	  	}
  	 if(count2 != 0)
  	 {
  	 	//alert('100');
		  var bannertd_id_2 = 'bannerTd'+i;
	  	  document.getElementById(bannertd_id_2).innerHTML='';
	  	  var temp2 = new Image();
		  //alert('101');
		  temp2.src = banArray2[counter2].src;
		   //alert(temp2.src);
		   //alert(typeArray[counter]);
		  if(urlArray2[counter2] == "")
		  {
		  	url_image2 = "";
		  }
		  else
		  {
		  	url_image2 = "http://"+urlArray2[counter2];
		  }
		  //alert('102');
		  //alert(typeArray[counter]);
		  if(typeArray2[counter2]=='i')
		  {
		  	if(url_image2 == "")
		  	{
		  		document.getElementById(bannertd_id_2).innerHTML= "<img src="+temp2.src+" border='0'>"; //sets a new banner
		  	}
		  	else
		  	{
		  		document.getElementById(bannertd_id_2).innerHTML= "<a href="+url_image2+" target='_blank'><img src="+temp2.src+" border='0'></a>"; //sets a new banner
		  	}
		  }else
		  {
		  		document.getElementById(bannertd_id_2).innerHTML="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='header' ALIGN='middle'><PARAM NAME='movie' VALUE="+temp2.src+"><PARAM NAME='quality' VALUE='high'><param name='wmode' value='transparent'><EMBED src="+temp2.src+" wmode='transparent' quality='high' bgcolor='#000000' NAME='header' ALIGN='middle' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>";
		  }
  	 }
	 counter2++; //increase the counter for the next banner
}
//////////////////////////////////////////////////////

///////////////////Shop Cart////////////////////
function on_click_assign_button(button_clicked)
{
	var root = document.update_item;
	root.button_clicked.value = button_clicked;	
}
function check_remove_items()
{
	var root = document.update_item;
	var button_clicked = root.button_clicked.value;
	if(button_clicked == 1)
	{	
		var j=0;
		var counter = root.counter;
		for(var i=1;i<=counter.value;i++)
		{
			var item_remove = root.eval('remove_'+i).checked;
			if(item_remove == true)
			{
				j++
			}
		}
		if(j==0)
		{
			alert('Please Choose at least one Item to remove');
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}
function validateShippingAddress(){
	var root = document.shipping;

	var prev=root.previousAddress;

	var address=root.address;
	var city=root.city;
	var country=root.country;
	var newShipping=document.getElementById('shippingNew');
	var shippingPrev=document.getElementById('shippingPrev');

	if(!shippingPrev.checked && !newShipping.checked){
		alert('Please select an old shipping address or add a new one.');
		return false;
	}

	if(shippingPrev.checked){
		if(prev.value==''){
			alert('Please select a previous shipping address.');
			prev.focus();
			return false;
		}
	}

	if(newShipping.checked){
		if(root.address.value==''){
			alert('Please specify the shipping address.');
			address.focus();
			return false;
		}
		if(root.city.value==''){
			alert('Please specify the city.');
			city.focus();
			return false;
		}
		if(root.country.value==''){
			alert('Please specify select a country.');
			country.focus();
			return false;
		}
	}
}

function showHideMemberMenu(){
	var theLayer=document.getElementById('memberMenu');
	if(theLayer.style.visibility=='hidden'){
		theLayer.style.visibility='visible';
	}
	else{
		theLayer.style.visibility='hidden';
	}
}
////////////////////////////////////////////////

///////////// Spell Checker //////////////////////
function checkSpelling(input,form_name,text_area_name)
{
	if (input.value == "")
	{
		alert("Please enter your text to check your spelling.");
		input.focus()
		return false;
 	} 
 	else 
 	{
		var string = input.value
		var string = string.replace(/\n/gi ,"<br>")
		var string_array = string.split(' ');
		var counter = 0;
		var string_length = string_array.length;
		if(string_length > 60)
		{
			alert("Please enter a text Less than 60 words to check your spelling.");
			return false;
		}
		var string = escape(string)
		window.open("/common/spellcheck.php?text=" + string + "&form_name=" + form_name + "&text_area_name=" + text_area_name,"SpellShecker","width=550,height=380,top=200,left=300,scrollbars=yes,toolbar=no,resizable=no,statusbar=no");
		return false;
	}
}

////////////////////////////////////////////////////
// SET PATH TO IMAGES...
var NDPPASS_pathToImages = "/images/";

	var NDPPASS_image0 = new Image();
	var NDPPASS_image1 = new Image();
	var NDPPASS_image2 = new Image();
	var NDPPASS_image3 = new Image();
	var NDPPASS_image4 = new Image();
	
	NDPPASS_image0.src = NDPPASS_pathToImages + "level0.gif";
	NDPPASS_image1.src = NDPPASS_pathToImages + "level1.gif";
	NDPPASS_image2.src = NDPPASS_pathToImages + "level4.gif";
	NDPPASS_image3.src = NDPPASS_pathToImages + "level4.gif";
	NDPPASS_image4.src = NDPPASS_pathToImages + "level4.gif";


function NDPPASS_evalPassword(password) {

	var level = NDPPASS_evalPasswordStrength(password);
	var cells = 0;
	
	switch(level) {
		case 1: cells = 1;
				break;
		case 2: cells = 2;
				break;
		case 3: cells = 3;
				break;
		case 4: cells = 4;
				break;
	}
	
	for (i=1; i<=cells; i++) {
		eval('document.cell_' + i + '.src = NDPPASS_image' + level + '.src');
	}
	for (i=4; i>cells; i--) {
		eval('document.cell_' + i + '.src = NDPPASS_image0.src');
	}
}

function NDPPASS_evalPasswordStrength (password) {
	// check invalid characters
	if (password.match(/^[a-zA-Z0-9^~#@_-]+$/)) {
	} else return -1;

	// short passwords
	if (password.match(/^[a-zA-Z0-9^~#@_-]{1,5}$/)) return 1;
	
	// level 1 [0-9], [a-z], [A-Z]
	if (password.match(/^[0-9]{6,}$/)) return 1;
	if (password.match(/^[a-z]{6,}$/)) return 1;
	if (password.match(/^[A-Z]{6,}$/)) return 1;

	// level 2 [a-zA-Z], [a-z0-9], [A-Z0-9]
	if (password.match(/^[a-zA-Z]{6,}$/)) return 2;
	if (password.match(/^[a-z0-9]{6,}$/)) return 2;
	if (password.match(/^[A-Z0-9]{6,}$/)) return 2;
	
	// level 3 [a-zA-Z0-9] or [a-zA-Z^~#@_-] or [a-z0-9^~#@_-] or [A-Z0-9^~#@_-]
	if (password.match(/^[a-zA-Z0-9]{6,}$/)) return 3;
	if (password.match(/^[a-zA-Z^~#@_-]{6,}$/)) return 3;
	if (password.match(/^[a-z0-9^~#@_-]{6,}$/)) return 3;
	if (password.match(/^[A-Z0-9^~#@_-]{6,}$/)) return 3;
	
	// level 4 [a-zA-Z0-9^~#@_-]
	if (password.match(/^[a-zA-Z0-9^~#@_-]{6,}$/)) return 4;
	
	return 0;

}

function NDPPASS_resetForm() {
	document.cell_1.src = NDPPASS_image0.src;
	document.cell_2.src = NDPPASS_image0.src;
	document.cell_3.src = NDPPASS_image0.src;
	document.cell_4.src = NDPPASS_image0.src;
	return true;
}

////////////////////////////////////////////////////
////////////////////////////////////////////////////
////////////////////////////////////////////////////
function sendJobToFriend(container,fullname,email,job_id)
{
	if(document.getElementById(container).innerHTML != '')
	{
		document.getElementById(container).innerHTML = "";
	}
	else
	{
		document.getElementById(container).innerHTML = "<form name='send_job_to_friend' action='send_job_to_friend.php' method='post' onsubmit='return check_send_job();'><table border=\"0\" width=\"510\" cellpadding=\"0\" cellspacing=\"3\" align=\"center\"><tr><td width=\"50%\" valign='top' align='left' class=\"vacancy_details_titles\" style='background-color: #F0F0F0;'><input type='hidden' name='job_id' value='"+job_id+"' />Your Name</td><td width=\"50%\" valign='top' align='left' class=\"vacancy_details_titles\" style='background-color: #F0F0F0;'>Friend's Name</td></tr><tr><td width=\"50%\" valign='top' align='left'><input type='text' name='name' value='"+fullname+"' class='inputProfile'/></td><td width=\"50%\" valign='top' align='left'><input type='text' name='friend_name' value='' class='inputProfile'/></td></tr><tr><td width=\"50%\" valign='top' align='left' class=\"vacancy_details_titles\" style='background-color: #F0F0F0;'>Your E-mail</td><td width=\"50%\" valign='top' align='left' class=\"vacancy_details_titles\" style='background-color: #F0F0F0;'>Friend's E-mail</td></tr><tr><td width=\"50%\" valign='top' align='left'><input type='text' name='email' value='"+email+"' class='inputProfile'/></td><td width=\"50%\" valign='top' align='left'><input type='text' name='friend_email' value='' class='inputProfile'/></td></tr><tr><td valign='top' align='center' style='height: 10px;'></td></tr><tr><td valign='top' align='center' colspan='2'><input type='image' src='/images/send_mail.gif' /></td></tr></table></form>";
	}
}
function check_send_job()
{
	var root = document.send_job_to_friend;
	var name = root.name;
	var email = root.email;
	var friend_name = root.friend_name;
	var friend_email = root.friend_email;
	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	if(name.value == '')
	{
		alert('please provide your name');
		name.focus();
		return false;
	}
	if(email.value == '')
	{
		alert('please provide your email address');
		email.focus();
		return false;
	}
	var flag1 = email.value.match(email_pattern);
	if(!flag1)
	{
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	if(friend_name.value == '')
	{
		alert('please provide your friend name');
		friend_name.focus();
		return false;
	}
	if(friend_email.value == '')
	{
		alert('please provide your friend email address');
		friend_email.focus();
		return false;
	}
	var flag2 = friend_email.value.match(email_pattern);
	if(!flag2)
	{
		alert("Please enter a valid email address");
		friend_email.select();
		return false;
	}
	return true;
}
function check_apply_now()
{
	var root = document.apply_now;
	var cv_id = root.cv_id;
	if(cv_id.value == '')
	{
		alert('please select a Resume');
		cv_id.focus();
		return false;
	}
	return true;
}
function validateInnerLogin()
{
	var root = document.inner_login;
	var username = root.username;
	var password = root.password;
	if(username.value == '')
	{
		alert('Please insert your username');
		username.focus();
		return false;
	}
	if(password.value == '')
	{
		alert('Please insert your password');
		password.focus();
		return false;
	}
	return true;
}
function check_send_targeted_job()
{
	var root = document.send_targeted_job;
	var country_id = root.country_id;
	if(country_id.value == '')
	{
		alert('Please select a country');
		country_id.focus();
		return false;
	}
	return true;
}
function check_send_letter(rowNB)
{
	var root = document.send_letter;
	var checked = 0;
//alert(rowNB);return false;
//	for(i=1;i<=rowNB;i++){
//		var temp = eval('root.cand_'+i+'.checked');
//		if (temp == true) checked++;
//	}
//	return false;
//	if (checked == 0) {
//		alert('Please select at least one candidate');
//		return false;
//	}
	var letter_id = root.letter_id;
	
	if(letter_id.value == '')
	{
		alert('Please select a letter');
		letter_id.focus();
		return false;
	}
	return true;
}
function change_letter_id()
{
	var root = document.send_letter;
	var letter_id = root.letter_id.value;
	var container = document.getElementById('container');
	xmlhttp.open("GET", "/members/employer/display_letter.php?letter_id="+letter_id);

	//Send the proper header information along with the request
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//xmlhttp.setRequestHeader("Content-length");
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange=function() {
		
  		if(xmlhttp.readyState==4) {
  			if(xmlhttp.status ==200){
  				var response = xmlhttp.responseText;
  				container.innerHTML = response;
  			}
 		 }
 	}
 	xmlhttp.send(null);
}

////////////////// in old career too /////////
function educationOnOff(){
	var root = document.add_education;
	
	var currentStatus = root.checkbox_status.value;
	
	if (currentStatus == 'on'){
		root.college_uni_name.style.backgroundColor='#D8D8D8';
		root.college_uni_name.disabled=true;
		
		root.city.style.backgroundColor='#D8D8D8';
		root.city.disabled=true;
		
		root.state.style.backgroundColor='#D8D8D8';
		root.state.disabled=true;
		
		root.country_id.style.backgroundColor='#D8D8D8';
		root.country_id.disabled=true;
		
		root.degree_level_id.style.backgroundColor='#D8D8D8';
		root.degree_level_id.disabled=true;
		
		root.major_level_id.style.backgroundColor='#D8D8D8';
		root.major_level_id.disabled=true;
		
		root.minor_level_id.style.backgroundColor='#D8D8D8';
		root.minor_level_id.disabled=true;
		
		root.emphasis_level_id.style.backgroundColor='#D8D8D8';
		root.emphasis_level_id.disabled=true;
		
		root.year.style.backgroundColor='#D8D8D8';
		root.year.disabled=true;
		
		root.month.style.backgroundColor='#D8D8D8';
		root.month.disabled=true;
		
		root.related_info.style.backgroundColor='#D8D8D8';
		root.related_info.disabled=true;
				
		root.checkbox_status.value = 'off';
	}
	
	else {
		root.college_uni_name.style.backgroundColor='#FFFFFF';
		root.college_uni_name.disabled=false;
		
		root.city.style.backgroundColor='#FFFFFF';
		root.city.disabled=false;
		
		root.state.style.backgroundColor='#FFFFFF';
		root.state.disabled=false;
		
		root.country_id.style.backgroundColor='#FFFFFF';
		root.country_id.disabled=false;
		
		root.degree_level_id.style.backgroundColor='#FFFFFF';
		root.degree_level_id.disabled=false;
		
		root.major_level_id.style.backgroundColor='#FFFFFF';
		root.major_level_id.disabled=false;
		
		root.minor_level_id.style.backgroundColor='#FFFFFF';
		root.minor_level_id.disabled=false;
		
		root.emphasis_level_id.style.backgroundColor='#FFFFFF';
		root.emphasis_level_id.disabled=false;
		
		root.year.style.backgroundColor='#FFFFFF';
		root.year.disabled=false;
		
		root.month.style.backgroundColor='#FFFFFF';
		root.month.disabled=false;
		
		root.related_info.style.backgroundColor='#FFFFFF';
		root.related_info.disabled=false;
		
		root.checkbox_status.value = 'on';
	}
}

/////////////////////////////////////////////////////////////////
function checkDegreeShutDown(){
	var root = document.add_education;
	var mySelect = root.degree_level_id[root.degree_level_id.selectedIndex].value;
	if (mySelect == 1 || mySelect == 2) {
		root.major_level_id.disabled = true;
		root.major_level_id.style.backgroundColor='#D8D8D8';
		
		root.minor_level_id.disabled = true;
		root.minor_level_id.style.backgroundColor='#D8D8D8';
		
		root.emphasis_level_id.disabled = true;
		root.emphasis_level_id.style.backgroundColor='#D8D8D8';
	}
	else {
		root.major_level_id.disabled = false;
		root.major_level_id.style.backgroundColor='#769F18';
		root.major_level_id.style.color='#FFFFFF';
		
		root.minor_level_id.disabled = false;
		root.minor_level_id.style.backgroundColor='#769F18';
		root.minor_level_id.style.color='#FFFFFF';
		
		root.emphasis_level_id.disabled = false;
		root.emphasis_level_id.style.backgroundColor='#769F18';
		root.emphasis_level_id.style.color='#FFFFFF';
	}
	
}

function redirectToEdit(headlineId){
	window.opener.location.href = '/resume/edit/redirect.php?headline_id='+headlineId+'';
	self.close();
}
function redirectToDelete(headlineId){
	var conf = confirm('Deleting a resume is unrecoverable. Are you sure you want to proceed?');
	if (conf) {
		window.opener.location.href = '/resume/delete_resume.php?headline_id='+headlineId+'';
		self.close();
	}
	return false;
}
function redirectToCopy(headlineId){
	var conf = confirm('Upon clicking Ok, a copy of this Resume will be created in your Career Amazon account. \\nDo you want to continue?');
	if (conf) {
		window.opener.location.href = '/resume/copy_resume.php?headline_id='+headlineId+'';
		self.close();
	}
	return false;
}

function shutDownEndDate(formName, count){
 	var temp = 'document.'+formName+'.year'+count+'[document.'+formName+'.year'+count+'.selectedIndex].value';
	temp = eval(temp);
	if (temp == '0') {
		var shutDown = 'document.'+formName+'.month'+count+'.disabled=true;';
		eval(shutDown);
		var shutDown = 'document.'+formName+'.month'+count+'.style.background=\'#D8D8D8\';';
		eval(shutDown);
		shutDown = 'document.'+formName+'.day'+count+'.disabled=true;';
		eval(shutDown);
		var shutDown = 'document.'+formName+'.day'+count+'.style.background=\'#D8D8D8\';';
		eval(shutDown);
	}
	else {
		var shutDown = 'document.'+formName+'.month'+count+'.disabled=false;';
		eval(shutDown);
		var shutDown = 'document.'+formName+'.month'+count+'.style.background=\'#769F18\';';
		var shutDown2 = 'document.'+formName+'.month'+count+'.style.color=\'#FFFFFF\';';
		eval(shutDown);
		eval(shutDown2);
		shutDown = 'document.'+formName+'.day'+count+'.disabled=false;';
		eval(shutDown);
		var shutDown = 'document.'+formName+'.day'+count+'.style.background=\'#769F18\';';
		var shutDown2 = 'document.'+formName+'.day'+count+'.style.color=\'#FFFFFF\';';
		eval(shutDown);
		eval(shutDown2);
	}
	return false;
}
function shutDownEndYearMonth(formName, count){
	var temp = 'document.'+formName+'.year'+count+'[document.'+formName+'.year'+count+'.selectedIndex].value';
	temp = eval(temp);
	if (temp == '0') {
		var shutDown = 'document.'+formName+'.month'+count+'.disabled=true;';
		eval(shutDown);
		shutDown = 'document.'+formName+'.month'+count+'.style.background=\'#D8D8D8\';';
		eval(shutDown);
	}
	else {
		var shutDown = 'document.'+formName+'.month'+count+'.disabled=false;';
		eval(shutDown);
		shutDown = 'document.'+formName+'.month'+count+'.style.background=\'#769F18\';';
		shutDown2 = 'document.'+formName+'.month'+count+'.style.color=\'#FFFFFF\';';
		eval(shutDown);
		eval(shutDown2);
	}
	return false;
}
function shutDownEndDateForEdit(formName, count) {
	var shutDown = 'document.'+formName+'.month'+count+'.disabled=true;';
	eval(shutDown);
	shutDown = 'document.'+formName+'.month'+count+'.style.background=\'#D8D8D8\';';
	eval(shutDown);
}
function setFocus() {
	document.forms[0].username.focus();
}

function setContactFocus() {
	document.forms[0].firstName.focus();
}
function validateAddCareerObjective(){
	var root = document.add_careerobjective;
//	var subject = root.subject.value;
//	if (subject == ''){
//		alert('Please give a subject for your Career Objective.');
//		root.subject.focus();
//		return false;
//	}
	var text = root.text.value;
	if (text == ''){
		alert('Please enter your Career Objective');
		root.text.focus();
		return false;
	}
	return true;
}
function workExperienceOnOff(){
	var root = document.add_workexperience;
	
	var currentStatus = root.checkbox_status.value;
		
	if (currentStatus == 'on'){
		root.company_name.style.backgroundColor='#D8D8D8';
		root.company_name.disabled=true;
		
		root.city.style.backgroundColor='#D8D8D8';
		root.city.disabled=true;
		
		root.state.style.backgroundColor='#D8D8D8';
		root.state.disabled=true;
		
		root.country_id.style.backgroundColor='#D8D8D8';
		root.country_id.disabled=true;
		
		root.job_title_id.style.backgroundColor='#D8D8D8';
		root.job_title_id.disabled=true;
		
		root.industry_id.style.backgroundColor='#D8D8D8';
		root.industry_id.disabled=true;
		
		root.year.style.backgroundColor='#D8D8D8';
		root.year.disabled=true;
		
		root.month.style.backgroundColor='#D8D8D8';
		root.month.disabled=true;
		
		root.year2.style.backgroundColor='#D8D8D8';
		root.year2.disabled=true;
		
		root.month2.style.backgroundColor='#D8D8D8';
		root.month2.disabled=true;
		
		root.department.style.backgroundColor='#D8D8D8';
		root.department.disabled=true;
		
		root.main_responsibilities.style.backgroundColor='#D8D8D8';
		root.main_responsibilities.disabled=true;
		
		if(root.authorities){		
		root.authorities.style.backgroundColor='#D8D8D8';
		root.authorities.disabled=true;
		}
		
		root.reported_to.style.backgroundColor='#D8D8D8';
		root.reported_to.disabled=true;
		
		root.list_of_major_achievements.style.backgroundColor='#D8D8D8';
		root.list_of_major_achievements.disabled=true;
		
		root.related_info.style.backgroundColor='#D8D8D8';
		root.related_info.disabled=true;
		
		root.checkbox_status.value = 'off';
	}
	
	else {
		root.company_name.style.backgroundColor='#FFFFFF';
		root.company_name.disabled=false;
		
		root.city.style.backgroundColor='#FFFFFF';
		root.city.disabled=false;
		
		root.state.style.backgroundColor='#FFFFFF';
		root.state.disabled=false;
		
		root.country_id.style.backgroundColor='#FFFFFF';
		root.country_id.disabled=false;
		
		root.job_title_id.style.backgroundColor='#FFFFFF';
		root.job_title_id.disabled=false;
		
		root.industry_id.style.backgroundColor='#FFFFFF';
		root.industry_id.disabled=false;
		
		root.year.style.backgroundColor='#FFFFFF';
		root.year.disabled=false;
		
		root.month.style.backgroundColor='#FFFFFF';
		root.month.disabled=false;
		
		root.year2.style.backgroundColor='#FFFFFF';
		root.year2.disabled=false;
		
		root.month2.style.backgroundColor='#FFFFFF';
		root.month2.disabled=false;
		
		root.department.style.backgroundColor='#FFFFFF';
		root.department.disabled=false;
		
		root.main_responsibilities.style.backgroundColor='#FFFFFF';
		root.main_responsibilities.disabled=false;
		
		if(root.authorities){		
		root.authorities.style.backgroundColor='#FFFFFF';
		root.authorities.disabled=false;
		}
		
		root.reported_to.style.backgroundColor='#FFFFFF';
		root.reported_to.disabled=false;
		
		root.list_of_major_achievements.style.backgroundColor='#FFFFFF';
		root.list_of_major_achievements.disabled=false;
		
		root.related_info.style.backgroundColor='#FFFFFF';
		root.related_info.disabled=false;
		
		root.checkbox_status.value = 'on';
	}
}
function shutDownTargetJob() {
	var root = document.add_targetjob;
	
	root.salary.style.backgroundColor='#D8D8D8';
	root.salary.disabled=true;
	
	root.currency_id.style.backgroundColor='#D8D8D8';
	root.currency_id.disabled=true;
	
	root.per_id.style.backgroundColor='#D8D8D8';
	root.per_id.disabled=true;

	root.elements[1].style.backgroundColor='#D8D8D8';
	root.elements[1].disabled=true;

	root.elements[2].style.backgroundColor='#D8D8D8';
	root.elements[2].disabled=true;

	root.elements[3].style.backgroundColor='#D8D8D8';
	root.elements[3].disabled=true;
	
	root.elements[4].style.backgroundColor='#D8D8D8';
	root.elements[4].disabled=true;
	
	root.elements[5].style.backgroundColor='#D8D8D8';
	root.elements[5].disabled=true;
	
	root.elements[6].style.backgroundColor='#D8D8D8';
	root.elements[6].disabled=true;
	
	root.elements[7].style.backgroundColor='#D8D8D8';
	root.elements[7].disabled=true;
	
	root.elements[8].style.backgroundColor='#D8D8D8';
	root.elements[8].disabled=true;
	
	root.elements[13].style.backgroundColor='#D8D8D8';
	root.elements[13].disabled=true;
	
	root.elements[14].style.backgroundColor='#D8D8D8';
	root.elements[14].disabled=true;
		
	root.travel_id.style.backgroundColor='#D8D8D8';
	root.travel_id.disabled=true;
}
function turnOnSold() {
	var root = document.add_project;
	
	root.buyer_name.style.backgroundColor='#FFFFFF';
	root.buyer_name.disabled=false;
	
	root.phone.style.backgroundColor='#FFFFFF';
	root.phone.disabled=false;
	
	root.email.style.backgroundColor='#FFFFFF';
	root.email.disabled=false;
}
function validateEditTargetJobDetails(){
	var root = document.add_targetjob_details;
	var name=root.name.value;
	if(name==''){
		alert('Please specify a target job name');
		root.name.focus();
		return false;
	}
	
	var job_title_id=root.job_title_id.value;
	if(job_title_id==''){
		alert('Please select a desired job title');
		root.job_title_id.focus();
		return false;
	}
	
	var industryCount = 0;
	
	for (var k = 0; k<root.elements[5].length; k++) {
			if (root.elements[5][k].selected) {
			industryCount++;
		}
	}
	//alert(industryCount); return false;
	if (industryCount < 1) {
		alert('Please select at least one industry');
		return false;
	}
	else if (industryCount > 5) {
		alert('A maximum of five industries is allowed.');
		return false;
	}
	var countryCount = 0;
	for (var l = 0; l<root.elements[6].length; l++) {
		if (root.elements[6][l].selected) 
		{
			countryCount++;
		}
	}
	if (countryCount < 1) {
		alert('Please select at least one country');
		return false;
	}
	else if (countryCount > 20) {
		alert('A maximum of twenty countries is allowed.');
		return false;
	}
	
}
function openMemoryHelp(){
	alert('- Click on Bold, Italic, or Paragraph and enter the desired text in order \n   to apply that action to the inserted text. \n\n- Click on New Line to go to the beginning of the line. \n   (note that if you clicked on enter while writing the text, the text will \n   not show an empty line while displaying it on the website. )\n\n- Click on Line in order to enter a horizontal line to your text. \n\n- Click on Clear in order to clear all the fields of the form.');
	return false;
}
function displayResumeForUser(id){
	var resume_id=eval('document.view_resme.resume'+ id +'.value');
	if(resume_id!="")
	window.open('/users/admin/display_full_resume.php?headline_id='+resume_id+'','my_window','width=600,height=500,top=100,left=200,scrollbars=1');
	else alert("Please choose a resume first");
	return false;
}
/////////////////////////////////////////////////////////////////
function validate_add_q_a()
{
	var root = document.add_subcategory;
	var question = root.question;


	if(question.value == '')
	{
		alert('Please enter the question');
		question.select();
		return false;
	}
	return true;
}

function getHear(){
	
	if (document.employer_register.hear.selectedIndex==6)
	{
		document.getElementById('hear_other').style.visibility='visible';
	} else document.getElementById('hear_other').style.visibility='hidden';
	
}
function remove_preference(doc){
	if(doc.checked){
		$('employment_type_employee').checked=false;
		$('employment_type_project').checked=false;
		$('employment_type_temporary').checked=false;
		$('employment_type_seasonal').checked=false;
		$('employment_type_contract').checked=false;
	}
}
function remove_preference2(doc){
	if(doc.checked){
		$('employment_type_no_preference').checked=false;
	}
}

var view_up_flag=0;
function view_up(){
	//if(view_up_flag==0){
		if(view_up_flag==0)
		Effect.Appear('wallaceDiv',{from: 0.0, to: 0.9});
	//}
}
function close_up(){
	if(document.getElementById('wallaceDiv').style.display=="")
		document.getElementById('wallaceDiv').style.display="none";
	if(document.getElementById('wallaceDiv').style.display=="block")
		Effect.Fade('wallaceDiv');
	view_up_flag=1;
//	alert(view_up_flag);
}


