//document.domain = 'woyo.com';
$(function(){
	clearBlurA();
	window.focus();
	eval(gExec);
	gExec=null;
	//除去 box 类下所有 button 元素的焦点
	$('.box button').clearBlur();
});

/*==================== 功能函数-fun ====================*/

/*
	window onresize 事件
	按添加callback顺序执行
*/
function resizeForWindow(){
	this.callback = {};
	this.num = 0;
	this.flag = true;
}

resizeForWindow.prototype = {
	add : function(name, callback){
		this.callback[name] = callback;
		this.num++;
		if(this.flag === true){
			this.bind();
		}
	},
	del : function(name){
		delete this.callback[name];
		this.num--;
		if(this.num <= 0 && this.flag === false){
			this.unbind();
		}
	},
	bind: function(){
		var self = this;
		$(window).resize(function(){
			if(self.num > 0){
				var tmp = null;
				for(tmp in self.callback){
					if(typeof self.callback[tmp] == 'function'){
						self.callback[tmp].apply(self);
					} else {
						eval(self.callback[tmp]);
					}
				}
			}
		});
		this.flag = false;
	},
	unbind: function(){
		$(window).unbind('resize');
		this.flag = true;
	}
}

var rfwObj = new resizeForWindow();

/*
	document 事件
	按添加callback顺序执行
*/
function bindDocumentEvent(){
	this._eventName = {};
	this.callback = {};
	this.num = {};
	this.flag = {};
}

bindDocumentEvent.prototype = {
	add : function(eName, name, callback){
		if(this._eventName[name] == undefined){
			this._eventName[name] = eName;
			if(this.callback[eName] == undefined){
				this.callback[eName] = {};
				this.callback[eName][name] = callback;
			} else {
				this.callback[eName][name] = callback;
			}
			if(this.num[eName] == undefined){
				this.num[eName] = 1;
			} else {
				this.num[eName] += 1;
			}
			if(this.flag[eName] == undefined){
				this.bind(eName, name);
			}
		}
		return this;
	},
	del : function(eName, name){
		if(this._eventName[name] != undefined){
			delete this.callback[eName][name];
			delete this._eventName[name];
			this.num[eName]--;
			if(this.num[eName] <= 0 && this.flag[eName] === false){
				this.unbind(eName);
			}
		}
		return this;
	},
	bind: function(eName, name){
		var self = this;
		$(document).bind(eName, function(e){
			if(self.num[eName] > 0){
				var tmp = null;
				for(tmp in self.callback[eName]){
					if(typeof self.callback[eName][tmp] == 'function'){
						self.callback[eName][tmp].apply(self,[e]);
					} else {
						eval(self.callback[eName][tmp]);
					}
				}
			}
		});
		this.flag[eName] = false;
	},
	unbind: function(eName){
		$(document).unbind(eName);
		delete this.flag[eName];
	}
}

var bindDomEventObj = new bindDocumentEvent();

//这个控制搜索的suggest
bindDomEventObj.add('click','search_suggest',function() {
	if($.id('autoWords') != null && $.id('autoWords').innerHTML !=''){
		$.id('autoWords').style.display = 'none';
	}
})

//清除A标签的焦点
function clearBlurA(){
	$("a[name!='no_blur']").each(function(){clearDrag(this);this.onfocus=function(){this.blur()}});
	clearBlurObject();
	clearImage();
}

/*
 * 除去目标对象的焦点
 * 使用示例： $('jQuery 选择器').clearBlur();
 * @Author: George Wing
 * @Created: 2010/01/28
 * 注意：如进行改动请添加修改时间和修改作者的注释
 */
(function($){
	$.fn.clearBlur = function(){
		return this.focus(function(){ $(this).blur(); });
	};
})(jQuery);

//清除Flash的焦点
function clearBlurObject(){
	//$("object").each(function(){clearDrag(this);this.onfocus=function(){this.blur()}});
}

//清除image的焦点
function clearImage(){
	$("img").each(function(){clearDrag(this);this.onfocus=function(){this.blur()}});
}

//多少毫秒后去做事
function delayExec(fun,time){
	time=(time==undefined)? 100:time;
	var timer=window.setInterval(function(){
		window.clearInterval(timer);
		if(typeof fun == 'function')fun.apply(this);
		else eval(fun);
	},time);
}

//注销选中事件
function clearDrag(obj){
	var tmp=null;
	// for IE 5 +
	if (window.ActiveXObject) {
		if(obj.length==undefined){
			obj.onselectstart = function(){return false;};
			obj.ondragstart = function(){return false;};
			obj.unselectable = "on";
		}
		else{
			for(tmp in obj){
				tmp.onselectstart = function(){return false;};
				tmp.ondragstart = function(){return false;};
				tmp.unselectable = "on";
			}
		}
	}
	// for non IE 5 +
	else{
		if(obj.length==undefined){
			if(obj.style==undefined)return;
			obj.style.mozUserSelect = 'none';
			obj.style.userSelect = 'none';
			obj.style.KhtmlUserSelect = 'none';
		}
		else{
			for(tmp in obj){
				if(tmp.style==undefined)continue;
				tmp.style.mozUserSelect = 'none';
				tmp.style.userSelect = 'none';
				tmp.style.KhtmlUserSelect = 'none';
			}
		}
	}
}

//msgbar控制
/*
function magBarControl(mode){
	var objbody = document.getElementById('body');
	var objhtml= document.getElementById('html_frame');
	var objmsg= document.getElementById('msgbar');
	if((objhtml.clientHeight - objbody.clientHeight)>=16)objmsg.style.bottom = '16px';
	if(mode === true)objmsg.style.bottom = '0px';
	$(window).resize(function(){
		if ((objhtml.clientHeight - objbody.clientHeight)>=16){
			if(objmsg.style.bottom!='16px')objmsg.style.bottom = '16px';
		} else {
			if(objmsg.style.bottom!='0px')objmsg.style.bottom = '0px';
		}
	});
}
*/

function msgBarFlush() {
    var timer = null;
    $('#msgBarWrap').hide();
    clearTimeout(timer);
    timer=setTimeout(function(){
        $('#msgBarWrap').show();
        $('#msgBarWrap').css('bottom',0).show();
    },500);
}

//异步加载msgbar
function makeMsgBar () {
    if (getQueryString("chatdebug") == "true") { //yuyii add 调试选项
        $.getScript("http://image.woyo.com/js/common/chat_1.0.2.js",function(){
    		delayExec(function (){$('#msgBarWrap').data('flagChatLoadStatus',1)},50);
    	});
    }
    else if(getQueryString("woyotoo") == "true") { //woyotoo 测试用
	    $.getScript("http://image.woyo.com/js/common/chat_1.0.js",function(){
		    delayExec(function (){$('#msgBarWrap').data('flagChatLoadStatus',1)},500);
	    });
    }
    else {
	    //$.getScript("http://image.woyo.com/js/common/chat_1.0.2.js",function(){
        $.getScript("http://image.woyo.com/js/common/chat_1.0.2-min.js",function(){
		    delayExec(function (){$('#msgBarWrap').data('flagChatLoadStatus',1)},50);
	    });
    }
    
    /*
    //使用iframe 要做ajax请求
    var m_content=document.createElement("iframe");
    m_content.name = "msgbar";
    m_content.id = "msgbar";
    m_content.scrolling="no";
    m_content.width="100%";
    m_content.height = "25";
    m_content.setAttribute("frameborder", "0", 0);
    m_content.src="http://msgbar.woyo.com/showMsgbar.php";
    $("#msgBarWrap").get(0).appendChild(m_content); 
    */
    
	//下面是新的版本，ff考css就能搞定，ie6需要下面的事件监听
	if($.browser.msie) {
        
        if ($.browser.version == '6.0') {
          /*
            var timer=null;
            function resizeLocation() {
                $('#msgBarWrap').hide();
                clearTimeout(timer);
                timer=setTimeout(function(){
                    $('#msgBarWrap').show();
                    $('#msgBarWrap').css('bottom',0).show();
                },500);
            }
            */
            var resizeLocation=msgBarFlush;

            jQuery(window).scroll(resizeLocation);
            jQuery(window).resize(resizeLocation);
        }
	}
	$('#msgBarWrap').data('flagChatLoadStatus',0);
	ajaxE({'domain':'msgbar.woyo.com','page':'showMsg','fun':'showMsg'});
}



function showMsgbarNoticeNum (newsNum) {
	if ($.id("msgbarNoticeNum") != null || $.id("msgbarNoticeNum") != 'undefined') {
		$.id("msgbarNoticeNum").innerHTML = newsNum;
		$("#msgbarNoticeNum").show();
	}
}

// 初始化聊天
function initChat(userid,webimip,webimport,ticket){
	delayExec(function(){
		if($('#msgBarWrap').data('flagChatLoadStatus') == 1){
			// 聊天对象已经存在，js加载完毕
			if(chatObj_g != undefined && chatObj_g != null){
				if(userid != undefined){
					chatObj_g.createChat(userid, webimip, webimport,ticket);
                    if(getQueryString("woyotoo") == "true") {
                        getWoyoToo(userid);
                    }
				}
			}
		} else {
			initChat(userid, webimip, webimport,ticket);
		}
	},13);
}

//获得woyotoo
//function getWoyoToo(mode){
function getWoyoToo(userid,mode){
	try{
		var woyotoo_handle = new ActiveXObject("ICCARD.ICCardCtrl.1");
		window.location.href="woyotoo://uid="+userid;
		return false;
	}
	catch(e){
		if(mode=='flash')window.open('http://www.woyo.com/superdown.php','superdown','fullscreen=yes');
		return true;
	}
}

//传ticket给flash,如果已经登录，就不在iwoyo内登录
var fsAirWin;
function upFsAirInstall(ticket){
	var date = new Date();
	var installStr = $(document).createSwf({
        src         : 'http://image.woyo.com/swf/upfs/badge.swf?'+date.getTime(),
        id          : "fm_install_wftps",
        w           : 252,
        h           : 220,
        ver         : 9,
        mode        : 3,
        vars        : {
            appname: 'WOYOFtp上传工具',
            appurl: 'http://image.woyo.com/swf/upfs/woyoupload.air',
			ticket:ticket,
			airversion: '1.0'
        },
        params      : {menu:'false',wmode:'transparent',allowScriptAccess:'always'}
    });

	fsAirWin = function(){
		popObj.close(true);
	}

	alertFun(function(){
        return '<div class="pop_container" style="display:none;width:250px;"><div class="pop_title-nav"><h2>欢迎使用我友相册/视频上传</h2><a href="#" class="pop_close" title="关闭"  onclick="popObj.close(true);return false;">&nbsp;</a></div><div class="pop_content after" style="height:220px;">'+installStr+'</div></div>';
    },'woyoFtpInstall',2);
}
function noGetself(){
alertFun(function(){return '<div class="pop_container" width:250px; height:45px;"><div class="pop_title-nav"><h2>温馨提示</h2><a href="#" class="pop_close" title="关闭"  onclick="popObj.close(true);return false;">&nbsp;</a></div><p style="line-height:45px;padding-left:10px;">不能给自己发站内短信息</p></div></div>';});
	}
//--------------------------------数据替换时的遮照--------------------------------------------------------

/*
createShield:
	mode=选择遮照模式
	para=[	w/width:0,宽
			h/height:0,高
			l/left:0,距左
			t/top:0,距上
			a/action:(true|false),是否隐藏input=select
			m:(undefined|true=1|false=2|3),[undefined:滑动|true=直接遮照和滑动消失|false=直接遮照和消失|3=直接遮照和渐渐消失]
			d/date:([500|1000|fast|slow|normal])滑动遮照和消失时间
			c/css:shield_child
		]
	fn=遮照后执行函数
*/
jQuery.fn.extend({
	createShield: function(mode,para,fn){
		if ($("#shieldHandle",this).get(0)!=undefined)return;
		var so=document.createElement("div"),self=this;
		so.id = "shieldHandle";
		so.className =(mode=='p')? "shield_wait" : "shield";
		with(so.style){
			if(para.l!=undefined)left=para.l+"px";
			if(para.t!=undefined)top=para.t+"px";
			width=(para.w==undefined || para.w==0)? (this.css('width')=='auto')? this.get(0).offsetWidth+"px" : this.css('width') : para.w+"px";
			height=(para.h==undefined)? (this.css('height')=='auto')? this.get(0).offsetHeight+"px" : this.css('height') : (para.h==0)? '100%':para.h+"px";
		}
		var so_c=document.createElement("div");
		so_c.className=(para.c==undefined)? "shield_child":para.c;
		with(so_c.style){
			width=so.style.width;
			height=so.style.height;
		}
		$(so).append(so_c);
		this.append(so);
		if(para.a==true)$("select[name!='no_hide']").hide();
		if(para.m==3 && para.d==undefined || para.d==0)para.d='fast';
		if(para.d==undefined || para.d==0)para.d=500;
		if(para.m==undefined){
			var tmp=$.toJSON({id:self[0].id,action:para.a,mode:0,date:para.d});
			$(so).slideDown(para.d,function(){if(/function/i.test(fn+""))fn.apply(self,[tmp])});
		}
		else{
			$(so).show();
			var tmp_mode=(para.m===true)? 1:(para.m===false)? 2:para.m;
			var tmp=$.toJSON({id:self[0].id,action:para.a,mode:tmp_mode,date:para.d});
			if(/function/i.test(fn+""))fn.apply(self,[tmp]);
		}
	}
});
function removeShield(args,fun){
	args=$.parseJSON(args);
	switch(args.mode){
		case 0:
		case 1:
			delayExec(function(){
				$("#shieldHandle",$.id(args.id)).slideUp(parseInt(args.date),function(){
					$(this).remove();
					if(args.action)$("select[name!='no_hide']").show();
					if(fun!=undefined)fun.apply();
				});
			},50);
			break;
		case 2:
			$("#shieldHandle",$.id(args.id)).remove();
			if(args.action)$("select[name!='no_hide']").show();
			if(fun!=undefined)fun.apply();
			break;
		case 3:
			delayExec(function(){
				$("#shieldHandle",$.id(args.id)).fadeOut(args.date,function(){
					$(this).remove();
					if(args.action)$("select[name!='no_hide']").show();
					if(fun!=undefined)fun.apply();
				});
			},50);
			break;
	}
}
function amendShield(args){
	args=$.parseJSON(args);
	var tmp=$.id(args.id);
	var height=($(tmp).css('height')=='auto')? tmp.offsetHeight+"px" : $(tmp).css('height');
	if($("#shieldHandle",$.id(args.id)).get(0)!=null && $("#shieldHandle",$.id(args.id)).get(0)!=undefined){
		$("#shieldHandle",$.id(args.id)).children(0).get(0).style.height=height;
		$("#shieldHandle",$.id(args.id))[0].style.height=height;
	}
}

/*==================== 异步提交数据-ajax ====================*/

var ajaxResponseData = null;

/*
	ajax	执行函数
	options 使用,以下是选项：
	type			= post | get
	domain		= www.woyo.com 没有 http 的全域名
	url			= index.php?u=allen 没有 域名 的 地址
	dir 			= 目录名称，多级目录用 index/page 如果在根目录下 请传 false
	page			= 页面名称
	fun			= 函数名称
	args			= ajax参数
	shieldArgs	= 遮照参数
	callFun		= ajax执行完成后的可执行函数
	callFailFun	= ajax执行发生错误后的可执行函数
	argsEncode	= true | false 通常在跨域时使用，因为跨域时涉及到中文编码问题 true = 编码
*/
function ajaxE(options){
	var re=/.+/;
	
	if(options.blockUI == undefined){
		options.blockUI = 0;
	}
	if(options.type == undefined){
		options.type = 'post';
	}
	if(options.dir == undefined){
		options.dir = 0;
	}
	if(options.page == undefined){
		return alertTip('ajaxE 参数错误： page 不能为空！');
	}
	if(options.fun == undefined){
		options.fun = 0;
	}

  /*
   * 添加同步异步选项 by dong4138 2009-12-16
   */
  if (options.async==undefined) {
    options.async = true;
  }
  /******** end by dong4138 ********/

	if(options.args == undefined){
		options.args = 0;
	} else {
		options.args = $.toJSON(options.args);
		if(options.argsEncode != undefined && options.argsEncode === true){
			options.args = encodeURIComponent(options.args);
		}
	}
	if(options.shieldArgs == undefined){
		options.shieldArgs = 0;
	}
	if(options.callFun == undefined){
		options.callFun = 0;
	}
	if(options.callFailFun == undefined){
		options.callFailfun = 0;
	}
	if(options.domain == undefined){
		options.domain = '/';
	} else {
		options.domain = 'http://'+options.domain+'/';
	}
	if(options.url == undefined){
		options.url = 'ajax.php';
	}

	options.dataType = 'json';
	
	var para = {
		ajax	:1,
		dir		:options.dir,
		page	:options.page,
		fun		:options.fun,
		args	:options.args
	}

	var url=options.domain+options.url;

	var ajaxDisp = function(key,val){
		switch(key){
			case 'innerhtml':
				$('#'+val[1]).html(val[2]);
				if(options.shieldArgs != 0)amendShield(options.shieldArgs);
				break;
			case 'alert':
				alertTip(val[1]);
				break;
			case 'append':
				$(val[2]).appendTo($.id(val[1]));
				break;
			case 'prepend':
				$(val[2]).prependTo($.id(val[1]));
				break;
			case 'appendb':
				$(val[2]).insertBefore($("#"+val[1]).children().get(0));
				break;
			case 'url':
				(val[1] == undefined || val[1] == 0)? window.location.reload(false) : window.location.replace(val[1]);
				break;
			case 'exec':
				eval(val[1]);
				break;
		}
	}

	var success = function(data){
		$.unblockUI();
		try{
			//没有数据返回时
			if(data!==0){
				var key=null;
				for(key in data){
					ajaxDisp(data[key][0],data[key]);
				}
			} else {
				if(options.shieldArgs != 0)removeShield(options.shieldArgs);
			}
			delayExec(function(){
				clearBlurA();
				if(options.shieldArgs != 0){
					removeShield(options.shieldArgs);
				}
				if(options.callFun != 0){
					if(typeof options.callFun == 'function'){
						options.callFun.apply(this);
					} else if(options.callFun != undefined) {
						eval(options.callFun);
					}
				}
			},500);
		}
		catch(exception){
			//alert(exception.message);
			if(options.shieldArgs != 0){
				removeShield(options.shieldArgs);
			}
			if(options.callFailFun != 0){
				if(typeof options.callFailFun == 'function'){
					options.callFailFun.apply(this);
				} else if(options.callFailFun != undefined) {
					eval(options.callFailFun);
				}
			}
		}
	}


	//解决跨域
	if(options.domain != '/'){
		para = "?ajax=1&dir="+para.dir+"&page="+para.page+"&fun="+para.fun+"&args="+para.args;
		$.getScript(url+para,function(){
			if(ajaxResponseData != null){
				success(ajaxResponseData);
			}
			ajaxResponseData = null;
		});
	} else {
		$.ajax({
			type	: options.type,
			url		: url,
			data	: para,
			dataType: options.dataType,
			async: options.async,
			success	: function(data){
				$.unblockUI();
				success(data);
			},
			error	: function(event, XMLHttpRequest, ajaxOptions, thrownError){
				$.unblockUI();
				//alertTip("服务器请求处理失败 或 服务器端出现错误！");
				if(options.callFailFun != 0){
					if(typeof options.callFailFun == 'function'){
						options.callFailFun.apply(this);
					} else if(options.callFailFun != undefined) {
						eval(options.callFailFun);
					}
				}
			}
		});
	}
}

/*==================== 提示对话框-dialog ====================*/

function popUp(tName){
	this._name = tName;
	this.str = '<table class="pop_dialog_table"><tr><td class="pop_top_left">&nbsp;</td><td class="pop_border">&nbsp;</td><td class="pop_top_right">&nbsp;</td></tr><tr><td class="pop_border" >&nbsp;</td><td><div id="popUpConId" style="width:300px;"></div></td><td class="pop_border">&nbsp;</td></tr><tr><td class="pop_bottom_left">&nbsp;</td><td class="pop_border">&nbsp;</td><td class="pop_bottom_right">&nbsp;</td></tr></table>';
	this.doc = null;
	this.isCreate = {};
	this.obj = {};
	this.conObj = {};
	this.did = {};
	this.time = {};
	this.tipTime = null;
	this.nowUseObj = null;
	this.afun = null;
}

popUp.prototype = {
	getConId: function(nid){
		return this.did[nid];
	},
	getFrmId: function(nid){
		return this.obj[nid];
	},
	create : function(nid){
		if(this.isCreate[nid] === undefined){
			this.doc =jQuery.doc();
			var dObj = document.createElement('DIV');
			dObj.id = nid+'_popUpObjId';
			dObj.className = 'pop_main_box';
			dObj.innerHTML = this.str;
			$(dObj).appendTo(document.body);
			this.obj[nid] = dObj.id;
			this.did[nid] = nid+'_popUpConId';
			$('#popUpConId',$(dObj)).attr('id',this.did[nid]);
			this.conObj[nid] = $('#'+this.did[nid],$(dObj)).get(0);
			this.isCreate[nid] = true;
			return true;
		}
		return false;
	},
	tip : function(msg, options){
		var nid = 'g_tip_9999';
		this.create(nid);
		if(options == undefined) options = {};
		if(options['title'] == undefined){
			options['title'] = '温馨提示';
		}
    		if(options['before'] !== undefined && typeof options['before']=="function"){
			options['before'].apply(this);
		}
		if(options['after'] !== undefined && typeof options['after']=="function"){
			this.afun = options['after'];
		}
   

		//this.conObj[nid].innerHTML = '<div class="pop_container"><h2><strong>'+options['title']+'</strong><a href="#" class="pop_close" onclick="popObj.close(\''+nid+'\');return false;">&nbsp;</a></h2><div class="pop_con">'+msg+'</div></div>';
		if(msg == '礼物发送成功')
		{
			this.conObj[nid].innerHTML = '<div class="pop_container"><div class="pop_title-nav"><h2>'+options['title']+'</h2><a title="关闭" class="pop_close" href="##" onclick="popObj.close(\''+nid+'\'); return false;"> </a></div><div class="pop_content after" style="padding:15px;">'+msg+'&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://gift.woyo.com/giftlist.php"><font color="#3980F4">继续赠送>></font></a>&nbsp;&nbsp;<a href="http://pay.woyo.com/"><font color="#3980F4">充值woyo币>></font></a></div></div>';
			this.center(nid);
		} else {
			this.conObj[nid].innerHTML = '<div class="pop_container"><div class="pop_title-nav"><h2>'+options['title']+'</h2><a title="关闭" class="pop_close" href="##" onclick="popObj.close(\''+nid+'\'); return false;"> </a></div><div class="pop_content after" style="padding:15px;">'+msg+'</div></div>';
			this.center(nid);
		}
		if(options['w'] != undefined && !isNaN(parseInt(options['w']))){
			$('#'+this.did[nid]).css('width',options['w']+'px');
		}
		if(this.tipTime != null){
			window.clearInterval(this.tipTime);
			this.tipTime = null;
		}
		var self = this;
		this.hideSelect();
		if(options['time'] == undefined) options['time'] = 3000;
		if(isNaN(parseInt(options['time']))) options['time'] = 3000;
		if(msg == '礼物发送成功')
		{
			options['time'] = 100000;
		}
		this.tipTime = window.setInterval(function(){
			popObj.close(nid);

		},parseInt(options['time']));
	},
	fun : function(callback, nid, mode, callBeforeFun, callAfterFun) {
		popObj.close('g_tip_9999');
		mode = parseInt(mode);
		if(mode === 1){ // 强制模式，强制刷新
			this.clear(nid);
		}
		var flag = this.create(nid);
		if(this.doc.clientHeight > this.doc.scrollHeight){
			this.createCover({height:this.doc.clientHeight});
		} else {
			this.createCover({height:this.doc.scrollHeight});
		}
		var self = this;
		this.nowUseObj = $('#'+this.obj[nid]);
		
		if(flag){
			this.conObj[nid].innerHTML = '<div id="'+nid+'_popUpLoadTipId" style="width:100%;height:100%;margin:0 auto;line-height:50px;text-align:center;">加载中...</div>';
			this.center(nid);
			this.time[nid] = window.setInterval(function(){
				if($.id(nid+"_popUpLoadTipId") == null){
					window.clearInterval(self.time[nid]);
					self.time[nid] = null;
					if(undefined !== callBeforeFun && null !== callBeforeFun && true === $.isFunction(callBeforeFun)){
						callBeforeFun.apply(this);
						delayExec(function(){
							if(mode === 2 || mode === 3 || mode === 4){
								self.display(nid, function (){
									if(undefined !== callAfterFun && null !== callAfterFun && true === $.isFunction(callAfterFun)){
										callAfterFun.apply(this);
									}
								});
							} else {
								self.move(nid, function (){
									if(undefined !== callAfterFun && null !== callAfterFun && true === $.isFunction(callAfterFun)){
										callAfterFun.apply(this);
									}
								});
							}
						},100);
					} else {
						if(mode === 2 || mode === 3 || mode === 4){
							self.display(nid, function (){
								if(undefined !== callAfterFun && null !== callAfterFun && true === $.isFunction(callAfterFun)){
									callAfterFun.apply(this);
								}
							});
						} else {
							self.move(nid, function (){
								if(undefined !== callAfterFun && null !== callAfterFun && true === $.isFunction(callAfterFun)){
									callAfterFun.apply(this);
								}
							});
						}
					}
				}
			},13);
			var con = callback.apply(this,[this.did[nid]]);
			if(con != undefined){
				$('#'+this.did[nid]).html(con);
			}
		} else {
			this.center(nid);
			$('#'+this.obj[nid]).show();
		}
		rfwObj.add('popup', function(){
			if(self.doc.clientHeight > self.doc.scrollHeight){
				self.createCover({height:self.doc.clientHeight});
			} else {
				self.createCover({height:self.doc.scrollHeight});
			}
		});
	},
	center : function(nid){
		$('#'+this.obj[nid]).show();
		with($.id(this.obj[nid]).style){
			left=((this.doc.clientWidth-$.id(this.obj[nid]).offsetWidth)/2)+"px";
			top=(this.doc.clientHeight/2-$.id(this.obj[nid]).offsetHeight/2)+this.doc.scrollTop+"px";
		}
	},
	getLTWH:function(nid){
		var childObj = $($(this.conObj[nid]).children(0));
		var h = childObj.outerHeight();
		var th = $('#'+this.obj[nid]).outerHeight();
		var w = childObj.outerWidth();
		var l = ((this.doc.clientWidth-w)/2);
		if(th < h)th = h;
		var t = (this.doc.clientHeight/2-th/2)+this.doc.scrollTop;
		if(t < 0) t = 45;
		return {w:w, h:h, l:l, t:t};
	},
	display : function(nid, callback){
		var whlt = this.getLTWH(nid);
		with($.id(this.obj[nid]).style){
			left = whlt.l+'px';
			top = whlt.t+'px';
		}
		with(this.conObj[nid].style){
			width = whlt.w+'px';
			height= whlt.h+'px';
		}
		
		/*
		var self = this;
		//回调函数中动态调整高度 added by yuyii 09/12/14
		$($(this.conObj[nid]).children(0)).show(function(){
			$(self.conObj[nid]).get(0).style.height = "auto";
			$.id(self.obj[nid]).style.height = "auto";
		});
		*/
		$($(this.conObj[nid]).children(0)).show();
		if(undefined !== callback && true === $.isFunction(callback)){
			callback.apply(this);
		}
	},
	move : function(nid, callback){
		var whlt = this.getLTWH(nid);
		var self = this;
		$('#'+this.obj[nid]).animate({ left : whlt.l}, "normal");
		$(this.conObj[nid]).animate({ width : whlt.w}, "normal");
		$('#'+this.obj[nid]).animate({ top : whlt.t}, "normal");
		$(this.conObj[nid]).animate({ height : whlt.h}, "normal");
        delayExec(function() {
            $($(self.conObj[nid]).children(0)).fadeIn('normal', function(){
				if(undefined !== callback && true === $.isFunction(callback)){
					callback.apply(this);
				}
			});
        },500);
		/*
			//动态调整高度 added by yuyii 09/12/14
			setTimeout(function(){
				$(self.conObj[nid]).get(0).style.height = "auto";
				$.id(self.obj[nid]).style.height = "auto";
			},1000);
		*/

	},
    execCallback: function(callback, nid, time){
        var self = this;
        if(time == undefined)time = 500;
        var fun = function() {
            if(callback!=undefined){
                if(typeof callback == 'function'){
                    callback.apply(self,[nid]);
                } else {
                    eval(callback);
                }
            }
        }
        if(time == 0){
            fun();
        } else {
            delayExec(fun, time);
        }
    },
    change:function(nid, execMode,callback,effect){
        if(execMode == 'before'){
			if(callback != undefined && callback != ''){
				this.execCallback(callback, nid, 0);
			}
        }

        this.conObj[nid].style.height = 'auto';
        var whlt = this.getLTWH(nid);
		if(effect == undefined){
			//yuyii on 2010-1-14 加动画会导致好友框伸缩
			/*
			$('#'+this.obj[nid]).animate({ left : whlt.l}, "normal");
			$(this.conObj[nid]).animate({ width : whlt.w}, "normal");
			$('#'+this.obj[nid]).animate({ top : whlt.t}, "normal");
			$(this.conObj[nid]).animate({ height : whlt.h}, "normal");
			*/
		} else {
			$.id(this.obj[nid]).style.left = whlt.l+'px';
			$.id(this.obj[nid]).style.top = whlt.t+'px';
			this.conObj[nid].style.width = whlt.w+'px';
			this.conObj[nid].style.height = whlt.h+'px';
		}
		
        if(execMode == 'after'){
			if(callback != undefined && callback != ''){
				this.execCallback(callback, nid);
			}
        }
    },
	changeMove:function(nid, w, h, callback){
		var nowLeft = ((this.doc.clientWidth-w)/2);
		var nowTop = (this.doc.clientHeight/2-h/2)+this.doc.scrollTop;
		if(nowTop < 0) nowTop = 45;
		$('#'+this.obj[nid]).animate({ left : nowLeft}, "normal");
		$('#'+this.obj[nid]).animate({ top : nowTop}, "normal");
        this.execCallback(callback, nid);
	},
	changeResize:function(nid, w, h, callback){
		var self = this;
		if(w != undefined && w != 0) {
			$(this.conObj[nid]).animate({ width : w}, "normal");
		}
		if(h != undefined && h != 0) {
			$(this.conObj[nid]).animate({ height : h}, "normal");
		}
        this.execCallback(callback, nid);
	},
	createCover: function(options){
		if ($.id('popUpCoverHandleId') == null){
			var shieldobj=document.createElement("div");
			shieldobj.id = "popUpCoverHandleId";
			shieldobj.className =(options['css']==undefined)? "cover":css;
			if(options['width'] != undefined && options['width'] > 0){
				shieldobj.style.width = options['width']+'px';
			}
			if(options['height'] != undefined && options['height'] > 0){
				shieldobj.style.height = options['height']+'px';
			}
			$(shieldobj).appendTo(document.body);
		} else {
			var shieldobj = $.id("popUpCoverHandleId");
			if(options['width'] != undefined && options['width'] > 0){
				shieldobj.style.width = options['width']+'px';
			}
			if(options['height'] != undefined && options['height'] > 0){
				shieldobj.style.height = options['height']+'px';
			}
			$(shieldobj).show();
		}
		this.hideSelect();
	},
	showSelect : function(objid){
		if(objid == undefined){
			$('select').each(function(){
			this.style.visibility = 'visible';
			});
		} else {
			if(typeof objid == 'object'){
				for(var t in objid){
					$('#'+objid[t]).css('visibility','visible');
				}
			} else {
				$('#'+objid).css('visibility','visible');
			}
		}
	},
	hideSelect : function(){
		$("select[name!='no_hide']").each(function(){
			this.style.visibility = 'hidden';
		});
	},
	close : function(nid){
		if(nid === undefined || nid === true){
			rfwObj.del('popup');
			if(this.nowUseObj != null){
				if(nid === true){
					var tmpid = this.nowUseObj.get(0).id;
					tmpid = tmpid.split('_');
					this.clear(tmpid[0]);
				} else {
					this.nowUseObj.hide();
				}
				this.nowUseObj = null;
			}
			
			this.showSelect();
		} else {
			var self = this;
			if('g_tip_9999' == nid){
				window.clearInterval(this.tipTime);
				this.tipTime = null;
			}
			this.clear(nid);
			if(this.nowUseObj == null){
				this.showSelect();
			}
			if(self.afun !== null && self !== undefined){
				self.afun.apply(self);
			}
		   
		}
		if(0 === $('.pop_main_box').length){
			$('#popUpCoverHandleId').hide();
			rfwObj.del('popup');
		} else {
			$('.pop_main_box').each(function(){
				if($.id('popUpCoverHandleId') != null && this.id !== 'g_tip_9999_popUpObjId' && $(this).css('display') != 'block'){
					$('#popUpCoverHandleId').hide();
					rfwObj.del('popup');
				}
			});
		}
		
	},
	clear : function(nid){
		if(this.obj[nid] != undefined){
			$('#'+this.obj[nid]).remove();
			delete this.isCreate[nid];
			delete this.conObj[nid];
			delete this.did[nid];
			delete this.time[nid];
			delete this.obj[nid];
		}
	}
}

var popObj = new popUp('myWoyoPopUp');

function alertTip(msg, options){
  popObj.tip(msg, options);
}

function alertCommonTip(msg, options){
	popObj.tip(msg, options);
}

/*
	弹出层
	callback = 函数
	idPrefix = ID
	mode	 = 使用模式 undefined | 0 = 正常 1 = 正常+强制刷新 2 = 直接弹出 3 = 直接弹出+强制刷新
*/
function alertFun(callback, idPrefix, mode, callBeforeFun, callAfterFun){
	popObj.fun(callback, idPrefix, mode, callBeforeFun, callAfterFun);
}

//--------------------------------COOKIE--------------------------------------------------------

function setCookie(name,value,expire,domain,issecure){
		if(domain==undefined || domain==null || domain=="")domain=".woyo.com";
		var secure=(issecure==undefined || issecure==null || issecure=="")? true : false;
		if(expire!=undefined && expire!=null && expire!=""){
			var date = new Date ();
			if(expire<=0)date.setTime(date.getTime()-(1*1000*3600*24));
			else date.setTime(date.getTime()+(expire*1000*3600*24));
			expire=";expires="+date.toGMTString();
		}
		else expire="";
		document.cookie=name+"="+escape(value)+expire+";path=/;domain="+domain+";"+secure;

}

function getCookie(name,mode){
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null) {
		switch(mode){
			case 1:
				return unescape(decodeURIComponent(arr[2]));
				break;
			default:
				return unescape(arr[2]);
				break;
		}
	}
	return "";
}

/*==================== 音乐试听-audition ====================*/

function musicTry(obj,url){
	var img=obj.firstChild;
	var imgsrc=img.src
	if(imgsrc.indexOf("music_off.gif")>=0){
		$("[@name='icon_music_try']").each(function(){
			this.src="http://image.woyo.com/m/image/music_off.gif";
		});
		img.src="http://image.woyo.com/m/image/music_on.gif";
		var emb=$.id('playbmusic');
		if(emb!=null)$(emb).remove();
		document.body.innerHTML+='<div id="playmobj"><object id="playbmusic" width="0" height="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param name="url" value="'+url+'" /><embed id="playbmusic" width="0" height="0" type="application/x-mplayer2" src="'+url+'"></embed></object></div>';
	}
	else{
		img.src="http://image.woyo.com/m/image/music_off.gif";
		var emb=$.id('playbmusic');
		if($.browser.msie) try{emb.stop();}catch(e){emb.url='';}
		if(emb!=null){
			$('#playmobj').empty();
			$('#playmobj').remove();
		}
	}
}

/*==================== 上传前的提示-upload ====================*/

//提示
function TempTransfer(){
	fireUp();
	//myWoyoMsgBoxO.open("亲爱的WOYO用户：<br/>请在上传内容的同时严格遵守《互联网视听节目服务管理规定》和《互联网著作权行政保护办法》，遵守著作权法律、行政法规的规定，尊重著作权人的合法权益。<br/>如上传含有以下内容之一的文件，WOYO将采取封闭用户名并追究法律责任的行动\n（一）反对宪法确定的基本原则的；<br/>\t（二）危害国家统一、主权和领土完整的；<br/>\t（三）泄露国家秘密、危害国家安全或者损害国家荣誉和利益的；<br/>\t（四）煽动民族仇恨、民族歧视，破坏民族团结，或者侵害民族风俗、习惯的；<br/>\t（五）宣扬邪教、迷信的；\n\t（六）扰乱社会秩序，破坏社会稳定的；<br/>\t（七）诱导未成年人违法犯罪和渲染暴力、色情、赌博、恐怖活动的；<br/>\t（八）侮辱或者诽谤他人，侵害公民个人隐私等他人合法权益的；<br/>\t（九）危害社会公德，损害民族优秀文化传统的；<br/>\t（十）有关法律、行政法规和国家规定禁止的其他内容。<br/>如上传时政类视听新闻节目时，务必是地（市）级以上广播电台、电视台制作、播出的节目和中央新闻单位网站登载的时政类视听新闻节目。用户应对个人上传的视频、音乐、图片负全部法律责任。",4,'fireUp$$'+gWeb['my_up_op']+'',0);
}

//flash版本错误提示
function TempTransferError(){
	myWoyoMsgBoxO.open('如果想正常上传内容，请您使用"Flash Player 9.0"，下载请点击[确定]按钮。',3,['flashPlayerDownload'],0);
}

//flash播放器下载
function flashPlayerDownload() {
	window.location.href='http://www.woyo.com/download/Adobe.zip';
}

//确定提示后的调用flash操作
function fireUp(chn) {
	if(chn!=undefined && chn!="undefined"){
		$.id("fm_"+chn+"_upload").TempTransfer();
	}
	else $.id("fm_upload").TempTransfer();
}

function debug(o,mode,action) {
	var str='',s='',s1='';
	switch(mode){
		case 1:
			for(s in o){
				str+="   "+s+"="+o[s];
			}
			break;
		case 2:
			for(s in o){
				str+="   "+s+"=";
				if(typeof o[s] == 'object'){
					for(s1 in o[s]){
						str+=" "+s1+"="+o[s][s1];
					}
				} else {
					str+= o[s];
				}
			}
			break;
		case 3:
			for(s in o){
				str+="   "+s;
			}
			break;
	}
	if(str == '')str = o;
	switch(action){
		case 'i':
		case 'ia':
		case 'iar':
			var obj = $.id('debugs');
			if(obj == null) obj = document.body;
			obj.innerHTML = (action == 'i')? str:(action == 'ia')? obj.innerHTML+str:obj.innerHTML+"<br/>"+str;
			break;
		default:
			alert(str);
			break;
	}
}


//------------------------------------这个用来看控制头部的弹出层  start
var hideSetTimeoutProcess = null;
function hideSetPop (status) {
	var divid = 'hideSet';
	if (status == 'block') {
		if(hideSetTimeoutProcess != null) clearTimeout(hideSetTimeoutProcess);
		$.id(divid).style.display = 'block';
	}
	if (status == 'none') {
		hideSetTimeoutProcess = setTimeout("$.id('"+divid+"').style.display = 'none';", 200);
	}
}
var searchSortTimeoutProcess = null;
function searchSortPop (status) {
	var divid = 'searchSort';
	if (status == 'block') {
		if(searchSortTimeoutProcess != null) clearTimeout(searchSortTimeoutProcess);
		$.id(divid).style.display = 'block';
	}
	if (status == 'none') {
		searchSortTimeoutProcess = setTimeout("$.id('"+divid+"').style.display = 'none';", 200);
	}
}
//------------------------------------这个用来看控制头部的弹出层  end
//------------------------------------这个用来看控制头部的搜索建议 start
function searchSuggest (e,value) {
	var e = e || window.event;
	if(e.keyCode!=38 && e.keyCode!=40) {
		if(e.keyCode==13)
		{
			$('#searchform').submit();
		}else{
			//这里需要判断下，要不服务器会挂
			ajaxE({domain:'search.woyo.com',type:'get',page:'searchSuggest',fun:'searchSuggestFun','argsEncode':true,args:{value:value}});
		}
	}

}

function searchSuggestPop () {
	$.id('autoWords').style.display='block';
}
$.getScript("http://image.woyo.com/js/common/jquery.hotkeys.js");
function keyUpDown(){
	$("#prevTrIndex").val("-1");//默认-1
	var trSize = $("#autoWords li").size();

	function clickTr(currTrIndex){
		var prevTrIndex = $("#prevTrIndex").val();
		if (currTrIndex > -1){
			$("#tr_" + currTrIndex).addClass("hover");
		}
		$("#tr_" + prevTrIndex).removeClass("hover");
		$("#prevTrIndex").val(currTrIndex);
	}
	$("#autoWords a").mouseover(function(){//鼠标滑过 
		$(".hover").removeClass("hover");
				$(this).addClass("hover");
				clickTr($(this).attr("index")); 
				$("#prevTrIndex").val($(this).attr("index"));
		
	});
	$("#autoWords li a").each(function(i){ 
		$(this).attr({id:"tr_" + i ,index:i});
	})
	
	$("#autoWords li a").click(function(){
	
		$("#searchText").val($(this).html());

	
	})

	$(document).bind('keydown', 'up', function(evt){
	var prevTrIndex = parseInt($("#prevTrIndex").val());
	if (prevTrIndex == -1 || prevTrIndex == 0){
	clickTr(trSize - 1);
	} else if(prevTrIndex > 0){
	clickTr(prevTrIndex - 1);
	}
	return false;
	})
	;
	$(document).bind('keydown', 'down', function(evt){ //↓
	var prevTrIndex = parseInt($("#prevTrIndex").val());
	if (prevTrIndex == -1 || prevTrIndex == (trSize - 1)){
	clickTr(0);
	} else if (prevTrIndex < (trSize - 1)) {
	clickTr(prevTrIndex + 1);
	}
	return false;
	});

	$(document).bind('keydown', 'return', function(evt){ 
	var prevTrIndex = parseInt($("#prevTrIndex").val());
	$("#searchText").val($("#tr_" + prevTrIndex).html());
	var curLinkId=$("#prevTrIndex").val();
	var openUrl=$("#tr_"+curLinkId).attr("href");
	window.location.href=openUrl;
	return false;
	});
	clickTr($("#prevTrIndex").val());
}
//------------------------------------这个用来看控制头部的搜索建议 end
function doSnsSearch () {
	var url='http://search.woyo.com/result.php?act=base&keyword='+encodeURI($.id('searchText').value);
	window.open(url);
}
function fnSearchKeyDownJelly(e){
	var url='http://search.woyo.com/result.php?act=base&keyword='+encodeURI($.id('searchText').value);
	if(jQuery.browser.msie){
		if(event.keyCode == 13){
			window.location.replace(url);
			return false;
		}
	}else{
		if(e.which == 13){
			window.location.replace(url);
			return false;
		}
	}
	return true;
}

//检查 字符串长度 ，obj有字符串的对象，msg字符串内容，len最大长度
function checkDataLen(obj,msg,len){
	//if($.trim(obj.value).length<=0)return alertTip(msg+"不能为空！");
	var tmp_value=$.trim(obj.value);
	var chineseR=/[\u0391-\uFFE5]/g;
	var re=/[\u4E00-\u9FA5\uF900-\uFA2D]+$/;
	var tmp_len=tmp_value.replace(chineseR,"***").length;
	if(tmp_len>len){
		var tmp=tmp_value;
		for(var i=tmp_value.length;i>0;i--){
			if(re.test(tmp.substr(i-1,1)))tmp_len-=3;
			else tmp_len--;
			tmp_value=tmp_value.substr(0,i-1);
			if(tmp_len<=len)break;
		}
		obj.value=tmp_value;
		alertTip(msg+"长度超过了最大限制("+(Math.round(len/3))+"个中文，"+len+"个英文)，我们将自动截取！");
		return false;
	}
	return true;
}

//根据给定的key,获取地址栏的指定querystring
//added by YuYii 09/10/14
function getQueryString(key) {
    var s = document.location.search;
    if (s == "") return false;
    s = s.substr(1);
    var b = s.split("&");
    var tmp;
    for(var i in b) {
        tmp = b[i].split("=");
        if (tmp[0] == key) {
            return tmp[1];
        }
    }
    return false;
}

//调试函数for webim
function myalert(s) {
    //if (console != undefined)
    //    console.log(s);
}

/**
 	wConfirm 确认框  added by YuYii 09/12/02
 	@param title string 标题
 	@param content string 内容
 	@param callback function 回调函数，绑定确定按钮
 	@param mode 打开方式，同alertFun的参数，默认为3，刷新且直接打开
**/
function wConfirm(title,content,callback,mode) {
	if (content == undefined) content = "";
	if (title == undefined || title == "") {
		title = "是否确定执行该操作";
	}
	if (mode == undefined)	mode = 3;

	alertFun(function(){
		var str ='<div class="pop_container">';
		str +='<div class="pop_title-nav">';
		str +='<h2>' + title + '</h2>';
		str +='<a href="#" class="pop_close" title="关闭" onclick="popObj.close();return false;">&nbsp;</a></div>';
		str +='<div class="pop_content after" style="padding:15px;">';
		str += content;
		str +='</div>';
		str +='<div class="pop_footer"> <a href="javascript:;" class="btnbg button1"><i>确定</i></a> &nbsp; <a href="#" class="btnbg button4" onclick="popObj.close();return false;"><i>取消</i></a> </div>';
		str +=' </div>';
		return str;
		},"wConfirm_id",mode
	);
	
	if (typeof callback == "function")
		$("#wConfirm_id_popUpConId .pop_footer a.button1").one("click",callback);
	$("#wConfirm_id_popUpConId .pop_footer a.button1").bind("click",function(){popObj.close()});
}


/*==================== 网站提示-tip ====================*/

function libTips(parent){
	if($('.i-item').length==0){	//增加道具标签
		$('.i-gift').parents('li').after('<li><a href="http://item.woyo.com/item_list.php"><span class="i i-item"></span>道具</a></li>');
	}
	var _b=null;
	if((_b=$.id('tipsBox'))==null){
		$("<div id='tipsBox' class='tips'></div>").appendTo(document.body);
		_b=$.id('tipsBox');
	}
	if(parent==undefined)parent=$(document.body);
	$('*[title]',parent).each(function(){
		var val=this.getAttribute('title'),tip=this;		
		//给<做转义，解决部分因<引起的不显示问题
		//val = val.replace(/</g, "&#60;");
		if (typeof val == "object") return;
		this.setAttribute('title','');
		if(val!="" && val!=null){
			$(tip).bind("mouseover",function(){
				_b.innerHTML='<span style="font-size: 11px;color: #333333;">'+val+'</span>';
				_b.style.visibility = "visible";
				$(tip).bind('mousemove',function(e){
					with(_b.style){
						left=$.pointerX(e)+"px";
						top=($.pointerY(e)+20)+"px";
					}
				});
			});
			$(tip).bind('mouseout',function(){_b.style.visibility="hidden"});
			$(tip).bind('mousedown',function(){_b.style.visibility="hidden"});
		}
	});
}
addLoadExec("libTips();");


/*==================blockUI=================*/
(function($) {

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
	alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
	return;
}

$.fn._fadeIn = $.fn.fadeIn;


var mode = document.documentMode || 0;
var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;

// global $ methods for blocking/unblocking the entire page
$.blockUI   = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
$.growlUI = function(title, message, timeout, onClose) {
	var $m = $('<div class="growlUI"></div>');
	if (title) $m.append('<h1>'+title+'</h1>');
	if (message) $m.append('<h2>'+message+'</h2>');
	if (timeout == undefined) timeout = 3000;
	$.blockUI({
		message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
		timeout: timeout, showOverlay: false,
		onUnblock: onClose, 
		css: $.blockUI.defaults.growlCSS
	});
};

// plugin method for blocking element content
$.fn.block = function(opts) {
	return this.unblock({ fadeOut: 0 }).each(function() {
		if ($.css(this,'position') == 'static')
			this.style.position = 'relative';
		if ($.browser.msie)
			this.style.zoom = 1; // force 'hasLayout'
		install(this, opts);
	});
};

// plugin method for unblocking element content
$.fn.unblock = function(opts) {
	return this.each(function() {
		remove(this, opts);
	});
};

$.blockUI.version = 2.26; // 2nd generation blocking at no extra cost!

// override these in your code to change the default behavior and style
$.blockUI.defaults = {
	message:  '',
	title: null,
	draggable: true, 
	theme: false,
	css: {
		padding:	0,
		margin:		0,
		width:		'30%',
		top:		'40%',
		left:		'35%',
		cursor:		'wait'
	},
	themedCSS: {
		width:	'30%',
		top:	'40%',
		left:	'35%'
	},
	overlayCSS:  {
		backgroundColor: '#000',
		opacity:	  	 0,
		cursor:		  	 'wait'
	},
	growlCSS: {
		width:  	'350px',
		top:		'10px',
		left:   	'',
		right:  	'10px',
		border: 	'none',
		padding:	'5px',
		opacity:	0,
		cursor: 	'default',
		color:		'#fff',
		backgroundColor: '#ccc',
		'-webkit-border-radius': '10px',
		'-moz-border-radius':	 '10px'
	},
	
	// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
	// (hat tip to Jorge H. N. de Vasconcelos)
	iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',

	// force usage of iframe in non-IE browsers (handy for blocking applets)
	forceIframe: false,

	// z-index for the blocking overlay
	baseZ: 1000,

	// set these to true to have the message automatically centered
	centerX: true, // <-- only effects element blocking (page block controlled via css above)
	centerY: true,

	// allow body element to be stetched in ie6; this makes blocking look better
	// on "short" pages.  disable if you wish to prevent changes to the body height
	allowBodyStretch: true,

	// enable if you want key and mouse events to be disabled for content that is blocked
	bindEvents: true,

	// be default blockUI will supress tab navigation from leaving blocking content
	// (if bindEvents is true)
	constrainTabKey: true,

	// fadeIn time in millis; set to 0 to disable fadeIn on block
	fadeIn:  200,

	// fadeOut time in millis; set to 0 to disable fadeOut on unblock
	fadeOut:  400,

	// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
	timeout: 0,

	// disable if you don't want to show the overlay
	showOverlay: true,

	// if true, focus will be placed in the first available input field when
	// page blocking
	focusInput: true,

	// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
	applyPlatformOpacityRules: true,

	// callback method invoked when unblocking has completed; the callback is
	// passed the element that has been unblocked (which is the window object for page
	// blocks) and the options that were passed to the unblock call:
	//	 onUnblock(element, options)
	onUnblock: null,

	// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
	quirksmodeOffsetHack: 4
};

// private data and functions follow...

var pageBlock = null;
var pageBlockEls = [];

function install(el, opts) {
	var full = (el == window);
	var msg = opts && opts.message !== undefined ? opts.message : undefined;
	opts = $.extend({}, $.blockUI.defaults, opts || {});
	opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
	var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
	var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
	msg = msg === undefined ? opts.message : msg;

	// remove the current block (if there is one)
	if (full && pageBlock)
		remove(window, {fadeOut:0});

	// if an existing element is being used as the blocking content then we capture
	// its current place in the DOM (and current display style) so we can restore
	// it when we unblock
	if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
		var node = msg.jquery ? msg[0] : msg;
		var data = {};
		$(el).data('blockUI.history', data);
		data.el = node;
		data.parent = node.parentNode;
		data.display = node.style.display;
		data.position = node.style.position;
		if (data.parent)
			data.parent.removeChild(node);
	}

	var z = opts.baseZ;

	// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
	// layer1 is the iframe layer which is used to supress bleed through of underlying content
	// layer2 is the overlay layer which has opacity and a wait cursor (by default)
	// layer3 is the message content that is displayed while blocking

	var lyr1 = ($.browser.msie || opts.forceIframe) 
		? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
		: $('<div class="blockUI" style="display:none"></div>');
	var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
	
	var lyr3;
	if (opts.theme && full) {
		var s = '<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:fixed">' +
					'<div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
					'<div class="ui-widget-content ui-dialog-content"></div>' +
				'</div>';
		lyr3 = $(s);
	}
	else {
		lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>')
					: $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');
	}						   

	// if we have a message, style it
	if (msg) {
		if (opts.theme) {
			lyr3.css(themedCSS);
			lyr3.addClass('ui-widget-content');
		}
		else 
			lyr3.css(css);
	}

	// style the overlay
	if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
		lyr2.css(opts.overlayCSS);
	lyr2.css('position', full ? 'fixed' : 'absolute');

	// make iframe layer transparent in IE
	if ($.browser.msie || opts.forceIframe)
		lyr1.css('opacity',0.0);

	$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
	
	if (opts.theme && opts.draggable && $.fn.draggable) {
		lyr3.draggable({
			handle: '.ui-dialog-titlebar',
			cancel: 'li'
		});
	}

	// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
	var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
	if (ie6 || expr) {
		// give body 100% height
		if (full && opts.allowBodyStretch && $.boxModel)
			$('html,body').css('height','100%');

		// fix ie6 issue when blocked element has a border width
		if ((ie6 || !$.boxModel) && !full) {
			var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
			var fixT = t ? '(0 - '+t+')' : 0;
			var fixL = l ? '(0 - '+l+')' : 0;
		}

		// simulate fixed position
		$.each([lyr1,lyr2,lyr3], function(i,o) {
			var s = o[0].style;
			s.position = 'absolute';
			if (i < 2) {
				full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
					 : s.setExpression('height','this.parentNode.offsetHeight + "px"');
				full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
					 : s.setExpression('width','this.parentNode.offsetWidth + "px"');
				if (fixL) s.setExpression('left', fixL);
				if (fixT) s.setExpression('top', fixT);
			}
			else if (opts.centerY) {
				if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
				s.marginTop = 0;
			}
			else if (!opts.centerY && full) {
				var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
				var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
				s.setExpression('top',expression);
			}
		});
	}

	// show the message
	if (msg) {
		if (opts.theme)
			lyr3.find('.ui-widget-content').append(msg);
		else
			lyr3.append(msg);
		if (msg.jquery || msg.nodeType)
			$(msg).show();
	}

	if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
		lyr1.show(); // opacity is zero
	if (opts.fadeIn) {
		if (opts.showOverlay)
			lyr2._fadeIn(opts.fadeIn);
		if (msg)
			lyr3.fadeIn(opts.fadeIn);
	}
	else {
		if (opts.showOverlay)
			lyr2.show();
		if (msg)
			lyr3.show();
	}

	// bind key and mouse events
	bind(1, el, opts);

	if (full) {
		pageBlock = lyr3[0];
		pageBlockEls = $(':input:enabled:visible',pageBlock);
		if (opts.focusInput)
			setTimeout(focus, 20);
	}
	else
		center(lyr3[0], opts.centerX, opts.centerY);

	if (opts.timeout) {
		// auto-unblock
		var to = setTimeout(function() {
			full ? $.unblockUI(opts) : $(el).unblock(opts);
		}, opts.timeout);
		$(el).data('blockUI.timeout', to);
	}
};

// remove the block
function remove(el, opts) {
	var full = (el == window);
	var $el = $(el);
	var data = $el.data('blockUI.history');
	var to = $el.data('blockUI.timeout');
	if (to) {
		clearTimeout(to);
		$el.removeData('blockUI.timeout');
	}
	opts = $.extend({}, $.blockUI.defaults, opts || {});
	bind(0, el, opts); // unbind events
	
	var els;
	if (full) // crazy selector to handle odd field errors in ie6/7
		els = $('body').children().filter('.blockUI').add('body > .blockUI');
	else
		els = $('.blockUI', el);

	if (full)
		pageBlock = pageBlockEls = null;

	if (opts.fadeOut) {
		els.fadeOut(opts.fadeOut);
		setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
	}
	else
		reset(els, data, opts, el);
};

// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
	els.each(function(i,o) {
		// remove via DOM calls so we don't lose event handlers
		if (this.parentNode)
			this.parentNode.removeChild(this);
	});

	if (data && data.el) {
		data.el.style.display = data.display;
		data.el.style.position = data.position;
		if (data.parent)
			data.parent.appendChild(data.el);
		$(data.el).removeData('blockUI.history');
	}

	if (typeof opts.onUnblock == 'function')
		opts.onUnblock(el,opts);
};

// bind/unbind the handler
function bind(b, el, opts) {
	var full = el == window, $el = $(el);

	// don't bother unbinding if there is nothing to unbind
	if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
		return;
	if (!full)
		$el.data('blockUI.isBlocked', b);

	// don't bind events when overlay is not in use or if bindEvents is false
	if (!opts.bindEvents || (b && !opts.showOverlay)) 
		return;

	// bind anchors and inputs for mouse and key events
	var events = 'mousedown mouseup keydown keypress';
	b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

// former impl...
//	   var $e = $('a,:input');
//	   b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
};

// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
	// allow tab navigation (conditionally)
	if (e.keyCode && e.keyCode == 9) {
		if (pageBlock && e.data.constrainTabKey) {
			var els = pageBlockEls;
			var fwd = !e.shiftKey && e.target == els[els.length-1];
			var back = e.shiftKey && e.target == els[0];
			if (fwd || back) {
				setTimeout(function(){focus(back)},10);
				return false;
			}
		}
	}
	// allow events within the message content
	if ($(e.target).parents('div.blockMsg').length > 0)
		return true;

	// allow events for content that is not being blocked
	return $(e.target).parents().children().filter('div.blockUI').length == 0;
};

function focus(back) {
	if (!pageBlockEls)
		return;
	var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
	if (e)
		e.focus();
};

function center(el, x, y) {
	var p = el.parentNode, s = el.style;
	var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
	var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
	if (x) s.left = l > 0 ? (l+'px') : '0';
	if (y) s.top  = t > 0 ? (t+'px') : '0';
};

function sz(el, p) {
	return parseInt($.css(el,p))||0;
};

})(jQuery);

//停止注册
//added by yuyii 2010/7/6
function showNotice() {
	var title = "公告";
	var content = "<div style='line-height:19px;text-align:justify;width:490px'><h5 style='font-size:14px;font-weight:700;color:#CC0000;padding-bottom:10px'>尊敬的我友用户：</h5><p style='text-indent:18px'>非常感谢您对我友网的关注与支持，为了更好的服务于您，我友网近期将进行改版，为此我们特别通知：自2010年7月6日起我友网将停止新用户注册，重新开放注册时间请关注本网最新通告。</p></div>";
	//alertTip(content);

	alertFun(function(){
		var str ='<div class="pop_container" style="width:540px;">';
		str +='<div class="pop_title-nav">';
		str +='<h2>' + title + '</h2>';
		str +='<a href="#" class="pop_close" title="关闭" onclick="popObj.close();return false;">&nbsp;</a></div>';
		str +='<div class="pop_content after" style="padding:25px;margin-bottom:0px;width:490px">';
		str += content;
		str +='</div>';
		str +='<div class="pop_footer"> <a href="#" onclick="popObj.close();return false;" class="btnbg button1"><i>确定</i></a> &nbsp;</div>';
		str +=' </div>';
		return str;
		}
	);
	

}