//-------------------------------------------------------------------
// isBlank(string)
//   Returns false if there is a non-blank character in the string
//-------------------------------------------------------------------
function isBlank(val) {
	if (val == null || val == "") return true;
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
		
}

//-------------------------------------------------------------------
// setNullIfBlank(input_object)
//   Sets a form field to "" if it isBlank()
//-------------------------------------------------------------------
function setNullIfBlank(obj){if(isBlank(obj.value)){obj.value="";}}

//-------------------------------------------------------------------
// checklength(textarea, maxchars)
//   Returns false if there are more than maxchars characters in the textarea
//-------------------------------------------------------------------
function checklength(textarea, maxchars) {
	var len = textarea.value;
	if (len.length > maxchars) {
		alert('The text is too long(' + len.length + ' characters). Please edit the text');
		return false;
	} else return true;
}

// Process Album addition
function processPhotoData(form) {
	// Check that filename and album are specified
	
	var msg = "Please specify ";
	if (isBlank(form.imageupload.value)) {
		if (msg != "Please specify ") msg += ", ";
		msg += "a file to upload";
	}
	if (form.album.selectedIndex == 0) {
		if (msg != "Please specify ") msg += ", ";
		msg += "an album";
	}
	if (msg != "Please specify ") {
			alert(msg);
			return false;	
	}
	return true;	
	
}



