function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function print_r(obj,hideValue){ 
     var objString = '<ul>';
     
     for( var varName in obj ) {
     	objString += '<li>'+ varName +'('+ typeof obj[varName] +')';
     	
     	if ( typeof obj[varName] == 'object' ) {
     		if ( hideValue ) continue;
     		objString += print_r(obj[varName],true);
     	} else {
     		objString += ':'+ escape(obj[varName]);
     	}
     }
     objString += '</ul>';
     return objString;
}

/*has a negative effect on input-field's focus...in IE (whenever deselect is called, the currentinput field, loses its focus)*/
function deselect(){
	if ( document.selection ) document.selection.empty();
	else if ( window.getSelection ) window.getSelection().removeAllRanges();
}

function rdebug(obj){
	debug(print_r(obj));
}

function debug(value){
	document.getElementById('debugOut').innerHTML += '<br>'+value;
}

function stopEvent(event){
	if ( event.stopPropagation ) { event.stopPropagation(); }
	else { event.cancelBubble = true; }
}

var oldClass;
function hoverIn (object) {
	object.style.backgroundColor = '#fafafa';
}
function hoverOut (object) {
	object.style.backgroundColor = '#ffffff';
}

function swapImage(newImagePath, imageName) {
	var newImage = new Image();
	newImage.src = newImagePath;
	document[imageName].src = newImage.src;
}



function showLayer(LayerName) {
	var divBody = document.getElementById("divBody");
	divBody.style.display = "block";
	divBody.style.opacity = 0.75;
	divBody.style.filter = "alpha(opacity=75)";
	
	var PopupLayer = document.getElementById(LayerName);
	PopupLayer.style.display = "block";
	
	if( typeof( window.innerWidth ) == "number" ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in "standards compliant mode"
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	divBody.style.width = myWidth;
	divBody.style.height = myHeight;
	
	posLeft = (myWidth/2)-(810/2) + "px";
	posTop = (myHeight/2)-(612/2) + "px";

	PopupLayer.style.left = posLeft;
	PopupLayer.style.top = posTop;
}



function hideLayer(LayerName) {
	var divBody = document.getElementById("divBody");
	divBody.style.display = "none";
	divBody.style.opacity = 1;
	divBody.style.filter = "alpha(opacity=100)";
	
	var PopupLayer = document.getElementById(LayerName);
	PopupLayer.style.display = "none";
}
