// JavaScript Document
var halfX;
var halfY;
var fullX;
var fullY;

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function initial() {
	IE = document.all ? true : false;
	fox = new RegExp("Firefox","i");
	chrome = new RegExp("Chrome","i");
	safari = new RegExp("Safari","i");
	opera = new RegExp("Opera","i");
	if (IE) {
		fullX = document.body.clientWidth;
		fullY = getWindowHeight();
	}
	else if (fox.test(navigator.userAgent) || chrome.test(navigator.userAgent) || safari.test(navigator.userAgent) || opera.test(navigator.userAgent)) {
		fullX = document.body.clientWidth;
		fullY = getWindowHeight();
	}
	else {
		fullX = pageXOffset;
		fullY = pageYOffset;
	}
	halfX = Math.floor(fullX / 2);
	halfY = fullY / 2;
}

function setAlpha(obj,per) {
	inone = per / 100;
	if (inone >= 1) inone = 0.99;
	obj.style.opacity = inone;
	obj.style.MozOpacity = inone;
	obj.style.KhtmlOpacity = per / 100;
	obj.style.filter = "alpha(opacity=" + per + ")";
}

function goAjax(url,target,args,parent) {
	var req;
	try {
		req= new XMLHttpRequest();
	} catch (e) {
		try {
			req= new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser not support!");
				return false;
			}
		}
	}
	
	if (parent != undefined) req.parent = parent;

	req.onreadystatechange = target;

	req.open("post",url);
	req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; UTF-8');
	req.send(args);
}

function IsNum(n) {
	strChk = "1234567890.";
	n = n + "";
	for (i = 0;i < n.length;i++) {
		c = n.charAt(i);
		if (c == ',') {
			ii = n.length - i;
			nnn = ii % 4;
			if (nnn != 0) return false;
		}
		else {
			if (strChk.indexOf(c) < 0) return false;
		}
	}
	return true;
}

var flashID = 1;
function showFlash(filename,w,h) {
	txt = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + w + "\" height=\"" + h + "\"><param name=\"movie\" value=\"" + filename + "\"><param name=\"quality\" value=\"high\"><embed src=\"" + filename + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"  width=\"" + w + "\" height=\"" + h + "\"></embed></object>";
	flashID++;
	document.write(txt);
}

var _popBG = null;
var _popFG = null;

function callDialog(txt,w,h,padding) {
	initial();
	if (padding == undefined) padding = 20;
	if (_popBG == null) {
		_popBG = document.createElement("div");
		_popBG.style.position = "fixed";
		_popBG.style.zIndex = 1;
		_popBG.style.backgroundColor = "#000";
		setAlpha(_popBG,50);
		document.body.appendChild(_popBG);
	}
	if (_popFG == null) {
		_popFG = document.createElement("div");
		_popFG.style.position = "fixed";
		_popFG.style.zIndex = 2;
		_popFG.style.backgroundColor = "#FFF";
		document.body.appendChild(_popFG);
	}
	_popBG.style.width = fullX + "px";
	_popBG.style.height = fullY + "px";
	_popBG.style.left = "0px";
	_popBG.style.top = "0px";
	_popFG.style.width = w;
	_popFG.style.height = h;
	_popFG.style.left = Math.round((fullX - w) / 2) + "px";
	_popFG.style.top = Math.round((fullY - h) / 2) + "px";
	_popFG.innerHTML = "<div style=\"padding:" + padding + "px\">" + txt + "</div>";
	_popBG.style.display = "";
	_popFG.style.display = "";
	return _popFG;
}

function closeDialog() {
	_popFG.style.display = "none";
	_popBG.style.display = "none";
}

