document.createElement("header");document.createElement("nav");document.createElement("article");document.createElement("section");document.createElement("aside");document.createElement("footer");var loc = 'http://acvecc.org/ajax/';
/*global $, document, top, window, location, confirm, loc, alert */

function changeCountry(i) {
	
	var c = $("#cc").val(), t = $("#person_id") !== undefined ? 1 : 0;
	
	loc += "change_country.php?i="+i+"&c="+c+"&t="+t;
	
	// window.open(loc);return;
	
	$.get(loc, function(json) {
		if (json.s) {
			$("#st").html(json.s);
		}
	});
	
}


/* -------------------------------------------------- */


function setStates(i,c,p) {
	
	// window.open(loc+"reset_state.php?c="+c+"&i="+i+"&p="+p);return;
	
	$.get(loc+"reset_state.php?c="+c+"&i="+i+"&p="+p, function(json) {
		if (json.s) {
			$("#"+i).html(json.s);
		}
	});
}

/* -------------------------------------------------- */


function toggle_member(i) {
	
	// window.open(loc+"toggle_member.php?i="+i);return;
	
	$.get(loc+"toggle_member.php?i="+i, function(json) {
		if (json.s==1) {
			alert(json.r);
		}
	});
}

/* -------------------------------------------------- */


function resetAltBands(id) {
	$("#"+id+" p").removeClass("even");
	$("#"+id+" p:even").addClass("even");
}

/* -------------------------------------------------- */


function filter_members(c,p,s,t,l) {
	
	// window.open(loc+"filter_members.php?p="+p+"&c="+c+"&s="+s+"&t="+t+"&l="+l);return;
	
	$.get(loc+"filter_members.php?c="+c+"&p="+p+"&s="+s+"&t="+t+"&l="+l, function(json) {
		
		if (json==0) {
			$("#mlist>div").hide();
			$("#result_msg").html("No results for: \""+t+"\"");
		} else if (json==-1) {
			// No input. show all.
			$("#mlist div").show();
			$("#result_msg").html("Showing all");
		} else {
			$("#mlist>div").hide();
			$.each(json,function(key,val){
				$("#m_"+val).show();
				$("#result_msg").html("Results for: \""+t+"\"");
			});
		}
	});
	
}

/* -------------------------------------------------- */


function deleteRTC(i) {
	
	if (confirm("Permanently delete this RTC?") === true) {
		
		// window.open(loc+"delete_rtc.php?i="+i);return;
		
		$.get(loc+"delete_rtc.php?i="+i, function(json) {
			if (json.del) {
				$("#rtcx_"+json.del).parent("span").parent("p").remove();
				resetAltBands("rtc_list");
			}
		});
	}
}


/* -------------------------------------------------- */


function toggleRTC(i) {
	
	// window.open(loc+"toggle_rtc.php?i="+i);return;
	
	$.get(loc+"toggle_rtc.php?i="+i, function(json) {
		if (json.msg) {
			$("#rtcx_"+json.rid).parent("span").parent("p").remove();
			resetAltBands("rtc_list");
			alert(json.msg);
		}
	});
}

/* -------------------------------------------------- */

function readCookie(name) {
	var nameEQ = name + "=", c, ca = document.cookie.split(';');
	for (var i=0;i < ca.length;i++) {
		c = ca[i];
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* -------------------------------------------------- */

$(document).ready(function(){
	$('a[rel=external]').attr('target','_blank');
	if(top.location!=location){top.location.href=document.location.href;}
	$(".mtog").click(function(){
		var c = $(this).is(":checked"), a = !c ? 'Dea' : 'A',i=$(this).attr("id");
		if (confirm(a+"ctivate Member?") === true) {
			toggle_member(i);
		}
	});
});


