var isIE = (window.ActiveXObject)?true:false;

function openWindow(w, h, url) {
	var l = Math.round((screen.width - w) / 2);
	var t = Math.round((screen.height - h) / 2) - 20;
	return window.open(url, null, "left="+l+",top="+t+",height="+h+",width="+w+",resizable=0,status=1,toolbar=0");
}

function isIExplore() {
	if (navigator.userAgent.indexOf("MSIE") == -1)
		return false;
	else
		return true;
}

function shortStr(str) {
	len = 60;
	if (str.length > len)
		str = str.substring(0, str.substring(0, len).lastIndexOf(" ")) + "...";
	return str;
}

function CSSUnitsToNumber(pval) {
	if (pval && (typeof pval == "string")) {
		var unit = pval.substr(pval.length-2, 2);
		if (unit == "px" || unit == "pt")
			return parseInt( pval.substr(0, pval.length-2) );
	}
	return pval;
}

function showStatus(msg) {
	if (document.getElementById("StatusMsg")) {
		hideMenuTooltip();
		document.getElementById("StatusMsg").innerHTML = msg;
		document.getElementById("StatusMsg").style.display = "inline";
	}
}

function hideStatus() {
	if (document.getElementById("StatusMsg"))
		document.getElementById("StatusMsg").style.display = "none";
}

function showMenuTooltip(text) {
	if (document.getElementById("MenuTooltip")) {
		document.getElementById("MenuTooltip").innerHTML = text;
		document.getElementById("MenuTooltip").style.display = "inline";
	}
}

function hideMenuTooltip() {
	if (document.getElementById("MenuTooltip")) {
		document.getElementById("MenuTooltip").innerHTML = "";
		document.getElementById("MenuTooltip").style.display = "none";
	}
}

// Images preloading script
var imgs;
function preloadImages(urls) {
	imgs = new Array;
	imgs.length = urls.length;
	for (i=0; i<urls.length; i++) {
		img = new Image();
		img.src = urls[i];
		imgs[i] = img;
	}
}
