// JavaScript Document<script language="javascript" type="text/javascript">
<!-- 
	var ajaxRequest;  // The variable that makes Ajax possible!
	var boardRequest;

//Browser Support Code
function ajaxConnect(){
	//document.getElementById('umap').innerHTML += "called getSelectClubInfo";
	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;
			}
		}
	}
	return true;
}
function refresh_board($id){
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			document.getElementById('board_txt').innerHTML = ajaxRequest.responseText;
			//document.getElementById('hunt_params').style.display = 'none';
			//document.getElementById('hunt_stat').style.left = (document.body.width/2) + (document.getElementById('hunt_stat').style.width/2);
		}
	}

	//document.getElementById('hunt_stat').style.display = 'block';
	//ajaxRequest.open("GET", "index.php?ajax=refreshboard&clubid="+$id, true);
	ajaxRequest.open("GET", "index.php?ajax=refreshboard&pid="+$id, true);
	ajaxRequest.send(null);
//alert("HELLO");
}

function enterHunt($id){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			document.getElementById('hunt_error_wrap').innerHTML = ajaxRequest.responseText;
			document.getElementById('hunt_params').style.display = 'none';
			//document.getElementById('hunt_stat').style.left = (document.body.width/2) + (document.getElementById('hunt_stat').style.width/2);
		}
	}

	//document.getElementById('hunt_stat').style.display = 'block';
	ajaxRequest.open("GET", "index.php?ajax=enterhunt&action=club&mode=enterhunt&clubid="+$id, true);
	ajaxRequest.send(null);
}
function getSelectedClubInfo(){
	// Create a function that will receive data sent from the server
	/*
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ajaxRequest.responseText != ""){
				document.getElementById('club_info').innerHTML = ajaxRequest.responseText;
				document.getElementById('hunt_data_wrap').style.display = 'none';
				document.getElementById('enter_hunt').style.display = 'none';
			}
		}
	}
	ajaxRequest.open("GET", "core/map/clubinfo.php", true);
	ajaxRequest.send(null); 
	*/
}

function updateSideBar(){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('sidebar_debug').innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "core/includes/debug.php", true);
	ajaxRequest.send(null);
}
function showHuntSightings($id){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			document.getElementById('hunt_stat_data').innerHTML = ajaxRequest.responseText;
			setHuntStatPos();
		}
	}
	document.getElementById('hunt_stat').style.height = "";
	document.getElementById('hunt_stat').style.display = 'block';
	ajaxRequest.open("GET", "index.php?ajax=showhuntsightings&statid="+$id, true);
	ajaxRequest.send(null);
}
function showMoreHunts($id){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('hunt_stat_data').innerHTML = ajaxRequest.responseText;
			setHuntStatPos();
		}
	}
	document.getElementById('hunt_stat').style.height = "";
	document.getElementById('hunt_stat_data').innerHTML = '<h3>Loading Stats...</h3>';
	document.getElementById('hunt_stat').style.display = 'block';
	ajaxRequest.open("GET", "index.php?ajax=showhuntsightings&clubid="+$id, true);
	ajaxRequest.send(null);
}
function setHuntStatPos(){
	//var $h = new String(document.documentElement.scrollTop);
	//if(window.innerWidth){
		var $h = new String(document.getElementById('hunt_tools').offsetTop);
		if(isIE8()){
			var $w = new String( document.body.offsetWidth/2 - 250);
		}else{
			var $w = new String( window.innerWidth/2 - 250);
		}
		//alert('h:' +$h.toString() + ' w:' + $w.toString());
		if($h && $w){
			document.getElementById('hunt_stat').style.height = "";
			document.getElementById('hunt_stat').style.top = $h + 'px';
			document.getElementById('hunt_stat').style.left = $w + 'px';
			document.getElementById('hunt_stat').style.zIndex = '100';
		}

	//}
}


function showResult(str){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			  document.getElementById("livesearch").innerHTML=ajaxRequest.responseText;
  			  document.getElementById("livesearch").style.border="1px solid #A5ACB2";
			  document.getElementById("livesearch").style.display="block";
		}
	}
	if(str.length>2){
		newstr = str.replace(" ","_");//replace and spaces with underscore
		ajaxRequest.open("GET", "index.php?ajax=getusers&str="+newstr, true);
		ajaxRequest.send(null);
	}else{
		//if user backspaces out text then hide search results
		document.getElementById("livesearch").style.display="none";
	}
}

function getNextMonth(mon,yr){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById("ecal").innerHTML=ajaxRequest.responseText;
		}
	}
	newtxt = '<div style="width:285px; height:100px; border:1px solid #FFF"><h3 style="margin:0px auto">UPDATING</h3>';
	newtxt += '<h4 style="margin:0px auto"><a style="cursor:pointer" onclick="getNextMonth('+mon+','+yr+')">Retry</a></h4></div>';
	document.getElementById("ecal").innerHTML=newtxt;
	ajaxRequest.open("GET", "index.php?ajax=ecalnextmonth&month="+mon+"&year="+yr, true);
	//alert("month="+mon+"&year="+yr);
	ajaxRequest.send(null);
}
//-->
