//
/////////////////////////////////////////////////////////////////
//	Don't submit a form entry twice ;)
//	Usage: <form method="POST" onSubmit="submitonce(this)">
/////////////////////////////////////////////////////////////////
//
function submitonce(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
		}
	}
}
//
/////////////////////////////////////////////////////////////////
// Confirmation Message Button
//
// href="" onClick="tmt_confirm('Are%20you%20sure%20you%20want%20to%20perform%20this%20action?');return document.MM_returnValue">
/////////////////////////////////////////////////////////////////
//
function tmt_confirm(msg){
	document.MM_returnValue=(confirm(unescape(msg)));
}
//
/////////////////////////////////////////////////////////////////
// Email Validation
/////////////////////////////////////////////////////////////////
//
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e)
{
	var returnval=emailfilter.test(e.value)
	if (returnval==false)
	{
		alert("Please enter a valid email address.")
		e.select()
	}
  return returnval
}
//
/////////////////////////////////////////////////////////////////
// Popup For Radio Window
/////////////////////////////////////////////////////////////////
//
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
//
function toggle(targetId)
{
	if(document.getElementById)
	{
		target=document.getElementById(targetId)
		if(target.style.display=="none"){
		target.style.display=""
		}else{
		target.style.display="none"}
	}
}
//
/////////////////////////////////////////////////////////////////
//	Limit Textarea Lengths
/////////////////////////////////////////////////////////////////
//
function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
	else 
	countfield.value = maxlimit - field.value.length;
}