// JavaScript Document

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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 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_openBrWindowFull(url) 
{
	var width = screen.width;
	var height = screen.height;
	var features = "width=" + width + ",height=" + height + ",scrollbars,resizable";

	
	newWindow = window.open(url,'win',features);
	newWindow.focus();


}


function MM_openBrWindow(theURL,winName,features) { //v2.0

	// create first array to hold values of 'features' array
	var temp = new Array(); 
	
	// split 'features' array at the ',' comma to reveal name value pairs (name = value)
	temp = features.split(','); 
	
	// create second array to hold name/value pairs
	var multi = new Array(); 

		// Loop through first array and split the name value pairs at the '=' sign
		for (i=0;i<temp.length;i++) {				
			multi[i] = temp[i].split('=');
			
				// if name = width, assign value to width variable
				if (multi[i][0] == "width") {
					var width = multi[i][1];
				}
					// if name = height, assign value to height variable
					if (multi[i][0] == "height") {
						var height = multi[i][1];
					}

		}
		
	// create left position and top position variables, append to 'features' argument
	// and return new window now positioned in middle of screen
	leftpos = (screen.width - width) / 2;
	toppos = (screen.height - height) / 2;
	newfeatures = features + ",left="+leftpos+",top="+toppos+"";
	
	NewWindow = window.open(theURL,winName,newfeatures);
	NewWindow.focus();
}


function register() {
	
	var activityID = document.getElementById('activityID').value;	
	var newCourseID = -1;
	
		for (i=0;i<document.getElementsByName('courseID').length;i++) {
		
			if (document.getElementsByName('courseID')[i].checked) {
			
				var newCourseID = document.getElementsByName('courseID')[i].value; 
			}
		}
	
	if (newCourseID == -1) {
			alert ("Please choose the race you would like to register for");
			return false;
		}
		
	else if(!document.getElementById('termagree').checked) {	
		alert("You need to agree with the waiver above to proceed.");
		return false;
	}	
		
	else {

	
	webaddress = 'http://online.activecommunities.com/elite/MyBasket/MyBasket.asp?Type=1&AddCourse=' + activityID + '~' + newCourseID + '~0~0~0~0~0';
	
    // alert ("Web Address = " + webaddress + "");
	
	newWindow = window.open(webaddress,'win','height=500,width=750,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes');	
	newWindow.focus();

	}

}

function registerTeam() {
	
	var activityID = document.getElementById('activityID').value;	
	var newCourseID = -1;
	var newWindow;
	
		for (i=0;i<document.getElementsByName('courseID').length;i++) {
		
			if (document.getElementsByName('courseID')[i].checked) {
			
				var newCourseID = document.getElementsByName('courseID')[i].value; 
			}
		}
	
	if (newCourseID == -1) {
			alert ("Please choose the category of your team/group");
			return false;
		}	
		
	else {

	
	webaddress = 'https://online.activecommunities.com/elite/MyAccount/MyAccountCreateNewTeam.asp?activityID=' + activityID + '&courseID=' + newCourseID + '';
	
    // alert ("Web Address = " + webaddress + "");
	
	newWindow = window.open(webaddress,'win','height=500,width=750,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes');	
	newWindow.focus();

	}

}

function termscond(){
	if(document.getElementById('termagree').checked) {	
		register();
		}
		else {
			alert("You need to agree with the waiver above to proceed.");
			return false;
		}
							   	
}

function show_answer(id){
	for (i=0;i<anz;i++){
		if (i==id){
			
			if (document.getElementById("answer_"+id).style.display=="block"){
				//alert(document.getElementById("faq_arrow_"+id).src);
				//document.getElementById("faq_arrow_"+id).src="img/faq_arrow_up.jpg";
				//alert(document.getElementById("faq_arrow_"+id).src);
				document.getElementById("answer_"+id).style.display="none";
				//document.getElementById("question_cnt_"+id).style.backgroundImage="url('img/spacer.gif')";
			}
			else{
				//document.getElementById("faq_arrow_"+id).src;
				//document.getElementById("faq_arrow_"+id).src="img/faq_arrow_down.jpg";
				document.getElementById("answer_"+id).style.display="block";
				//document.getElementById("question_cnt_"+id).style.backgroundImage="url('img/faq_question_bg_down.jpg')";
				//document.getElementById("question_cnt_"+id).style.backgroundRepeat="no-repeat";	
				//document.getElementById("answer_"+id).style.backgroundImage="url('img/faq_answer_bg_down.jpg')";	
				//document.getElementById("answer_"+id).style.backgroundRepeat="repeat-y";			
			}
		}
		else {
			//document.getElementById("faq_arrow_"+i).src="img/faq_arrow_up.jpg";
			document.getElementById("answer_"+i).style.display="none";
			//document.getElementById("question_cnt_"+i).style.backgroundImage="url('img/spacer.gif')";	
		}
	}
}


function validategooglesearch() {
	
	var f = document.getElementById('cse-search-box');
	var q = f.q;
	
	if (!q.value) { alert ('Please enter a search term'); return false }
}