
function removePSRField(field){
	$("."+field).remove();
	$.get("http://www.heroesofnewerth.com/ajaxPsrGrid.php", { rField: field } );
}
var t;
var tt;
function timer(){
	t=setTimeout("doCheck()",10000);
}
function doCheck(){
	loadXMLDoc('http://clans.heroesofnewerth.com/ajaxBuddyCheck.php?p=0','persist');
	tt=setTimeout("timer()",10000);
}
function showNicks() {
	var inputer = document.getElementById('autocomplete_playername').value;
	if(inputer.length > 1){
		$("#autoCompletePrint").fadeIn("fast", function() {
			/*$("#autoCompletePrint").empty();*/
		});
	} else {
		$("#autoCompletePrint").fadeOut("fast", function() {
			/*$("#autoCompletePrint").empty();*/
		});
	}
}
function getActionBox(id,cId){
	document.getElementById('actions').className = 'showPlz';
	loadXMLDoc('http://clans.heroesofnewerth.com/viewApp.php?submitId='+id+'&clan_id='+cId,'replaceMe');
}
function rPQ(pId){
	$(function(){
        $("#"+pId).empty()
		$("#div"+pId).empty();
	});
}
function addOneQ(){
	var range = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
	var assignId;
	var textId;
	for( var i in range ){
		if(document.getElementById('qp'+range[i])){
			continue;
		} else {
			assignId = 'qp'+range[i];
			textId = 'app_q_'+range[i];
			break;
		}
	}
	$(function(){
		$("#recruitAppDiv").append('<p id="'+assignId+'">Question '+range[i]+' - <a onclick="rPQ(\''+assignId+'\');" class="curserPlz">remove</a><br/></p><div class="textinput" style="width:100%; margin-top:8px;" id="div'+assignId+'"><b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b><div class="boxcontent" style="text-align:center;"><textarea class="expanding" style="overflow:hidden; width:98%; height:36px; min-height:46px; display:block;" name="'+textId+'" /></div><b class="bottom"><b class="b4b"></b><b class="b3b"></b><b class="b2"></b><b class="b1b"></b></b></div>')
	});
}
function toggleNumQuestions(clan_id){
	var q = document.getElementById('qquestions').value;
	if(q != '#'){
		loadXMLDoc('http://clans.heroesofnewerth.com/loadApp.php?clan_id='+clan_id+'&questions='+q,'recruitAppDiv');
	}
}
function toggleApp(clan_id){
	if(document.getElementById('recruitAppDiv').className == 'hidePlz'){
		document.getElementById('recruitAppDiv').className = 'showPlz';
		loadXMLDoc('http://clans.heroesofnewerth.com/loadApp.php?edit=true&clan_id='+clan_id,'recruitAppDiv');
	} else {
		document.getElementById('recruitAppDiv').className = 'hidePlz';
	}
}
function confirmDelete(delUrl,delName) {
	if (confirm("Are you sure you want to remove "+delName)) {
		document.location = delUrl;
	}
}
function confirmDemote(delUrl,delName) {
	if (confirm("Are you sure you want to demote "+delName)) {
		document.location = delUrl;
	}
}
function confirmPromote(delUrl,delName) {
	if (confirm("Are you sure you want to promote "+delName)) {
		document.location = delUrl;
	}
}
function confirmLeader(delUrl,delName) {
	if (confirm("Promoting "+delName+" will demote you. Are you sure you want to give leadership to "+delName)) {
		document.location = delUrl;
	}
}
function clearNicks() {
		$("#autoCompletePrint").fadeOut("fast", function() {
			/*$("#autoCompletePrint").empty();*/
		});
}
function clearNicksToo() {
		$("#autoCompletePrintzz").fadeOut("fast", function() {
			/*$("#autoCompletePrint").empty();*/
		});
}
function displayDiv(id){
	document.getElementById(id).className = 'showPlz';
}
function loadXMLDoc(pageLoad, divId) {
        var pager = pageLoad.split("?");
        var page = pager[0];
        var gets = pager[1].split("&");
        var variables = new Array();
        for (var i=0;i<gets.length;i++)
        {
            var get = gets[i].split("=")
            variables[i] = "'"+get[0]+"':'"+get[1]+"'";
        }
        variables.join(", ");
        variables = "{ "+variables+" }";
        $(function(){
            $("#"+divId)
            .html("<div id='loading' style='text-align:center; padding-top:12px;'><img src='http://clans.heroesofnewerth.com/loading.gif'></div>")
            $.get(page, eval( "("+variables+")"),
                function(data) {
                    $("#"+divId).html(data)
                    $("#loading").remove()
                });
        });
}
function runAjaxy(){
	var ajaxer = $.ajax({
		url: "http://clans.heroesofnewerth.com/persistent.php",
		success: function(){
			document.getElementById('imWindow').innerHTML = ajaxer.responseText;
		}
	});
}
function filterCheck(userId, officer){
	var filters = "";
	if(document.getElementById('filter1').checked == true){
		filters = filters + "&filter1=1";
	}
	if(document.getElementById('filter2').checked == true){
		filters = filters + "&filter2=1";
	}
	if(document.getElementById('filter3').checked == true){
		filters = filters + "&filter3=1";
	}
	if(document.getElementById('filter4').checked == true){
		filters = filters + "&filter4=1";
	}
	if(officer == 1){
		loadXMLDoc("http://clans.heroesofnewerth.com/filterEvents.php?o=true&clanId="+userId+"&numFilters=4"+filters,"filterResponse");
	} else {
		loadXMLDoc("http://clans.heroesofnewerth.com/filterEvents.php?clanId="+userId+"&numFilters=4"+filters,"filterResponse");
	}
} 

function prizeCheck(){
	if(document.getElementById('noPrizes').checked == 1){
		document.tournPrizes.action = 'http://tournaments.heroesofnewerth.com/admin';
	} else {
		document.tournPrizes.action = 'http://tournaments.heroesofnewerth.com/tournPrizes';
	}
	document.tournPrizes.submit();
}

function showDateForm(val){
    if(val=="range"){
       showIt('daterange');
    } else {hideIt('daterange'); }
}

function showIt(div){
     if (document.getElementById) {  // for Netscape
       myDiv = document.getElementById(div);
          myDiv.style.display = 'block';
     }

     if (document.all) {     // for IE
       eval("myDiv = "+div+";");
          myDiv.style.display = 'block';
     }
}
function hideIt(div){
     if (document.getElementById) {  // for Netscape
       myDiv = document.getElementById(div);
          myDiv.style.display = 'none';
     }

     if (document.all) {     // for IE
       eval("myDiv = "+div+";");
          myDiv.style.display = 'none';
     }
}

function makeHover(div){
	document.getElementById(div).className = 'hoverIt';
}
function unMakeHover1(div){
	document.getElementById(div).className = 'hoverStyle1';
}
function unMakeHover2(div){
	document.getElementById(div).className = 'hoverStyle2';
}