function validateCollege(inputId1, inputId2, helpText, errorMessage){
	
	if(inputId1.value == ""){
		$('education_college_new').style.display="table-row";
		return validateFieldNotEmpty(inputId2,helpText,errorMessage);
	}else{
		$('education_college_new').style.display="none";
		return true;		
	}
}
function checkDate(date2,date1,helpText,errorMessage){
	if(date2.value == ""){
		return validateFieldNotEmpty(date2,helpText,'<?php echo EDUCATION_EDIT_EMPTY_FIELD;?>');		
	}else{
		if(date1.value > date2.value){
			helpText.style.display="inline";
			helpText.innerHTML = errorMessage;
			return false;
		}else{
			helpText.style.display="none";
			helpText.innerHTML = '';
			return true;
		}
	}
	
}
function checkDate2(year2,month2,year1,month1,helpText,errorMessage, errorMessage2){
	if(year2.value == "" || month2.value == ""){
		validateFieldNotEmpty(month2, helpText, errorMessage);		
		validateFieldNotEmpty(year2, helpText, errorMessage);
		return false;
	}else{
		if(year1.value >= year2.value && month1.value >= month2.value){
			helpText.style.display="inline";
			helpText.innerHTML = errorMessage2;
			return false;
		}else{
			helpText.style.display="none";
			helpText.innerHTML = '';
			return true;
		}
	}
	
}
function validateCountry(inputId1, inputId2, helpText, errorMessage){
	if(inputId1.value != "138"){
		$('education_college_new').style.display="table-row";
		$('education_college_select').style.display="none";
		return validateFieldNotEmpty(inputId2,helpText,errorMessage);
	}else{
		$('education_college_new').style.display="none";
		$('education_college_select').style.display="table-row";
		return true;		
	}
}
function validateEducation(){
	submit = 0;
	if(!validateCollege($('collegeOptions'), $('college_new_name'),$('college_help'),'<?php echo ADD_NEW_COLLEGE;?>')){
		submit +=1;
	}
	if(!validateFieldNotEmpty($('select_degree'),$('degree_help'),'<?php echo EDUCATION_EDIT_EMPTY_FIELD;?>')){
		submit +=1;
	}
	if(!validateFieldNotEmpty($('education_area'),$('area_help'),'<?php echo EDUCATION_EDIT_EMPTY_FIELD;?>')){
		submit +=1;
	}
	if(!validateFieldNotEmpty($('yearDate1Options'),$('datefrom_help'),'<?php echo EDUCATION_EDIT_EMPTY_FIELD;?>')){
		submit +=1;
	}if(!checkDate($('yearDate2Options'),$('yearDate1Options'),$('dateto_help'),'<?php echo DATE_ERROR;?>')){
		submit +=1;
	}
	
	if(submit > 0){
		return false;
	}else{
		return true;
	}
	
} 
function showDate2 (current,rowId){
      if(current.getValue() == '1'){
        rowId.style.display = "none";
      }else{
        rowId.style.display = "table-row"
      }   
    
}
function validateTextNote(inputField,noteText){
	if(inputField.value == noteText){
		inputField.value = "";		
	}
}
function validateDate(eyear, emonth, eday, helpText,errorMessage){
	var currentTime = new Date();
	var month = parseInt(currentTime.getMonth() + 1);
	var day = parseInt(currentTime.getDate());
	var year = parseInt(currentTime.getFullYear());
	ey = parseInt(eyear.value);
	em = parseInt(emonth.value);
	ed = parseInt(eday.value);
	if(ed < day){
		if(em <= month){
			if(ey <= year){
				if(helpText != null){
					helpText.innerHTML = errorMessage;
					helpText.style.display="inline";
				}
				return false;
			}else{				
				helpText.innerHTML = '';
				helpText.style.display="none";
				return true;
			}	
		}else{			
			helpText.innerHTML = '';
			helpText.style.display="none";
			return true;
		}
	}else{		
		helpText.innerHTML = '';
		helpText.style.display="none";
		return true;
	}
	
}
