function step1Validate(formName){
	if (!echeck(formName.email.value, "Invalid email!")){
		formName.email.focus();
		return false;
	}
	if (!echeck(formName.reEmail.value, "Retype your email corect!")){
		formName.reEmail.focus();
		return false;
	}
	if (formName.email.value != formName.reEmail.value){
		alert("Retype your email identical to first one!");
		formName.reEmail.focus();
		return false;
	}
	var pass = trim(formName.password.value);
	if (pass.length < 6){
		alert("Password must have at least 6 characters!");
		formName.password.focus();
		return false;
	}
	if (formName.password.value != formName.rePassword.value){
		alert("Retpye your password corect!");
		formName.rePassword.focus();
		return false;
	}
	return true;
}
function step2Validate(formName){
	if (trim(formName.firstname.value) == ""){
		alert("Type your first name!");
		formName.firstname.focus();
		return false;
	}
	if (trim(formName.lastname.value) == ""){
		alert("Type your last name!");
		formName.lastname.focus();
		return false;
	}
	if (trim(formName.address1.value) == ""){
		alert("Type your address!");
		formName.address1.focus();
		return false;
	}
	if (trim(formName.city.value) == ""){
		alert("City is mandatory!");
		formName.city.focus();
		return false;
	}
	if (formName.country.value == "US" && formName.state.value==""){
		alert("Select your state!");
		formName.state.focus();
		return false;
	}
	return true;
}

function step3Validate(formName){
	if (trim(formName.availableDate.value).length != 8){
		alert("Available date is not corect!");
		formName.availableDate.focus();
		return false;
	}
	//
	var contracts = formName.elements["contractType[]"];
	var isFtMandatory = false;
	var isContractMandatory = false;
	g = 0;
	for (var i = 0; i < contracts.length; i++) {
		if (contracts[i].selected ) {
			if (i == 0){
				isContractMandatory = true;
				isFtMandatory = true;
			} 
			if (i == 1){
				isFtMandatory = true;
			}
			if (i > 1){
				isContractMandatory = true;
			}

		}
		else { g++;}
	}
	//		
	if (formName.yearSalary.value == "" && isFtMandatory){
		alert("Salary as FT employee is mandatory!");
		formName.yearSalary.focus();
		return false;
	}
	if (formName.hourSalary.value == "" && isContractMandatory){
		alert("Hourly rate for contract is mandatory!");
		formName.hourSalary.focus();
		return false;
	}
	var skills = formName.elements["skills[]"];
	
	if (!multipleSelectValidate(skills)){
		alert("Select your skills");
		formName.elements["skills[]"].focus();
		return false;
	}
	return true;
}

function validateLogin(formName){
	if (!echeck(formName.username.value, "Invalid email!")){
		formName.username.focus();
		return false;
	}
	if (trim(formName.password.value) == ""){
		alert("Type your password!");
		formName.password.focus();
		return false;
	}
	return true;
	
}

function changePassValidate(formName){

	var pass = trim(formName.old_password.value);
	if (pass.length < 6){
		alert("Old password must have at least 6 characters!");
		formName.old_password.focus();
		return false;
	}
	var pass_new = trim(formName.password.value);
	if (pass_new.length < 6){
		alert("New password must have at least 6 characters!");
		formName.password.focus();
		return false;
	}
	if (formName.password.value != formName.rePassword.value){
		alert("Retpye your new password corect!");
		formName.rePassword.focus();
		return false;
	}
	return true;
}

function validateActivationForm(formName){
	if (!echeck(formName.username.value, "Invalid email!")){
		formName.username.focus();
		return false;
	}
	if (trim(formName.code.value) == ""){
		alert("Type your activation code!");
		formName.code.focus();
		return false;
	}
}

function confirmDeleteJob(jobid){
	if (confirma("Are you sure you want to delete the job!")){
		document.location.href='job_action.php?action=2&id='+jobid;
		return true;
	}
	return false;
}

function confirmaDelApplicant(appid){
	if (confirma("Are you sure you want to delete the applicant!")){
		document.location.href='../candidate/del_app.php?id='+appid;
		return true;
	}
	return false;
}


function confirmaDelUser(userid){
	if (confirma("Are you sure you want to delete the user!")){
		document.location.href='../candidate/del_user.php?id='+userid;
		return true;
	}
	return false;
}

function step2ValidateAdmin(formName){
	if (trim(formName.firstname.value) == ""){
		alert("Type your first name!");
		formName.firstname.focus();
		return false;
	}
	if (trim(formName.lastname.value) == ""){
		alert("Type your last name!");
		formName.lastname.focus();
		return false;
	}
	return true;
}	

function confirmSendEmail(userid){
	if (confirm("Are you sure you want to send the email!")){
		document.location.href='../sendmail/?id='+userid;
	}
}