NS4 = (document.layers) ? 1 : 0;
NS5 = (document.getElementById) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
if(IE4 == 1) {
	NS5 = 0;
}

function ShowElement(element, posX, posY, show) {
	if (NS4) {
		document.layers[element].left = posX;
		document.layers[element].top = posY;
		if(show == true) {
			document.layers[element].visibility = "show";
		}
		else {
			document.layers[element].visibility = "hide";
		}
	} 

	if (NS5) {
			document.getElementById(element).style.left = posX;
			document.getElementById(element).style.top = posY;
		if(show == true) {
			document.getElementById(element).style.visibility = "visible";
		}
		else {
			document.getElementById(element).style.visibility = "hidden";
		}
	} 

	if (IE4) {
		document.all[element].style.pixelLeft = posX;
		document.all[element].style.pixelTop = posY;
		if(show == true) {
			document.all[element].style.visibility = "visible";
		}
		else {
			document.all[element].style.visibility = "hidden";
		}
	} 
}

function escapeString(text) {
  output = "";
  escapedChar = "";
  for (i=0;i<text.length;i++) {
    escapedChar = escape(text.substring(i, i+1));
    if(escapedChar.length > 1) {
        escapedChar = escapedChar.replace("%", "&#x");
        output += escapedChar + ";";
    } else {
        output += escapedChar;
    }
  }
  return output;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function addUnLoadEvent(func) {
	var oldunonload = window.unonload;
	if (typeof window.unonload != 'function') {
		window.unonload = func;
	} else {
		window.unonload = function() {
			if (oldunonload) {
				oldunonload();
			}
			func();
		}
	}
}
