	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, April 2006
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	

	var ajaxBox_offsetX = 0;
	var ajaxBox_offsetY = 0;
	//var ajax_list_externalFile = 'ajax-list-countries.php';	// Path to external file
	var minimumLettersBeforeLookup = 1;	// Number of letters entered before a lookup is performed.
	
	var ajax_list_objects = new Array();
	var ajax_list_cachedLists = new Array();
	var ajax_list_activeInput = false;
	var ajax_list_activeItem;
	var ajax_list_optionDivFirstItem = false;
	var ajax_list_currentLetters = new Array();
	var ajax_optionDiv = false;
	var ajax_optionDiv_iframe = false;

	var ajax_list_MSIE = false;
	if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)ajax_list_MSIE=true;
	
	var currentListIndex = 0;
	
	function yellowIt(){
		document.body.style.backgroundColor = 'yellow';
	}
	

	
	
	
	
	/************************************************************************************************************/
	/******************************Page load code to resolve onload problem *************************************/
	/******************************http://simonwillison.net/2004/May/26/addLoadEvent/****************************/
	/************************************************************************************************************/
	
	function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}



//*********************************************************************	
// Used to read home and away place to calc %ages for home and away place
//*********************************************************************	
function ajaxPlaceOffPercentForAgainst(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
	try{
		if(document.getElementById('awaybox').value){
		var awayplace= document.getElementById('awaybox').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('homebox').value){
		var homeplace= document.getElementById('homebox').value;
		}
	} catch (e) {}	

		
		
	var queryString = "?awayplace="+awayplace+"&&homeplace="+homeplace;
	ajaxRequest.open("GET", "ajaxplaceoffpercentforagainst.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxpercentforagainstdiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}

//*********************************************************************	
// Reads user submitted email etc for notification if place rated
//*********************************************************************	
function ajaxEmailrateSubmitClick(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

	try{
		if(document.getElementById('yourstate').value){
		var yourstate= document.getElementById('yourstate').value;
		}
	} catch (e) {}

	try{
		if(document.getElementById('yourplace').value){
		var yourplace= document.getElementById('yourplace').value;
		}
	} catch (e) {}		
	
	try{
		if(document.getElementById('yourname').value){
		var yourname= document.getElementById('yourname').value;
		}
	} catch (e) {}		
	
	try{
		if(document.getElementById('youremail').value){
		var youremail= document.getElementById('youremail').value;
		}
	} catch (e) {}		
	
		
	var queryString = "?yourstate="+yourstate+"&&yourplace="+yourplace+"&&yourname="+yourname+"&&youremail="+youremail;
	ajaxRequest.open("GET", "ajax_submitemailrate.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('emailratediv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}

//*********************************************************************	
// Loads events for a state and place
//*********************************************************************	
function ajaxLoadEvents(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

	try{
		if(document.getElementById('statebox').value){
		var statebox= document.getElementById('statebox').value;
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('placebox').value){
		var placebox= document.getElementById('placebox').value;
		}
	} catch (e) {}		
	
	try{
		if(document.getElementById('datebox').value){
		var datebox= document.getElementById('datebox').value;
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('timebox').value){
		var timebox= document.getElementById('timebox').value;
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('whatbox').value){
		var whatbox= document.getElementById('whatbox').value;
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('wherebox').value){
		var wherebox= document.getElementById('wherebox').value;
		}
	} catch (e) {}	

	try{
		if(document.getElementById('moreinfobox').value){
		var moreinfobox= document.getElementById('moreinfobox').value;
		}
	} catch (e) {}	

	try{
		if(document.getElementById('yournamebox').value){
		var yournamebox= document.getElementById('yournamebox').value;
		}
	} catch (e) {}	

	try{
		if(document.getElementById('youremailbox').value){
		var youremailbox= document.getElementById('youremailbox').value;
		}
	} catch (e) {}		

		
	var queryString = "?statebox="+statebox+"&&placebox="+placebox+"&&datebox="+datebox+"&&timebox="+timebox+"&&whatbox="+whatbox+"&&wherebox="+wherebox+"&&moreinfobox="+moreinfobox+"&&yournamebox="+yournamebox+"&&youremailbox="+youremailbox;
	ajaxRequest.open("GET", "ajaxsubmitevent.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxeventdiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}

//*********************************************************************	
// Outputs rates for and against for state and place - away place
//*********************************************************************	
function ajaxPlaceOffOneZeroAway(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
	try{
		if(document.getElementById('placeoffdiv').innerHTML){
		var awayplace= document.getElementById('placeoffdiv').innerHTML;
		}
	} catch (e) {}

		
	var queryString = "?awayplace="+awayplace;
	ajaxRequest.open("GET", "ajaxplaceoffaway.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('awayonezerodiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}




//*********************************************************************	
// Outputs rates for and against for certain state and place - home place
//*********************************************************************	
function ajaxPlaceOffOneZeroHome(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
	try{
		if(document.getElementById('homebox').value){
		var homeplace= document.getElementById('homebox').value;
		}
	} catch (e) {}

		
	var queryString = "?homeplace="+homeplace;
	ajaxRequest.open("GET", "ajaxplaceoffhome.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('homeonezerodiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}


//*********************************************************************	
// Outputs next place for next increment of PlaceOff to placeoffdiv - this will be altered so only display place without postcode or state
//*********************************************************************	
function ajaxOutputPlaceOnlyToDiv(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	try{
		if(document.getElementById('homebox').value){
		var homeplace= document.getElementById('homebox').value;
		//alert(awayplace);
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('distancearrayindexbox').value){
		var distancearrayindexbox= document.getElementById('distancearrayindexbox').value;
		}
	} catch (e) {}		
		
	var queryString = "?homeplace="+homeplace+"&&distancearrayindexbox="+distancearrayindexbox;
	ajaxRequest.open("GET", "ajaxplaceoffdivdisplay.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('placeoffdiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


	
	}

//*********************************************************************	
// Outputs next place for next increment of PlaceOff to awaybox textbox
//*********************************************************************	
function ajaxPlaceOff(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	try{
		if(document.getElementById('hometickbox').value){
		var hometickbox= document.getElementById('hometickbox').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('awaytickbox').value){
		var awaytickbox= document.getElementById('awaytickbox').value;
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('homebox').value){
		var homeplace= document.getElementById('homebox').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('awaybox').value){
		var awayplace= document.getElementById('awaybox').value;
		//alert(awayplace);
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('distancearrayindexbox').value){
		var distancearrayindexbox= document.getElementById('distancearrayindexbox').value;
		}
	} catch (e) {}	
		
	var queryString = "?hometickbox="+hometickbox+"&&awaytickbox="+awaytickbox+"&&homeplace="+homeplace+"&&awayplace="+awayplace+"&&distancearrayindexbox="+distancearrayindexbox;
	ajaxRequest.open("GET", "ajaxplaceoff.php"+queryString, true);
	ajaxRequest.send(null);	
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('awaybox');
			ajaxDisplay.value = ajaxRequest.responseText;
		}
	}


	
	}


//*********************************************************************	
function ajaxmayorquestionsubmitclick(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('mayorquestiondiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	try{
		if(document.getElementById('yourname').value){
		var nVal= document.getElementById('yourname').value;
		//alert(fnVal);
		}
	} catch (e) {}	

	try{
		if(document.getElementById('youremailmayorquestion').value){
		var emVal= document.getElementById('youremailmayorquestion').value;
		//alert(emVal);
		}
	} catch (e) {}	

	try{
		if(document.getElementById('mayorstate').value){
		var mS= document.getElementById('mayorstate').value;
		//alert(emVal);
		}
	} catch (e) {}
	

	try{
		if(document.getElementById('mayorplace').value){
		var mP= document.getElementById('mayorplace').value;
		//alert(emVal);
		}
	} catch (e) {}	
	
	try{
		if(document.getElementById('yourquestion').value){
		var yQ= document.getElementById('yourquestion').value;
		//alert(emVal);
		}
	} catch (e) {}		
	
	var queryString = "?yourname="+nVal+"&&youremail="+emVal+"&&yourquestion="+yQ+"&&mayorstate="+mS+"&&mayorplace="+mP;
	ajaxRequest.open("GET", "ajax_answermayor.php" + queryString, true);
	ajaxRequest.send(null);
	
	}

	/************************************************************************************************************/
	

//*********************************************************************	
function ajaxmayornamesubmitclick(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('mayorcandidatediv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	try{
		if(document.getElementById('mayorname').value){
		var nVal= document.getElementById('mayorname').value;
		//alert(fnVal);
		}
	} catch (e) {}	

	try{
		if(document.getElementById('mayoremail').value){
		var emVal= document.getElementById('mayoremail').value;
		//alert(emVal);
		}
	} catch (e) {}	

	try{
		if(document.getElementById('mayorstate').value){
		var mS= document.getElementById('mayorstate').value;
		//alert(emVal);
		}
	} catch (e) {}
	

	try{
		if(document.getElementById('mayorplace').value){
		var mP= document.getElementById('mayorplace').value;
		//alert(emVal);
		}
	} catch (e) {}	
	
	var queryString = "?mayorname="+nVal+"&&emval="+emVal+"&&mayorstate="+mS+"&&mayorplace="+mP;
	ajaxRequest.open("GET", "ajax_submitmayor.php" + queryString, true);
	ajaxRequest.send(null);
	
	}

	/************************************************************************************************************/
	
	//Browser Support Code
	function ajaxFlagForReview(flagIndex){
		
		//ajaxFagForReview(flagIndex,s,np,category,stateplace,myplace)
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var ajaxDisplay = document.getElementById('flagajaxdiv'+flagIndex);
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}

				
		var queryString;
		/*if(s!=''){
			queryString="?=flag="+flagIndex+"s="+s+"&np="+np+"&category="+category+"&stateplace="+stateplace+"&myplace="+myplace;
		}else{
			queryString="?=flag="+flagIndex+""category="+category+"&stateplace="+stateplace+"&myplace="+myplace;
		}*/
			
		queryString="?flag="+flagIndex;
		ajaxRequest.open("GET", "ajax_flagindex.php" + queryString, true);
		ajaxRequest.send(null); 
		
	}


	
	
	/************************************************************************************************************/
function topN_notAjax(){

	try{
		if(document.getElementById('rank').value){
		var rank= document.getElementById('rank').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('stateN').value){
		var stateN= document.getElementById('stateN').value;
		}
	} catch (e) {}	
	

	try{
		if(document.getElementById('popN').value){
		var popN= document.getElementById('popN').value;
		}
	} catch (e) {}		

	try{
		if(document.getElementById('timeFrame').value){
		var timeFrame= document.getElementById('timeFrame').value;
		}
	} catch (e) {}	

	window.location.href="home.php?rank=" + rank + "&&stateN="+stateN  + "&&popN="+popN + "&&timeFrame="+timeFrame;
}	
//*********************************************************************	
function ajaxRateCalcs(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('runningaveragediv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	try{
		if(document.getElementById('crime').value){
		var crimeVal= document.getElementById('crime').value;
		alert("youhoo");
		}
	} catch (e) {}	


	try{
		if(document.getElementById('entertainment').value){
		var entartainmentVal= document.getElementById('entertainment').value;
		}
	} catch (e) {}	
	
	runningAverageVal=(crimeVal+entertainmentVal)/2;


	var queryString = "?runningaverageval="+runningAverageVal;
	ajaxRequest.open("GET", "runningaverageval.php" + queryString, true);
	ajaxRequest.send(null);
	
	}
//************************************************************************************************
function ajaxFunctionMap(place, state){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('mapdiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}


		if(document.getElementById('mapdiv').style.visibility == 'visible'){
			document.getElementById('mapdiv').style.visibility = 'hidden';
//			document.getElementById('mapdiv').style.height= '0';
		}else{
		document.getElementById('mapdiv').style.visibility = 'visible';
		//	document.getElementById('mapdiv').style.left='200';//screen.width/2;
		//document.getElementById('mapdiv').style.top='40';
		}
		


	
	var queryString = "?state=" + state + "&&place="+place;
	ajaxRequest.open("GET", "embedmap.php" + queryString, true);
	ajaxRequest.send(null); 
}



	//Browser Support Code
function ajaxFunctionTopN(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	try{
		if(document.getElementById('rank').value){
		var rank= document.getElementById('rank').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('stateN').value){
		var stateN= document.getElementById('stateN').value;
		}
	} catch (e) {}	
	

	try{
		if(document.getElementById('popN').value){
		var popN= document.getElementById('popN').value;
		}
	} catch (e) {}		

	try{
		if(document.getElementById('timeFrame').value){
		var timeFrame= document.getElementById('timeFrame').value;
		}
	} catch (e) {}	
	
	var queryString = "?rank=" + rank + "&&stateN="+stateN  + "&&popN="+popN + "&&timeFrame="+timeFrame;
	ajaxRequest.open("GET", "league.php" + queryString, true);
	ajaxRequest.send(null); 
}


/************************************************************************************************/
function ajaxFunctionRateN(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
/*
	try{
		if(document.getElementById('rank').value){
		var rank= document.getElementById('rank').value;
		}
	} catch (e) {}
	
	try{
		if(document.getElementById('stateN').value){
		var stateN= document.getElementById('stateN').value;
		}
	} catch (e) {}	
	

	try{
		if(document.getElementById('popN').value){
		var popN= document.getElementById('popN').value;
		}
	} catch (e) {}		
*/
	//var queryString = "?rank=" + rank + "&&stateN="+stateN  + "&&popN="+popN;
	ajaxRequest.open("GET", "poop.php",true);
	ajaxRequest.send(null); 
}
/************************************************************************************************/


	function ajax_setFilename(phpFile)
	{
		ajax_list_externalFile =phpFile;
	}
	
	function ajax_getTopPos(inputObj)
	{
		
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null){
	  	returnValue += inputObj.offsetTop;
	  }
	  return returnValue;
	}
	function ajax_list_cancelEvent()
	{
		return false;
	}
	
	function ajax_getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  
	  return returnValue;
	}
	
	function ajax_option_setValue(e,inputObj)
	{
		if(!inputObj)inputObj=this;
		var tmpValue = inputObj.innerHTML;
		if(ajax_list_MSIE)tmpValue = inputObj.innerText;else tmpValue = inputObj.textContent;
		if(!tmpValue)tmpValue = inputObj.innerHTML;
		ajax_list_activeInput.value = tmpValue;
		if(document.getElementById(ajax_list_activeInput.name + '_hidden'))document.getElementById(ajax_list_activeInput.name + '_hidden').value = inputObj.id; 
		ajax_options_hide();
	}
	
	function ajax_options_hide()
	{
		if(ajax_optionDiv)ajax_optionDiv.style.display='none';	
		if(ajax_optionDiv_iframe)ajax_optionDiv_iframe.style.display='none';
	}

	function ajax_options_rollOverActiveItem(item,fromKeyBoard)
	{
		if(ajax_list_activeItem)ajax_list_activeItem.className='optionDiv';
		item.className='optionDivSelected';
		ajax_list_activeItem = item;
		
		if(fromKeyBoard){
			if(ajax_list_activeItem.offsetTop>ajax_optionDiv.offsetHeight){
				ajax_optionDiv.scrollTop = ajax_list_activeItem.offsetTop - ajax_optionDiv.offsetHeight + ajax_list_activeItem.offsetHeight + 2 ;
			}
			if(ajax_list_activeItem.offsetTop<ajax_optionDiv.scrollTop)
			{
				ajax_optionDiv.scrollTop = 0;	
			}
		}
	}
	
	function ajax_option_list_buildList(letters,paramToExternalFile)
	{
		
		ajax_optionDiv.innerHTML = '';
		ajax_list_activeItem = false;
		if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length<=1){
			ajax_options_hide();
			return;			
		}
		
		
		
		ajax_list_optionDivFirstItem = false;
		var optionsAdded = false;
		for(var no=0;no<ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length;no++){
			if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].length==0)continue;
			optionsAdded = true;
			var div = document.createElement('DIV');
			var items = ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].split(/###/gi);
			
			if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length==1 && ajax_list_activeInput.value == items[0]){
				ajax_options_hide();
				return;						
			}
			
			
			div.innerHTML = items[items.length-1];
			div.id = items[0];
			div.className='optionDiv';
			div.onmouseover = function(){ ajax_options_rollOverActiveItem(this,false) }
			div.onclick = ajax_option_setValue;
			//div.onclick=onclickHeader(ajax_option_setValue);
			if(!ajax_list_optionDivFirstItem)ajax_list_optionDivFirstItem = div;
			ajax_optionDiv.appendChild(div);
		}	
		if(optionsAdded){
			ajax_optionDiv.style.display='block';
			if(ajax_optionDiv_iframe)ajax_optionDiv_iframe.style.display='';
			ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true);
		}
					
	}
	
	function ajax_option_returnSetValue(e,inputObj)
{
		if(!inputObj)inputObj=this;
		var tmpValue = inputObj.innerHTML;
		if(ajax_list_MSIE)tmpValue = inputObj.innerText;else tmpValue = inputObj.textContent;
		if(!tmpValue)tmpValue = inputObj.innerHTML;
		ajax_list_activeInput.value = tmpValue;
		if(document.getElementById(ajax_list_activeInput.name + '_hidden'))document.getElementById(ajax_list_activeInput.name + '_hidden').value 	= inputObj.id; 
		ajax_options_hide();
		return tmpValue;
}
	function onclickHeader(myItem){
		location.href = 'http://www.likeplace.co.uk/places/index.php?'+ajax_option_returnSetValue(false,myItem);
	}
	
	function ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,whichIndex)
	{
		if(whichIndex!=currentListIndex)return;
		var letters = inputObj.value;
		var content = ajax_list_objects[ajaxIndex].response;
		var elements = content.split('|');
		ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()] = elements;
		ajax_option_list_buildList(letters,paramToExternalFile);
		
	}
	
	function ajax_option_resize(inputObj)
	{
		ajax_optionDiv.style.top = (ajax_getTopPos(inputObj) + inputObj.offsetHeight + ajaxBox_offsetY) + 'px';
		ajax_optionDiv.style.left = (ajax_getLeftPos(inputObj) + ajaxBox_offsetX) + 'px';
		if(ajax_optionDiv_iframe){
			ajax_optionDiv_iframe.style.left = ajax_optionDiv.style.left;
			ajax_optionDiv_iframe.style.top = ajax_optionDiv.style.top;			
		}		
		
	}
	
	function ajax_showOptions(inputObj,paramToExternalFile,e)
	{
		if(e.keyCode==13 || e.keyCode==9)return;
		if(ajax_list_currentLetters[inputObj.name]==inputObj.value)return;
		if(!ajax_list_cachedLists[paramToExternalFile])ajax_list_cachedLists[paramToExternalFile] = new Array();
		ajax_list_currentLetters[inputObj.name] = inputObj.value;
		if(!ajax_optionDiv){
			ajax_optionDiv = document.createElement('DIV');
			ajax_optionDiv.id = 'ajax_listOfOptions';	
			document.body.appendChild(ajax_optionDiv);
			
			if(ajax_list_MSIE){
				ajax_optionDiv_iframe = document.createElement('IFRAME');
				ajax_optionDiv_iframe.border='0';
				ajax_optionDiv_iframe.style.width = ajax_optionDiv.clientWidth + 'px';
				ajax_optionDiv_iframe.style.height = ajax_optionDiv.clientHeight + 'px';
				ajax_optionDiv_iframe.id = 'ajax_listOfOptions_iframe';
				
				document.body.appendChild(ajax_optionDiv_iframe);
			}
			
			var allInputs = document.getElementsByTagName('INPUT');
			for(var no=0;no<allInputs.length;no++){
				if(!allInputs[no].onkeyup)allInputs[no].onfocus = ajax_options_hide;
			}			
			var allSelects = document.getElementsByTagName('SELECT');
			for(var no=0;no<allSelects.length;no++){
				allSelects[no].onfocus = ajax_options_hide;
			}

			var oldonkeydown=document.body.onkeydown;
			if(typeof oldonkeydown!='function'){
				document.body.onkeydown=ajax_option_keyNavigation;
			}else{
				document.body.onkeydown=function(){
					oldonkeydown();
				ajax_option_keyNavigation() ;}
			}
			var oldonresize=document.body.onresize;
			if(typeof oldonresize!='function'){
				document.body.onresize=function() {ajax_option_resize(inputObj); };
			}else{
				document.body.onresize=function(){oldonresize();
				ajax_option_resize(inputObj) ;}
			}
				
		}
		
		if(inputObj.value.length<minimumLettersBeforeLookup){
			ajax_options_hide();
			return;
		}
				

		ajax_optionDiv.style.top = (ajax_getTopPos(inputObj) + inputObj.offsetHeight + ajaxBox_offsetY) + 'px';
		ajax_optionDiv.style.left = (ajax_getLeftPos(inputObj) + ajaxBox_offsetX) + 'px';
		if(ajax_optionDiv_iframe){
			ajax_optionDiv_iframe.style.left = ajax_optionDiv.style.left;
			ajax_optionDiv_iframe.style.top = ajax_optionDiv.style.top;			
		}
		
		ajax_list_activeInput = inputObj;
		ajax_optionDiv.onselectstart =  ajax_list_cancelEvent;
		currentListIndex++;
		if(ajax_list_cachedLists[paramToExternalFile][inputObj.value.toLowerCase()]){
			ajax_option_list_buildList(inputObj.value,paramToExternalFile,currentListIndex);			
		}else{
			var tmpIndex=currentListIndex/1;
			ajax_optionDiv.innerHTML = '';
			var ajaxIndex = ajax_list_objects.length;
			ajax_list_objects[ajaxIndex] = new sack();
			var url = ajax_list_externalFile + '?' + paramToExternalFile + '=1&letters=' + inputObj.value.replace(" ","+");
			ajax_list_objects[ajaxIndex].requestFile = url;	// Specifying which file to get
			ajax_list_objects[ajaxIndex].onCompletion = function(){ ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,tmpIndex); };	// Specify function that will be executed after file has been found
			ajax_list_objects[ajaxIndex].runAJAX();		// Execute AJAX function		
		}
		
			
	}
	
	function ajax_option_keyNavigation(e)
	{
		if(document.all)e = event;
		
		if(!ajax_optionDiv)return;
		if(ajax_optionDiv.style.display=='none')return;
		
		if(e.keyCode==38){	// Up arrow
			if(!ajax_list_activeItem)return;
			if(ajax_list_activeItem && !ajax_list_activeItem.previousSibling)return;
			ajax_options_rollOverActiveItem(ajax_list_activeItem.previousSibling,true);
		}
		
		if(e.keyCode==40){	// Down arrow
			if(!ajax_list_activeItem){
				ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true);
			}else{
				if(!ajax_list_activeItem.nextSibling)return;
				ajax_options_rollOverActiveItem(ajax_list_activeItem.nextSibling,true);
			}
		}
		
		if(e.keyCode==13 || e.keyCode==9){	// Enter key or tab key
			if(ajax_list_activeItem && ajax_list_activeItem.className=='optionDivSelected')ajax_option_setValue(false,ajax_list_activeItem);
			if(e.keyCode==13)return false; else return true;
		}
		if(e.keyCode==27){	// Escape key
			ajax_options_hide();			
		}
	}
	
	
	document.documentElement.onclick = autoHideList;
	
	function autoHideList(e)
	{
		if(document.all)e = event;
		
		if (e.target) source = e.target;
			else if (e.srcElement) source = e.srcElement;
			if (source.nodeType == 3) // defeat Safari bug
				source = source.parentNode;		
		if(source.tagName.toLowerCase()!='input' && source.tagName.toLowerCase()!='textarea')ajax_options_hide();
		
	}
