<!--

var js_delimiter1 = "||";
var js_delimiter2 = "**";
var homePageIMGs = 4;
var currentIMG = 1;
var rotateTime = 3500;

function rotateIMG() {
  currentIMG ++;
  if (currentIMG > homePageIMGs) { currentIMG = 1; }
  document.getElementById("imgR").src = "img/design/home_rotate" + currentIMG + ".jpg";
  setTimeout('rotateIMG()', rotateTime);
}

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 < 1) {
    // Select Option selected
    for (i=document.aForm.eventID.options.length;i>=0;i=i-1) {
      document.aForm.eventID.options[i] = null;
    }
    addOption(document.aForm.eventID, 'Please select a state', '');
    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 < 1) {
    // Select Option selected
    for (i=document.aForm.teamID.options.length;i>=0;i=i-1) {
      document.aForm.teamID.options[i] = null;
    }
    addOption(document.aForm.teamID, 'Please select a state', '');
    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 corporationSelected(i) {

  if (i < 1) {
    // Select Option selected
    for (i=document.aForm.corporationState.options.length;i>=0;i=i-1) {
      document.aForm.corporationState.options[i] = null;
    }
    for (i=document.aForm.teamID.options.length;i>=0;i=i-1) {
      document.aForm.teamID.options[i] = null;
    }
    return;
  }

  var a = teamIDs[i-1].split(js_delimiter2);
  var b = teamStates[i-1].split(js_delimiter2);

  if (a == -100) {
    alert('There are no team captains registered for your corporation. Either register as the team captain by going back to page 1 of the registration form or contact your team captain and request that they register');
    for (i=document.aForm.corporationState.options.length;i>=0;i=i-1) {
      document.aForm.corporationState.options[i] = null;
    }
    for (i=document.aForm.teamID.options.length;i>=0;i=i-1) {
      document.aForm.teamID.options[i] = null;
    }
    return;
  }

  for (i=document.aForm.corporationState.options.length;i>=0;i=i-1) {
    document.aForm.corporationState.options[i] = null;
  }

  for (j = 0; j < b.length; j++) {
    addOption(document.aForm.corporationState, b[j], b[j]);
  }

  document.aForm.teamID.options[0] = null;
  addOption(document.aForm.teamID, 'Please select a state', '');

}

function corporationStateSelected(i,state) {

if (i < 1) {
    // 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++) {
    if (j == 0) {
      addOption(document.aForm.teamID, b[j], a[j]);
    }

    if (b[j].substring(0, 3) == state.substring(0, 2).toUpperCase() + '_') {
      addOption(document.aForm.teamID, b[j].substring(3, b[j].length), a[j]);
    }
  }

}



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=590')

}


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;
}

/* disable additional walkers if participant not attending walk */
function addWalkers() {
    if (document.aForm.attending.checked) {
        document.aForm.additionalWalkers.disabled = false
    } else {
        document.aForm.additionalWalkers.disabled = 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(eventID, 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=' + eventID;
        } else {
          document.location.href = pageName + '&leID=' + eventID;
        }
        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=" + eventID + 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 jsWebRequest(URL, POST, fallbackURL, divName, callFunction) {
	// If eeeyax is available use
	var xmlHttp;

	//if (POST) alert("POST");


	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 (fallbackURL != '') {
					document.location.href = fallbackURL;
				} else {
					alert(e.description);
				}
				return;
			}
		}
	}

	// Code to execute once web request complete
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.responseText != '') {

				 //alert(xmlHttp.responseText);

				if (divName != '') {
					x = document.getElementById(divName);
					if (x) x.innerHTML = xmlHttp.responseText;
				}
				if (callFunction != '') {
					if (callFunction.indexOf(')') > -1) { callFunction = callFunction.substring(0, callFunction.indexOf(')')); }
					if (callFunction.indexOf('(') == -1) { callFunction += '('; }
					eval(callFunction + "'" + escape(xmlHttp.responseText) + "')");
				}
			} else {
				if (fallbackURL != '') {
					document.location.href = fallbackURL;
				}
			}
		}
	}

	if (POST) {
		var i = URL.indexOf("?");
		params = URL.substring(URL.length-(URL.length-i-1));
		URL = URL.substring(0, i);
		xmlHttp.open("POST", URL, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(params);
	} else {
		xmlHttp.open("GET", URL + returnUniqueID(URL), true);
		xmlHttp.send(null);
	}

}
function refeshCaptcha() {
    document.images.captchImg.src = "refreshCaptcha.asp?aaa=111" + returnUniqueID();
}
//-->
