//This function is used to allow subsequent presses of the Enter button
//following validation. See http://www.velocityreviews.com/forums/t122174-default-button-not-working-after-validation.html
function defaultButtonFix() {
	__defaultFired = false;
}

//This function opens a new window; used for viewing videos
function wopen(url, name, w, h)
{
 w += 28;
 h += 76;
 var win = window.open(url,
	name,
	'width=' + w + ', height=' + h + ', ' +
	'location=no, menubar=no, ' +
	'status=no, toolbar=no, scrollbars=no, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

//This function is used by the search field; the code-behind calls it in the
//onKeyPress event for that field; its purpose is to mimic clicking the Go
//button if the user presses Enter while in the search field; otherwise, if
//there are other fields on the page, the default submit button will fire.
//This code should appear exactly in all MasterPages.
function clickButton(e, buttonid){
	var bt = document.getElementById(buttonid);
	if (typeof bt == 'object'){
		 if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
			  if (event.keyCode == 13){
					bt.click();
					return false;
			  }
		 } else {
			  if (e.keyCode == 13){
					bt.click();
					return false;
			  }
		 }
	}
}

function makeFieldUppercase(field){
  field.value = field.value.toUpperCase();
}

function formatPhoneNumber(field){
  if(field.value.length!=10){
    return;
  }
  field.value = "(" + field.value.substring(0,3) + ") " + 
    field.value.substring(3,6) + "-" + field.value.substring(6,10);
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Torsten Frey (tf@tfrey.de) -->
<!-- Web Site:  http://www.tfrey.de -->
function check_date(field){
  var checkstr = "0123456789";
  var DateField = field;
  var Datevalue = "";
  var DateTemp = "";
  var seperator = "/";
  var day;
  var month;
  var year;
  var leap = 0;
  var err = 0;
  var i;
  err = 0;
  DateValue = DateField.value;
  /* Delete all chars except 0..9 */
  for (i = 0; i < DateValue.length; i++) {
    if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
      DateTemp = DateTemp + DateValue.substr(i,1);
    } else {
      if(DateTemp.length==1){ //user entered a one-digit month
        DateTemp = '0' + DateTemp;
      } else if(DateTemp.length==3){ //user entered a one-digit day
        DateTemp = DateTemp.substr(0,2) + '0' + DateTemp.substr(2,3);
      }
    }
  }
  DateValue = DateTemp;
  /* Always change date to 8 digits - string*/
  /* if year is entered as 2-digit / always assume 20xx */
  if (DateValue.length == 6) {
    DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); 
  }
  if (DateValue.length != 8) {
    err = 19;
  }
  /* year is wrong if year = 0000 */
  year = DateValue.substr(4,4);
  if (year == 0) {
    err = 20;
  }
  /* Validation of month*/
  month = DateValue.substr(0,2);
  if ((month < 1) || (month > 12)) {
    err = 21;
  }
  /* Validation of day*/
  day = DateValue.substr(2,2);
  if (day < 1) {
    err = 22;
  }
  /* Validation leap-year / february / day */
  if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
    leap = 1;
  }
  if ((month == 2) && (leap == 1) && (day > 29)) {
    err = 23;
  }
  if ((month == 2) && (leap != 1) && (day > 28)) {
    err = 24;
  }
  /* Validation of other months */
  if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
    err = 25;
  }
  if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
    err = 26;
  }
  /* if 00 ist entered, no error, deleting the entry */
  if ((day == 0) && (month == 0) && (year == 00)) {
    err = 0; day = ""; month = ""; year = ""; seperator = "";
  }
  /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
  if (err == 0) {
    DateField.value =  month + seperator + day + seperator + year;
  }
  /* Error-message if err != 0 */
  else {
    alert("The date is not in the correct format of MM/DD/YY.");
    DateField.select();
    DateField.focus();
  }
}

/* Begin Ajax section for checking for valid filename */
var xmlHttp
var errorSpanIdGlobal
function checkFilename(filename,errorSpanId)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        // browser does not support ajax
        return;
    } 
    errorSpanIdGlobal = errorSpanId;
    var url="checkFile.aspx";
    url=url+"?file="+filename;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 
function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    { 
        document.getElementById(errorSpanIdGlobal).innerHTML=xmlHttp.responseText;
    }
}
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
/* End Ajax section for checking for valid filename */

/* Ajax function to check whether a name exists in the summit registration table. */
/* Uses helper functions defined above for the file checker. */
function checkSummitRegistration(name,errorSpanId)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        // browser does not support ajax
        return;
    } 
    errorSpanIdGlobal = errorSpanId;
    var url="checkSummitRegistration.aspx";
    url=url+"?name="+name;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

/* Ajax function to check whether a name exists in the pres club registration table. */
/* Uses helper functions defined above for the file checker. */
function checkPresClubRegistration(first_name,last_name,errorSpanId)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        // browser does not support ajax
        return;
    } 
    errorSpanIdGlobal = errorSpanId;
    var url="checkPresClubRegistration.aspx";
    url=url+"?first_name="+first_name;
    url=url+"&last_name="+last_name;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 
