// return an element with a specified id
function $g(name){
	return document.getElementById(name);
}

// toggle the display of an element
function toggle(el) {
	if ($g(el).style.visibility != "hidden" ) {
		$g(el).style.visibility = "hidden";
	} else {
		$g(el).style.visibility = "visible";
	}
}

function showFull(theid) {
	if (document.all) {
		$g(theid).style.paddingTop = "2px";
	}

	$g(theid).style.visibility = "visible";
}

function showTrunc(theid) {
	$g(theid).style.visibility = "hidden";
}

function updateStatus(aid) {
	AjaxRequest.get({
		'url':'updatestatus.php',
		'parameters':{
			'aid':aid,
			'status':$g('astatus'+aid).value,
			'group':$g('agroup'+aid).value
		},
		'onSuccess':function () {
			getAccounts();
		}
	});
}

function getAccounts(aid) {
	AjaxRequest.get({
		'url':'loadaccounts.php',
		'parameters':{
			'aid':aid
		},
		'element':'accountlist'
	});
}

function getMessages(tid) {
	if ($g('messages'+tid).style.display == "none") {
		$g('messages'+tid).innerHTML = "Loading Messages...";
		$g('messages'+tid).style.display = "block"
		AjaxRequest.get({
			'url':'loadmessages.php',
			'parameters':{
				'tid':tid
			},
			'element':'messages'+tid
		});
	} else {
		$g('messages'+tid).innerHTML = "";
		$g('messages'+tid).style.display = "none";
	}
}

function newImage(aid) {
	if(aid > 0) {
		$g('imageLink').style.display = "none";
		$g('editImage').style.display = "block";
	} else {
		$g('imageLink').style.display = "block";
		$g('editImage').style.display = "none";
	}
}

function calcPrices(mid) {
	$g('mtotal').innerHTML = 35 * $g('member').value;
	$g('ntotal').innerHTML = 40 * $g('nonmember').value;
	$g('stotal').innerHTML = 15 * $g('student').value;
	$g('grandtotal').innerHTML = parseFloat($g('mtotal').innerHTML)
		+ parseFloat($g('ntotal').innerHTML)
		+ parseFloat($g('stotal').innerHTML);
	$g('check').innerHTML=$g('grandtotal').innerHTML;
	thecount = ($g('member').value*1) + ($g('nonmember').value*1) + ($g('student').value*1);
	getFood(mid,parseFloat(thecount));
}

function getFood(mid,thecount) {
	AjaxRequest.get({
		'url':'getFood.php',
		'parameters':{
			'mid':mid,
			'thecount':thecount
		},
		'element':'guests'
	});
}