/*
 * @author dashzhao
 * @update 2008.5.30 
 * @javascript base frameWork 1.3
 */
(function(){
	var dashzhao=window.dashzhao={
		extend:function(e, methods) {if(e.type=="textarea"){return false};
		for (property in methods) { 
			e[property] = methods[property];  }
		return e;},
		  getPos: function() {
		var el=this, valueT = 0, valueL = 0;
		do {
			valueT += el.offsetTop  || 0;
			valueL += el.offsetLeft || 0;
			el = el.offsetParent;
		} while (el);
		return [valueL, valueT];
		},
	    Height:function(){return parseInt(this.offsetHeight)||parseInt(this.clientHeight);},
		Width:function(){return parseInt(this.offsetWidth)||parseInt(this.clientWidth);},
	    wrap:function(){this.style.display = (this.getStyle().display != 'none' ? 'none' : 'block' );return this},
		getStyle:function(){return this.currentStyle||document.defaultView.getComputedStyle(this,null)||this.style},
		css: function(val,key){if(key){this.style[val] = key;return this;} else { return this.style[val];}},
		setStyle:function(s){
            var sList = s.split(";");
            for (var i=0,j; j=sList[i]; i++){
                var k = j.split(":");
                this.style[k[0]] = k[1];
            }
            return this;
        },
		hasClassName:function(Name){
			var h = false;
		this.className.split(' ').each(function(s){
			if (s == Name) {h = true}
		});
		return h;
			}, 
		addClass:function(Name){if(!this.hasClassName(this,Name)){this.className+=" "+Name};return this;},
	    removeClass:function(Name){if(this.hasClassName(Name)){var cn=this.className.replace(Name,"").replace(/(^\s*)/g, "");this.className=cn;};return this;},
			//dom; 
		nextElement:function(){
            var n = this;
            for (var i=0,n; n = n.nextSibling; i++){
                if(n.nodeType==1) return n;
            }
            return null;
        },
		previousElement:function(){
            var n = this;
            for (var i=0,n; n = n.previousSibling; i++){
                if(n.nodeType==1)return n;
            }
            return null;
        },
		moveAhead:function(){
            if (this.previousElement()){
                this.parentNode.insertBefore(this,this.previousElement());
            }
            return this;
        },
		moveNext:function(){
            var n = this.nextElement();
            if (n){
                this.parentNode.removeChild(n);
                this.parentNode.insertBefore(n,this);
            }
            return this;
        },
		appendBefore:function(e){this.insertBefore(e,this.firstChild);return this;},
		html: function(v){if(v){this.innerHTML = v;return this;}else{return this}},
		remove:function(){this.parentNode.removeChild(this);},
		empty:function(){while(this.firstChild)this.removeChild( this.firstChild );return this;},
		//html deal;
		stripTags: function(){this.innerHTML=this.innerHTML.replace(/<\/?[^>]+>/gi, '');return this},
		addEventHandler:function (e,fn) {
               if (this.addEventListener) { this.addEventListener(e, fn, false);
                 } else if (this.attachEvent) { this.attachEvent("on" + e, fn);} 
	            else { this["on" + e] = fn;}
				return this
        }
	};

String.prototype.trim=function(type){//"l","r","";
  switch (type)
  {
  case "l": return this.replace(/(^\s*)/g,"");
  case "r": return this.replace(/(\s*$)/g,"");
  default : return this.replace(/(^\s*)|(\s*$)/g, "");
  }
};
Array.prototype.each=function(func){
	for(var i=0,l=this.length;i<l;i++) {func(this[i],i);dashzhao.extend(this[i],dashzhao)};
    };

var $=window.$=function(e){
    var elem = typeof(e)=="string"?document.getElementById(e):e;
    if (!elem){return null}
    else{
		dashzhao.extend(elem,dashzhao);
		if(dashzhao.methods){dashzhao.extend(elem,dashzhao.methods)};
		};
    return elem;
    };
$.c=function(array){var nArray = [];for (var i=0,l=array.length;i<l;i++) nArray.push(array[i]);return nArray;};
$.broswer=function(){var b = navigator.userAgent.toLowerCase();
    if(/webkit/.test(b)){return "safari";}
	if(/opera/.test(b)){return "opera";}
	if(/msie/.test(b) && !/opera/.test(b)){return "msie";}
	if(/mozilla/.test(b) && !/(compatible|webkit)/.test(b)){return "mozilla";} };
$.ajax= {
    xmlPool: [],
	length:0,
    pull: function ()
    {
        for (var i = 0,l=this.xmlPool.length; i <l; i ++)
        {
            if (this.xmlPool[i].readyState == 0 || this.xmlPool[i].readyState == 4)
            {
                return this.xmlPool[i];
            }
        }
        this.xmlPool[this.xmlPool.length] = this.create();
        return this.xmlPool[this.xmlPool.length - 1];
    },
     create: function(){
	return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
},
	request: function (config,data,args){
	  config.timeout=config.timeout||5;
	   var setTime=setTimeout(function(){if(config.ontimeout){config.ontimeout()}},config.timeout*1000);
		if(config.onstart){config.onstart();}//add for ajax request start;
	    config.method=config.method||"GET";
		config.async=config.async||true;
		if(!data){data=null};
        var XMLHttp = this.pull();
        with(XMLHttp)
        {
            try
            {
                open(config.method, config.url, config.async);
                setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
				setRequestHeader('Expires', '-1');
				setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT');
                send(data);
                onreadystatechange = function ()
                { 
                    if (XMLHttp.readyState == 4 && ((XMLHttp.status >= 200&&XMLHttp.status< 300) || XMLHttp.status == 304))
                    {
                     config.oncomplete(XMLHttp,args);XMLHttp=null;clearTimeout(setTime);
					
                    };										
                };
				 
            }
            catch(e)
            {
                alert("数据请求出错:"+e);if(config.error){config.error();};//error;
            };
			
        };
    }
};
$.cookies={
   read : function(n){
        var dc = "; "+document.cookie+"; ";
        var coo = dc.indexOf("; "+n+"=");
        if (coo!=-1){
            var s = dc.substring(coo+n.length+3,dc.length);
            return unescape(s.substring(0, s.indexOf("; ")));
        }else{
            return null;
        }
    },
    set : function(name,value,expires){
        var expDays = expires*24*60*60*1000;
        var expDate = new Date();
        expDate.setTime(expDate.getTime()+expDays);
        var expString = expires ? "; expires="+expDate.toGMTString() : "";
        var pathString = ";path=/";
        document.cookie = name + "=" + escape(value) + expString + pathString;
    },
    del : function(n){
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval=this.get(n);
        if(cval!=null) {document.cookie= n + "="+cval+";expires="+exp.toGMTString()};
    },
	cn_encode:function(str){
		var strRtn=new Array;
　		for(var i=0;i<str.length;i++){
			var code=str.charCodeAt(i);
　　		strRtn.push(code);
　		}
　		return strRtn;
	},
	cn_decode:function(str){
		var strArr;
		var strRtn="";
		strArr=str.split(",");
		try{
			for (var i=0;i<strArr.length;i++)
				strRtn+=String.fromCharCode(strArr[i]);
			}catch(e){
		}
		return strRtn;
	}
};

})();

onready = (function(){
    // create event function stack
    var load_events = [],
        load_timer,
        script,
        done,
        exec,
        old_onload,
        init = function () {
            done = true;

            // kill the timer
            clearInterval(load_timer);

            // execute each function in the stack in the order they were added
            while (exec = load_events.shift())
                exec();

            if (script) script.onreadystatechange = '';
        };

    return function (func) {
        // if the init function was already ran, just run this function now and stop
        if (done) return func();

        if (!load_events[0]) {
            // for Mozilla/Opera9
            if (document.addEventListener)
                document.addEventListener("DOMContentLoaded", init, false);

            // for Internet Explorer
            /*@cc_on @*/
            /*@if (@_win32)
                document.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");
                script = document.getElementById("__ie_onload");
                script.onreadystatechange = function() {
                    if (this.readyState == "complete")
                        init(); // call the onload handler
                };
            /*@end @*/

            // for Safari
            if (/WebKit/i.test(navigator.userAgent)) { // sniff
                load_timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState))
                        init(); // call the onload handler
                }, 10);
            }

            // for other browsers set the window.onload, but also execute the old window.onload
            old_onload = window.onload;
            window.onload = function() {
                init();
                if (old_onload) old_onload();
            };
        }

        load_events.push(func);
    }
})();

formToStr=function(fc) {
		var i,qs="",and="",ev="";
		for(i=0;i<fc.length;i++) {
			e=fc[i]; 
			if (e.name!='') {
				if (e.type=='select-one'&&e.selectedIndex>-1) ev=e.options[e.selectedIndex].value;
				else if (e.type=='checkbox' || e.type=='radio') {
					if (e.checked==false) continue;
					ev=e.value;
				}
				else ev=e.value;
				//ev=escape(ev);
				qs+=and+e.name+'='+ev;
				and="&";
			}
		}
		return qs;
	};

//md5加密
var hex_chr="0123456789abcdef";function rhex(num)
{str="";for(j=0;j<=3;j++)
str+=hex_chr.charAt((num>>(j*8+4))&0x0F)+
hex_chr.charAt((num>>(j*8))&0x0F);return str;}
function str2blks_MD5(str)
{nblk=((str.length+8)>>6)+1;blks=new Array(nblk*16);for(i=0;i<nblk*16;i++)blks[i]=0;for(i=0;i<str.length;i++)
blks[i>>2]|=str.charCodeAt(i)<<((i%4)*8);blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=str.length*8;return blks;}
function add(x,y)
{var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}
function rol(num,cnt)
{return(num<<cnt)|(num>>>(32-cnt));}
function cmn(q,a,b,x,s,t)
{return add(rol(add(add(a,q),add(x,t)),s),b);}
function ff(a,b,c,d,x,s,t)
{return cmn((b&c)|((~b)&d),a,b,x,s,t);}
function gg(a,b,c,d,x,s,t)
{return cmn((b&d)|(c&(~d)),a,b,x,s,t);}
function hh(a,b,c,d,x,s,t)
{return cmn(b^c^d,a,b,x,s,t);}
function ii(a,b,c,d,x,s,t)
{return cmn(c^(b|(~d)),a,b,x,s,t);}
function MD5(str)
{x=str2blks_MD5(str);var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(i=0;i<x.length;i+=16)
{var olda=a;var oldb=b;var oldc=c;var oldd=d;a=ff(a,b,c,d,x[i+0],7,-680876936);d=ff(d,a,b,c,x[i+1],12,-389564586);c=ff(c,d,a,b,x[i+2],17,606105819);b=ff(b,c,d,a,x[i+3],22,-1044525330);a=ff(a,b,c,d,x[i+4],7,-176418897);d=ff(d,a,b,c,x[i+5],12,1200080426);c=ff(c,d,a,b,x[i+6],17,-1473231341);b=ff(b,c,d,a,x[i+7],22,-45705983);a=ff(a,b,c,d,x[i+8],7,1770035416);d=ff(d,a,b,c,x[i+9],12,-1958414417);c=ff(c,d,a,b,x[i+10],17,-42063);b=ff(b,c,d,a,x[i+11],22,-1990404162);a=ff(a,b,c,d,x[i+12],7,1804603682);d=ff(d,a,b,c,x[i+13],12,-40341101);c=ff(c,d,a,b,x[i+14],17,-1502002290);b=ff(b,c,d,a,x[i+15],22,1236535329);a=gg(a,b,c,d,x[i+1],5,-165796510);d=gg(d,a,b,c,x[i+6],9,-1069501632);c=gg(c,d,a,b,x[i+11],14,643717713);b=gg(b,c,d,a,x[i+0],20,-373897302);a=gg(a,b,c,d,x[i+5],5,-701558691);d=gg(d,a,b,c,x[i+10],9,38016083);c=gg(c,d,a,b,x[i+15],14,-660478335);b=gg(b,c,d,a,x[i+4],20,-405537848);a=gg(a,b,c,d,x[i+9],5,568446438);d=gg(d,a,b,c,x[i+14],9,-1019803690);c=gg(c,d,a,b,x[i+3],14,-187363961);b=gg(b,c,d,a,x[i+8],20,1163531501);a=gg(a,b,c,d,x[i+13],5,-1444681467);d=gg(d,a,b,c,x[i+2],9,-51403784);c=gg(c,d,a,b,x[i+7],14,1735328473);b=gg(b,c,d,a,x[i+12],20,-1926607734);a=hh(a,b,c,d,x[i+5],4,-378558);d=hh(d,a,b,c,x[i+8],11,-2022574463);c=hh(c,d,a,b,x[i+11],16,1839030562);b=hh(b,c,d,a,x[i+14],23,-35309556);a=hh(a,b,c,d,x[i+1],4,-1530992060);d=hh(d,a,b,c,x[i+4],11,1272893353);c=hh(c,d,a,b,x[i+7],16,-155497632);b=hh(b,c,d,a,x[i+10],23,-1094730640);a=hh(a,b,c,d,x[i+13],4,681279174);d=hh(d,a,b,c,x[i+0],11,-358537222);c=hh(c,d,a,b,x[i+3],16,-722521979);b=hh(b,c,d,a,x[i+6],23,76029189);a=hh(a,b,c,d,x[i+9],4,-640364487);d=hh(d,a,b,c,x[i+12],11,-421815835);c=hh(c,d,a,b,x[i+15],16,530742520);b=hh(b,c,d,a,x[i+2],23,-995338651);a=ii(a,b,c,d,x[i+0],6,-198630844);d=ii(d,a,b,c,x[i+7],10,1126891415);c=ii(c,d,a,b,x[i+14],15,-1416354905);b=ii(b,c,d,a,x[i+5],21,-57434055);a=ii(a,b,c,d,x[i+12],6,1700485571);d=ii(d,a,b,c,x[i+3],10,-1894986606);c=ii(c,d,a,b,x[i+10],15,-1051523);b=ii(b,c,d,a,x[i+1],21,-2054922799);a=ii(a,b,c,d,x[i+8],6,1873313359);d=ii(d,a,b,c,x[i+15],10,-30611744);c=ii(c,d,a,b,x[i+6],15,-1560198380);b=ii(b,c,d,a,x[i+13],21,1309151649);a=ii(a,b,c,d,x[i+4],6,-145523070);d=ii(d,a,b,c,x[i+11],10,-1120210379);c=ii(c,d,a,b,x[i+2],15,718787259);b=ii(b,c,d,a,x[i+9],21,-343485551);a=add(a,olda);b=add(b,oldb);c=add(c,oldc);d=add(d,oldd);}
return rhex(a)+rhex(b)+rhex(c)+rhex(d);}


function getPath(obj){
	if (obj) {
		if ($.broswer()=="msie") {
			obj.select();
			// IE下取得图片的本地路径
			return document.selection.createRange().text;
		} else if($.broswer()=="mozilla") {
				if (obj.files) {
					// Firefox下取得的是图片的数据
					return obj.files.item(0).getAsDataURL();
				}
				return obj.value;
		}
		return obj.value;
	}
}
//*编辑器函数*//

//显示表情菜单
function showFace(showid, target) {
	var div = $('my_face_bg');
	if(div==null) {
			div = document.createElement('div');
			div.id = 'my_face_bg';
			document.body.appendChild(div);
	}

	div.onclick = function() {
		$(showid+'_menu').style.display = 'none';
		$('my_face_bg').style.display = 'none';
	}
		
	if($(showid + '_menu') != null) {
		$(showid+'_menu').style.display = 'none';
	} else {
		var faceDiv = document.createElement("div");
		faceDiv.id = showid+'_menu';
		faceDiv.className = 'facebox';
		faceDiv.style.position = 'absolute';
		var faceul = document.createElement("ul");
		for(i=1; i<41; i++) {
			var faceli = document.createElement("li");
			faceli.innerHTML = '<img src="'+img_server+'face/'+i+'.gif" onclick="insertFace(\''+showid+'\','+i+', \''+ target +'\')" style="cursor:pointer; position:relative;" />';
			faceul.appendChild(faceli);
		}
		faceDiv.appendChild(faceul);
		document.body.firstChild.appendChild(faceDiv)
	}
	//定位菜单
	var pos=$(showid).getPos();
	$("my_face_bg").wrap();
	$(showid+'_menu').setStyle("display:block;position:absolute;left:"+pos[0]+"px;top:"+(pos[1]+23)+"px;");
}
//插入表情
function insertFace(showid, id, target) { 
	var faceText = '[em:'+id+':]';
	if($(target) != null) {
		insertContent(target, faceText);
	}
	$(showid+'_menu').style.display = 'none';
	$('my_face_bg').style.display = 'none';
}


function insertContent(target,text,movestart, moveend,noselect) {
	var obj = $(target); var movestart=movestart||0;var moveend=moveend||0;
	var selection = document.selection;
	checkFocus(target);
	if(!isUndefined(obj.selectionStart)) {
		var opn = obj.selectionStart + 0;
		obj.value = obj.value.substr(0, obj.selectionStart) + text + obj.value.substr(obj.selectionEnd);
		obj.selectionStart = opn+movestart;
		obj.selectionEnd = opn + strlen(text)-moveend;
		if(movestart==0){obj.selectionStart+=strlen(text);}
	} else if(selection && selection.createRange) {
		var sel = selection.createRange();
		sel.text = text.replace(/\r?\n/g, '\r\n');
		sel.moveStart('character', -strlen(text)+movestart);
		sel.moveEnd('character', -moveend);
		if(movestart!=0&&noselect){sel.select();}
	} else {
		obj.value += text;
	}
}

function textCounter(obj, showid, maxlimit) {
	var len = strLen(obj.value);
	var showobj = $(showid);
	if(len > maxlimit) {
		obj.value = getStrbylen(obj.value, maxlimit);
		showobj.innerHTML = '0';
	} else {
		showobj.innerHTML = maxlimit - len;
	}
	if(maxlimit - len > 0) {
		showobj.parentNode.style.color = "";
	} else {
		showobj.parentNode.style.color = "red";
	}
	
}
function getStrbylen(str, len) {
	var num = 0;
	var strlen = 0;
	var newstr = "";
	var obj_value_arr = str.split("");
	for(var i = 0; i < obj_value_arr.length; i ++) {
		if(i < len && num + byteLength(obj_value_arr[i]) <= len) {
			num += byteLength(obj_value_arr[i]);
			strlen = i + 1;
		}
	}
	if(str.length > strlen) {
		newstr = str.substr(0, strlen);
	} else {
		newstr = str;
	}
	return newstr;
}
function byteLength (sStr) {
	aMatch = sStr.match(/[^\x00-\x80]/g);
	return (sStr.length + (! aMatch ? 0 : aMatch.length));
}
function strLen(str) {
	var charset = document.charset; 
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == "utf-8" ? 3 : 2) : 1;
	}
	return len;
}

function strlen(str) {
	return ($.broswer()=="msie" && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
//Ctrl+Enter 发布
function ctrlEnter(event, btnId, onlyEnter) {
	if(isUndefined(onlyEnter)) onlyEnter = 0;
	if((event.ctrlKey || onlyEnter) && event.keyCode == 13) {
		$(btnId).click();
		return false;
	}
	return true;
}
function checkFocus(target) {
	var obj = $(target);
	if(!obj.hasfocus) {
		obj.focus();
	}
}
function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function pm(to,toname,obj){//短消息
	dashzhao.extend(obj,dashzhao);var pos=obj.getPos();
	$('global_box').setStyle("display:block;left:"+pos[0]+"px;top:"+pos[1]+"px");
	if(userid==0){		
			$('global_box_html').html("抱歉 您还没登录 发不了短信哦");
			setTimeout(function(){
				$('global_box').style.display="none";
			},3000);
	}else if(userid==to){
			$('global_box_html').html("给自己发短信有点无聊哦");
			setTimeout(function(){
				$('global_box').style.display="none";
			},3000);
	}else{
		$('global_box_html').html('<form action="'+siteurl+'cp.php" method="post" onsubmit="return ajaxpm('+to+',\''+toname+'\',this);"><p><a href="###" id="pm_global_face" onclick="showFace(this.id, \'pm_message\');return false;"><img src="'+img_server+'global/facelist.gif" align="absmiddle" /></a></p><p><textarea name="message" id="pm_message" onkeydown="ctrlEnter(event, \'pmsubmit\');"></textarea></p><p><input type="submit" id="pmsubmit" name="pmsubmit" value="发送" class="btn_blue"/></p></form>');
		$('global_box_tit').html('给'+toname+"发送短信息");
		$("pm_message").focus();
	}
}
function ajaxpm(to,toname,form){//提交短消息
		if(form.elements['message'].value!=''){
			$("loading").setStyle("display:block;");
			$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
					if(returns.responseText==1){
						$('global_box_html').html("信息已发送成功");
						$("loading").setStyle("display:none;");
						setTimeout(function(){
							$('global_box').style.display="none";
						},3000);
					}						
			}},"do=message&ac=send&inajax=1&msgto="+toname+"&msgtoid="+to+"&message="+form.elements['message'].value);
		}
	return false;
}
function ajaxdelpm(pmid){
	$("loading").setStyle("display:block;");
	$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
		if(returns.responseText==1){
				$("pm"+pmid).remove();
			}
		$("loading").setStyle("display:none;");
	}},"do=message&ac=del&pmid="+pmid);

}

function ajaxfriend(uid,uname,obj){//添加好友
	dashzhao.extend(obj,dashzhao);var pos=obj.getPos();
	$('global_box').setStyle("display:block;left:"+pos[0]+"px;top:"+pos[1]+"px");
	if(userid==0){		
			$('global_box_html').html("您还没有登录 不能添加好友");
			setTimeout(function(){
							$('global_box').style.display="none";
						},3000);
	}else{
		$('global_box_html').html('<form action="'+siteurl+'cp.php" method="post" onsubmit="return ajaxfriendpost('+uid+',\''+uname+'\',this);"><p><a href="###" id="pm_global_face" onclick="showFace(this.id, \'message\');return false;"><img src="'+img_server+'global/facelist.gif" align="absmiddle" /></a></p><p><textarea name="message" id="message" onkeydown="ctrlEnter(event, \'friendsubmit\');"></textarea></p><p><input type="submit" id="friendsubmit" name="friendsubmit" value="确定" class="btn_blue"/></p></form>');
		$('global_box_tit').html('添加'+uname+"为好友 附言:");
		$("message").focus();
	}
}
function ajaxfriendpost(uid,uname,form){
	$("loading").setStyle("display:block;");
			$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
					if(returns.responseText==1){
						$('global_box_html').html("请求已发送 等待对方确认.");
					}else{
						$('global_box_html').html("你们已经是好友.");
					}
						setTimeout(function(){
							$('global_box').style.display="none";
						},3000);
						$("loading").setStyle("display:none;");
			}},"do=friend&ac=add&inajax=1&friendname="+uname+"&uid="+uid+"&message="+form.elements['message'].value);
	return false;
}
function delfriend(target_uid,target_name){
	if(confirm("确定要解除好友关系吗?")){
		$("loading").setStyle("display:block;");
		$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
			if(returns.responseText==1){
				$('firend_wrap').html('<a href="cp.php?ac=friend&op=add&uid={$userinfo[uid]}&friendname={$userinfo[username]}" id="a_friend_li" onclick="ajaxfriend('+target_uid+',\''+target_name+'\',this,1);return false;">加为好友</a>');
				$("loading").setStyle("display:none;");
			}

		}},"do=friend&ac=del&inajax=1&target_uid="+target_uid+"&target_name="+target_name);
	}
	return false;
}
//举报用户
function ajax_report(uid,type,obj){
	dashzhao.extend(obj,dashzhao);var pos=obj.getPos();
	$('global_box').setStyle("display:block;left:"+pos[0]+"px;top:"+pos[1]+"px");
	if(userid==0){		
			$('global_box_html').html("您还没有登录 不能添加好友");
			setTimeout(function(){
							$('global_box').style.display="none";
						},3000);
	}else{
		$('global_box_html').html('<form action="'+siteurl+'" method="post" onsubmit="return send_report(this);"><input type="hidden" name="do" value="report"><input type="hidden" name="url" value="'+escape(location.href)+'"><input type="hidden" name="target_uid" value="'+uid+'"><p><textarea name="report_con" id="report_con" onkeydown="ctrlEnter(event, \'reportsubmit\');"></textarea></p><p><input type="submit" id="reportsubmit" name="reportsubmit" value="确定" class="btn_blue"/></p></form>');
		$('global_box_tit').html("举报用户 理由:");
		$("report_con").focus();
	}
}
//提交举报
function send_report(form){
	$("loading").setStyle("display:block;");
	$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
		if(returns.responseText==1){
			$('global_box_html').html("感谢您的举报,管理团队会尽快处理,举报属实您将获得系统金币奖励.");
		}else{
			$('global_box_html').html("抱歉 举报失败.");
		}
		setTimeout(function(){
			$('global_box').style.display="none";
			},3000);
		$("loading").setStyle("display:none;");
	}},formToStr(form));
	return false;
}
//提交评论
function ajaxcomment(name,form){
	if($("commentmsg").value!=""&&userid!=0){
		$("loading").setStyle("display:block;");
		$.ajax.request({url:siteurl+"cp.php",method:"post",oncomplete:function(returns){
			if(returns.responseText==1){
				var lastTime = new Date();
				var lastmin=lastTime.getMinutes()>10?lastTime.getMinutes():lastTime.getMinutes()+10;
				var time=lastTime.getFullYear()+"-"+(lastTime.getMonth()+1)+"-"+lastTime.getDate()+" "+lastTime.getHours()+":"+lastmin+":"+lastTime.getSeconds();
				var newcomm=document.createElement("li");
				newcomm.innerHTML='<p><span class="user-name"><a href="?do=space&uid='+userid+'">'+name+'</a></span><span class="grey">'+time+'</span></p><h6>'+$("commentmsg").value.replace(/\[em:(.+?):\]/gi,'<img src="'+img_server+'face/$1.gif" />')+'</h6>';
				$("commentmsg").value='';
				$("commentlist").appendBefore(newcomm);
				$("loading").setStyle("display:none;");
			}
		}},formToStr(form)+"&inajax=1");
	}
	if(userid==0){
		$('announce').html("您当前为游客 请登录后再留言");
	}
	return false;
}

function mousePosition(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function drag(o){
	o=typeof(o)=='object'?o:$(o);
	o.style.position="absolute";
	o.onmousedown=function(e){
		e=e||window.event;
		o.style.cursor="move";
		var x=e.layerX||e.offsetX; 
		var y=e.layerY||e.offsetY;
		document.onmousemove=function(e){
			e=e||window.event;
			var tag_src=$.broswer()=='msie'? e.srcElement.tagName : e.target.tagName;
			if(tag_src=='TEXTAREA'||tag_src=='INPUT'||tag_src=='BUTTON'||tag_src=='SELECT'||tag_src=='IMG'||tag_src=='A'){
				return ;
			}
			o.style.left=(e.clientX-x)+"px"; 
			o.style.top=(e.clientY-y+document.body.firstChild.scrollTop)+"px";
		};
		document.onmouseup=function(){
			o.style.cursor='auto';
			document.onmousemove=null;
		};
	};

}
function doane(event) {
	e = event ? event : window.event;
	if(!e) return;
	if($.broswer()=='msie') {
		e.returnValue = false;
		e.cancelBubble = true;
	} else if(e) {
		e.stopPropagation();
		e.preventDefault();
	}
}

//tab
function setTab(name,cursel,n){
	for(var i=1;i<=n;i++){
		var menu=$(name+i),con=$("con_"+name+"_"+i);
		menu.className=i==cursel?"current":"";
		con.style.display=i==cursel?"block":"none";
	 }
}
function adv(){ var stit='一生缘-首家全免费婚恋交友网站';return window.sidebar?window.sidebar.addPanel(stit, location.href, ''):window.external.addFavorite(location.href,stit);}
//全局导航
old_type='';
function ajax_map(type){
	if($('ajax_sitemap')==null){
		var div = document.createElement('div');
		div.id = 'ajax_bg';
		div.innerHTML='<iframe id="hiddenframe2"></iframe>';
		document.body.appendChild(div);
		var mymap=document.createElement('div');
		mymap.innerHTML='<img src="'+img_server+'global/loading.gif"/>操作执行中 请稍后...';
		mymap.id='ajax_sitemap';
		document.body.appendChild(mymap);
	};
	if(old_type!=type){
		if(type=='sitemap'){
			$.ajax.request({url:siteurl,method:"post",oncomplete:function(returns){
					if(returns.responseText){			
						$('ajax_sitemap').html(returns.responseText);
					}
			}},"do="+type+"&inajax=1");
		}else{
			$('ajax_sitemap').html('<div class="clearfix maptit" ><span class="left">短消息</span><img src="'+img_server+'global/close.gif" onclick="hidemap()" class="right"/></div><iframe src="'+siteurl+'?do=message&inajax=1" style="padding:0;border:0;height:600px;width:100%;" frameborder="0" scrolling="no" frameborder="0"></iframe>');
		};
	old_type=type;
	}
	$('ajax_sitemap').style.display=$('ajax_bg').style.display="block";
	return false;
}

function hidemap(){$('ajax_sitemap').style.display=$('ajax_bg').style.display="none";};

onready(function(){
	$("loading").setStyle("display:none");
	
});
window.onbeforeunload=function(){
	$('loading').setStyle('display:block');
}