	function verifyFields(locsReq) {
		var error = false;
		var selectedCategory = document.photoForm.catId.selectedIndex;
		var selectedLocation = document.photoForm.locId.selectedIndex;

		if (!document.photoForm.userName.disabled) {
			document.photoForm.userName.value = trim(document.photoForm.userName.value);
			if (document.photoForm.userName.value == '') {
				alert("You must enter your name.");
				document.photoForm.userName.className = 'invalidInput';
				error = true;
			}
		}

		if (!document.photoForm.email.disabled) {
			document.photoForm.email.value = trim(document.photoForm.email.value);
			if (document.photoForm.email.value  == '') {
				alert("You must enter your email address.");
				document.photoForm.email.className = 'invalidInput';
				error = true;
			} else if (!validEmail(document.photoForm.email.value)) {
				alert("You must enter a valid email address.");
				document.photoForm.email.className = 'invalidInput';
				error = true;
			}
		}

		document.photoForm.title.value = trim(document.photoForm.title.value);
		if (document.photoForm.title.value == '') {
			alert("You must enter a title for the photo.");
			document.photoForm.title.className = 'invalidInput';
			error = true;
		}
		if (document.photoForm.title.value.length > 75 ) {
			alert("The title cannot exceed 75 characters.");
			document.photoForm.title.className = 'invalidInput';
			error = true;
		}

		document.photoForm.description.value = trim(document.photoForm.description.value);
		if (document.photoForm.description.value == '') {
			alert("You must enter a description for the photo.");
			document.photoForm.description.className = 'invalidInput';
			error = true;
		}
		if (document.photoForm.description.value.length > 350 ) {
			alert("The description cannot exceed 350 characters.");
			document.photoForm.description.className = 'invalidInput';
			error = true;
		}

		/* Optionally Required Fields */
		if (document.photoForm.requireCity) {
			if (document.photoForm.city.value == '') {
				alert("You must enter a city");
				document.photoForm.city.className = 'invalidInput';
				error = true;
			}
		}

		if (document.photoForm.requireState) {
			if (document.photoForm.state.value == '') {
				alert("You must choose a state");
				document.photoForm.state.className = 'invalidInput';
				error = true;
			}
		}

		if (document.photoForm.requirePhotoCategory) {
			if (document.photoForm.catId.value == '') {
				alert("You must select a photo category");
				document.photoForm.catId.className = 'invalidInput';
				error = true;
			}
		}
		/* /Optionally Required Fields  */

	/*
		if(selectedCategory == 0){
			alert("You must select a category.");
			document.photoForm.catId.style.backgroundColor = '#FFDFDF';
			error = true;
		}
 */
		if(selectedLocation == 0){
			alert("You must select a neighborhood.");
			document.photoForm.locId.className = 'invalidInput';
			error = true;
		}

		//if (document.photoForm.catId.options[c].value == '') {
		//	alert("You must select a category");
		//	document.photoForm.catId.style.backgroundColor = '#FFDFDF';
		//	error = true;
		//}

		//if (locsReq = 'true') {
		//	if (document.photoForm.locId.options[l].value == '') {
		//		alert("You must select a location.");
		//		document.photoForm.locId.style.backgroundColor = '#FFDFDF';
		//		error = true;
		//	}
		//}

		try{document.photoForm.photo.value = trim(document.photoForm.photo.value)}catch(e){}
		if (document.photoForm.photo.value == '') {
			alert("You must upload a photo.");
			document.photoForm.photo.className = 'invalidInput';
			error = true;
		}else if(document.photoForm.photo.value != ''){
			if(!supportedImgFormat(document.photoForm.photo.value)){
				alert("Only .gif .jpg and .png image types are supported.");
				document.photoForm.photo.className = 'invalidInput';
				error = true;
			}
		}

		if (error == false) {
			document.photoForm.userEmail.value = document.photoForm.email.value;
			document.photoForm.submit();
		}

	}

	function validEmail(address){
		var emailRegEx = new RegExp("\^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+\$");
		if(emailRegEx.test(address)){return true;}else{return false;}

	}


	function rTrim(value){
		var w_space = String.fromCharCode(32);
		var v_length = value.length;
		var strTemp = "";
		if(v_length < 0){
			return"";
		}
		var iTemp = v_length -1;

		while(iTemp > -1){
			if(value.charAt(iTemp) == w_space){
			}else{
				strTemp = value.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;

		}

		return strTemp;
	}

	function lTrim(value){
		var w_space = String.fromCharCode(32);
		if(v_length < 1){
		return"";
		}
		var v_length = value.length;
		var strTemp = "";

		var iTemp = 0;

		while(iTemp < v_length){
			if(value.charAt(iTemp) == w_space){
			}else{
				strTemp = value.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}
		return strTemp;
	}

	function trim(value){
		if(value.length < 1){return "";}

		value = rTrim(value);
		value = lTrim(value);

		return value;
	}

	function supportedImgFormat(value){
		var imgFormat = new RegExp("(\.(jpg|gif|png))$","i");
		if(imgFormat.test(value)){return true;}else{return false;}
	}

/**
 * Used for char max and char counting
 */
	function updateCharCount(input, countInput, max){
		if(input.value.length > max){
			input.value = input.value.substring(0, max);
		}
		document.getElementById(countInput).innerHTML = input.value.length;
	}
/**
 *
 */

	function setUp() {
		if (document.photoForm != null) {
	        document.getElementById('titleCount').innerHTML = document.photoForm.title.value.length;
    	    document.getElementById('descCount').innerHTML = document.photoForm.description.value.length;
			titleText = document.photoForm.title.value;
			descText = document.photoForm.description.value;
		}
	}

	function redirectCancel(url) {
		window.location = url;
	}
