var currentbubble = "";
var xmlhttp = false;

if (window.XMLHttpRequest) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.overrideMimeType('text/xml');
} else if (window.ActiveXObject) {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}


function togglebubble(element) {
	var current = document.getElementById(element).style.display;
	
	if (currentbubble != "") {
	 document.getElementById(currentbubble).style.display = "none";
	}
	if (current != "block") {
		document.getElementById(element).style.display = "block";
		currentbubble = element;
	} else {
		document.getElementById(element).style.display = "none";
		currentbubble = "";
	}
	return false;
}

function grow(element) {
  element.position = "absolute";
  element.style.marginTop = "-20px";
  element.height += 10;
  element.width += 10;
}

function shrink(element) {
  element.style.marginTop = "0px";
  element.height = 36;
  element.width = 33;
}

function changemap(day, level) {
	if (!xmlhttp) { return true; }
	currentbubble = "";

	url = "?day=" + day + "&level=" + level + "&maponly";
	xmlhttp.open("GET", "index.psp"+url, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			//alert(xmlhttp.responseText);
			//alert(xmlhttp.getAllResponseHeaders());
			response = xmlhttp.responseText;
			document.getElementById("campusmap").innerHTML = response;
		}
	}
	xmlhttp.send(url);
	return false;
}

function nottaking(module) {
	if (!xmlhttp) { return true; }
	url = "hidemodule.psp?m=" + module;
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
		}
	}
	xmlhttp.send(url);
	return false;
}

function expandmarkers(element) {
  children = element.getElementsByTagName("a");
  if (children.length <= 1) {
    return;
  }
  for (i=0; i<children.length; i++) {
    children[i].style.marginLeft = (i * 18) + "px";
  }
}

function shrinkmarkers(element) {
  children = element.getElementsByTagName("a");
  if (children.length <= 1) {
    return;
  }
  for (i=0; i<children.length; i++) {
    children[i].style.marginLeft = (i * 5) + "px";
  }
}
