function redraw() {
	if (window.opera) {
		document.body.style.display = "none";
		document.body.style.display = "block";
	}
}
function getXmlHttp() {
	var xmlhttp = false;


	try {
		xmlhttp = new XMLHttpRequest()
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (E) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlhttp;
}

var fadeTimeout = new Array();


function setOpacity(obj, opacity) {
	opacity = (opacity == 100) ? 99.999 : opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.opacity = opacity/100;

	obj.style.KHTMLOpacity = opacity/100;

	obj.style.MozOpacity = opacity/100;

	lastOpacity[obj.id] = opacity;

}
var lastOpacity = new Array();
function fadeOut(objId,opacity, shouldTimeOut, ending, amount, interval) {
	if (shouldTimeOut) {
		fadeTimeout = window.setTimeout("fadeOut('"+objId+"',"+opacity+")", shouldTimeOut);
		return false;
	}
	haltFade(objId, true);
	if (amount == null) {
		amount = 1;
	}
	if (interval == null) {
		interval = 50;
	}
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (ending == null) {
			ending = 0;
		}
		if (opacity >= ending) {
			setOpacity(obj, opacity);
			opacity -= amount;
			window.clearTimeout(fadeTimeout);
			fadeTimeout[objId] = window.setTimeout("fadeOut('"+objId+"',"+opacity+", false, "+ending+", "+amount+")", interval);
		} else {
			if (ending == 0) {
				obj.style.visibility = "hidden";
				setOpacity(obj, 100);
			}
		}
	}
}

function fadeIn(objId, starting, opacity, amount) {
	if (opacity == null) {
		opacity = starting;
	}
	if (amount == null) {
		amount = 4;
	}
	haltFade(objId, true);
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity < 100) {
			setOpacity(obj, opacity);
			opacity += amount;
			window.clearTimeout(fadeTimeout);
			fadeTimeout[objId] = window.setTimeout("fadeIn('"+objId+"', "+starting+", "+opacity+", "+amount+")", 50);
		} else {
			setOpacity(obj, 100);
		}
	}
}

function haltFade(objId, dontReset) {
	obj = document.getElementById(objId);
	window.clearTimeout(fadeTimeout[objId]);
	if (!dontReset) {	
		setOpacity(obj, 100);
	}
	obj.style.visibility = "visible";
}

function raiseAlert(text, posx, posy) {
	haltFade("alert");
	var alert = document.getElementById("alert");


	if (posx != undefined) {
		alert.style.left = posx
	} else {
		alert.style.left = "0px";
	}

	if (posy != undefined) {
		alert.style.top = posy;
	} else {
		alert.style.top = "0px";
	}
	
	if (!window.XMLHttpRequest) {
		alert.style.position = "absolute";
		alert.style.top = (document.body.scrollTop)+"px";
	}
	alert.innerHTML = text;
	alert.style.visibility = "visible";
	setOpacity(alert, 100, 0);
	fadeTimeout["alert"] = window.setTimeout("fadeOut('alert', 100, 0)", 8000);
}
function suspendAlert() {
	window.clearTimeout(fadeTimeout["alert"]);
	var alert = document.getElementById("alert");
	alert.style.top = "0px";
	alert.style.visibility = "hidden";
	setOpacity(alert, 100, 0);
}

function getElementsByClassName(element, tag, className){
	var classRegex = new RegExp("{^|\\\\s)"+ className +"(\\\\s|$}");
	var tag = tag || "*";
	var element = element || document;
	var elements = (tag == "*" && element.all) ? element.all : element.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(classRegex.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}
function addEventHandler(element,event,handler) {
	if (element.addEventListener) {
		element.addEventListener(event,handler,false);
	} else if (element.attachEvent) {
		element.attachEvent("on"+event,handler);
	} else {
		return false;
	}
}
function setCookie(cookieName, cookieValue, cookieHoursExpire) {
	var time = "";
	if (cookieHoursExpire) {
		var date = new Date();
		date.setTime(date.getTime()+(cookieHoursExpire*60*60*1000));
		time = "; expires="+date.toGMTString();
	}
	document.cookie = cookieName+"="+escape(cookieValue)+time+"; path=/";
}
function readCookie(name) {
	var nameString = name + "=";
	var ca = document.cookie.split(';');
	var dataString = "";
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameString) == 0) {
			dataString = unescape(c.substring(nameString.length,c.length));
			break;
		}
	}
	if (dataString != "") {
		var values = dataString.split('||');
		var returnAssociativeArray = new Array();
		for (var i = 0; i < values.length;i++) {
			var pairs = values[i].split(':');
			returnAssociativeArray[pairs[0]] = pairs[1];
		}
		return returnAssociativeArray;
	} else {
		return null;
	}

}