
/*
* Refresh Online JavaScript Support
*/
var Ikuaimen = new Object();
Ikuaimen.refreshUrl = "http://online.ikuaimen.com/refresh";
Ikuaimen.refreshRate = 60000;
Ikuaimen.originalTitle = document.title;
Ikuaimen.title1 = "【新消息】 | 快门";
Ikuaimen.title2 = "【　　　】 | 快门";
Ikuaimen.cookieKey = "koncept_session_cookie";
Ikuaimen.cookieIsLoginKey = "koncept_session_login";
/*Property end*/

Ikuaimen.Cookie = {get:function (name) {
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
	if (arr != null) {
		return unescape(arr[2]);
	}
	return null;
}};

/* Flash window title */
step = 0;
function FlashTitle(name) {
	this.timer;
	this.name = name;
	this.timerate = 1000;
}
FlashTitle.prototype.start = function () {
	step++;
	if (step == 3) {
		step = 1;
	}
	if (step == 1) {
		document.title = Ikuaimen.title1;
	}
	if (step == 2) {
		document.title = Ikuaimen.title2;
	}
	this.timer = setTimeout("flashtitle.start()", 1000);
};
FlashTitle.prototype.stop = function () {
	clearTimeout(this.timer);
};

var flashtitle = new FlashTitle("flashtitle");
/*Get online stat message count */
var onlineMessage = null;
function onlineMsgCount() {
	if (Ikuaimen.Cookie.get(Ikuaimen.cookieKey) && Ikuaimen.Cookie.get(Ikuaimen.cookieIsLoginKey) != "false") {
		jQuery.getScript(Ikuaimen.refreshUrl, function () {
			if (onlineMessage) {
				if (onlineMessage.invited > 0 || onlineMessage.message > 0 || onlineMessage.request > 0) {
					flashtitle.stop();
					flashtitle.start();
				} else {
					flashtitle.stop();
					window.document.title = Ikuaimen.originalTitle;
				}
			}
		});
	}else{
		flashtitle.stop();
		window.document.title = Ikuaimen.originalTitle;
	}
}

/* Begin get online message data and flash title */
onlineMsgCount();
setInterval("onlineMsgCount()", Ikuaimen.refreshRate);