
function scr3RecordDisplayAs(data)
{
	return data.companyName + " " + data.startDate + " - " + data.endDate;
}

function scr3SortMethod(a,b)
{
	if (a.startDate > b.startDate)
		return -1;
	else if (a.startDate < b.startDate)
		return 1;
	else
	{
		if (a.endDate > b.endDate)
			return -1;
		else if (a.endDate < b.endDate)
			return 1;
		else
			return 0;
	}
}

function scr5RecordDisplayAs(data)
{
	return data.institution + (data.startYear && data.endYear ? " - " + data.startYear + " - " + data.endYear : "");
}

function scr5SortMethod(a,b)
{
	if (a.startYear > b.startYear)
		return -1;
	else if (a.startYear < b.startYear)
		return 1;
	else
	{
		if (a.endYear > b.endYear)
			return -1;
		else if (a.endYear < b.endYear)
			return 1;
		else
			return 0;
	}
}

function scr6RecordDisplayAs(data)
{
	return (data.institute ? data.institute + " - " : "") + data.course;
}

function scr6SortMethod(a,b)
{
	if (a.endDate > b.endDate)
		return -1;
	else if (a.endDate < b.endDate)
		return 1;
	else
		return 0;
}





//field validations

//Aliya Year
function customFieldValidation16(value)
{
	if (value != null && value != "" && (getFieldData(getFieldByName("birthCountry")) == "" || getFieldData(getFieldByName("birthCountry")) == "ישראל"))
		return validationError(0,"שים לב, ציינת שנת עליה, למרות שלא ציינת שנולדת בארץ זרה.",false);
		
	return null;
}

function isHebrew(str)
{
	if (str == null) return true;
	
	for (var i=0;i<str.length;i++)
	{
		if (str[i] >= 'א' && str[i] <= 'ת')
			return true;
	}
	return false;
}

//Company Name
function customFieldValidation14(value)
{
	if (value != null && value != "")
	{
		if (value.length < 8)
		{
			return FieldValidationError(0,"שדה זה צריך להכיל לפחות 8 ספרות",false);
		}
	}
	return null;
}

//Company Name
function customFieldValidation6(value)
{
	if (value != null && !isHebrew(value))
	{
		var words = value.split(" ");
		if (words[i].length > 0 && words[0].substring(0,1).toUpperCase() != words[0].substring(0,1))
		{
			return FieldValidationError(0,"שם החברה שהקשת אינו מתחיל באות גדולה. מומלץ להקפיד על כך, דבר היעיד על מודעות שיווקית ואסתטית.",true);
		}
	}
	return null;
}

//Education end date
function customFieldValidation25(value)
{
	var start = getFieldData(getFieldByName("startYear"));
	if (value != null && value != "" && start != "")
	{
		if (value < start)
		{
			return FieldValidationError(0, "התאריכים שהקשת אינם תקינים: תאריך הסיום צריך להיות מאוחר מתאריך התחילה.", false);
		}
	}
	return null;
}

//Education end date
function customFieldValidation29(value)
{
	var start = getFieldData(getFieldByName("startYear"));
	if (value != null && value != "" && start != "")
	{
		if (value < start)
		{
			return FieldValidationError(0, "התאריכים שהקשת אינם תקינים: תאריך הסיום צריך להיות מאוחר מתאריך התחילה.", false);
		}
	}
	return null;
}

//Education end date
function customFieldValidation11(value)
{
	var start = getFieldData(getFieldByName("startDate"));
	if (value != null && value != "" && start != "")
	{
		if (value < start)
		{
			return FieldValidationError(0, "התאריכים שהקשת אינם תקינים: תאריך הסיום צריך להיות מאוחר מתאריך התחילה.", false);
		}
	}
	return null;
}

// lost focus events

function scr2Field15Changed(field)
{
	var element = document.getElementById(field.name);
	if (element.value == "" || element.value == "ישראל")
	{
		document.getElementById("aliyaYear").value = "";
		document.getElementById("aliyaYearLine").style.display = "none";
		//document.getElementById("birthDateYear").focus();
	}
	else
	{
		document.getElementById("aliyaYearLine").style.display = "";
	}
}