// JavaScript Document

var ie = navigator.userAgent.indexOf("MSIE") != -1;

function showMessage(nodeWidth, nodeHeight, htmlString,overflowValue) {
	this.nodeWidth = nodeWidth;
	this.nodeHeight = nodeHeight;
	this.htmlString = htmlString;
	theNode = "message";
	alignment = "middle";
	theObj = document.getElementById(theNode);
	currentHTML = theObj.value;
	if (htmlString != currentHTML) {
		if (fadeCount == 1) {
			opacityValue = .50;
		}
		theObj.style.opacity = opacityValue;
		theObj.style.filter = 'alpha(opacity=' + opacityValue * 100 + ')';
		if(overflowValue){
		theObj.style.overflow = 'scroll';
		}
		placeLayerCenter(theNode, nodeWidth, nodeHeight, alignment);
		setLayerHTML(theNode,htmlString);
		fadeIn(theNode);
	}
}

function placeLayerCenter(theNode, nodeWidth, nodeHeight, alignment) {
	var wres = screen.width;
	var hres = screen.height;
	var wresavail = screen.availWidth;
	var hresavail = screen.availHeight;
	if (ie) {
		wBody = document.body.clientWidth;
		hBody = document.body.clientHeight;
	}
	else {
		wBody = window.innerWidth;
		hBody = window.innerHeight;
		
	}

	theObj = document.getElementById(theNode);
	if (nodeWidth != 0 && nodeHeight != 0) {
		theObj.style.width = nodeWidth;
		theObj.style.height = nodeHeight;
	}
	if (alignment == "middle") {
		if (ie) {
			vscroll = document.body.scrollTop;
		}
		else {
			vscroll = window.pageYOffset;
		}
		theObj.style.left = parseInt((wBody - nodeWidth) / 2);
		theObj.style.top = parseInt((hBody - nodeHeight) / 2) + vscroll;
	}
}

function setLayerHTML(theNode,htmlString) {
	theObj = document.getElementById(theNode);
	theObj.innerHTML = htmlString;
	theObj.value = htmlString;
}

fadeTimer = null;
opacityValueHigh = 1;
opacityValueLow = 0.25;
opacityValue = opacityValueLow;
changeVal = 0.1;
fadeCount = 0;

function fadeIn(theNode) {
	if (fadeTimer != null) clearTimeout(fadeTimer);
	this.theNode = theNode;
	fadeObj = document.getElementById(theNode);
	if (fadeCount == 0) {
		fadeObj.style.display = "block";
		fadeObj.style.visibility = "visible";
		fadeCount = 1;
	}
	fadeObj.style.opacity = opacityValue;
	fadeObj.style.filter = 'alpha(opacity=' + opacityValue * 100 + ')';
	if (opacityValue <= opacityValueHigh) {
		opacityValue = opacityValue + changeVal;
		fadeTimer = setTimeout("fadeIn(theNode)",50);
	}
	else {
		opacityValue = opacityValueHigh;
		fadeObj.style.opacity = opacityValue;
		fadeObj.style.filter = 'alpha(opacity=' + opacityValue * 100 + ')';
	}
}

function fadeOut(theNode) {
	if (fadeTimer != null) clearTimeout(fadeTimer);
	this.theNode = theNode;
	fadeObj = document.getElementById(theNode);
	fadeObj.style.opacity = opacityValue;
	fadeObj.style.filter = 'alpha(opacity=' + opacityValue * 100 + ')';
	if (opacityValue >= opacityValueLow) {
		opacityValue = opacityValue - changeVal;
		fadeTimer = setTimeout("fadeOut(theNode)",50);
	}
	else {
		opacityValue = opacityValueLow;
		fadeObj.style.opacity = opacityValue;
		fadeObj.style.filter = 'alpha(opacity=' + opacityValue * 100 + ')';
		fadeObj.style.display = "none";
		fadeObj.style.visibility = "hidden";
		fadeCount = 0;
		fadeObj.value = "";
		fadeObj.style.width = 1;
		fadeObj.style.height = 1;
	}
}


