function updatePaymentStatus (val) {
	var form = document.getElementById("received_payment_form");
	form.payment_by_mail_received.value = val;
	form.submit();
}

function getPrintButton (imagePath) {
	if (isMac() && isIE()) return "";
	
	var str = "<a href=\"#\" title=\"Print this Page\" class=\"imagelink\" onclick=\"window.print(); return false;\">";
	str += "<img src=\"" + imagePath + "/print.gif\" width=\"20\" height=\"18\" alt=\"Print\" border=\"0\" id=\"print_button\" />";
	str += "</a>";
	
	return str;
}

function getDeleteButton (type, id) {
	var str = "<a href=\"#\" title=\"Delete Applicant\" class=\"imagelink\" onclick=\"deleteApp('" + type + "', '" + id + "');\">";
	str += "<img src=\"../images/delete.gif\" width=\"11\" height=\"14\" alt=\"Delete Applicant\" border=\"0\" />";
	str += "</a>";
	
	return str;
}

function hideButtons (hideID, showID) {
	var hide = document.getElementById(hideID);
	var show = document.getElementById(showID);
	
	show.innerHTML = "Processing...";
	
	hide.style.display = "none";
	show.style.display = "inline";
}

function deleteApp (type, id) {
	var response = confirm("Are you sure you want to delete this? Deletions are permanent and cannot be undone!");
	
	if (response) {
		window.location = ".?type=" + type + "&id=" + id + "&delete=1";
	} 
}

function isSafari () {
	var agt = navigator.userAgent.toLowerCase();
	return agt.indexOf("safari") != -1;
}

function isIE () {
	var agt = navigator.userAgent.toLowerCase();
	return agt.indexOf("msie") != -1;
}

function isMac () {
	var opsys = navigator.platform.toLowerCase();
	return opsys.indexOf("mac") != -1;
}

function popWin (theURL, w, h, scroll) {
	winIncrement++;
	
	if (scroll == null) scroll = "no";
	
	if (isSafari()) {
		w = w - 2;
		h = h - 1;
	}
	
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2) - 10;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
	
	win = window.open(theURL, winIncrement, winprops);
	
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus(); 
	}
}

winIncrement = 0;

//FRAME BREAKOUT
if (top.location != self.location) {
	top.location = self.location;
}

//BROWSER-SPECIFIC CSS
document.write("<style type=\"text/css\">");
document.write(".updated { font-size: .65em; color: #333333; }");

if (isSafari()) document.write("#nav ul li { background-position: 0px 3px; }");

if (isIE()) {
	document.write("#nav ul li { background-position: 0px 2px; }");
	if (!isMac()) document.write("#header_organized { margin-top: 62px; }");
}

if (!isMac()) {
	document.write(".updated { font-size: .7em; color: #333333; }");
}

document.write("</style>");
