
function X(id){
	return document.getElementById(id);
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	return [pageWidth, pageHeight];
}


function imgOff(obj, sw){
	var img=obj.src;
	var ext=img.substring(img.lastIndexOf(".") + 1, img.length);
	var imgOff=img.replace("_on."+ext, "."+ext);
	obj.src=imgOff;
}

function imgOn(obj){
	var img=obj.src;
	var ext=img.substring(img.lastIndexOf(".") + 1, img.length);
	var imgOn=img.replace("."+ext, "_on."+ext);
	obj.src=imgOn;
}


function preloadImages(path) {
	if (path == "" || path == undefined) path = "./images/";
	if (document.images) {
		document.tmp = new Array();
		for (var i = 0; i < arguments.length; i++) {
			document.tmp[i] = new Image;
			document.tmp[i].src = path + arguments[i];
		}
	}
}


function setOpacity(obj, v) {
	obj.style.opacity = v / 10;
	obj.style.khtmlOpacity = v / 10;
	obj.style.filter = "alpha(opacity=" + (v * 10) + ")";
}


function showMsg(v) {
	alert(v);
	return;
	var win = getPageSize();
	var w = win[0];
	var h = win[1];
	if (!X("x__msg__x")) {
		var obj = document.createElement("DIV");
		obj.id = "x__msg__x";
		obj.style.position = "absolute";
		obj.style.zIndex = 9998;
		obj.style.top = "0px";
		obj.style.left = "0px";
		obj.style.backgroundColor = "#333333";
		setOpacity(obj, 5);
		obj.style.cursor = "wait";
		obj.style.width = w + "px";
		obj.style.height = h + "px";
		obj.onclick = function() {
			X("x__msg__x").style.display = "none";
			X("x__msg_txt__x").style.display = "none";
		}
		var txt = document.createElement("DIV");
		txt.onclick = function() {
			X("x__msg__x").style.display = "none";
			X("x__msg_txt__x").style.display = "none";
		}
		txt.id = "x__msg_txt__x";
		txt.style.position = "absolute";
		txt.style.zIndex = 9999;
		txt.style.width = "260px";
		txt.style.left = ((w - 260 ) / 2) + "px";
		txt.className = 'fw_error_message'
		txt.style.top = "200px";
		document.body.appendChild(txt);
		document.body.appendChild(obj);
	} else {
		var obj = X("x__msg__x");
		obj.style.width = w + "px";
		obj.style.height = h + "px";

		var txt = X("x__msg_txt__x");
		txt.style.left = ((w - 260 ) / 2) + "px";
		txt.style.top = "200px";
	}	
	txt.innerHTML = v;
	obj.style.display = "block";
	txt.style.display = "block";
	setTimeout("X(\"x__msg__x\").style.display=\"none\";X(\"x__msg_txt__x\").style.display=\"none\"", 10000);
}

function addEvent(obj, evType, evListener, fnc, p) {
	var xFnc = null;
	if (evListener) {
		xFnc = (p != undefined && p != null) ? function(event){fnc.apply(obj, [event || window.event].concat(p||[]));} : fnc;
	} else {
		xFnc = (p != undefined && p != null) ? function(){fnc.apply(obj, [].concat(p||[]));} : fnc;
	}
	if (obj.addEventListener) {
		obj.addEventListener(evType, xFnc, false);		
	} else {
		obj.attachEvent('on'+evType, xFnc);
	}
}

function stopEvent(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
