
//////////////////////////////////////////////////////////////////////
// js.ijji.cookie

var domainName = "ijji.com";
var serviceDomainName = document.domain;
// session cookie prefix. Cookies with this prefix will be deleted when logout
var sessionCookiePrefix = "NHN_S_";

function getFixDomain() {
	var s = document.domain;

	if ( s.indexOf(domainName) >= 0 ) {
		return domainName;
	}
	else {
		var n = s.indexOf(".");
		var test = s.split(".");
		if (test.length > 2)
		{
			return s.substring(n + 1, s.length);
		}else{
			return s;
		}
	}
}

function getServiceDomain(name) {
	if ( (location.host).indexOf("dev") == 0 || (location.host).indexOf("alpha") == 0 ) {
		return "alpha-" + name;
	}
	if ( (location.host).indexOf("beta") == 0 ) {
		return "beta-" + name;
	}
	return name;
}

function setDomain() {
	if ( typeof(_doNotSetDomain)=="boolean" && _doNotSetDomain==true ) return;
	document.domain = getFixDomain();
}

function getCookie(name) {
	var aRec;
	var aCook = document.cookie.split("; ");

	for (var i=0; i<aCook.length; i++) {
		aRec = aCook[i].split("=");
		if (name.toLowerCase()==unescape(aRec[0].toLowerCase())) return aRec[1];
	}

	return "";
}

function setCookie(name, value) {
	var argv = setCookie.arguments;
   	var argc = setCookie.arguments.length;
   	var expires = (2 < argc) ? argv[2] : null;
   	var path = (3 < argc) ? argv[3] : null;
   	var domain = (4 < argc) ? argv[4] : null;
   	var secure = (5 < argc) ? argv[5] : false;
   	document.cookie = name + "=" + escape (value) +
      	((expires == null) ? "" :
        ("; expires=" + expires.toGMTString())) +
      	((path == null) ? "" : ("; path=" + path)) +
      	((domain == null) ? "" : ("; domain=." + getFixDomain())) +
      	((secure == true) ? "; secure" : "");
}

function deleteCookie(name) {
  document.cookie = name + "=dumy; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

//////////////////////////////////////////////////////////////////////
//js.ijji.url
function getPhase(host) { // e.g.) use location.host for host
	if ( host.indexOf("dev-")==0 || host.indexOf("alpha-")==0 ) {
		return "alpha";
	} else if ( host.indexOf("beta-")==0 ) {
		return "beta";
	}
	return "";
}

function adjustIjjiUrl(url, noSSL) {
	var docPhase = getPhase(location.host);
	var uriObj = parseUri(url);
	var phase = getPhase(uriObj.host);
	
	if ( docPhase == phase ) return url;
	var host = uriObj.host;
	if ( host.indexOf(domainName) < 0 ) return url; // if not ijji.com
	
	if ( phase == "alpha" || phase == "beta") {
		uriObj.host = docPhase + (docPhase.length > 0 ? "-" : "" ) + host.substr(host.indexOf("-")+1);
		if ( noSSL ) {
			uriObj.protocol = "http";
		}
	} else if ( phase == "" ) {
		uriObj.host = docPhase + (docPhase.length > 0 ? "-" : "" ) + host;
	}
	
	return unparseUri(uriObj);	
}

//parseUri 1.2.2
//(c) Steven Levithan <stevenlevithan.com>
//MIT License

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});
	
	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};
//parseUri 1.2.2

// added
function unparseUri(uri) {
	return uri.protocol + "://" + uri.host + (uri.port.length > 0 ? ":" + uri.port : "") +
			(uri.relative.length > 0 ? uri.relative : "" );
};

//////////////////////////////////////////////////////////////////////
// js.ijji.string

function defaultIfEmpty(obj, value) {
	if ( obj == null || obj == "" || obj == undefined || obj == "undefined") return value;
	if (typeof value == "boolean" || typeof value == "number") return eval(obj);
	return obj;
}

function isCp1252CharCode(charCode){
	var cp1252ExtCharCodes = new Array(338,339,352,353,376,381,382,402,710,732,8211,8212,8216,8217,8218,8220,8221,8222,8224,8225,8226,8230,8240,8249,8250,8364,8482);
	if(charCode > 0 && charCode <= 0xFF) return true; //Latin1
	for(var i=0; i < cp1252ExtCharCodes.length; i++)
		if(cp1252ExtCharCodes[i] == charCode) return true;
	return false;
}

function getInvalidCp1252Chars(str) {
	var arr = new Array();
	for(var i=0;i<str.length;i++)
		if(!isCp1252CharCode(str.charCodeAt(i))) arr.push( str.charAt(i) );
	if(arr.length == 0) return null;
	return arr;
}

function isCp1252Str(str) {
	for(var i=0;i<str.length;i++)
		if(!isCp1252CharCode(str.charCodeAt(i))) return false;
	return true;
}

//////////////////////////////////////////////////////////////////////
// js.ijji.browser.agent

function isXPSP2(){
    if (!isMSIE() ) return false;

	var agent = window.navigator.userAgent;
	if(agent.indexOf("SV1")) return true;
	if(isXP() && agent.indexOf("MSIE 7.") !=-1) return true;
	// todo : would be removed, if prepare to support Vista
	if (isVista()) return true;
	return false;
}

function isXP(){
	if (!isMSIE() ) return false;
	var agent = window.navigator.userAgent;
	if(agent.indexOf("NT 5.1") !=-1) return true;     //SP1

	return false;
}

function isVista(){
	if (!isMSIE() ) return false;
	var agent = window.navigator.userAgent;
	if(agent.indexOf("NT 6.") !=-1) return true;

    return false;
}

function isMSIE() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") !=-1 ) return true;
	else return false;
}

function isFirefox() {
	var agent = window.navigator.userAgent;
	if (agent.toUpperCase().indexOf("FIREFOX") !=-1 ) return true;
	else return false;
}

function isGameSupportedBrowser() {
	return isMSIE() || isFirefox();
}

function isXPComEnabled(){
	if (isMSIE() ) return false;
	var agent = window.navigator.userAgent;
	if(agent.toUpperCase().indexOf("GECKO") !=-1) return true;     //FireFox, Netscape
	if(agent.toUpperCase().indexOf("OPERA") !=-1) return true;     //Opera
	return false;
}

function isWindows(){
	var agent = window.navigator.userAgent;
	if(agent.toUpperCase().indexOf("WINDOWS") !=-1) return true;
	return false;
}
//////////////////////////////////////////////////////////////////////
// js.ijji.activex

function viewActiveObject(html){
	document.write(html);
}

//////////////////////////////////////////////////////////////////////
// js.ijji.popup

function openSimpleFrameWindow(url, target, width, height) {
	return window.open(url, target, "scrollbars=no,statusbar=no,toolbar=no, menu=no,width=" + width + ",height=" + height);
}


//////////////////////////////////////////////////////////////////////
// js.ijji.html

function addEvent(ev, el) {
	addEventOnObject(window, ev, el, false);
}
function removeEvent(ev, el) {
	removeEventFromObject(window, ev, el, false);
}

function addEventOnObject(obj, evType, fn, useCapture){
	if(evType.substring(0,2) == "on") {
		evType = evType.substring(2);
	}

	if (obj.addEventListener){
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
} 
function removeEventFromObject(obj, evType, fn, useCapture){
	if(evType.substring(0,2) == "on") {
		evType = evType.substring(2);
	}

	if (obj.removeEventListener) {
		obj.removeEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.detachEvent) {
		var r = obj.detachEvent("on"+evType, fn);
		return r;
	}
} 

function favor() {
	window.external.AddFavorite('http://www.ijji.com', 'ijji - Where Gamers Unite!');
}

//////////////////////////////////////////////////////////////////////
// js.ijji.prototype

String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.cut = function(len, tail) {
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) {
        l += (str.charCodeAt(i) > 128) ? 2 : 1;
        if (l > len) return str.substring(0,i) + tail;
    }
    return str;
}


//////////////////////////////////////////////////////////////////////
// js.ijji.nds
function isExcludedNdsUrl(url) {

	var ndsExcludeList = new Array(
			"channel.ijji.com", "lcs.ijji.com"
	);

	for (var i = 0 ; i < ndsExcludeList.length ; i++ ) {
		if (location.host.indexOf(ndsExcludeList[i]) >= 0) {
			return true;
		}
	}
	return false;
}
try {
	jQuery(document).ready( function() {
		if (typeof(_doNotSetNDS)=="boolean" && _doNotSetNDS==true) {
			return;
		}
		if (isExcludedNdsUrl(location.host)) {
			return;
		}
		if ( document.URL.indexOf("/nds/u") >= 0 ) {
			return;
		}
		var url = "";
		if ( location.protocol == "https:" ) {
			url = "https://" + getServiceDomain('billing') + ".ijji.com/nds/u{" + getNDSI18NAddedURL(document.URL) + "}";
		} else {
			url = "http://lcs.ijji.com/u{" + getNDSI18NAddedURL(document.URL) + "}";
		}
		
		// add iframe
		jQuery("body").append('<iframe src="' + url + '" id="__ndsIframe" width="0" height="0" style="display:none;"/>');
	});
} catch (e) {}

//////////////////////////////////////////////////////////////////////
// js.ijji.misc

function toggleDisplay(id) {
  if ( document.getElementById(id).style.display == 'none' ) {
    document.getElementById(id).style.display = "";
  } else {
    document.getElementById(id).style.display = 'none';
  }
}

function parseCurrency(str) {
	var temp = new String(str);
	var SIZE = 3;
	var strings = new Array();

	if ( temp.length <= SIZE ) return temp;

	for (var i = 0; i < temp.length / SIZE; i++ ) {
		if ( temp.length < (i + 1) * SIZE) {
			strings[strings.length] = temp.substr(0,  temp.length - i * SIZE );
		} else {
			strings[strings.length] = temp.substr( temp.length - (i + 1) * SIZE, SIZE);
		}
	}

	var result = "";
	 for (var i = 0; i < strings.length; i++ ) {
	 		if ( result == "" ) result = strings[i];
	 		else result = strings[i] + "," + result;
	 }

	 return result;
}

//////////////////////////////////////////////////////////////////////
// play live
function goPlay(gameId, subId) {
	//alert(__mouse_pos_x + ',' + __mouse_pos_y);
	var startFrame = document.getElementById("startFrame");
	if (startFrame == null)	{
		var obj = document.createElement('iframe');
		obj.setAttribute('id','startFrame');
		obj.style.border = '0px';
		obj.style.width = '0px';
		obj.style.height = '0px';
		obj.style.visibility = 'hidden';
		startFrame = document.body.appendChild(obj);
	}
	startFrame.src="/common/prelaunch.nhn?gameId=" + gameId + "&subId=" + subId + "&posx=" + __mouse_pos_x + "&posy=" + __mouse_pos_y;
}
// gamestart function for reactor 
function gamestart(gameId) {
	var startFrame = document.getElementById("startFrame");
	if (startFrame == null)	{
		var obj = document.createElement('iframe');
		obj.setAttribute('id','startFrame');
		obj.style.border = '0px';
		obj.style.width = '0px';
		obj.style.height = '0px';
		obj.style.visibility = 'hidden';
		startFrame = document.body.appendChild(obj);
	}
	startFrame.src="/common/pregamestart.nhn?gameId=" + gameId + "&posx=" + __mouse_pos2_x + "&posy=" + __mouse_pos2_y;
}
function showDownloadPopup(flag) {
	var alertLayer = document.getElementById('alertLayer');
	if (flag) {
		alertLayer.style.display = 'block';
	} else {
		alertLayer.style.display = 'none';
	}
}

function startDownloadAutoInstaller() {
	showDownloadPopup(false);
	var hgstartURL = "/nhnusa/dist/hansetup/ijjiAutoInstaller.exe";
	if ( (location.host).indexOf("dev") == 0 || (location.host).indexOf("alpha") == 0 ) {
		hgstartURL = "http://alpha.ijji.com" + hgstartURL;
	} else {
		hgstartURL = "http://cdn.ijjimax.com" + hgstartURL;
	}
	
	location.href = hgstartURL;
}

// AD
function showAd(categories, width, height) {
	var size = 2;
	var seed =  Math.floor(Math.random() * size);

	if (seed == 0) {
		getAdExpo9(categories, width, height);
	}
	else {
		getAdExpo9(categories, width, height);
	}

}

function getAdExpo9(categories, width, height) {
   var e9 = new expo9_ad();
   e9.addBlockingCategories=categories;
   e9.size =  width + "x" + height;
   e9.showAd();
}

// CRM 2 Functions
// @Deprecated after completed Ijji Multi Language 2nd
var _crmPopup = null;

function hasCrmAlert() {
	var checkURL = "services.ijji.com/crm/popupcheck";
	if ( (location.host).indexOf("dev") == 0 || (location.host).indexOf("alpha") == 0 ) {
		checkURL = "alpha-" + checkURL;
	} else if ( (location.host).indexOf("beta") == 0 ) {
		checkURL = "beta-" + checkURL;
	}

	checkURL = "http://" + checkURL;
	ajaxHttpRequest(checkURL, "showCrmLayer");
}

function showCrmLayer(json) {

	var crmLayer = document.getElementById("crm_layer");

	if ( !crmLayer || !json || json.popupyn != "Y") {
		return;
	}

	if ( json.popuptype == "POPUP" ) {
		popupCrm(json.popupURL);
		return;
	}

	var crmP = document.createElement("P");
	crmP.className = "txt";
	crmP.appendChild(document.createTextNode(json.message));
	crmP.appendChild(document.createElement("BR"));
	var crmA = document.createElement("A");
	crmA.appendChild(document.createTextNode("Click for details!"));
	crmA.href = "javascript:popupCrm('"+json.popupURL+"');";

	crmP.appendChild(crmA);
	crmLayer.appendChild(crmP);
	crmLayer.style.display = "block";
}

function popupCrm(url) {
	if ( !url ) { return ; }
	_crmPopup = window.open(url, 'CRM2', 'fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no,menubar=no,width=200,height=200');
	document.getElementById("crm_layer").style.display = "none";
}

function closeCrmLayer() {
	document.getElementById("crm_layer").style.display = "none";
}
//////////////////////////////////////////////////////////////////////
// js.ijji.i18n
var __userSelectedLocale = "i18n_userSelectedLocale";
var __determinedLanguage = "i18n_lang";
var __defaultLanguageCode = "en";
var __ndsLangParam = "_lang";
var __langOrder = new Array("en","es","de");

function getLangCode() {
	var langCode = getCookie(__determinedLanguage);
	if ( langCode == null || langCode.length == 0 ) {
		return __defaultLanguageCode;
	}
	return langCode;
}

function getUserSelectedLangCode() {
	return getCookie(__userSelectedLocale);
}

function getLanguageName(langCode) {
	var names = {"en":"English", "es":"Español", "de":"Deutsch"};
	return names[langCode];
}

function getLangNum() {
	var code = getLangCode();
	for ( var i = 0 ; i < __langOrder.length ; i++ ) {
		if ( code == __langOrder[i] ) return i;
	}
	return 0;
}

function setLangCode(langCode) {
	var expires = 1000 * 60 * 60 * 24 * 365 * 10;
	var expires_date = new Date( (new Date()).getTime() + (expires) );
	setCookie(__userSelectedLocale, langCode, expires_date, "/", "." + domainName);
}

function setLangCodeNReload(langCode, section, stay) {
	// set cookie
	setLangCode(langCode);
	// call wbers
	try {
		var host = location.host;
		host = host.substr(0,host.indexOf("."));
		section = section + "_" + host;
		if ( location.protocol == "https:" ) {
			var url = adjustIjjiUrl("https://billing.ijji.com/wbers/wbers/post.php?project=multilang&subject=initsel&lang=" + langCode + "&section=" + section, false);
		} else {
			var url = adjustIjjiUrl("http://wbers.ijji.com/wbers/post.php?project=multilang&subject=initsel&lang=" + langCode + "&section=" + section);
		}
		// add iframe
		jQuery("body").append('<iframe src="' + url + '" id="__wbersIframe" width="0" height="0" style="display:none;"/>');
	} catch (e) {}
	// reload
	if ( stay ) return;
	setTimeout("location.reload(true);",500);
}

function getNDSI18NAddedURL(url) {
	if ( url == null || url.length <= 0 ) return url;
	
	// check service not in spanish
	var re = new Array(
		/^(http|https):\/\/[^\.]*luminary\.ijji\.com/,
		/^(http|https):\/\/[^\.]*rohan\.ijji\.com/,
		/^(http|https):\/\/[^\.]*channel\.ijji\.com/,
		/^(http|https):\/\/[^\.]*avatar\.ijji\.com/,
		/^(http|https):\/\/[^\.]*game\.ijji\.com/,
		/^(http|https):\/\/[^\.]*flash\.ijji\.com/,
		/^(http|https):\/\/[^\.]*miningboy\.ijji\.com/
	);
	for (var i = 0 ; i < re.length ; i++ ) {
		if ( re[i].test(url) ) {
			return url;
		}
	}
	
	url = url.replace(/[\?&]+$/,"");
	var n = url.indexOf("?");
	if ( n > 0 ) {
		return url + "&" + __ndsLangParam + "=" + getLangCode();
	}
	return url + "?" + __ndsLangParam + "=" + getLangCode();
}

function ialert() {
	var num = getLangNum();
	var msg = "";
	if ( num < arguments.length ) {
		msg = arguments[num];
	} else if ( arguments.length >= 1 ) {
		msg = arguments[0];
	}
	alert(msg);
}

//////////////////////////////////////////////////////////////////////
// ui
function findAbsPos(obj) {
	var curLeft = 0;
	var curTop = 0;
	var n = 0; // exit within 100 loops
	if (obj.offsetParent) {
		do {
			curLeft += obj.offsetLeft;
			curTop += obj.offsetTop;
			n++;
			obj = obj.offsetParent;
		} while ( obj && n < 100 );
	}
	return new Array(curLeft, curTop);
}


//////////////////////////////////////////////////////////////////////
// automatic initializers

// Premier Coupon
var cookieShowPrmrCoupon;
var cookieUsePrmrCoupon;

function hasPremierCoupon(service, useruid, ctype, pcode) {
	if (typeof(service) == 'undefined') service = '';
	if (typeof(useruid) == 'undefined') useruid = '';
	if (typeof(ctype) == 'undefined') ctype = '';
	if (typeof(pcode) == 'undefined') pcode = '';
	
	cookieShowPrmrCoupon = "showPremierCoupon"+useruid+service;
	cookieUsePrmrCoupon = "usePremierCoupon"+useruid;
	
	var prmrCoupon = getCookie(cookieShowPrmrCoupon);
	if ( prmrCoupon == null || prmrCoupon.length == 0 ) {
		var checkURL = "premier.ijji.com/coupon/chkCoupon.nhn";
		if ( (location.host).indexOf("dev") == 0 || (location.host).indexOf("alpha") == 0 ) {
			checkURL = "alpha-" + checkURL;
		} else if ( (location.host).indexOf("beta") == 0 ) {
			checkURL = "beta-" + checkURL;
		}
		checkURL = "http://" + checkURL + "?ctype="+ctype+"&pcode="+pcode;
		ajaxHttpRequest(checkURL, "showPremierCouponLayer");
	}
}

function showPremierCouponLayer(json) {
	var prmrLayer = document.getElementById("prmrCouponLayer");
	if ( !prmrLayer || !json || json.rtn != "0") {
//		closePremierCouponLayer();
		return;
	}
	
	var prmrPkg = document.getElementById("ajax_pcoupon");
	if(prmrPkg) {
		prmrPkg.innerHTML= json.pname;
	}
	
	var pgcoin = document.getElementById("ajax_pcoupon_pgcoin");
	if(pgcoin) {
		pgcoin.innerHTML= json.pgcoin;
	}
	
	prmrLayer.style.display = "block";
}

function closePremierCouponLayer() {
	document.getElementById('prmrCouponLayer').style.display = "none";
	// set cookie
	var validDays=1;
	var exp=new Date();
	exp.setDate(exp.getDate()+validDays);
	document.cookie = cookieShowPrmrCoupon+"=N; path=/; domain="+getFixDomain()+"; expires="+exp.toGMTString()+"; ";
}

function usePremierCoupon() {
	// set cookie
	var validDays=1;
	var exp=new Date();
	exp.setDate(exp.getDate()+validDays);
	document.cookie = cookieUsePrmrCoupon+"=Y; path=/; domain="+getFixDomain()+"; expires="+exp.toGMTString()+"; ";

	// redirect to registration page
	var prmrReg = "premier.ijji.com/premieroptions/ccart.nhn";
	if ( (location.host).indexOf("dev") == 0 || (location.host).indexOf("alpha") == 0 ) {
		prmrReg = "alpha-" + prmrReg;
	} else if ( (location.host).indexOf("beta") == 0 ) {
		prmrReg = "beta-" + prmrReg;
	}
	prmrReg = "http://" + prmrReg;
	document.location.href=prmrReg;
}

////////////////////////////////////////////////////////////////////////////////
// Codes related with Window Event

// mouse position
var __mouse_pos_x = 0;
var __mouse_pos_y = 0;
var __mouse_pos2_x = 0;
var __mouse_pos2_y = 0;

document.onmousemove=mtrack;
function mtrack(e) {
	var scrolledValue = getScrollXY();

	if ( typeof(window.screenLeft) == 'number' ) {
		__mouse_pos_x = event.screenX - window.screenLeft + scrolledValue[0];
		__mouse_pos_y = event.screenY - window.screenTop + scrolledValue[1];
		__mouse_pos2_x = event.screenX - top.screenLeft;
		__mouse_pos2_y = event.screenY - top.screenTop;
	} else {
		if (typeof(event) != 'undefined'){
			__mouse_pos_x = event.clientX;
			__mouse_pos_y = event.clientY;
			__mouse_pos2_x = event.clientX;
			__mouse_pos2_y = event.clientY;
		} else {
			__mouse_pos_x = e.pageX;
			__mouse_pos_y = e.pageY;
			var __winpos = getWindowsPos();
			__mouse_pos2_x = e.pageX + __winpos.x;
			__mouse_pos2_y = e.pageY + __winpos.y;
		}
	}
}

function getWindowsPos() {
    var win = window;
    pos = {x:0, y:0};
    while (win && win!=top) {
        var obj = win.frameElement;
        while (obj) {
            pos.x += obj.offsetLeft;
            pos.y += obj.offsetTop;
            obj = obj.offsetParent;
        }
        win = win.parent;
    }
    return pos;
}


function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

// Codes related with Window Event
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Code related with Ijji Clock
Date.prototype.getTimeZone = function() {
	return this.timeZone;
}
Date.prototype.setTimeZone = function(t) {
	this.timeZone = t.toUpperCase();
}
Date.prototype.adjustTimeZone = function() {
	/*************************************
	* US. 2007 energy policy
	* DST starts:      at 2:00am in standard time
	*                  on the second Sunday in March
	* DST ends:        at 2:00am in daylight time
	*                  on the first Sunday in November
	* ***********************************
	*/
	
	var pdtStartInPST = new Date(this.getFullYear(),2,8,2,0);
	if ( pdtStartInPST.getDay() > 0 ) {
		pdtStartInPST = new Date(this.getFullYear(),2,8+7-pdtStartInPST.getDay(),2,0);
	}
	pdtStartInPDT = new Date(pdtStartInPST.getTime() + 1000*60*60);
	
	var pstStartInPST = new Date(this.getFullYear(),10,1,1,0);
	if ( pstStartInPST.getDay() > 0 ) {
		pstStartInPST = new Date(this.getFullYear(),10,7-pstStartInPST.getDay(),1,0);
	}
	pstStartInPDT = new Date(pstStartInPST.getTime() + 1000*60*60);
	
	if ( this.getTimeZone() == "PDT" ) {
		if ( this.getTime() >= pstStartInPDT.getTime() || this.getTime() < pdtStartInPDT.getTime() ) {
			this.setTime(this.getTime() - 1000*60*60);
			this.setTimeZone("PST");
		}
	} else if ( this.getTimeZone() == "PST" ) {
		if ( this.getTime() >= pdtStartInPST.getTime() && this.getTime() < pstStartInPST.getTime() ) {
			this.setTime(this.getTime() + 1000*60*60);
			this.setTimeZone("PDT");
		}	
	}
}

var __ijji_local_clock = new Date();

function setIjjiLocalServerTime(year, month, day, hour, min, sec, timeZone) {
	__ijji_local_clock = new Date(year, month, day, hour, min, sec);
	__ijji_local_clock.setTimeZone(timeZone);
	__ijji_local_clock.adjustTimeZone();
}
function startIjjiClockTimer() {
	__ijji_local_clock.setTime(__ijji_local_clock.getTime() + 1000);
	__ijji_local_clock.adjustTimeZone();
	setTimeout("startIjjiClockTimer()", 1000);
}
function getIjjiLocalClockDate() {
	return __ijji_local_clock;
}
function getIjjiLocalTimeString() {

	var clock_hours = __ijji_local_clock.getHours();
	var clock_minutes = __ijji_local_clock.getMinutes();
	var clock_seconds = __ijji_local_clock.getSeconds();
	if (clock_hours < 10){
		clock_hours = "0" + clock_hours;
	}
	if (clock_minutes < 10){
		clock_minutes = "0" + clock_minutes;
	}
	if (clock_seconds < 10){
		clock_seconds = "0" + clock_seconds;
	}
	return clock_hours + ":" + clock_minutes + ":" + clock_seconds;
}
function getIjjiLocalDateString() {
	var month = __ijji_local_clock.getMonth()+1;
	var date = __ijji_local_clock.getDate();
	if (month < 10){
		month = "0" + month;
	}
	if (date < 10){
		date = "0" + date;
	}
	return __ijji_local_clock.getFullYear()+"-"+month+"-"+date;
}

addEventOnObject(window, "onload", startIjjiClockTimer, false);
////////////////////////////////////////////////////////////////////////////////

setDomain();

// Start Quantcast tag
function quantCall() {
    var quant_src = "http://pixel.quantserve.com/pixel/p-bab2-LCsBITgs.gif"; 
	    
    if ("https:"==document.location.protocol) 
		quant_src = "https://secure.quantserve.com/pixel/p-bab2-LCsBITgs.gif"; //secure site

    var quant_img = document.createElement("img");
    quant_img.setAttribute("name","quantImg");
    quant_img.setAttribute("src",quant_src);
    quant_img.setAttribute("height",1);
    quant_img.setAttribute("width",1);
    quant_img.style.display = "none";
    document.body.appendChild(quant_img);
}

addEvent("onload",quantCall);
// End Quantcast tag

function includeJavaScriptMsg(msgfile, msgroot, lang)
{
	if (msgfile == null) return;
	if (msgroot == null) msgroot = '/scripts/msg';
	if (lang == null) lang = getLangCode();
	document.write('<script type="text/javascript" src="' + msgroot + '/' + lang + '/' + msgfile + '.js"></scr' + 'ipt>');
}
