function showPermitNo(frm){
	target = document.getElementById('row_1');
	if (frm.workPermit[0].checked) {
   		target.style.display = "";
  	} 
	else {
		frm.workPermitNo.value = '';
		target.style.display = "none";
	}	
}
function showPermitNoReg(frm){
	target = document.getElementById('row_1');
	if (frm.site_user_custom2[0].checked) {
   		target.style.display = "";
  	} 
	else {
		frm.site_user_custom5.value = '';
		target.style.display = "none";
	}	
}
 function validateuser_register1(frm) {
    checkString(frm.firstname,"First name");
	checkString(frm.secondname,"Surname");
	checkNumber(frm.site_user_custom1,"Phone number",1);
	checkEmail(frm.email,"Email",1);
	checkString(frm.password,"Password");
    checkString(frm.passwordconfirm,"Confirm password");
	//checkString(frm.cv,"CV");
		
	if (frm.password.value.length > 0 && frm.passwordconfirm.value.length > 0){
		if (frm.password.value != frm.passwordconfirm.value){
			addError("Password and Confirm password do not match");
		}
	}
	if (frm.password.value.length <6){
		addError("Password must be minimum 6 characters");		
	}
	
	//if (frm.workPermit[0].checked && frm.workPermitNo.value.length < 4) {
   	//	addError("Please complete your Work Permit Number");
  	//}
	
	
	checkString(frm.site_user_custom3,"Collins McNicholas Branch");
	if (!frm.site_user_custom4.checked) {
        	addError("Agreement that you accept the terms and conditions");		
   	}
	checkString(frm.file1,"Your CV");
	
	return checkError();
}
   

function validateuser_register3(frm) {
    checkString(frm.firstname,"First name");
	checkString(frm.surname,"Surname");
	checkNumber(frm.phone,"Phone number",1);
	checkEmail(frm.email,"Email",1);		
	checkString(frm.file1,"Your CV");
	
	return checkError();
}
function validate_register4(frm) {
    	checkEmail(frm.email,"Email",1);		
                checkString(frm.site_user_custom3,"Collins McNicholas Branch")
	checkString(frm.file1,"Your CV");
	
	return checkError();
}
function validate_job(frm) {
    checkString(frm.company_name,"Company Name");
    checkString(frm.firstname,"Firstname")
    checkString(frm.secondname,"Surname");
    checkEmail(frm.email,"Email",1);		
    checkNumber(frm.telephone,"Telephone number",1);

    checkString(frm.vacancy_title,"Vacancy Title");
    checkString(frm.vacancy_location,"Vacancy Location");
    checkString(frm.vacancy_duration,"Vacancy Duration");
    checkString(frm.vacancy_type,"Vacancy Type");
    checkString(frm.site_user_custom3,"Collins McNicholas Branch");

   return checkError();
}
function validate_contact(frm) {
    checkString(frm.firstname,"Firstname")
    checkString(frm.surname,"Surname");
    checkEmail(frm.email,"Email",1);		
    checkString(frm.subject,"Subject")
    checkString(frm.query,"Query")
    checkString(frm.site_user_custom3,"Collins McNicholas Branch")

   return checkError();
}
function validate_referfriend(frm) {
    checkString(frm.firstname,"Your Firstname")
    checkString(frm.surname,"Your Surname");
    checkString(frm.col_firstname,"Friend/Colleagues Firstname")
    checkString(frm.col_surname,"Friend/Colleagues Surname");
    checkString(frm.query,"Preferred Position")
    checkString(frm.site_user_custom3,"Collins McNicholas Branch")

   return checkError();
}

function showEmail(frm){
	target = document.getElementById('group2');
	if (frm.delivery[0].checked) {
		target.style.display = "";
		frm.sms.value = '';
		target = document.getElementById('group3');
		target.style.display = "none";
  	} 
	else {
		frm.email.value = '';
		target.style.display = "none";
	}	
}

function showSMS(frm){
	target = document.getElementById('group3');
	if (frm.delivery[1].checked) {
   		target.style.display = "";
		frm.email.value = '';
		target = document.getElementById('group2');
		target.style.display = "none";
  	} 
	else {
		frm.sms.value = '';
		target.style.display = "none";
	}	
}

   
 function validatealertform(frm) {
    checkString(frm.alert_title,"Alert Title");
    checkString(frm.category_id,"At least 1 Category");
    checkString(frm.subcategory_id,"At least 1 Subcategory");
    checkString(frm.location_id,"At least 1 Location");
    checkString(frm.frequency,"Frequency");
	//if (!frm.delivery[0].checked && !frm.delivery[1].checked){
	//		addError("Please select Email or SMS delivery");
	//}
	//if (frm.delivery[0].checked && frm.email.value.length < 3){
				checkEmail(frm.email,"Email",1);
	//}
	//if (frm.delivery[1].checked && frm.sms.value.length < 3){
	//		checkString(frm.sms,"SMS Number");
	//}
    
	
	if (checkError()) {
		 document.awpform.action ="process_add_alert.jsp";		
		 awpform.submit();
	} else {
		 return false;
	}
	
}
function validateeditalertform(frm) {
    checkString(frm.alert_title,"Alert Title");
    checkString(frm.category_id,"At least 1 Category");
    checkString(frm.subcategory_id,"At least 1 Subcategory");
    checkString(frm.location_id,"At least 1 Location");
    checkString(frm.frequency,"Frequency");
	//if (!frm.delivery[0].checked && !frm.delivery[1].checked){
	//		addError("Please select Email or SMS delivery");
	//}
	//if (frm.delivery[0].checked && frm.email.value.length < 3){
				checkEmail(frm.email,"Email",1);
	//}
	//if (frm.delivery[1].checked && frm.sms.value.length < 3){
	//		checkString(frm.sms,"SMS Number");
	//}
	if (checkError()) {
		 document.awpform.action ="process_edit_alert.jsp";		
		 awpform.submit();
	} else {
		 return false;
	}
}

function validateuser_register2(frm) {
    checkString(frm.firstname,"First name");
	checkString(frm.secondname,"Surname");
	checkNumber(frm.site_user_custom1,"Phone number",1);
	checkEmail(frm.email,"Email",1);
	checkString(frm.password,"Password");
    checkString(frm.passwordconfirm,"Confirm password");
	//checkString(frm.cv,"CV");
		
	if (frm.password.value.length > 0 && frm.passwordconfirm.value.length > 0){
		if (frm.password.value != frm.passwordconfirm.value){
			addError("Password and Confirm password do not match");
		}
	}
	if (frm.password.value.length <6){
		addError("Password must be minimum 6 characters");		
	}

	//if (frm.workPermit[0].checked && frm.workPermitNo.value.length < 4) {
   	//	addError("Please complete your Work Permit Number");
  	//}
	
	checkString(frm.site_user_custom3,"Collins McNicholas Branch");
	if (!frm.site_user_custom4.checked) {
        	addError("Please give your agreement that you accept the terms and conditions");
   	}
	if(validationErrorArray != null && validationErrorArray.length > 0) {
			return checkError();
	}
	
	if (frm.file1.value.length <3){
			return confirm("Please click ok if you DO NOT wish to attach your cv at this time");
	}
	
	
}


function validateform3(frm) {
    checkString(frm.firstname,"First name");
	checkString(frm.secondname,"Surname");
	checkNumber(frm.phone,"Phone number",1);
	//checkString(frm.cv,"CV");
		

	return checkError();
}

