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, initialOpacity, noHide) {
	if (shouldTimeOut) {
		fadeTimeout[objId] = window.setTimeout("fadeOut('"+objId+"',"+opacity+")", shouldTimeOut);
		return false;
	}
	haltFade(objId, true);
	if (amount == null) {
		amount = 1;
	}
	if (interval == null) {
		interval = 50;
	}
	if (initialOpacity == null) {
		initialOpacity = 0;
	}
	if (noHide == null) {
		noHide = false;
	}

	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+", "+initialOpacity+", "+noHide+")", interval);
		} else {
			if (ending == 0) {
				if (!noHide) {
					obj.style.visibility = "hidden";
				}
				setOpacity(obj, initialOpacity);
			}
		}
	}
}
function fadeIn(objId, starting, opacity, amount, until) {
	if (opacity == null) {
		opacity = starting;
		
	}

	if (amount == null) {
		amount = 4;
	}
	if (until == null) {
		until = null;
	}
	haltFade(objId, true);
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (until != null && opacity >= until) {
			return;
		}
		if (opacity < 100) {
			setOpacity(obj, opacity);
			opacity += amount;
			window.clearTimeout(fadeTimeout);
			fadeTimeout[objId] = window.setTimeout("fadeIn('"+objId+"', "+starting+", "+opacity+", "+amount+", "+until+")", 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 getScrollY() {
	return window.pageYOffset || document.documentElement.scrollTop;
}

function getScrollX() {
	return window.pageXOffset || document.documentElement.scrollLeft;
}

function addWindowOnload(newFunction) {
  var previousOnload = window.onload;
  
  if (typeof window.onload != "function") {
    window.onload = newFunction;
  } else {
    window.onload = function() {
      if (previousOnload) {
        previousOnload();
      }
      newFunction();
    }
  }
}

function addOnclick(newFunction, obj) {
  var previousOnclick = obj.onclick;
  
  if (typeof obj.onclick != "function") {
    obj.onclick = newFunction;
  } else {
    obj.onclick = function() {
      if (previousOnclick) {
        previousOnclick();
      }
      newFunction();
    }
  }
}

function stopEvent(e) {
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();

}

function replaceTarget(newTarget) {
	// Strip the target
	
	if (newTarget != undefined && newTarget != null && newTarget != "") {
		window.location.hash = "#" + newTarget;
	} else {
		window.location.hash = "#";
	}
}

function scavengeCursorPosition(e) {
	var posx = 0;
	var posy = 0;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
		+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
		+ document.documentElement.scrollTop;
	}
	
	var returnArray = new Array();
	returnArray["x"] = posx;
	returnArray["y"] = posy;
	return returnArray;
}
