// This set of function are general includes for validation
// They are designed in pairs the validation and the event function
// the event function will call the validation with the event src

function display_name(item) {
	var strDisplay = item.getAttribute("DisplayName");
	if (strDisplay==null || strDisplay=="")
		strDisplay="Field";
	return strDisplay;
}

function default_value(item) {
	var strDefault = item.defaultValue;
	if (strDefault==null || strDefault=="")
		strDefault="";
	return strDefault;
}

function trim_string() {
	var ichar, icount;
	var strValue = this;
	ichar = strValue.length - 1;
	icount = -1;
	while (strValue.charAt(ichar)==' ' && ichar > icount)
		--ichar;
	if (ichar!=(strValue.length-1))
		strValue = strValue.slice(0,ichar+1);
	ichar = 0;
	icount = strValue.length - 1;
	while (strValue.charAt(ichar)==' ' && ichar < icount)
		++ichar;
	if (ichar!=0)
		strValue = strValue.slice(ichar,strValue.length);

	//* weird: when comparing two values(even the same) produced by this function it would give me false w/o +"".....
	return strValue+"";
}

function remove_commas_from_number(itemValue){
	var ichar, strValue;
	strValue = "";
	ichar = itemValue.length;
	for(var i=0; i<itemValue.length; i++){
		if(itemValue.charAt(i) != ","){
			strValue = strValue + itemValue.charAt(i);
		}
	}
	
	return strValue;
}

function es_non_blank() {
	var item = event.srcElement;
	event.returnValue = vs_non_blank(item);
}
function vs_non_blank(item, displayName, b_showAlert) {
	if (typeof(b_showAlert) != "boolean") {b_showAlert = true;}
	item.value=item.value.Trim();
	if (item.value.length==0) {
		if (b_showAlert) {
			item.focus();
			alert(strMustBeFilled.replace(/%1/, displayName));
		}		
		return false;
	}
	return true;
}

function vs_check_length(item, displayName, len) {
	item.value=item.value.Trim();
	var currLen = item.value.length;
	var strDisplayNameSizeTemp = strDisplayNameSize //This variable has to be reset to default so as it works fine for multiple checks in single page
	if (currLen > len) {
		strDisplayNameSizeTemp = strDisplayNameSizeTemp.replace(/%1/, displayName)
		strDisplayNameSizeTemp = strDisplayNameSizeTemp.replace(/%2/, len)
		strDisplayNameSizeTemp = strDisplayNameSizeTemp.replace(/%3/, (currLen - len))
		alert(strDisplayNameSizeTemp);
		item.focus();
		return false;
	}	
	return true;
}

function es_valid_number() {
	var item = event.srcElement;
	event.returnValue = vs_valid_number(item);
}
function vs_valid_number(item, displayName, minArg, maxArg) {
    
	var strErrorMsg = strValidNum.replace(/%1/, displayName);

	var strDefault = default_value(item);
	if (strDefault.length==0) {strDefault="0";}

	item.value=item.value.Trim();
	if (item.value.length==0)	{item.value=strDefault;}

    
    if((item.value.indexOf("0") ==0) && (item.value != 0)) {
        item.value=item.value.substring(1, item.value.length);
    }
    

	if(item.value.indexOf(",") >=0){
		var tempResult = remove_commas_from_number(item.value); 
		tempResult = parseInt(tempResult);
	}else{
		var tempResult = parseInt(item.value);
	}
	
	if (isNaN(tempResult)) {
			item.focus();
			alert(strErrorMsg);
			return false;
	} 

	if (typeof(minArg) == "number" || typeof(maxArg) == "number") {
		strErrorMsg = "";
		if (typeof(minArg) == "number" && tempResult < minArg) {
			strErrorMsg = strGreaterThan.replace(/%1/, displayName);
			strErrorMsg = strErrorMsg.replace(/%2/, minArg);
/* we do not want to alter the originally string 'strGreaterThan' because this string may be used again.
	if string was changed '%1' and '%2' will not be found and cannot be replaced by appropriate values

			strGreaterThan = strGreaterThan.replace(/%1/, displayName);
			strGreaterThan = strGreaterThan.replace(/%2/, minArg);
			strErrorMsg = strGreaterThan;
*/
		} else if (typeof(maxArg) == "number" && tempResult > maxArg) {
			strErrorMsg = strLessThan.replace(/%1/, displayName);
			strErrorMsg = strErrorMsg.replace(/%2/, maxArg);
/* we do not want to alter the originally string 'strLessThan' because this string may be used again.
	if string was changed '%1' and '%2' will not be found and cannot be replaced by appropriate values
			strLessThan = strLessThan.replace(/%1/, displayName);
			strLessThan = strLessThan.replace(/%2/, maxArg);
			strErrorMsg = strLessThan;
*/
		}
		if (strErrorMsg != "") {
			item.focus();
			alert(strErrorMsg);
			return false;
		}
	}

	item.value = tempResult;
	return true;
}
function vs_valid_integer(item, displayName) {
	var strErrorMsg = strValidNum.replace(/%1/, displayName);
	var strDefault = default_value(item);
	if (strDefault.length==0) {strDefault="0";}

	item.value=item.value.Trim();
	if (item.value.length==0)	{item.value=strDefault;}

	var tempResult = parseFloat(item.value);
	
	if (isNaN(tempResult)) {
			item.focus();
			alert(strErrorMsg);
			return false;
	} 

	item.value = tempResult;
	return true;
}


function es_valid_currency() {
	var item = event.srcElement;
	event.returnValue = vs_valid_currency(item);
}
function vs_valid_currency(item, displayName) {
	var strErrorMsg = strValidNum.replace(/%1/, displayName);

	var strDefault = default_value(item);
	if (strDefault.length==0) {strDefault="0";}

	item.value=item.value.Trim();
	if (item.value.length==0)	{item.value=strDefault;}
	
	if(item.value.indexOf(",",0)){
		var tempResult = remove_commas_from_number(item.value); 
	}

	if (isNaN(tempResult)) {
			item.focus();
			alert(strErrorMsg);
			return false;
	} 
	
	item.value = parseInt(parseFloat(tempResult) * 100)/100;
	return true;
}


function es_valid_hours() {
	var item = event.srcElement;
	event.returnValue = vs_valid_hours(item);
}
function vs_valid_hours(item, displayName) {
	if (!vs_valid_number(item))
		return false;
	var itemValue = new Number(item.value);
	if ((itemValue < 0 || itemValue > 80)) {
		item.focus();
		alert(strValidHours.replace(/%1/, displayName));
		return false;
	}
	itemValue *= 4;
	if ((itemValue)!=Math.ceil(itemValue)) {
		item.focus();
		alert(strQuarterlyInc.replace(/%1/, displayName));
		return false;
	}
	return true;
}


function date_toSimpleForm() {
	var toSimpleForm = new String;
	//* month+1 is b/c getMonth returns based on 0
	toSimpleForm = this.getMonth()+1 + "/" + this.getDate() + "/" + this.getFullYear()
	return toSimpleForm;
}

function es_valid_date() {
	var item = event.srcElement;
	event.returnValue = vs_valid_date(item);
}



function vs_valid_date(item, displayName) {
//	alert(getDateArray(item.value));
	var arrDate = getDateArray(item.value); 
//	var arrDate = item.value.split(dateSep); 
//	debugger;
	//* check if 2 (/)
	if (arrDate.length != 3) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	//* check if all numeric
	for (var i = 0; i < 3; i++) {	    
		if (isNaN(arrDate[i])) {
			item.focus();
			alert(strValidDate.replace(/%1/, displayName));
			return null;
		}
	}
	//* check if month is from 1 to 12
	if (arrDate[0] < 1 || arrDate[0] > 12) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	//* check if date < 1
	if (arrDate[1] < 1) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	//* check for months with 31 days
	if ((arrDate[0] == 1 || arrDate[0] == 3 || arrDate[0] == 5 || arrDate[0] == 7 || arrDate[0] == 8 || arrDate[0] == 10 || arrDate[0] == 12) && arrDate[1] > 31) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	//* check for months with 30 days
	if ((arrDate[0] == 4 || arrDate[0] == 6 || arrDate[0] == 9 || arrDate[0] == 11) && arrDate[1] > 30) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	//* check for February
	if (arrDate[0] == 2) {
		if ((arrDate[2] % 4 == 0 && arrDate[1] > 29) || (arrDate[2] % 4 != 0 && arrDate[1] > 28)) {
			item.focus();
			alert(strValidDate.replace(/%1/, displayName));
			return null;
		}
	}
	//* i will check if they entered 2 digit year and if it is from 00-29, i will append 20, otherwise 19
	tempStr = item.value
	whatYear = arrDate[2]; //tempStr.substring(tempStr.lastIndexOf(dateSep)+1, tempStr.length)
	if (whatYear.toString().length != 2 && whatYear.toString().length != 4) {
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	else if (whatYear.toString().length != 2 && (!(whatYear > 0) || whatYear.substr(0, 1) == "0"))
	{
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	else if (whatYear.length == 2) {
		if (new Number(whatYear) < 30) {
			item.value = tempStr.substring(0, tempStr.lastIndexOf(dateSep)+1) + "20" + whatYear
		}else{
			item.value = tempStr.substring(0, tempStr.lastIndexOf(dateSep)+1) + "19" + whatYear
		}
	}
	//* doublecheck for valid date (just in case)
	//* MikeG -- that doesn't work with German dates
	/*
	if (isNaN(Date.parse(item.value))) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return null;
	}
	*/
	
	//* check if the date is within 1/1/1900 - 1/1/2100 range
	
	var dtDate = new Date(top.getUnlocalizedDateJS(item.value));
	
	var startDate = new Date("1/1/1900");
	var endDate = new Date("1/1/2100");
	if (dtDate < startDate || dtDate > endDate) {
		alert(strOutOfDateRange.replace(/%1/, displayName));
		return null;
	}

//I18n
//	var dtItem = new Date(Date.parse(item.value));
//	item.value = dtItem.toSimpleForm();

	return dtDate;
}

function vs_valid_date2(item, displayName) {
	if (isNaN(Date.parse(item.value))) {
		item.focus();
		alert(strValidDate.replace(/%1/, displayName));
		return false;
	}
	//i will check if they entered 2 digit year and if it is from 00-29, i will append 20, otherwise 19
	tempStr = item.value
	whatYear = tempStr.substring(tempStr.lastIndexOf("/")+1, tempStr.length)
	if (whatYear.toString().length =z= 3 || whatYear.toString().length == 1) {
		alert(strValidYear.replace(/%1/, displayName))
		return false;
	}else if (whatYear.length == 2) {
		if (new Number(whatYear) < 30) {
			item.value = tempStr.substring(0, tempStr.lastIndexOf("/")+1) + "20" + whatYear
		}else{
			item.value = tempStr.substring(0, tempStr.lastIndexOf("/")+1) + "19" + whatYear
		}
	}
	//alert(item.value)

	var dtItem = new Date(Date.parse(item.value));
	item.value = dtItem.toSimpleForm();

	return true;
}


function es_item_selected() {
	var item = event.srcElement;
	event.returnValue = vs_item_selected(item);
}
function vs_item_selected(item, displayName) {
	if (item.selectedIndex==0) {
		item.focus();
		alert(strValidSelection.replace(/%1/, displayName));
		return false;
	}
	return true;
}

function es_valid_zip() {
	var item = event.srcElement;
	event.returnValue = vs_valid_zip(item);
}
function vs_valid_zip(item, displayName) {
	item.value=item.value.Trim();
	if (!(/^\d{5}$/.test(item.value) || /^\d{5}-\d{4}$/.test(item.value))) {
		item.focus();
		alert(strValidZipCode.replace(/%1/, displayName));
		return false;
	}
	return true;
}

function es_valid_ssnbr() {
	var item = event.srcElement;
	event.returnValue = vs_valid_ssnbr(item);
}
function vs_valid_ssnbr(item, displayName) {
	item.value=item.value.Trim();
	if (!(/^\d{3}-\d{2}-\d{4}$/.test(item.value))) {
		item.focus();
		alert(strValidSSN.replace(/%1/, displayName));
		return false;
	}
	return true;
}

function es_valid_email() {
	var item = event.srcElement;
	event.returnValue = vs_valid_email(item);
}
function vs_valid_email(item, displayName) {
	item.value=item.value.Trim();
	data = item.value;
	//this string doesn't allow following emails: blah@411.com or blah@BLAH.com
	//if (!(/^[\w\.]+@[a-z\.]+$/.test(item.value))) {
	if (data.indexOf("@")==-1 || data.indexOf(".")==-1) {
		item.focus();
		alert(strValidEmail.replace(/%1/, displayName));
		return false;
	}
	return true;
}

var valStr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
function vs_valid_login(item, displayName) {
	var valStr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
	var thischar
	item.value=item.value.Trim();
	data = item.value;
	if (data == "") {item.focus();alert(strValidName.replace(/%1/, displayName));return false;}
	for (var i=0; i < data.length; i++){
	   thischar = data.substring(i, i+1);
	   if (valStr.indexOf(thischar) ==-1){
				item.focus();
				alert(strValidName.replace(/%1/, displayName));
	      return false;
	   }
	}
	return true
}
function vs_valid_password(item, displayName) {
	var thischar
	item.value=item.value.Trim();
	data = item.value;
	if (data == "") {item.focus();alert(strValidPassword.replace(/%1/, displayName));return false;}
	for (var i=0; i < data.length; i++){
	   thischar = data.substring(i, i+1);
	   if (valStr.indexOf(thischar) ==-1){
				item.focus();
				alert(strValidPassword.replace(/%1/, displayName));
	      return false;
	   }
	}
	return true
}

function vs_valid_first_char(item, displayName){
	valStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	if (valStr.indexOf(item.value.charAt(0)) ==-1){
		item.focus();
		alert(strStartWithChar.replace(/%1/, displayName));
	    return false;
	 }
	return true
}

// build the validation object
function validation_setup() {
	this.eventNonBlank = es_non_blank;
	this.nonBlank = vs_non_blank;
	this.checkLength = vs_check_length;
	this.eventValidNumber = es_valid_number;
	this.validNumber = vs_valid_number;
	this.validInteger = vs_valid_integer;
	this.validCurrency = vs_valid_currency;
	this.eventValidHours = es_valid_hours;
	this.validHours = vs_valid_hours;
	this.eventValidDate = es_valid_date;
	this.validDate = vs_valid_date;
	this.eventItemSelected = es_item_selected;
	this.itemSelected = vs_item_selected;
	this.eventValidZip = es_valid_zip;
	this.validZip = vs_valid_zip;
	this.eventValidSSNbr = es_valid_ssnbr;
	this.validSSNbr = vs_valid_ssnbr;
	this.eventValidEmail = es_valid_email;
	this.validEmail = vs_valid_email;

	this.validLogin = vs_valid_login;
	this.validPassword = vs_valid_password;
	this.validFirstChar = vs_valid_first_char;
	this.getCheckboxCollectionLength = get_checkbox_collection_length;
	return this;
}

// Extend the string object to include a trim function
String.prototype.Trim = trim_string;
// Extend the date object to include a simple form string conversion
Date.prototype.toSimpleForm = date_toSimpleForm;

// Construct the validation object
var validation = new Object;
validation = validation_setup();


// This set of function are for processing the key press event
// Used to restrict input on numerics and pure textual fields

function kp_integer() {
	if ((event.keyCode < 48 || event.keyCode > 57))
		event.returnValue = false;
}
function kp_numeric() {
	if ((event.keyCode != 46) && (event.keyCode < 48 || event.keyCode > 57))
		event.returnValue = false;
	if (event.keyCode == 46) {
		if (event.srcElement.value.indexOf(".") > -1)
			event.returnValue = false;
	}
}


function kp_character() {
	if ((event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122))
		event.returnValue = false;
}
function kp_convert_upper() {
	if ((event.keyCode >= 97 && event.keyCode <= 122))
		event.keyCode -= 32;
}
function kp_convert_lower() {
	if ((event.keyCode >= 65 && event.keyCode <= 90))
		event.keyCode += 32;
}


function kp_setup() {
	this.Integer = kp_integer;
	this.Numeric = kp_numeric;
	this.Character = kp_character;
	this.ConvertUpper = kp_convert_upper;
	this.ConvertLower = kp_convert_lower;
	return this;
}

var keyPressInput = new Object;
keyPressInput = kp_setup();

function validLoginPassvord(data){
	var thischar
	for (var i=0; i < data.length; i++){
	   thischar = data.substring(i, i+1);
	   if (valStr.indexOf(thischar) ==-1){
	      return false
	   }
	}
	return true
}

//takes a checkbox or radiobutton form reference and 
//and returns the length of the checked collection or returns
//-1 if the collection doesn't exist or returns 0 if the
//collection exists but no items are checked
function get_checkbox_collection_length(elemColl){
	var Cntr = 0;
	if (!elemColl) {return -1};

	var elemCollLen = elemColl.length;
	if(typeof(elemCollLen) == "undefined"){
		Cntr = (elemColl.checked == true) ? 1 : 0;
	}else{
		for(var x = 0; x < elemCollLen; x++){
			if(elemColl[x].checked == true){
				Cntr++;
			}
		}
	}

	return Cntr;
}

//***************
// OTHER usefull functions
function ArrayContains(arrRef, val) {
	for (var i=0; i < arrRef.length; i++) {
		if (arrRef[i] == val) {
			return true;
		}
	}
	return false;
}


function noSymbol(sSymbol, itemValue){
	for(var i=0; i<itemValue.length; i++){
		if(itemValue.charAt(i) == sSymbol){
			alert(strNoSymbol.replace(/%1/, sSymbol));
			return;
		}
	}
	return true;
}
//* Select a dropdown item.  Pass in formRef and the value to select. 
function selectItem(elemCollRef, itemValue) {
	if (!elemCollRef) return;
	var elemCollLen = elemCollRef.length;
	for (var i = 0; i < elemCollLen; i++) {
		if (elemCollRef[i].value == itemValue) {
			elemCollRef[i].selected = true;
			break;
		}
	}
}

//* Select a checkbox item.  Pass in formRef and the value to check. 
function checkItem(elemCollRef, itemValue) {
	if (!elemCollRef) return;
	var elemCollLen = elemCollRef.length;
	if (typeof(elemCollLen) == "undefined") {
		if (elemCollRef.value == itemValue) {
			elemCollRef.checked = true;
		}
	} else {
		for (var i = 0; i < elemCollLen; i++) {
			if (elemCollRef[i].value == itemValue) {
				elemCollRef[i].checked = true;
				break;
			}
		}
	}
}

//*****************************
	function escapeUTF(str) {
		var returnStr = "";
		if (typeof(encodeURIComponent ) == "undefined") {
			returnStr = Utf8UrlEncode(str);
//			alert("Utf8UrlEncode: " + str + " : " + returnStr)
		} else {
			returnStr = encodeURIComponent (str);
//			alert("encodeURI: " + str + " : " + returnStr)
		}	
		return returnStr;
	}

	function Utf8UrlEncode(originaltext) {
		var SAFECHARS = "0123456789" +					// Numeric
						"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetci
						"abcdefghijklmnopqrstuvwxyz" +
						"-_.!~*'()";					// RFC2396 Mark characters
		var HEX = "0123456789ABCDEF";
	
		var encoded = "";
		for (var i = 0; i < originaltext.length; i++ ) {
			var ch = originaltext.charAt(i);
		    if (ch == " ") {
			    encoded += "+";	// x-www-urlencoded, rather than %20
			} else if (SAFECHARS.indexOf(ch) != -1) {
			    encoded += ch;
			} else {
			    var charCode = ch.charCodeAt(0);
				if (charCode > 127) {
	
					// all chars in range 127 to 2047 => 2byte
					if((charCode > 127) && ( charCode < 2048)) {
						encoded += '%' + ((charCode >> 6)|192).toString(16);
						encoded += '%' + ((charCode & 63)|128).toString(16);
					}
					// all chars in range 2048 to 66536 => 3byte
					else {
						encoded += '%' + ((charCode >> 12)|224).toString(16);
						encoded += '%' + (((charCode >> 6)&63)|128).toString(16);
						encoded += '%' + ((charCode & 63)|128).toString(16);
					}
	
				} else {
					encoded += "%";
					encoded += HEX.charAt((charCode >> 4) & 0xF);
					encoded += HEX.charAt(charCode & 0xF);
				}
			}
		} // for
		
		return encoded;
	}	

	
/*
This function disables the element collection a reference to which was passed in
*/	
function disableElemColl(elemCollRef, b_disable) {
	if (b_disable != true && b_disable != false) b_disable = true;
	if (typeof(elemCollRef) == "undefined") return;
	
	var elemCollRefLength = elemCollRef.length;
	if (typeof(elemCollRefLength) == "undefined") {
		if (elemCollRef.type == "submit" || elemCollRef.type == "button") {	
			elemCollRef.disabled = b_disable;	
		}
	} else {
		for (var i = 0; i < elemCollRefLength; i++) {
			if (elemCollRef[i].type == "submit" || elemCollRef[i].type == "button") {	
				elemCollRef[i].disabled = b_disable;
			}
		}
	} 
}

/*this function will check and allow only 500 users information to be submitted to server for processing
done as a part of optimization improvements
*/		
function chkSelectCheckBoxCnt(formRef){
	alertStr = ""
	var numPickedAllowed = 500;
	numPicked = get_checkbox_collection_length(formRef)

	var parentLevel = "";
	if (typeof(formRef.bCoursesFromParentLevel) != 'undefined')
		parentLevel = "bCoursesFromParentLevel";
	if (typeof(formRef.bCurriculaFromParentLevel) != 'undefined')
		parentLevel = "bCurriculaFromParentLevel";
	if (typeof(formRef.bUsersFromParentLevel) != 'undefined')
		parentLevel = "bUsersFromParentLevel";
	if (parentLevel != "") {
		var objParentLevel = document.getElementById(parentLevel);
		if (objParentLevel.checked) {
			numPicked = numPicked - 1;
		}
	}
	if (numPicked > numPickedAllowed){
		alertStr = you_have_selected_1_users;
		alertStr = alertStr.replace(/%1/, numPicked);
		
		alertStr += you_will_have_to_process_the_remaining_3 ;
		alertStr = alertStr.replace(/%2/, numPickedAllowed);
		alertStr = alertStr.replace(/%3/, numPicked - numPickedAllowed);
		
		alertStr += "\n\n\n" + would_you_like_to_proceed;
		
		if (confirm(alertStr)){
			numPicked = 0
			for(i=0; i<formRef.elements.length; i++) {
				if (formRef.elements[i].checked) {
					numPicked++;
					if (numPicked > numPickedAllowed){
						formRef.elements[i].checked = false;				
					}
				}
			}
		} else {	
			return false;
		}
	}
	return true;
}
function chkSelectCheckBoxCntCourses(formRef, numPickedAllowed){
	alertStr = ""
	if (numPickedAllowed=='') {
		var numPickedAllowed = 500;
	}
	numPicked = get_checkbox_collection_length(formRef)
	if (numPicked > numPickedAllowed){
		alertStr = "You have selected %1 courses, The system can only process %2 courses at a time.\nYou will have to process the remaining %3 courses with another request.";

		alertStr = alertStr.replace(/%1/, numPicked);
		alertStr = alertStr.replace(/%2/, numPickedAllowed);
		alertStr = alertStr.replace(/%3/, numPicked - numPickedAllowed);
		
		alertStr += "\n\n\n" + would_you_like_to_proceed;
		
		if (confirm(alertStr)){
			numPicked = 0
			for(i=0; i<formRef.elements.length; i++) {
				if (formRef.elements[i].checked) {
					numPicked++;
					if (numPicked > numPickedAllowed){
						formRef.elements[i].checked = false;				
					}
				}
			}
		} else {	
			return false;
		}
	}
	return true;
}