// Javascript Document
function checkURL() {
	var URL = window.location.toString().toLowerCase();
	if (URL.indexOf("www.chenangoicerink")!=-1) {	
		if (window.location.toString().toLowerCase().indexOf("alhazzardtu")!=-1) {
			window.location.replace("http://www.alhazzardtu.org");
		}
	} else 	if (URL.indexOf("www.alhazzardtu")!=-1) {	
		if (window.location.toString().toLowerCase().indexOf("cir")!=-1) {
			window.location.replace("http://www.chenangoicerink.com");
		}
	}
}

function process(action) {
	checkURL();
	if (action=="gallery" || action=="goToLogIn" || action == "logOff" || action=="bulletinBoard" || 
	    action=="commitPost" || action=="changeGalleryMonth" || action=="buddy") {
		document.tuForm.action.value=action;
		document.tuForm.submit();
	} else {
		if (window.location.toString().indexOf("index.jsp") == -1) {
			document.tuForm.action.value=action;
			document.tuForm.submit();
		}
		if (document.getElementById("displayArea")!=null) {
			document.getElementById("displayArea").innerHTML = document.getElementById(action).innerHTML; 
		}
	}
}

function processImage() {
	document.imageForm.submit();
}

function submitOnReturn(action) {
	if (window.event.keyCode == 13) {
		process(action);
	}
}
// functions to prevent use of character keystrokes in numeric only fields
var isNS4 = (navigator.appName=="Netscape")?1:0;
function preventCharacters(type) {
	if (!isNS4) {
	   if ((event.keyCode < 45 || event.keyCode > 57) || event.keyCode == 45 || event.keyCode == 46 || event.keyCode == 47) {
		   event.returnValue = false;
	   }
	} else {
		if ((event.which < 45 || event.which > 57) || event.which == 45 || event.keyCode == 46 || event.which == 47)  {
			returnfalse;
		}
	}
}

function preventCharAllowDecimal(type) {
	if (!isNS4) {
	   if ((event.keyCode < 45 || event.keyCode > 57) || event.keyCode == 45 || event.keyCode == 47) {
		   event.returnValue = false;
	   }
	} else {
		if ((event.which < 45 || event.which > 57) || event.which == 45 || event.which == 47)  {
			returnfalse;
		}
	}
}

function preventCharAllowDash(type) {
	if (!isNS4) {
	   if ((event.keyCode < 45 || event.keyCode > 57) || event.keyCode == 44 || event.keyCode == 46) {
		   event.returnValue = false;
	   }
	} else {
		if ((event.which < 45 || event.which > 57) || event.which == 44 || event.which == 46)  {
			returnfalse;
		}
	}
}

function preventNumbers() {
	if (!isNS4) {
	   if ((event.keyCode > 43 && event.keyCode < 58) || event.keyCode == 43 || event.keyCode == 61 || event.keyCode == 45 || event.keyCode == 95){
	   		event.returnValue = false;
	   }
	} else {
		if ((event.keyCode > 43 && event.keyCode < 58) || event.keyCode == 43 || event.keyCode == 61 || event.keyCode == 45 || event.keyCode == 95) {
			returnfalse;
		}
	}
}
// Tabs the cursor through the SSN lookup automagically ,submits form on return keypress
function autotab(original,destination){
	if (original.getAttribute&&
		(window.event.keyCode!=9)&&(event.keyCode!=16)&&
		original.value.length==original.getAttribute("maxlength")) {
		destination.focus();
		if(destination.type=="text" || destination.type=="textarea") {
			destination.select();
		}
	}
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength")) {
		if (window.event.keyCode == 13) {
			process('clSearch');
		}
	}
}

// Clear the value of the field
function clearText(thefield){
	if (thefield.defaultValue==thefield.value) {
		thefield.value = ""
	}
}
function confirmAction(sMessage, sAction) {
   if (confirm(sMessage)) {
	  window.status='';
	  process(sAction);	  
   } 
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
 