// JavaScript Document

function toggleNews(){

	if (document.getElementById('news').style.display == 'block'){

		document.getElementById('news').style.display = 'none';

		document.getElementById('newsOff').style.display = 'block';

	}

	else{

		document.getElementById('news').style.display = 'block';

		document.getElementById('newsOff').style.display = 'none';

	}

}



function showTourney(state,action,id,spots){

  var xmlHttp;

  try{

    // Firefox, Opera 8.0+, Safari

    xmlHttp=new XMLHttpRequest();

  }

  catch (e){

    // Internet Explorer

    try{

      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (e){

      try{

        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

      catch (e){

        alert("Your browser does not support AJAX!");

        return false;

      }

    }

  }

    xmlHttp.onreadystatechange=function(){

      if(xmlHttp.readyState==4){

		  document.getElementById('tournaments').innerHTML = xmlHttp.responseText;

      }

    }

	

	var url="include/charity.php";

	url=url+"?action="+action+"&state="+state+"&id="+id+"&s="+spots;

   	xmlHttp.open("POST",url,true);

   	xmlHttp.send(null);	

}



function togglePP(what){

	if(what == 'paypal'){

		document.getElementById('payable').style.display = "none";

		document.getElementById('payable_field').value = "";

		document.getElementById('paypal').style.display = "block";

	}

	else if(what == 'payable'){

		document.getElementById('payable').style.display = "block";

		document.getElementById('paypal').style.display = "none";

		document.getElementById('paypal_field').value = "";

	}

	

}



function submitInfo(){

	var errorString = "";

	if(document.getElementById('tax_id_ssn').value == ''){

		errorString += 'Please enter a Tax ID# or your Social Security #.\n';

	}

	if((document.getElementById('pp').checked) && (document.getElementById('paypal_field').value == '')){

		errorString += 'Please enter the Paypal address we should send your money to!\n';

	}

	if((document.getElementById('pp2').checked) && (document.getElementById('payable_field').value == '')){

		errorString += 'Please enter the name of the company or individual we should make your check out to\n';

	}

	if(errorString != "")

		alert(errorString);

	else

		document.completeInfo.submit();

}



function affLogon(){

	document.affLogon.submit();

}

function addOption(selectbox,text,value ){

var optn = document.createElement("OPTION");

optn.text = text;

optn.value = value;

selectbox.options.add(optn);

}



function loadCourse(action, city, state){

	var xmlHttp;

	try{

    	// Firefox, Opera 8.0+, Safari

		xmlHttp=new XMLHttpRequest();

	}

	catch (e){

		// Internet Explorer

		try{

			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

		}

		catch (e){

		try{

			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

		}

		catch (e){

			alert("Your browser does not support AJAX!");

			return false;

		}

	}

}

xmlHttp.onreadystatechange=function(){

	if(xmlHttp.readyState==4){

		var r = xmlHttp.responseText.substr(1,xmlHttp.responseText.length);

		if(xmlHttp.responseText.substr(0,1)=='1'){

			document.getElementById('city').options.length = 0;

			

			var newOptions = r.split("|");

			for(i=0;i<newOptions.length-1;i++){

				 addOption(document.getElementById('city'),newOptions[i],newOptions[i]);



			}

		}

		else if(xmlHttp.responseText.substr(0,1)=='2'){

			var innerString = "";

			var coursesTemp = r.split("|");

			var courses = Array();

			innerString += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"font-size:12px\">";

			for(i=0;i<coursesTemp.length-1;i++){

				courses[i] = coursesTemp[i].split("+");

				innerString += "<tr><td width=\"370\">"+courses[i][0]+"</td><td width=\"185\">"+courses[i][1]+"</td><td width=\"345\">"+courses[i][2]+"</td></tr>";

				

			}

			innerString += "</table>";

			document.getElementById('courses').innerHTML = innerString;



		}

	}

}

	var url="include/courseDir.php";

	url=url+"?action="+action+"&city="+city+"&state="+state;

	xmlHttp.open("POST",url,true);

	xmlHttp.send(null);

}
