<!--

var js_delimiter1 = "||"
var js_delimiter2 = "**"


function upw() {
  document.getElementById("lipw").innerHTML = "<input type='password' name='password' value='' class='inputPass' />";
  document.loginF.password.value = '';
  document.loginF.password.focus();
  document.loginF.password.focus();
}

function checkBoxes(frmObj, chk) { 
    for (i=0; i < frmObj.length; i++) { 
        frmObj[i].checked = chk; 
    } 
} 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


function eventStateSelected(i) {

  if (i < 0) {
    // Select Option selected
    return;
  }

  var a = eventIDs[i-1].split(js_delimiter2);
  var b = eventNames[i-1].split(js_delimiter2);
  var c = eventDates[i-1].split(js_delimiter2);
  
  for (i=document.aForm.eventID.options.length;i>=0;i=i-1) {
    document.aForm.eventID.options[i] = null;
  }
  
  for (j = 0; j < a.length; j++) {
    if (b[j] != 'Select...') {
      addOption(document.aForm.eventID, b[j] + ' - ' + c[j], a[j]);
    } else {
      addOption(document.aForm.eventID, b[j], a[j]);
    }
  }

}

function teamStateSelected(i) {

  if (i < 0) {
    // Select Option selected
    return;
  }

  var a = teamIDs[i-1].split(js_delimiter2);
  var b = teamNames[i-1].split(js_delimiter2);
  
  for (i=document.aForm.teamID.options.length;i>=0;i=i-1) {
    document.aForm.teamID.options[i] = null;
  }
  
  for (j = 0; j < a.length; j++) {
    addOption(document.aForm.teamID, b[j], a[j]);
  }

}


function participantTypeSelected() {
  var h;
  var x = document.getElementById('packageH');
  
  if (x) {
  
	if (document.aForm.participantType[0].checked == true || document.aForm.participantType[2].checked == true) {
	  // Team Captiain  || Individual Rider
	  h = '<input name="package" type="radio" value="1" checked /> <a href="Javascript:openInfoWindow(51)">Full Package Rider</a> ($3,500 minimum)<br/><input name="package" type="radio" value="2" /> <a href="Javascript:openInfoWindow(52)">Weekend only rider</a> ($2,800 minimum)<br/><input name="package" type="radio" value="3" /> <a href="Javascript:openInfoWindow(53)">Day only rider</a> ($1,000 minimum)<br/>';
	  
	} else if (document.aForm.participantType[1].checked == true) {
	  // Team Member
	  h = '<input name="package" type="radio" value="1" checked /> <a href="Javascript:openInfoWindow(51)">Full Package Rider</a> ($3,500 minimum)<br/><input name="package" type="radio" value="2" /> <a href="Javascript:openInfoWindow(52)">Weekend only rider</a> ($2,800 minimum)<br/><input name="package" type="radio" value="3" /> <a href="Javascript:openInfoWindow(53)">Day only rider</a> ($1,000 minimum)<br/>';
	  
	} else if (document.aForm.participantType[3].checked == true) {
	  // Supporting Rider
	  h = '<input name="package" type="radio" value="4" checked /> <a href="Javascript:openInfoWindow(54)">Non-riding supporter</a> ($2,000 minimum)<br/>';
	  
	}
  
    x.innerHTML = h;
 
  }

}


function addOption(formElement, optiontext, optionValue) {
  var optionName = new Option(optiontext, optionValue, false, false)
  var length = formElement.length;
  formElement.options[length] = optionName;
}


function editPage(m) {
  openBrWindow('accountEditWebFunctions.asp?m=' + m,'Receipt','toolbar=no,menubar=no,scrollbars=yes,resizable=no,width=590,height=400')
  
}


function openInfoWindow(contentID) {
  // opens receipt window for input itemid
  openBrWindow("default.asp?contentID="+contentID,"info","scrollbars=yes,width=600,height=350");
}


function isWholeDollarAmount() {
  var fld = aForm.sponsorAmountOther;
  if (fld.value == '') { return true; }
  if (fld.value.indexOf(".") > -1 && fld.value.indexOf(".00") == -1) {
    alert("Please enter a whole dollar sponsorship amount eg. $50.00.");
    fld.focus();
    return false;
  }
  return true;
}

function selectItems(num, items, values) {
  // pass in list of fields to set values on, pass in function name and value as ** to execute function
  var itemsA = items.split("||");
  var valuesA = values.split("||");

  if (valuesA[num] == '**') {
    eval(itemsA[num]);
  } else {
	fld = eval('document.aForm.' + itemsA[num]);
	for (j = 0; j < fld.length; j++) {
	  if (fld[j].value == valuesA[num]) {
		fld.selectedIndex = j;
		break;
	  }
	}
  }
  
  if (num < itemsA.length-1) {
	num++;
	setTimeout("selectItems(" + num + ",'" + items + "','" + values + "')", 100);
  }
}


function updateLeaderboard(participantType, pageName) {

  // If eeeyax is available use
  var xmlHttp;
  try {
    // Firefox, Opera 8.0+, Safari (best browser by the way)
    xmlHttp = new XMLHttpRequest();
  }
  catch(e) {
    // Billies special browser
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
        // browser is bad and can't handle eeeeyaxe (Suprised it isn't IE)
        if (pageName.indexOf('?') == -1) {
          document.location.href = pageName + '?leID=' + participantType;
        } else {
          document.location.href = pageName + '&leID=' + participantType;
        }
        return;
      }
    }
  }

  xmlHttp.onreadystatechange = function() {
    if(xmlHttp.readyState == 4) {
      if (xmlHttp.responseText != '') {
        x = document.getElementById("leaderboard");
        x.innerHTML = xmlHttp.responseText;
      }
    }
  }

  xmlHttp.open("GET","leaderboard_ajax.asp?leID=" + participantType + returnUniqueID(), true);
  xmlHttp.send(null);


}


function returnUniqueID() {
  var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
  var myStr = '&';
  for (var i=0; i<8; i++) {
    var randNum = Math.floor(Math.random() * chars.length);
    myStr += chars.substring(randNum, randNum+1);
  }
  myStr += "="
  for (var i=0; i<8; i++) {
    var randNum = Math.floor(Math.random() * chars.length);
    myStr += chars.substring(randNum, randNum+1);
  }
  return myStr;
}



function openEditor2(frm, fld, styleSheet) {
   window.open('../inc/editor2.asp?formName=' + escape(frm) + '&fieldName=' + escape(fld) + '&styleSheet=' + escape(styleSheet),'editor2','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=650');
}


//-->