// JavaScript Document

function autofocus(field, limit, next, evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && field.value.length == limit) {
        field.form.elements[next].focus();
    }
}

function popitup(url) {
	newwindow = window.open(url,'name','height=400,width=800,center=yes,resize=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus();}
	return false;
}
window.name = "main";
function SIF(id) {
	var answer = confirm ("This is to register for a sport. If you have already registered using the Athlete Interest Form, Click OK, otherwise, click CANCEL.");
	if (answer) {
		popitup('/forms/SIF_verify.php?id=' + id);
	} else {
		alert ("You are being redirected to the Athlete Interest Form.");
		location = "/forms/Athlete_Interest_Form.php";
	}
}

function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == 0) {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}

/* Change
function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
			tempobj.disabled = true;
		}
		return true;
	}else {
		alert("The form has been submitted.  But, since you're not using IE 4+ or NS 6, the submit button was not disabled on form submission.");
		return false;
	}
} */