function loaded() {
	externalLinks();
}
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
function nOver(total, x) {
	for (var i = 0; i <= total; i++) {
		num = i <= 9 ? "0"+i : i; 
		document.getElementById('nav'+num).src = "images/nav"+num+"0.jpg";
	}
	document.getElementById('nav'+x).src = "images/nav"+x+"1.jpg";
}
function nOut(total) {
	for (var i = 0; i <= total; i++) {
		num = i <= 9 ? "0"+i : i; 
		document.getElementById('nav'+num).src = "images/nav"+num+"0.jpg";
	}
}
function toggle(x) {
	document.getElementById(x).style.display = document.getElementById(x).style.display == "none" ? "block" : "none";
	document.getElementById(x).blur();
}

function addnew(x,num) {
	if (x.substring(0,4) != "null") {
		document.getElementById("dialog").style.display = "block";
		document.getElementById(x+num).style.display = "block";
	} else {
		return false;
	}
}
function preset(x) {
	if (x.value.substring(0,4) != "null") {
		document.getElementById("aTitle").value = document.getElementById("selectPre").options[document.getElementById("selectPre").selectedIndex].text;
		document.getElementById("aText").value = pre[x.value];
		
		document.getElementById("dialog").style.display = "block";
		document.getElementById("action1").style.display = "block";
	} else {
		return false;
	}
}
function dialogHide(x) {
	if (document.getElementById("selectAdd"))
		document.getElementById("selectAdd").options[0].selected = true;
	if (document.getElementById("selectPre"))
		document.getElementById("selectPre").options[0].selected = true;
	document.getElementById(x).style.display = "none";
	document.getElementById('dialog').style.display = "none";
	if (document.getElementById(x+"form"))
		document.getElementById(x+"form").reset();
}
function contact(x) {
	if (x) {
		document.getElementById("ctitle").value = organs[x][0];
		document.getElementById("cname").value = organs[x][1];
		document.getElementById("ctelephone").value = organs[x][2];
		document.getElementById("cfax").value = organs[x][3];
		document.getElementById("cemail").value = organs[x][4];
		document.getElementById("ccampus").value = organs[x][5];
		document.getElementById("cbuilding").value = organs[x][6];
		document.getElementById("cfloor").value = organs[x][7];
		document.getElementById("croom").value = organs[x][8];
	}
	
	document.getElementById("contact1").style.display = "block";
	document.getElementById("dialog").style.display = "block";
}
function enlargeImage(imsrc, ww, wh, imtitle) {
	var w1 = window.open('Gemini Karts - '+imtitle,'ImageEnlarged'+Math.floor(Math.random()*99),'width='+(ww+60)+',height='+(wh+80)+',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,dependent=yes,innerHeight='+wh+',innerWidth='+ww+'');
	w1.document.open();
	var html = '<html>';
	html += '<head>';
	html += '<title>Gemini Karts<\/title>';
	html += '<style type="text/css" media="screen">';
	html += 'html, body {	width: 100%; height: 100%; margin: 0; padding: 0; text-align: center; background: #697e4a url(images\/bgTile.png) repeat-x top; background-attachment: fixed; }';
	html += '#img {			margin: 0 auto; padding: 10px; background-color: #fff; }';
	html += '#close {		display: block; float: right; width: 26px; height: 27px; margin: 10px 20px 0 0; background: transparent url(images\/btn_close0.png) no-repeat top left; }';
	html += '#close:hover { background: transparent url(images\/btn_close1.png) no-repeat top left; }';
	html += 'a img {		border: 0; }';
	html += 'h2 {			display: block; margin: 0 0 10px 0; padding: 13px 0 3px 0; text-align: center; font-size: 17px; font-family: Arial, sans-serif; color: #fff; font-weight: normal; }';
	html += '<\/style>';
	html += '<\/head>';
	html += '<body>';
	html += '<a id="close" href="javascript:window.close();"></a>';
	html += '<h2 id="imtitle">'+imtitle+'</h2>';
	html += '<a href="javascript:window.close();"><img id="img" src="' + imsrc + '" width="'+ww+'" height="'+wh+'" alt="" /></a>';
	html += '<\/body><\/html>';
	w1.document.write(html);
	//w1.document.body.focus();
}

function id (x) {
	return document.getElementById(x);
}
function qty (positiveNegative, prefix, num) {
	if (positiveNegative == "n" && parseFloat(id(prefix+num).value) > 0)
		id(prefix+num).value = parseFloat(id(prefix+num).value)-1;
	else if (positiveNegative == "p")
		id(prefix+num).value = parseFloat(id(prefix+num).value)+1;
}