var sysurl="http://www.iaibi.com";
var cookiedomain=".iaibi.com";
var cookiepre="popo_";
/**************网站收藏夹与设首页*****************/
function addtofav(){
	window.external.AddFavorite(sysurl, 'iaibi积分小游戏');
}
var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	},
	extend: function(destination, source) {
		for (property in source) {
			destination[property] = source[property];
		}
		return destination;
	}
}
var isFunction = function(a) {
	return typeof a == "function";
};
var isNull = function(a) {
	return typeof a == "object" && !a;
};
var isObject = function(a) {
	return (a && typeof a == "object") || isFunction(a);
};
var isString = function(a) {
	return typeof a == "string";
};
var isUndef = function(a) {
	return typeof a == "undefined";
};
var DoUnchanged = function(a) {
	return a;
}
var isMSIE = function() {
	return ((window.navigator.userAgent.toLowerCase().indexOf("msie") != -1) && (!isOpera()) && (!isSaf()));
};
var isFireFox = function() {
	return window.navigator.appName == "Netscape";
};
var isOpera = function() {
	return window.navigator.userAgent.indexOf("opera") != -1;
};
var isSaf = function() {
	return ((window.navigator.userAgent.indexOf("applewebkit") != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
};
var $ = function() {
	var elements = [];
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (isString(element)) element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
};

var Enumerable = {
	each: function(iterator) {
		var index = 0;
		try {
			this._each(function(value) {
				try {
					iterator(value, index++);
				} catch(e) {
					if (e != $continue) throw e;
				}
			});
		} catch(e) {
			if (e != $break) throw e;
		}
	},
	all: function(iterator) {
		var result = true;
		this.each(function(value, index) {
			result = result && !!(iterator || DoUnchanged)(value, index);
			if (!result) throw $break;
		});
		return result;
	},
	any: function(iterator) {
		var result = true;
		this.each(function(value, index) {
			if (result = !!(iterator || DoUnchanged)(value, index)) throw $break;
		});
		return result;
	},
	map: function(iterator) {
		var results = [];
		this.each(function(value, index) {
			results.push(iterator(value, index));
		});
		return results;
	},
	find: function(iterator) {
		var result;
		this.each(function(value, index) {
			if (iterator(value, index)) {
				result = value;
				throw $break;
			}
		});
		return result;
	},
	select: function(iterator) {
		var results = [];
		this.each(function(value, index) {
			if (iterator(value, index)) results.push(value);
		});
		return results;
	},
	grep: function(pattern, iterator) {
		var results = [];
		this.each(function(value, index) {
			var stringValue = value.toString();
			if (stringValue.match(pattern)) results.push((iterator || DoUnchanged)(value, index));
		});
		return results;
	},
	include: function(element) {
		var found = false;
		this.each(function(value) {
			if (value == element) {
				found = true;
				throw $break;
			}
		});
		return found;
	},
	pluck: function(property) {
		var results = [];
		this.each(function(value, index) {
			results.push(value[property]);
		});
		return results;
	},
	max: function(iterator) {
		var result;
		this.each(function(value, index) {
			value = (iterator || DoUnchanged)(value, index);
			if (value >= (result || value)) result = value;
		});
		return result;
	},
	min: function(iterator) {
		var result;
		this.each(function(value, index) {
			value = (iterator || DoUnchanged)(value, index);
			if (value <= (result || value)) result = value;
		});
		return result;
	},
	toArray: function() {
		return this.map(DoUnchanged);
	}
}

var $A = function(iterable) {
	if (!iterable) return [];
	if (iterable.toArray) return iterable.toArray();
	if (isString(iterable) || isUndef(iterable.length)) return [iterable];
	var results = [];
	for (var i = 0; i < iterable.length; i++) results.push(iterable[i]);
	return results;
}
if (!Array.prototype.push) {
	Array.prototype.push = function() {
		var len = this.length;
		for (var i = 0; i < arguments.length; i++) {
			this[len + i] = arguments[i];
		}
		return this.length;
	}
}
if (!Array.prototype.pop) {
	Array.prototype.pop = function() {
		var returnValue = this[this.length - 1];
		this.length--;
		return returnValue;
	}
}
if (!Array.prototype.splice) {
	Array.prototype.splice = function(start, deleteCount) {
		var len = arguments.length - 2;
		var returnValue = this.slice(start);
		for (var i = 0; i < len; i++) {
			this[start + i] = arguments[i + 2];
		}
		for (var i = 0; i < returnValue.length - deleteCount; i++) {
			this[start + len + i] = returnValue[deleteCount + i];
		}
		this.length = start + len + returnValue.length - deleteCount;
		returnValue.length = deleteCount;
		return returnValue;
	}
}

Class.extend(Array.prototype, Enumerable);
Class.extend(Array.prototype, {
	_each: function(iterator) {
		for (var i = 0; i < this.length; i++) iterator(this[i]);
	},
	indexOf: function(element) {
		var index = -1;
		this.each(Delegate.create(this,
		function(value, i) {
			if (this[i] == element) {
				index = i;
				throw $break;
			}
		}));
		return index;
	},
	contain: function(element) {
		return this.indexOf(element) != -1;
	},
	clear: function() {
		this.length = 0;
	},
	insert: function(position) {
		for (var i = arguments.length - 1; i > 0; i--) this.splice(position, 0, arguments[i]);
	},
	remove: function(position, count) {
		count = isUndef(count) ? 1 : count;
		this.splice(position, count);
	},
	exclude: function(element) {
		var position = this.indexOf(element);
		if (position == -1) return;
		this.remove(position);
	},
	empty: function() {
		return this.length == 0;
	},
	first: function() {
		return this[0];
	},
	last: function() {
		return this[this.length - 1];
	},
	clone: function() {
		return this.slice(0);
	},
	shuffle: function() {
		var result = [];
		var source = this.clone();
		var index;
		this.each(function() {
			index = Math.floor(Math.random() * source.length);
			result.push(source[index]);
			source.remove(index);
		});
		return result;
	}
});


Class.extend(String.prototype,{trim:function(){return this.replace(/(^\s+)|(\s+$)/g,"");},bytes:function(){return this.replace(/[^\x00-\xff]/g,"  ").length;},truncate:function(bytes,tail){tail=tail||"";var result;for(var i=0;i<this.length;i++){if((result=this.substr(0,i)).bytes()>=bytes)
return result+tail;}
return this.substr(0);},count:function(string,caseSensitive){var result=this.match(new RegExp(string,"g"+(caseSensitive?"":"i")));return isNull(result)?0:result.length;},strip:function(){var temp=this;temp=temp.replace(/&/ig,"&amp;");temp=temp.replace(/</ig,"&lt;");temp=temp.replace(/>/ig,"&gt;");temp=temp.replace(/\"/ig,"&quot;");temp=temp.replace(/\'/ig,"&#39;");temp=temp.replace(/ /ig,"&nbsp;");temp=temp.replace(/(\r?\n)|\r/ig,"<br />");return temp;},revert:function(){var temp=this;temp=temp.replace(/&apos;/ig,"\'");temp=temp.replace(/&quot;/ig,"\"");temp=temp.replace(/&gt;/ig,">");temp=temp.replace(/&lt;/ig,"<");temp=temp.replace(/&nbsp;/ig," ");temp=temp.replace(/&amp;/ig,"&");temp=temp.replace(/<br.*?>|<\/p><p(\s*|\s+.+?)>/ig,"\n").replace(/<\/?p(\s*|\s+.+?)>/ig,"");return temp;},camelize:function(){var result=this.replace(new RegExp("(\\W)+","g"),"");return result.charAt(0).toLowerCase()+result.substr(1);},toFileSize:function(){if(/^\d+(?:\.\d+)?(K|M|G|T)B$/ig.test(this))
return this;if(!this.match(/^(\d+)B?$/ig))
return"0B";var suffixes=["B","KB","MB","GB","TB"];var size=parseInt(RegExp.$1);var k=1024;var h=100;var s=size*h;while(s>=k*h){s=parseInt(s/k);suffixes.shift();}
return s/100+suffixes[0];}})
var Events=function(){};Events.prototype={addEventListener:function(evt,handler){if(isUndef(this.__listeners__[evt]))
this.__listeners__[evt]=[];else
this.removeEventListener(evt,handler);this.__listeners__[evt].push(handler);},removeEventListener:function(evt,handler){if(!isUndef(this.__listeners__[evt]))
this.__listeners__[evt].exclude(handler);},dispatchEvent:function(evtObj){if(isString(evtObj))
evtObj={type:evtObj,target:this};if(!evtObj.type)return;if(isUndef(evtObj.target))
evtObj.target=this;(this[evtObj.type+"Handler"]||DoNothing)(evtObj);var queue=this.__listeners__[evtObj.type];if(!isUndef(queue)){for(var i=0;i<queue.length;i++){if(isFunction(queue[i]))
queue[i](evtObj);else if(isObject(queue[i])){var o=queue[i];(o.handleEvent||DoNothing)(evtObj);(o[evtObj.type]||DoNothing)(evtObj);}else{}}}}};Class.extend(Events,{initialize:function(object){if(isUndef(this._dispatcher))
this._dispatcher=new Events();object.addEventListener=this._dispatcher.addEventListener;object.removeEventListener=this._dispatcher.removeEventListener;object.dispatchEvent=this._dispatcher.dispatchEvent;object.__listeners__={};},KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(event){return event.target||event.srcElement;},isLeftClick:function(event){return(((event.which)&&(event.which==1))||((event.button)&&(event.button==1)));},pointerX:function(event){return event.pageX||(event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));},pointerY:function(event){return event.pageY||(event.clientY+(document.documentElement.scrollTop||document.body.scrollTop));},stop:function(event){if(event.preventDefault){event.preventDefault();event.stopPropagation();}else{event.returnValue=false;event.cancelBubble=true;}},findElement:function(event,tagName){var element=Events.element(event);while(element.parentNode&&(!element.tagName||(element.tagName.toUpperCase()!=tagName.toUpperCase())))
element=element.parentNode;return element;},__listeners__:[],addListener:function(obj,evt,handler,useCapture){if(evt=="keypress"&&(obj.attachEvent||navigator.appVersion.match(/Konqueror|Safari|KHTML/)))
evt="keydown";useCapture=useCapture||false;Events.__listeners__.push([obj,evt,handler,useCapture]);if(obj.addEventListener)
obj.addEventListener(evt,handler,useCapture);else if(obj.attachEvent)
obj.attachEvent("on"+evt,handler);},removeListener:function(obj,evt,handler,useCapture){if(evt=="keypress"&&(obj.attachEvent||navigator.appVersion.match(/Konqueror|Safari|KHTML/)))
evt="keydown";useCapture=useCapture||false;if(obj.removeEventListener)
obj.removeEventListener(evt,handler,useCapture);else if(obj.detachEvent)
obj.detachEvent("on"+evt,handler);},unloadListeners:function(){var listeners=Events.__listeners__;if(listeners.empty())return;listeners.each(function(l){Events.removeListener.apply(this,l);l[2]=null;});listeners.clear();}});Events.addListener(window,"unload",Events.unloadListeners);var Element={visible:function(element){return $(element).style.display!="none";},toggle:function(){for(var i=0;i<arguments.length;i++){var element=$(arguments[i]);Element[Element.visible(element)?"hide":"show"](element);}},hide:function(){for(var i=0;i<arguments.length;i++){$(arguments[i]).style.display="none";}},show:function(){for(var i=0;i<arguments.length;i++){$(arguments[i]).style.display="";}},remove:function(element){element=$(element);element.parentNode.removeChild(element);},classNames:function(element){return new Element.ClassNames(element);},hasClassName:function(element,className){if(!(element=$(element)))
return;return Element.classNames(element).include(className);},addClassName:function(element,className){if(!(element=$(element)))
return;return Element.classNames(element).add(className);},removeClassName:function(element,className){if(!(element=$(element)))
return;return Element.classNames(element).remove(className);},replaceClassName:function(element,classNameSrc,classNameDest){if(!(element=$(element)))
return;return Element.classNames(element).replace(classNameSrc,classNameDest);},getStyle:function(element,style){return $(element).style[style];},setStyle:function(element,style){element=$(element);for(name in style)
element.style[name]=style[name];}};Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(element){this.element=$(element);},_each:function(iterator){this.element.className.split(/\s+/).select(function(name){return name.length>0;})._each(iterator);},set:function(className){this.element.className=className;},add:function(classNameToAdd){if(this.include(classNameToAdd))
return;this.set(this.toArray().concat(classNameToAdd).join(" "));},remove:function(classNameToRemove){if(!this.include(classNameToRemove))
return;this.set(this.select(function(className){return className!=classNameToRemove;}).join(" "));},replace:function(classNameSrc,classNameDest){this.set(this.select(function(className){return className!=classNameSrc&&className!=classNameDest;}).concat(classNameDest).join(" "));},toString:function(){return this.toArray().join(" ");}}
Class.extend(Element.ClassNames.prototype,Enumerable);if(window.HTMLElement){if(!window.HTMLElement.prototype.insertAdjacentElement){window.HTMLElement.prototype.insertAdjacentElement=function(where,element){switch(where){case"beforeBegin":this.parentNode.insertBefore(element,this);break;case"afterBegin":this.insertBefore(element,this.firstChild);break;case"beforeEnd":this.appendChild(element);break;case"afterEnd":if(this.nextSibling)
this.parentNode.insertBefore(element,this.nextSibling);else
this.parentNode.appendChild(element);break;}}}
if(!window.HTMLElement.prototype.insertAdjacentHTML){window.HTMLElement.prototype.insertAdjacentHTML=function(where,htmlText){var rng=this.ownerDocument.createRange();rng.setStartBefore(this);this.insertAdjacentElement(where,rng.createContextualFragment(htmlText));}}}

var Insertion = {
	_insertContent: function(element, content, where) {
		element = $(element);
		if (isString(content)) {
			element.insertAdjacentHTML(where, content);
			return;
		}
		if (isObject(content)) {
			element.insertAdjacentElement(where, content);
			return;
		}
	},
	before: function(element, content) {
		Insertion._insertContent(element, content, "beforeBegin");
	},
	top: function(element, content) {
		Insertion._insertContent(element, content, "afterBegin");
	},
	bottom: function(element, content) {
		Insertion._insertContent(element, content, "beforeEnd");
	},
	after: function(element, content) {
		Insertion._insertContent(element, content, "afterEnd");
	}
};

var Cookie = {
	set: function(label, value, expireTime) {
		var cookie = cookiepre + label + "=" + escape(value) + "; domain="+cookiedomain+"; path=/;";
		if (isUndef(expireTime)) document.cookie = cookie;
		else {
			var expires = new Date();
			expires.setTime(expires.getTime() + expireTime * 1000);
			document.cookie = cookiepre + label + "=" + escape(value) + "; domain="+cookiedomain+"; path=/; expires=" + expires.toGMTString() + ";";
		}
	},
	get: function(label) {
		return isNull(document.cookie.match(new RegExp("(^" + cookiepre + label + "| " + cookiepre + label + ")=([^;]*)"))) ? "": unescape(RegExp.$2);
	},
	clear: function(label) {
		Cookie.set(cookiepre + label, "");
	},
	getAll: function() {
		return document.cookie;
	}
};
var ojax="/source/ajax.php";
var cpurl="/cp.php";
var Login={
	popDiv:null,
	loginRet:false,
	callBackFunc:function(){},
	showInterface:function(callBackFunc){
		if(Login.popDiv==null){
			Login.popDiv=document.createElement("DIV");
			Login.popDiv.id="login_pop_id";
			Login.popDiv.innerHTML='<div class="login_bg"><div class="login_c"><h6><span><a href="javascript:Login.exit();" class="a_close" title="关闭登录窗口"></a></span>泡泡用户登录</h6><div class="login"><form id="form1" action="/source/ajax.php?ac=login&do=login" target="login_submit_iframe" method="post" onsubmit="return Login.validateInput();"><fieldset><ul><li><label for="u">请输入您的帐号：</label><input id="u" name="u" type="text" value="" class="input_lo"  maxlength="50" /></li><li><label>请输入您的密码：</label><input name="p" type="password" maxlength="50"  class="input_lo"/></li><li><label>输入验证码：</label><input name="seccode" type="text" maxlength="10"  class="input_lo yz" /><img id="verify_code" style="margin:0px 3px;" /><a href="#" onclick="$(\'verify_code\').src=\'/source/seccode.php?rnd=\'+new Date().getTime();return false;">看不清？换一个</a></li><li class="ct"><input type="checkbox" class="pop_checkbox" name="cookietime" value="315360000" />下次自动登录&nbsp;&nbsp;<input type="submit" class="pop_button" value="登录" /><input type="reset" class="pop_button" value="重置" /></li><li class="ct"><a href="user/forgetpass.html" target="_blank">忘记密码啦？</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="user/register.html" target="_blank">快速注册</a></li></ul></fieldset></form><iframe name="login_submit_iframe" style="display:none" onload="Login.checkRet()"></iframe></div></div></div>';
			Insertion.bottom(document.body,Login.popDiv);
			Login.popDiv.style.position="absolute";
			Login.backDiv=document.createElement("DIV");
			Login.backDiv.style.backgroundColor="Black";
			Login.backDiv.style.filter="alpha(opacity=40)";
			Login.backDiv.style.MozOpacity="0.4";
			Login.backDiv.style.position="absolute";
			Login.backDiv.style.left="0px";
			Login.backDiv.style.top="0px";
			Insertion.bottom(document.body,Login.backDiv);
			Login.backDiv.style.zIndex=101;
			Login.popDiv.style.zIndex=102;
		}else{
			Login.popDiv.style.display=Login.backDiv.style.display="";
		}
		if(!isUndef(callBackFunc))
			Login.callBackFunc=callBackFunc;
		if(window.attachEvent){
			window.attachEvent("onresize",this.setPos);
			window.attachEvent("onscroll",this.setPos);
		}else{
			window.addEventListener("onresize",this.setPos,false);
			window.addEventListener("onscroll",this.setPos,false);
		}
		this.setPos();$('verify_code').src='/source/seccode.php?rnd='+new Date().getTime();$("u").focus();
	},
	validateInput:function(){
		if($("form1").u.value.length==0)
			{alert("请您输入用户名!")
			return false;
		}
		if($("form1").p.value.length==0){
			alert("请您输入密码!")
			return false;
		}
		if($("form1").seccode.value.length==0){
			alert("请您输入验证码!")
			return false;
		}
		this.disablePopDiv(true);
		Login.loginRet=true;
		return true;
	},
	setPos:function(){
		Login.popDiv.style.left=(document.documentElement.clientWidth/2+document.documentElement.scrollLeft-207)+"px";
		Login.popDiv.style.top=(document.documentElement.clientHeight/2+document.documentElement.scrollTop-142)+"px";
		Login.backDiv.style.width=Math.max(document.body.scrollWidth,document.documentElement.clientWidth)+"px";
		Login.backDiv.style.height=Math.max(document.body.scrollHeight,document.documentElement.clientHeight)+"px";
	},
	exit:function(){
		$("form1").reset();
		Login.popDiv.style.display=Login.backDiv.style.display="none";
		this.disablePopDiv(false);
		if(window.detachEvent){
			window.detachEvent("onresize",this.setPos);
			window.detachEvent("onscroll",this.setPos);
		}else{
			window.removeEventListener("onresize",this.setPos,false);
			window.removeEventListener("onscroll",this.setPos,false);
		}
		myf.dshow();
	},
	disablePopDiv:function(tag){
		$A(Login.popDiv.getElementsByTagName("INPUT")).each(function(eachInput){
			eachInput.style.disabled=tag;
		});
	},
	checkRet:function(){
		if(Login.loginRet){
			var verifyRet=Cookie.get("chklogin");
			if(verifyRet=="success"){
				noticewin("登录成功！",3000,500);
				LoginBanner.set();
				Login.exit();
				myf.show();
				return;
			}
			if(verifyRet=="wrongcode")
				alert("验证码错误");
			else if(verifyRet=="nouser")
				alert("该用户尚未注册");
			else if(verifyRet=="denied")
				alert("用户名或密码错误");
			else if(verifyRet=="wrongpost")
				alert("用户名或密码为空");
			else if(verifyRet=="closed")
				alert("该用户已经禁止登录！");
			else if(verifyRet=="syserror")
				alert("系统错误，请联系管理员解决。");
			else
				alert("登录失败 "+Cookie.get("chklogin")+" cookie");
			this.disablePopDiv(false);
			$('verify_code').src='/source/seccode.php?rnd='+new Date().getTime();
		}
	}
};

/*------------Ajax登录返回--------------*/
var LoginBanner= {
	set:function(){
		$("loginstatus").innerHTML = myajax.sal("post",ojax,"ac=cookie&f=main");
	},
	setindex:function(){
		$("loginstatus").innerHTML = myajax.sal("post",ojax,"ac=cookie&f=index");
	}
};
var finish_login = 0;
function login() {
	myf.hidden();
	Login.showInterface(function() {
		if (typeof(afterLogin) == "function") afterLogin();
	});
}
function logout(){
	var lgout = myajax.sal("post",ojax,"ac=login&do=lgout");
	if(lgout){
		myf.hidden();
		noticewin("<b>"+lgout+"</b>",2700,500);
		LoginBanner.set();
		if(typeof(afterLogout)=="function"){
			afterLogout();
		}
		myf.show();
	}
}
function logout_i(){
	var lgout = myajax.sal("post",ojax,"ac=login&do=lgout");
	if(lgout){
		noticewin("<b>"+lgout+"</b>",2700,500);
		LoginBanner.setindex();
		if(typeof(afterLogout)=="function"){
			afterLogout();
		}
	}
}
function seccode() {
	var img = 'source/seccode.php?rand='+Math.random();
	document.writeln('<img id="img_seccode" src="'+img+'" align="absmiddle">');
}
/*******************漂出 提示 效果*************************/
function display(id) {
	$(id).style.display = $(id).style.display == '' ? 'none' : '';
}
function display_opacity(id, n) {
	if(!$(id)) {
		return;
	}
	if(n >= 0) {
		n -= 10;
		$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';
		$(id).style.opacity = n / 100;
		setTimeout('display_opacity(\'' + id + '\',' + n + ')', 50);
	} else {
		$(id).style.display = 'none';
		$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		$(id).style.opacity = 1;
	}
}
function noticewin(s, t, c) {
	c = !c ? '' : c;
	s = '<table cellspacing="0" cellpadding="0" class="popolayer"><tr><td class="pc_c" valign="middle" align="center">' + s +
		(c ? '' : '') + '</td></tr></table>';
	if(!$('ntcwin')) {
		var div = document.createElement("div");
		div.id = 'ntcwin';
		div.style.display = 'none';
		div.style.position = 'absolute';
		div.style.zIndex = '99999';
		$('ajaxwaitid').appendChild(div);
	}
	$('ntcwin').innerHTML = s;
	$('ntcwin').style.display = '';
	$('ntcwin').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
	$('ntcwin').style.opacity = 0;
	pbegin = document.documentElement.scrollTop + (document.documentElement.clientHeight / 2);
	pend = document.documentElement.scrollTop + (document.documentElement.clientHeight / 5);
	setTimeout(function () {noticewin_show(pbegin, pend, 0, t)}, 10);
	$('ntcwin').style.left = ((document.documentElement.clientWidth - $('ntcwin').clientWidth) / 2) + 'px';
	$('ntcwin').style.top = pbegin + 'px';
}
function noticewin_show(b, e, a, t) {
	step = (b - e) / 10;
	newp = (parseInt($('ntcwin').style.top) - step);
	if(newp > e) {
		$('ntcwin').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + a + ')';
		$('ntcwin').style.opacity = a / 100;
		$('ntcwin').style.top = newp + 'px';
		setTimeout(function () {noticewin_show(b, e, a += 10, t)}, 10);
	} else {
		$('ntcwin').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		$('ntcwin').style.opacity = 1;
		setTimeout('display_opacity(\'ntcwin\', 100)', t);
	}
}
/*******************漂出 提示 效果*************************/
/********数字表单验证**********/
function checknum(iid,maxnum){
	var patrn = /^[0-9]*[1-9][0-9]*$/;
	var wnum = $(iid).value;
	if(Math.floor(wnum) > maxnum) {
		alert("不能大于 "+maxnum+" ！");
		$(iid).focus();
		return false;
	}else if(!patrn.exec(wnum)){
		alert("必须填正整数");
		$(iid).focus();
		return false;
	}
	return true;
}
function numchk(iid,minnum,maxnum){
	var patrn = /^[0-9]*[1-9][0-9]*$/;
	var wnum = $(iid).value;
	if(Math.floor(wnum) > maxnum) {
		alert("不能大于 "+maxnum+" ！");
		$(iid).focus();
		return false;
	}else if(Math.floor(wnum) < minnum){
		alert("不能小于 "+minnum+" ！");
		$(iid).focus();
		return false;
	}else if(!patrn.exec(wnum)){
		alert("必须填正整数");
		$(iid).focus();
		return false;
	}
	return true;
}
/*------------获取GET方式Url传递参数--------------*/
function getAr(paras){
	var url = location.href;
	var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");
	var paraObj = {}
	for (i=0; j=paraString[i]; i++){
		paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);
	}
	var returnValue = paraObj[paras.toLowerCase()];
	if(typeof(returnValue)=="undefined"){
		return "";
	}else{
		return returnValue;
	}
}
var myxml;
var myas;
function getajax() {
	try {
		myxml = new ActiveXObject("Microsoft.XMLHTTP");
		myas = 1;
	} catch(e) {
		try {
			myxml = new ActiveXObject("Msxml2.XMLHTTP");
			myas = 1;
		} catch(e) {
			try {
				myxml = new XMLHttpRequest();
				myas = 2;
			} catch(e) {
				myxml = null;
				myas = 0;
			}
		}
	}
}

/*------------Ajax 返回传递函数--------------*/
var myajax = {
	sal: function doXMLHTTP(method, url, pars) {
		getajax();
		if (myas == 0) {
			alert("您的浏览器不支持XMLHTTP，无法完成此操作");
		} else {
			myxml.open(method, url, false);
			if (method == "post") {
				myxml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			} else {
				myxml.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
			}
			myxml.send(pars);
			var htmlcode;
			if (myas == 1) {
				if (myxml.readyState == 4) {
					htmlcode = myxml.responseText;
				}
			} else {
				htmlcode = myxml.responseText;
			}
			return htmlcode;
		}
	}
};
var mydo = {
	/*------------收藏夹--------------*/
	fav:function(style,fname,furl){
		if(Cookie.get("loginuser")==""){
			alert("您还没有登录，无法进行收藏夹操作。");
		}else{
			var refav = myajax.sal("post",ojax,"ac=favorite&style="+style+"&fname="+fname+"&furl="+furl);
			if(refav=="success"){
				myf.hidden();
				noticewin("添加到我的收藏夹成功",2700,500);
				myf.show();
			}else if(refav=="exist")
				alert("收藏夹中已经有此数据了。");
			else if(refav=="denied")
				alert("添加到收藏夹出错了，请联系管理人员解决问题。");
			else
				alert("未知系统错误，请联系管理人员解决问题。");
		}
	},
	/*------------兑换--------------*/
	exchange:function(pid){
		$('excform').style.display='';
		$('excform').innerHTML='<h4><a name="info" href="#" class="active">礼品兑换</a></h4><div style="padding:30px 0;text-align:center;"><img src="/images/loading_c_c.gif"><br>正在加载中，请稍候......</div>';
		$('excform').innerHTML = myajax.sal("post",ojax,"ac=exchange&id="+pid);
	},
	del:function(style,id){
		var res = myajax.sal("post",ojax,"ac=favorite&op=del&style="+style+"&id="+id);
		if(res=='del_ok'){
			noticewin("<b>删除成功!~~~</b>",2700,500);
			$('li_'+id).style.display = 'none';
			$('li_'+id).style.zIndex=-10;
		}
	},
	excclose:function(){
		$('excform').style.display='none';
	},
	/*------------使用道具--------------*/
	MUse:function(mc){
		var mub = myajax.sal("post",cpurl,"ac=magic&op=use&mc="+mc+"&from=userpanel");
		var mubs = new Array();
		mubs = mub.split(",");
		if(mubs[0]=='success'){
			if(mubs[1]==1){
				setTimeout("window.location.href ='"+mubs[2]+"';", 5000);
				var jumpinfo = '页面跳转中';
			}
			noticewin('<img src="/images/loading_01.gif"><br>操作成功.'+jumpinfo,3000,500);
		}else if(mubs[0]=='error'){
			alert('操作失败.');
		}
	},
	getdaypoint:function(){
		var restatus =  myajax.sal("post",ojax,"ac=app&do=daypoint");
		if(restatus=='needlogin'){
			alert("还未登录或登录已经超时！");
		}else if(restatus=='success'){
			$('snd').src='/images/daypoint.mp3';
			noticewin("<b>领取每日积分成功!~~~</b>",2700,500);
			$('daypoint').disabled='disabled';
		}else{
			alert("非法操作！");
		}
	}
};
var myf={
	hidden:function(){
		/*------------Hide Flash Div--------------*/
		if($("showflash")){
			$("showflash").style.width="0px";
			$("showflash").style.overflow="hidden";
		}
	},
	show:function(){
		/*--------------恢复flash的wmode模式为空--------------*/
		if($("showflash")) setTimeout('$("showflash").style.width="100%";', 2800);
	},
	dshow:function(){
		/*--------------恢复flash的wmode模式为空--------------*/
		if($("showflash")) setTimeout('$("showflash").style.width="100%";', 0);
	}
};
/*------------游戏快速通道--------------*/
var mypop={
	hall:null,
	callBackFunc:function(){},
	showAllgame:function(callBackFunc){
		myf.hidden();
		if(mypop.hall==null){
			mypop.hall=document.createElement("DIV");
			mypop.hall.id="gameHall";
			mypop.hall.innerHTML='<div class="mypop_title" onmousedown="drag(event,this);"><span onclick="mypop.exit();">[关闭]</span><b>选择游戏</b></div><div class="hallcont"><div class="hallclass" id="hallclass"><img src="/images/loading_04.gif"> 加载中，请稍候......</div><div class="hallgame" id="hallgame"><div style="padding:20px;text-align:center;"><img src="/images/loading_c_c.gif"></div></div></div>';
			Insertion.bottom(document.body,mypop.hall);
			mypop.hall.style.position="absolute";
			mypop.bg=document.createElement("DIV");
			mypop.bg.style.backgroundColor="Black";
			mypop.bg.style.filter="alpha(opacity=40)";
			mypop.bg.style.MozOpacity="0.4";
			mypop.bg.style.position="absolute";
			mypop.bg.style.left="0px";
			mypop.bg.style.top="0px";
			Insertion.bottom(document.body,mypop.bg);
			mypop.bg.style.zIndex=101;
			mypop.hall.style.zIndex=102;
		}else{
			mypop.hall.style.display=mypop.bg.style.display="";
		}
		if(!isUndef(callBackFunc))
			mypop.callBackFunc=callBackFunc;
		if(window.attachEvent){
			window.attachEvent("onresize",this.setPos);
			window.attachEvent("onscroll",this.setPos);
		}else{
			window.addEventListener("onresize",this.setPos,false);
			window.addEventListener("onscroll",this.setPos,false);
		}
		this.setPos();
		$('hallclass').innerHTML = myajax.sal("post",ojax,"ac=hall&do=class");
		$('hallgame').innerHTML = myajax.sal("post",ojax,"ac=hall&do=game");
	},
	setPos:function(){
		mypop.hall.style.left=((document.documentElement.clientWidth-760)/2)+"px";
		mypop.hall.style.top=(118)+"px";
		mypop.bg.style.width=Math.max(document.body.scrollWidth,document.documentElement.clientWidth)+"px";
		mypop.bg.style.height=Math.max(document.body.scrollHeight,document.documentElement.clientHeight)+"px";
	},
	exit:function(){
		myf.dshow();
		mypop.hall.style.display=mypop.bg.style.display="none";
		if(window.detachEvent){
			window.detachEvent("onresize",this.setPos);
			window.detachEvent("onscroll",this.setPos);
		}else{
			window.removeEventListener("onresize",this.setPos,false);
			window.removeEventListener("onscroll",this.setPos,false);
		}
	},
	randomPlay:function(){
		myf.hidden();
		noticewin('<img src="/images/loading_01.gif"><br>正在为您随机选择游戏，请稍等...',3000,500);
		setTimeout("window.location.href ='"+myajax.sal("post",ojax,"ac=hall&do=random")+"';", 3000);
	}
};
function openHall() {
	mypop.showAllgame(function() {
	});
}
function reHallgame(cid){
	$('hallgame').innerHTML = '<div style="padding:20px;text-align:center;"><img src="/images/loading_c_c.gif"></div>';
	$('hallgame').innerHTML = myajax.sal("post",ojax,"ac=hall&do=game&cid="+cid);
}
/* 鼠标拖动 */
var oDrag = "";
var ox,oy,nx,ny,dy,dx;
function drag(e,o){
	var e = e ? e : event;
	var mouseD = document.all ? 1 : 0;
	if(e.button == mouseD)
	{
		oDrag = o.parentNode;
		//alert(oDrag.id);
		ox = e.clientX;
		oy = e.clientY;		
	}
}
function dragPro(e){
	if(oDrag != "")
	{	
		var e = e ? e : event;
		//$(oDrag).style.left = $(oDrag).offsetLeft + "px";
		//$(oDrag).style.top = $(oDrag).offsetTop + "px";
		dx = parseInt($(oDrag).style.left);
		dy = parseInt($(oDrag).style.top);
		//dx = $(oDrag).offsetLeft;
		//dy = $(oDrag).offsetTop;
		nx = e.clientX;
		ny = e.clientY;
		$(oDrag).style.left = (dx + ( nx - ox )) + "px";
		$(oDrag).style.top = (dy + ( ny - oy )) + "px";
		ox = nx;
		oy = ny;
	}
}
document.onmouseup = function(){oDrag = "";}
document.onmousemove = function(event){dragPro(event);}

var ajaxwin={
	FormRet:false,
	callBackFunc:function(){},
	show:function(wurl,popwidth,popheight){
		ajaxwin.bg=document.createElement("DIV");
		ajaxwin.bg.style.backgroundColor="Black";
		ajaxwin.bg.style.filter="alpha(opacity=60)";
		ajaxwin.bg.style.MozOpacity="0.6";
		ajaxwin.bg.style.position="absolute";
		ajaxwin.bg.style.display="block";
		ajaxwin.bg.style.left="0px";
		ajaxwin.bg.style.top="0px";
		Insertion.bottom(document.body,ajaxwin.bg);
		ajaxwin.bg.style.zIndex=98;
		
		$("append_parent").style.display="";
		$("append_parent").style.zIndex=99;
		$("append_parent").style.position="absolute";
		$("append_parent").style.width=popwidth+"px";
		$("append_parent").style.border="4px solid #ff9900";
		$("append_parent").style.background="#ffffff";
		$("append_parent").style.height=popheight+"px";
		$("append_parent").innerHTML = myajax.sal("post",wurl,"inajax=1");
		Insertion.bottom(document.body,ajaxwin.popwin);
		
		$('append_parent').style.left=((document.documentElement.clientWidth-popwidth)/2)+"px";
		$('append_parent').style.top=((document.documentElement.clientHeight-popheight)/2)+"px";
		ajaxwin.bg.style.width=Math.max(document.body.scrollWidth,document.documentElement.clientWidth)+"px";
		ajaxwin.bg.style.height=Math.max(document.body.scrollHeight,document.documentElement.clientHeight)+"px";
	},
	exit:function(){
		if($("append_parent")&&ajaxwin.bg){
			$("append_parent").style.display=$("append_parent").style.display="none";
			$("append_parent").style.zIndex=-1;
			ajaxwin.bg.style.display="none";
			ajaxwin.bg.style.zIndex=-1;
		}
	},
	MBuy:function(){
		if($("myform").buynum.value.length==0){
			alert("请输入数字!")
			return false;
		}
		ajaxwin.FormRet=true;
		return true;
	},
	MBuyRet:function(){
		if(ajaxwin.FormRet==true){
			var verifyRet=Cookie.get("MagicBuy");
			if(verifyRet=="success"){
				noticewin("购买成功！<br>已存入你的道具库。",3000,500);
				ajaxwin.exit();
			}
			if(verifyRet=="error")
				alert("购买失败！");
			else if(verifyRet=="needlogin")
				alert("您还没有登录！");
			else if(verifyRet=="NotEnough")
				alert("余额不足！");
		}
		ajaxwin.FormRet=false;
	}
};

