// JavaScript Document
function validateForm(theForm){
	var error = 0;
	if (!filecheck()){error=1;}
	if (!imagetitle()){error=1;}
	if (!checkApproval(theForm)){error=1;}
	
	if (error == 1){
		return false;
	}else{
		return true;
	}
}
/**********************************************************
 * File Extention Check
 * Date: 2008-02-22
 * HTML EVENT HANDLERS
 * <form>
 * 		onSubmit=\"return filecheck();
 **********************************************************/
function filecheck() {
  var ext = document.getElementById("uploaded").value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext == 'jpg' || ext == 'JPG') {
	return true;
  } else {
    alert('You selected a .'+ext+' file; please select a JPEG image file instead!');
    return false; 
  }
}

function imagetitle() {
  if(document.getElementById("title").value != '') {
	return true;
  } else {
    alert("You must enter a 'Name' for your photo!");
    return false; 
  }
}

function checkApproval(theForm) {
	if (theForm.approve.checked == false){
		alert ("You need to read and accept the Official Rules before continuing!");
		return false;
	} else { 	
		return true;
	}
}
/**********************************************************
 * Limit Textarea Length
 * Date: 2008-02-22
 * HTML EVENT HANDLERS
 * - Textarea <textarea></textarea> 
 * - Text Field <input type="text" />
 *		onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,100);" 
 *		onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,100);"
 **********************************************************/
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function mywindow(mylink)
{
	window.open(mylink,'',"scrollbars=yes,width=700,height=500");
}