// JavaScript Document



function setupTooltips(){
	var tipBase = new Array("li","img","div","span","a","input");
	for(i=0;i<tipBase.length;i++){
		var elems = document.getElementsByTagName(tipBase[i]);
		
		for(k=0;k<elems.length;k++){
			var element = elems[k];
			if(element.getAttribute("tooltip")){
				//element.setAttribute("onMouseOver",element.getAttribute("onMouseOver") + "; document.getElementById('tooltip').innerHTML = this.getAttribute('tooltip'); document.getElementById('tooltip').style.display = 'block';");
				//element.setAttribute("onMouseOut",element.getAttribute("onMouseOut") + "; document.getElementById('tooltip').style.display = 'none';");
				btn.addEvent(element,"mouseover",function(){document.getElementById('tooltip').innerHTML = this.getAttribute('tooltip'); document.getElementById('tooltip').style.display = 'block';});
				btn.addEvent(element,"mouseout",function(){document.getElementById('tooltip').style.display = 'none';});
			}
		}
	}
}
function showError(text){
	var html = "<img src='/images/exclamation_button.png' style='float: left; height: 50px; width: 50px; margin: 0px 10px 5px 0px;' />";
	html += "<div style='font-size: 1.3em; font-weight: bold;'>Error</div>";
	html += text;
	popupHTML(html, "OK");
}
function showWarning(text){
	var html = "<img src='/images/warning_button.png' style='float: left; height: 50px; width: 50px; margin: 0px 10px 5px 0px;' />";
	html += "<div style='font-size: 1.3em; font-weight: bold;'>Warning</div>";
	html += text;
	popupHTML(html, "OK");
}
function popupHTML(html, closeText){
	//hide flash objects
	var elems = document.getElementsByTagName("object");
	for(k=0;k<elems.length;k++){
		var element = elems[k];
		element.style.display = 'none';
	}
	
	//show popup
	//html = "<img src='/images/x_button.png' style='float: right; cursor: pointer; width: 16px; height: 16px; margin: 3px 4px;' />" + html;
	if(closeText) html += "<br /><br /><center><input type='button' class='btn' id='popup_ok_button' value='" + closeText + "' onclick='popupClose();' /></center>";
	document.getElementById("popup").style.display = "block";
	document.getElementById("popup_content").innerHTML = html;
	if(btn && navigator.appVersion.toLowerCase().indexOf("msie") == -1) btn.transform(document.getElementById("popup_ok_button"));
	document.getElementById("popup_ok_button").focus();
}
function popupPage(url){
	popupHTML("");
	xmlhttp=GetXmlHttpObject();
	if (!xmlhttp){
		window.location = url;
		return;
	}
	
	url += (url.indexOf("?",0) >= 0?"&":"?") + "_t=none" + "&sid="+Math.random();

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
		
}
function popupClose(){
	//hide popup
	document.getElementById("popup").style.display = "none";
	document.getElementById("popup_content").innerHTML = "";
	
	//show flash objects
	var elems = document.getElementsByTagName("object");
	for(k=0;k<elems.length;k++){
		var element = elems[k];
		element.style.display = 'block';
	}
}
	
function recieveAjaxPopup(){
	if (xmlhttp.readyState!=4) return;
	document.getElementById("popup_content").innerHTML = xmlhttp.responseText;
}

function GetXmlHttpObject(){
	// code for IE7+, Firefox, Chrome, Opera, Safari
	if (window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
	// code for IE6, IE5
	if (window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}