function CheckRadio(oElement){
	var iItemCounter = 0;
	while(iItemCounter < oElement.length){
		if ( eval("oElement["+iItemCounter+"].checked") )
			return true;
		iItemCounter++;
	}
	/*var iItemCounter = 0;
	var ElementLength = oForm.elements.length;
	var RadioArrayLength = oElement.length;
	var ArrayPosition = 0;
	alert(RadioArrayLength)

	while(iItemCounter < ElementLength - 1){
		while( ArrayPosition < RadioArrayLength - 1 )
			if ( oForm.elements[+iItemCounter+].name") == oElement.name )
				if ( eval("oForm.elements[5].checked") )
					return true;
			ArrayPosition++;
		iItemCounter++;
		ArrayPosition = 0;
	}*/	
	if(oElement.length >= 0){
		strValidationMessage += "Please " + FormatElementError(oElement[0]) + ".\n";
		if(oFocusElement == "")
			oFocusElement = oElement[0].name;
	}
	return false;
}

function CheckLength(oElement, MinLength, MaxLength){
	//alert('double adfa')
	if(oElement.value.length < MinLength){
		strValidationMessage += "You have not entered enough characters for " + FormulateName(oElement) + ".\n";
		if(oFocusElement == "")
			oFocusElement = oElement.name;
		return false;	
	}else if(oElement.value.length > MaxLength){
		strValidationMessage += "You entered too many characters for " + FormulateName(oElement) + ".\n";
		if(oFocusElement == "")
			oFocusElement = oElement.name;
		return false;	
	}
	return true;
}

function CheckEmpty(oElement){
	if(oElement.value.length <= 0){
		strValidationMessage += "Please " + FormatElementError(oElement) + ".\n";
		if(oFocusElement == "")
			oFocusElement = oElement.name;
		return false;
	}
	return true;
}

function CheckListBox(oElement){
	if(oElement.selectedIndex <= 0 || oElement.options[oElement.selectedIndex].value == "-1"){
		strValidationMessage += "Please choose a " + FormatElementError(oElement) + ".\n";
		if(oFocusElement == "")
			oFocusElement = oElement.name;
		return false;
	}
	return true;
}

function FormatElementError(oElement){
	if(oElement.type == "select-one" || oElement.type == "select-multiple"){
		return FormulateName(oElement) + " from the list";
	}else if(oElement.type == "text"){
		return "enter a value for " + FormulateName(oElement);
	}else if(oElement.type == "password"){
		return "enter a value for " + FormulateName(oElement);
	}else if(oElement.type == "radio"){
		return "choose a " + FormulateName(oElement);
	}
}

function FormulateName(oElement){
	var arSplit = new Array();
	var strReturn = "";
	arSplit = oElement.name.split("_");
	//alert(arSplit.length);
	for(var i = 0; i < arSplit.length; i++){
		strReturn += arSplit[i].substr(0, 1).toUpperCase() + arSplit[i].substr(1, arSplit[i].length).toLowerCase();
		if(i < (arSplit.length - 1))
			strReturn += " ";
	}
	return strReturn;
}

function checkemail(oElement){
	var str = oElement.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if(!filter.test(str)){
		strValidationMessage += "Please provide a valid email address.\n";
		if(oFocusElement == "")
			oFocusElement = oElement.name;
		return false;
	}
	return true;	
}


