//////////////////////////////////////////////////////////////////////////////

var para_settingFilePath = "jswin-je.xml";

var para_enableBachgroundImage = true;

var UUID_Last = 0;

$Para = {};
$Lang = {};

//////////////////////////////////////////////////////////////////////////////

var $ = function(tag) {
	return document.getElementById(tag);
}

var $C = function(tag) {	
	return document.createElement(tag);
}

var cutstr = function(str, len) {
	if (str.length > len + 2)
	{
		return str.substr(0, len) + "…";
	}
	return str;
}

var $DC = function(o) {
	while (o.childNodes.length > 0)
	{
		o.removeChild(o.childNodes[0]);
	}
}

var getAvaWidth = function()
{
	return screen.availWidth;
}

var getAvaHeight = function()
{
	return screen.availHeight;
}

var getTimeStamp = function()
{
	return new Date().valueOf() + "";
}

var getClientBrowser = function() {
    switch (navigator.appName)
    {
    case "Microsoft Internet Explorer":
        {
            return 1;
        }
    case "Netscape":
        {
            return 2;
        }
    case "Opera":
        {
            return 3;
        }
    default:
        {
            return 0;
        }
    }
}

var delNode = function(parent, node) {
	while (node.childNodes.length > 0) {
		delNode(node, node.childNodes[0]);
	}
	
	parent.removeChild(node);
}

var getLengthByPx = function(str) {
	return parseInt(str.substr(0, str.length - 2));
}

var changeDivSize = function(div, x, y, step, desFunc) {
	var needRef = true;
	
	var newWidth = getLengthByPx($(div).style.width) + step;
	var newHeight = getLengthByPx($(div).style.height) + step;
	
	if (newWidth > x)
	{
		newWidth = x;
	}
	
	if (newHeight > y)
	{
		newHeight = y;
	}
	
	if (newWidth == x && newHeight == y)
	{
		needRef = false;
	}
	
	$(div).style.width = (newWidth + step) + "px";
	$(div).style.height = (newHeight + step) + "px";
	
	if (needRef == true)
	{
		var newfunc = "changeDivSize(\"" + div + "\", " + x +", " + y + ", " + step + ", \"" + desFunc + "\")";
		//alert(newfunc);
		setTimeout(newfunc, 100);
	}
	else
	{
		if (desFunc != null)
		{
			alert(desFunc);
			
			//setTimeout(desFunc, 100);
		}
	}
}

var generalCellOnMouseOver = function()
{	
	if (para_enableBachgroundImage)
	{
		this.style.backgroundImage = "url('" + $Para.strings.systemFocus01Image + "')";
	}
	else
	{
		this.style.backgroundColor = $Para.strings.systemFocus01Color;
	}
}

var generalCellOnMouseOut = function()
{	
	if (para_enableBachgroundImage)
	{
		this.style.backgroundImage = "url('" + $Para.strings.systemFocusNonImage + "')";
	}
	else
	{
		this.style.backgroundColor = $Para.strings.systemFocusNonColor;
	}
}

var getUUID = function()
{
	var v = "uuid" + UUID_Last;
	UUID_Last++;
	
	return v;
}

var showDiv = function(id, a)
{
	var div = $(id);
	
	div.style.visibility = "visible";
	
	var alpha = a + 10;
	
	if (a > 100)
	{
		a = 100;
		
		if (getClientBrowser() == 1)
		{
			div.style.filter = "alpha(opacity:" + alpha + ")";	// ------ IE
		}
		else
		{
			div.style.opacity = (alpha / 100) + "";
		}
	}
	else
	{
		if (getClientBrowser() == 1)
		{
			div.style.filter = "alpha(opacity:" + alpha + ")";	// ------ IE
		}
		else
		{
			div.style.opacity = (alpha / 100) + "";
		}
		
		setTimeout("showDiv('" + id + "', " + alpha + ")", $Para.strings.aniTimeInterval);
	}
}

var hideDiv = function(id, a)
{
	var div = $(id);
	
	var alpha = a - 10;
	
	if (a < 0)
	{
		a = 0;
		
		if (getClientBrowser() == 1)
		{
			div.style.filter = "alpha(opacity:" + alpha + ")";	// ------ IE
		}
		else
		{
			div.style.opacity = (alpha / 100) + "";
		}
		
		div.style.visibility = "hidden";
	}
	else
	{
		if (getClientBrowser() == 1)
		{
			div.style.filter = "alpha(opacity:" + alpha + ")";	// ------ IE
		}
		else
		{
			div.style.opacity = (alpha / 100) + "";
		}
		
		setTimeout("hideDiv('" + id + "', " + alpha + ")", $Para.strings.aniTimeInterval);
	}
}
