
function ensureInput(objForm, strFieldName, strCultureCode) 
{
	strValue = getValueByFieldName(objForm, strFieldName);
	strLabel = getLabelByCultureCode(strFieldName, strCultureCode);
		
	if (strValue == "") {
		return "> " + strLabel + "\n";
	} else {
		return "";
	}
}


function ensureNumber(objForm, strFieldName, strCultureCode) 
{
	strValue = getValueByFieldName(objForm, strFieldName);
	strLabel = getLabelByCultureCode(strFieldName, strCultureCode);
		
	if ( (strValue == "") || (isNaN(strValue)) ) {
		return "> " + strLabel + "\n";
	} else {
		return "";
	}
}

function ensureEmailAddress(objForm, strFieldName, strCultureCode) 
{
	strValue = getValueByFieldName(objForm, strFieldName);
	strLabel = getLabelByCultureCode(strFieldName, strCultureCode);
		
	if (isValidEmailAddress(strValue)==false) {
		return "> " + strLabel + "\n";
	} else {
		return "";
	}
}

function ensurePhone(objForm, strFieldName, strCultureCode) 
{
	strValue = getValueByFieldName(objForm, strFieldName);
	strLabel = getLabelByCultureCode(strFieldName, strCultureCode);
		
	if ((strValue == "") || (strValue.length < 10)) {
		return "> " + strLabel + "\n";
	} else {
		return "";
	}
}

function ensureCheckbox(objCheckbox)
{
	return objCheckbox.checked;
}



function ensureRadio(objForm, strFieldName, strCultureCode)
{
	strLabel = getLabelByCultureCode(strFieldName, strCultureCode);
	
	blnIsValid = isValidRadio(objForm, strFieldName);
	
	if (blnIsValid==false) {
		return "> " + strLabel + "\n"; 
	} else {
		return "";
	}
	
}

function isValidRadio(objForm, strFieldName)
{
	blnHasOneChecked = false;
	
	objRadio = objForm.elements[strFieldName];
	
	for (i=0; i < objRadio.length; i++)
	{
		if (objRadio[i].checked) {
			blnHasOneChecked = true;
		}
	}
	return blnHasOneChecked;
}







function getElementByFieldName(objForm, strFieldName)
{
	for (i=0; i < objForm.elements.length; i++) 
	{
		objElement = objForm.elements[i];
		if (objElement.name == strFieldName) {
			return objElement;
		}
	}
}


function getValueByFieldName(objForm, strFieldName)
{
	strValue = "";
	
	for (i=0; i < objForm.elements.length; i++) 
	{
		objElement = objForm.elements[i];
		if (objElement.name == strFieldName) {
			strValue = objElement.value;
		}
	}
	
	return strValue;
}



function isValidEmailAddress(strValue)
{
	var objRegExp  = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	return objRegExp.test(strValue);
}

function getLabelByCultureCode(strFieldName, strCultureCode)
{
	strLabel = "";

	if (strFieldName == "strFirstName") {
		if (strCultureCode == "nl-NL") { strLabel = "Voornaam"; }
		if (strCultureCode == "en-US") { strLabel = "First name"; }
	}
	else if (strFieldName == "strLastName") {
		if (strCultureCode == "nl-NL") { strLabel = "Achternaam"; }
		if (strCultureCode == "en-US") { strLabel = "Last name"; }
	}
	else if (strFieldName == "strStreet") {
		if (strCultureCode == "nl-NL") { strLabel = "Straat"; }
		if (strCultureCode == "en-US") { strLabel = "Street"; }
	}
	else if (strFieldName == "strAddress") {
		if (strCultureCode == "nl-NL") { strLabel = "Adres"; }
		if (strCultureCode == "en-US") { strLabel = "Address"; }
	}
	else if (strFieldName == "strPhone") {
		if (strCultureCode == "nl-NL") { strLabel = "Telefoon"; }
		if (strCultureCode == "en-US") { strLabel = "Phone"; }
	}
	else if (strFieldName == "strCity") {
		if (strCultureCode == "nl-NL") { strLabel = "Plaats"; }
		if (strCultureCode == "en-US") { strLabel = "City"; }
	}
	else if (strFieldName == "strEmailAddress") {
		if (strCultureCode == "nl-NL") { strLabel = "E-mail adres"; }
		if (strCultureCode == "en-US") { strLabel = "Email address"; }
	}
	else if (strFieldName == "strEmailAddressOne") {
		if (strCultureCode == "nl-NL") { strLabel = "E-mail adres 1"; }
		if (strCultureCode == "en-US") { strLabel = "Email address 1"; }
	}
	else if (strFieldName == "strEmailAddressTwo") {
		if (strCultureCode == "nl-NL") { strLabel = "E-mail adres 2"; }
		if (strCultureCode == "en-US") { strLabel = "Email address 2"; }
	}
	else if (strFieldName == "strEmailAddressThree") {
		if (strCultureCode == "nl-NL") { strLabel = "E-mail adres 3"; }
		if (strCultureCode == "en-US") { strLabel = "Email address 3"; }
	}
	else if (strFieldName == "strKlantNummer") {
		if (strCultureCode == "nl-NL") { strLabel = "Klantnummer"; }
		if (strCultureCode == "en-US") { strLabel = "ClientNumber"; }
	}
	else if (strFieldName == "strZipCode") {
		if (strCultureCode == "nl-NL") { strLabel = "Postcode"; }
		if (strCultureCode == "en-US") { strLabel = "Zipcode"; }
	}
	else if (strFieldName == "strHuisNummer") {
		if (strCultureCode == "nl-NL") { strLabel = "Huisnummer"; }
		if (strCultureCode == "en-US") { strLabel = "Number"; }
	}
	else if (strFieldName == "strCompany") {
		if (strCultureCode == "nl-NL") { strLabel = "Organisatie"; }
		if (strCultureCode == "en-US") { strLabel = "Company"; }
	}
	else if (strFieldName == "strFullName") {
		if (strCultureCode == "nl-NL") { strLabel = "Naam"; }
		if (strCultureCode == "en-US") { strLabel = "Name"; }
	}
	else if (strFieldName == "strReactionXHTML") {
		if (strCultureCode == "nl-NL") { strLabel = "Reactie"; }
		if (strCultureCode == "en-US") { strLabel = "Reaction"; }
	}
	else if (strFieldName == "intGender") {
		if (strCultureCode == "nl-NL") { strLabel = "Geslacht"; }
		if (strCultureCode == "en-US") { strLabel = "Gender"; }
	}
	else if (strFieldName == "strDOB") {
		if (strCultureCode == "nl-NL") { strLabel = "Geboortedatum"; }
		if (strCultureCode == "en-US") { strLabel = "Date of Birth"; }
	}
	else if (strFieldName == "strMessage") {
		if (strCultureCode == "nl-NL") { strLabel = "Bericht"; }
		if (strCultureCode == "en-US") { strLabel = "Message"; }
	}
	else if (strFieldName == "strProduct") {
		if (strCultureCode == "nl-NL") { strLabel = "Product"; }
		if (strCultureCode == "en-US") { strLabel = "Product"; }
	}
	
	else 
	{
		strLabel = "Veldnaam";
	}
	
 	return strLabel;
}



