function getURL(URL){
	var str = URL.split("?");
	if(str[0].charAt(0) == '/') {
		str[0] = str[0].substr(1,str[0].length -1);
	}
	var newURL = urlBase
				+ str[0]
				+ ";jsessionid="
				+ jsessionid;
	if(str[1] != null) {
		newURL = newURL
				+ "?"
				+ str[1];
	}
	return newURL;
}

function OpenHelp(){
//	if(locale == "en_US") {
	if(locale == "en" || locale.substr(0, 3) == "en_") {
		window.open(getURL("/help/US/index.htm"),"Help","toolbar=no,menubar=no,resizable=yes,status=no,titlebar=no,left=10,top=10,width=700,height=500");
	} else {
		window.open(getURL("/help/index.htm"),"Help","toolbar=no,menubar=no,resizable=yes,status=no,titlebar=no,left=10,top=10,width=700,height=500");
	}
}

function gotoPageTop(){
		window.scroll(0,0);
}

/**
 * MODULE NAME: Browser Utility
 * BUILD DATE: 2007-03-14
 * LAST UPDATE DATE: 2007-03-14
 *
 */

// ------------------------------------------------------------- Constructor ---
Browser = function () {
	this.is_ie = (!!document.all);
	this.is_ff = (document.getElementById && !document.all);
}

// --------------------------------------------------------------- Constants ---
Browser.is_ie = (!!document.all);
Browser.is_ff = (document.getElementById && !document.all);
Browser.is_ie6 = (navigator.userAgent.indexOf("MSIE 6") != -1);
Browser.is_ie7 = (navigator.userAgent.indexOf("MSIE 7") != -1);


// ----------------------------------------------------------------- Methods ---
Browser.getTarget = function(event) {
	var target;
	if (Browser.is_ff) target = event.target;
	else if (Browser.is_ie) target = event.srcElement;
	return target;
}

/**
 * MODULE NAME: Style Utility
 * BUILD DATE: 2007-10-24
 * LAST UPDATE DATE: 2007-10-24
 *
 */

// ------------------------------------------------------------- Constructor ---
Style = function () {
}

// --------------------------------------------------------------- Constants ---
Style.DISPLAY_SHOW = true;
Style.DISPLAY_HIDDEN = false;

// ----------------------------------------------------------------- Methods ---

/**
 * getDisplayTextByBrowser: return a value of "object.style.display" by browser.
 * Return "block", if the browser is IE6 or IE7; otherwise return "".
 * Return null, if the index is neither Style.DISPLAY_SHOW nor 
 * Style.DISPLAY_HIDDEN.
 */
Style.getDisplayText = function(index) {
	var text = null;
	if (Style.DISPLAY_SHOW == index) {
		if (Browser.is_ie6 || Browser.is_ie7) {
			text = "block";
		} else {
			text = "";
		}
	} else if (Style.DISPLAY_HIDDEN == index) {
		text = "none";
	}
	return text;
}

/**
 * MODULE NAME: Number Utility
 * BUILD DATE: 2007-03-16
 * LAST UPDATE DATE: 2007-03-16
 *
 */
//------------------------------------------------------------------ Methods ---

/**
 * isPtN: isPositiveNumber, return true if the given number is positive number.
 */
Number.prototype.isPtN = function(num) {
	var i = 0, num = num.toString(), ret = true;
	while ((num.length - i) >= 1) {
		var c = num.charAt(i);
		if (i != 0) {
			if ("1234567890".indexOf(c) == -1) {
				ret = false;
				break;
			}
		} else {
			if ("123456789".indexOf(c) == -1) {
				ret = false;
				break;
			}
		}
		i++;
	}
	return ret;
};

/** check the value is hex or not. */
Number.isHexValue = function(value) {
	if (value == null) return false;
	if (value.length == 0) return false;
	for (var i = 0; i < value.length; i++) {
		if ("1234567890abcdefABCDEF".indexOf(value.charAt(i)) == -1) {
			return false;
		}
	}
	return true;
}

Number.removeHTMLHexValuePrefix = function(value) {
	if (value == null) return value;
	if (value.length != 7) return value;
	if (value.charAt(0) != "#") return value;
	if (!Number.isHexValue(value.substring(1, value.length))) return value;
	value = value.substring(1, value.length);
	return value;
}

/**
 * MODULE NAME: Date and Time Format Utility
 * BUILD DATE: 2007-03-09
 * LAST UPDATE DATE: 2007-03-09
 * 
 * KEYWORDS LIST
 * s: second
 * m: minute(0-59)
 * h: hour(0-11)
 * H: hour(0-23)
 * d: day in month
 * D: day in year
 * M: month in year(0-11)
 * y: year
 *
 */
//----------------------------------------------------------- Basic Variable ---

var baseYear = 0; //a temp base year value.

Date.BASE_YEAR = 1970; //a base point of year for calcute. 
Date.ERROR_001 = "err01", //type not correct.
Date.ERROR_002 = "err02"; //value is out of range.
Date.ERROR_003 = "err03"; //value is not a date.

//----------------------------------------------------------- Basic Function ---

Date.prototype.getADYear = function(_year) {
	if (Browser.is_ff) _year = _year + this.getBaseYear();
	else if (Browser.is_ie) _year = _year;
	return _year;
}

Date.prototype.zeroPad = function(num, width) {
	num = num.toString();
	while (num.length < width)
	num = "0" + num;
	return num;
}

Date.prototype.setBaseYear = function(_year) {
	baseYear = _year;
}

Date.prototype.getBaseYear = function() {
	if (baseYear.length == 0) return Date.BASE_YEAR;
	else return baseYear;
}

Date.prototype.getDaysInMonth = function(_M, _y) {
	var d = -1; M = 0, y = 0;
	
	//check
	if (isNaN(_M)) return Date.ERROR_001;
	if (M.isPtN(_M)) M = parseInt(_M, 10);
	else return Date.ERROR_002;
	if (M < 0 || M > 11) return Date.ERROR_002;
	
	if (isNaN(_y)) return Date.ERROR_001;
	y = parseInt(_y, 10);
	
	//main
	if (M <= 6) {
		if ((M % 2) == 0) d = 31;
		else if (M == 1) {
			if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) d = 29;
			else d = 28;
		} else {
			d = 30;
		}
	} else {
		if ((M % 2) == 0) d = 30;
		else d = 31;
	}
	return d;
}

/** return true if the given values can be a date. */
Date.prototype.isDate = function(_d, _M, _y) {
	var d = 0;
	d = parseInt(_d);
	if (d < 28 || d > 31) return Date.ERROR_002;
	var ret = this.getDaysInMonth(_M, _y);
	if (ret.toString().indexOf("err") == -1) {
		if (d != ret) return false;
		else return true;
	} else {
		return ret;
	}
}

/** return "days in year" by a date */
Date.prototype.getDaysInDate = function(_d, _M, _y) {
	var flag = this.isDate(_d, _M, _y);
	if (!flag) return Date.ERROR_003;
	var _D = _d;
	for (var i = 0; i < _M; i++) {
		_D += this.getDaysInMonth(_M, _y);
	}
	return _D;
}

/** return total days of a specified year. */
Date.prototype.getDaysInYear = function(_y) {
	var _D = 0;
	for (var i = 0; i <= 11; i++) {
		_D += this.getDaysInMonth(i, _y);
	}
	return _D;
}

/**
 * return days from baseYear "1970" to the given value.
 * example: if the give value is "1972", 
 * then return 1970,1971,1972, total days.
 */
Date.prototype.getDaysFromBaseYearToGivenYear = function(_y) {
	var days = 0;
	while (_y >= this.getBaseYear()) {
		days += this.getDaysInYear(_y);
		_y--;
	}
}

/** return time as a long value by the given Date object. */
Date.prototype.getTimeInMillis = function(_date) {
	var longnum = 0;
	s = _date.getSeconds();
	m = _date.getMinutes();
	h = _date.getHours();
	d = _date.getDate();
	M = _date.getMonth();
	y = _date.getYear();
	D = this.getDaysInDate(d, M, y);
	longnum += s;
	longnum += m*60;
	longnum += h*60*60;
	longnum += D*24*60*60;
	longnum += this.getDaysFromBaseYearToGivenYear((y-1))*24*60*60;
	return longnum;
}
