﻿/********************
* Author: xuanhu last modify 2007-07-21
********************/
//function killErrors(){return true;}window.onerror=killErrors;
var ploy={
    chk : "/inc/chk.aspx",
    ajax :"/inc/ajax.aspx"
}
//CTRL+鼠标滚轮放大或缩小图片： 
function imgzoom(o) { 
    if(event.ctrlKey) { 
        var zoom = parseInt(o.style.zoom, 10) || 100; 
        zoom -= event.wheelDelta / 12; 
        if(zoom > 0) { 
            o.style.zoom = zoom + '%'; 
        } 
        return false; 
    } else { 
        return true; 
    } 
} 

function getImgsize(x) { 
    var picSize=x.fileSize; 
    if (picSize>1000) picSize=Math.round(picSize/1024*100)/100+'KB'; 
    else if (picSize > 0) picSize=picSize+'字节'; 
    else picSize='未知'; 
    return picSize; 
} 

function ImgSizeAuto(img)
{
    if(img.width > screen.width*0.7)
    {
        var percent = Math.round(screen.width*0.7/img.width);
        img.resized=true;
        img.width=screen.width*0.7;
        img.height = img.height * percent;
        img.style.cursor='hand';
        img.alt='点击在新窗口浏览图片\\nCTRL+Mouse 滚轮可放大/缩小';
        img.onmousewheel=imgzoom(img);
    }
   
}

function ImgOpen(img)
{
    if(!img.resized)
    {return true;}
    else 
    {window.open(img.src);}
}
//关键字 

/* XQ */
XQ = 
{
    attwindow : window,
    chk : "/inc/chk.aspx",
    ajax : "/inc/ajax.aspx"
    ,urlCopy : function(ob)
    {   
        var obj=$(ob); 
	    if (obj)
	    {
		    obj.select();js=obj.createTextRange();js.execCommand("Copy");
		}
		alert('复制成功，粘贴发给好友一起玩吧，谢谢!');
	}
	,openNote:function(o)
	{
	    var o = $(o);
	    if(!o.visible())
	    {
	        o.show();
	    }
	    else
	    {
	        o.hide();
	    }
	}
	,setKeys:function(o)
	{
	    if(typeof keysArray!="object") return;
	    if(!o) return;
	    var t = o.value.trim().toLowerCase();
	    var to = $("keys");
	    var tem = new Array();
	    try
	    {
	       for (var k=0;k<keysArray.size();k++)
	       {
               if(t.indexOf(keysArray[k])!=-1)
               {
                   if(!tem.include(keysArray[k]))
                      tem.push(keysArray[k]);
               }
           }
	    }
	    catch(e){alert("keys:"+e.message);}
	}
	,createAddPop:function()
    {//创建加入条件窗口
        var _pop = $("xq__add");
        if (_pop!=null && _pop.tagName.toLowerCase()=="div") {
            return _pop;
		}
		var w = getPagePosition(this.attwindow);
        var _hiddiv = document.createElement("div");
        _hiddiv.id = "xqaddhidforms";
        _hiddiv.style.position = "absolute";
        _hiddiv.style.display = "none";
        _hiddiv.style.top = 0+"px";
        _hiddiv.style.left = 0+"px";
        _hiddiv.style.zIndex = 1000;
        _hiddiv.style.width    = w.clientWidth+"px";
        _hiddiv.style.height   = document.body.clientHeight+"px";
        _hiddiv.style.backgroundColor = "#ffffff";
        _hiddiv.style.overflow = "hidden";
        _hiddiv.style.filter   = "alpha(opacity=70)";
        this.hidepop = $(_hiddiv);
        document.body.insertBefore(_hiddiv,document.body.firstChild);
        
        var _pop=document.createElement("div");
        _pop.id="xq__add";
        _pop.style.zIndex = 1001;
        _pop.style.display = "none";
        _pop.style.position = "absolute";
        _pop.className ="xqTchu xqTchuA";
        document.body.appendChild(_pop);
        
        return $(_pop);
    }
    ,showAddHTML:function(xqid,xqname,onup)
    {

       var _html = "<h1 id=\"xq_add_Head\"><span><a href=\"javascript:;\" id=\"xq_add_close\"></a></span>您好！尊敬的会员</h1>"
       +"<h2>您现在申请加入小区 <span>"+xqname+"</span></h2>"
       +"<form id=\"xq_add_xq\" method=\"post\">"
       +"<h2>请选择您在该小区的身份：";
       if(onup){
           _html+=" <input name=\"groupid\" id=\"groupid6\" type=\"radio\" value=\"6\" checked />"
           +" 业主"
           +" <input name=\"groupid\" id=\"groupid8\" type=\"radio\" value=\"8\" disabled />"
           +" 友人";
       }else
       {
           _html+=" <input name=\"groupid\" id=\"groupid6\" type=\"radio\" value=\"6\" />"
           +" 业主"
           +" <input name=\"groupid\" id=\"groupid8\" type=\"radio\" value=\"8\" />"
           +" 友人";
       }
       _html+="</h2>"
       +"<dl id=\"xq_messagebox\" ";
       if(onup!=true){
        _html+="style=\"display:none;\" ";
       }
       _html+=">"
       +" <dd><span>手 机 号：</span>"
       +"   <input name=\"tel\" type=\"text\"  maxlength=\"11\" onkeyup=\"value=value.replace(/[^0-9]/g,'')\"/>"
       +" </dd>"
       +" <dd><span>门 牌 号：</span>"
       +"   <input name=\"door\" type=\"text\"/>"
       +" </dd>"
       +" <dd><span>真实姓名：</span>"
       +"   <input name=\"poster\" type=\"text\" />"
       +" </dd>"
       +" <dd><span>识别卡号：</span>"
       +"   <input name=\"code\" type=\"text\" onkeyup=\"value=value.replace(/[^0-9]/g,'')\" size=\"15\"/>"
       +" </dd>"
       +"</dl>"
       +"<dl>"
       +" <dt><input name=\"xqid\" type=\"hidden\" value=\""+xqid+"\" />"
       +"   <input name=\"send\" type=\"submit\" value=\"提交\" />"
       +"   <input id=\"xq_add_reset\" type=\"button\" value=\"取消\" />"
       +" </dt>"
       +"</dl>"
       +"</form>";

        this.AddPop.innerHTML = _html;
        
        var w = getPagePosition(this.attwindow);
        this.hidepop.show();
        this.AddPop.show();

        this.AddPop.style.left = parseInt(w.clientWidth/2)-(this.AddPop.offsetWidth/2);
        this.AddPop.style.top = parseInt(w.clientHeight/2)-(this.AddPop.offsetHeight/2) + w.scrollTop;

        HideOverSels(this.hidepop);
        document.body.style.width="1002px";
        document.getElementsByTagName('html')[0].style.overflow="hidden";
        
        this.AddPop.Head = $("xq_add_Head");
        this.AddPop.Form = $("xq_add_xq");
        this.AddPop.Messagebox = $("xq_messagebox");
        Event.observe($("groupid6"),"click",this.showmessagebox.bind(this));
        Event.observe($("groupid8"),"click",this.hidemessagebox.bind(this));
        Event.observe(this.AddPop.Head,"mousedown",startDragLogin.callWith(this.AddPop.id));
        Event.observe(this.AddPop.Form,"submit",this.addsubmit.bind(this));
        Event.observe($("xq_add_close"),"click",this.addclose.bind(this));
        Event.observe($("xq_add_reset"),"click",this.addclose.bind(this));
    }
    ,showIdentcodeHTML:function(xqid,xqname)
    {
       var _html = "<h1 id=\"xq_addcode_Head\"><span><a href=\"javascript:;\" id=\"xq_add_close\"></a></span>您好！尊敬的会员</h1>"
       +"<h2>您现在进行的是小区 <span>"+xqname+"</span> 身份识别<br>认证后您将直接成为小区业主</h2>"
       +"<form id=\"xq_addcode_xq\" method=\"post\">"
       +"<dl>"
       +" <dd><span>识别卡号：</span>"
       +"   <input name=\"code\" type=\"text\" />"
       +" </dd>"
       +"</dl>"
       +"<dl>"
       +" <dt><input name=\"xqid\" type=\"hidden\" value=\""+xqid+"\" />"
       +"   <input name=\"send\" type=\"submit\" value=\"提交\" />"
       +"   <input id=\"xq_add_reset\" type=\"button\" value=\"取消\" />"
       +" </dt>"
       +"</dl>"
       +"</form>";

        this.AddPop.innerHTML = _html;
        
        var w = getPagePosition(this.attwindow);
        this.hidepop.show();
        this.AddPop.show();

        this.AddPop.style.left = parseInt(w.clientWidth/2)-(this.AddPop.offsetWidth/2);
        this.AddPop.style.top = parseInt(w.clientHeight/2)-(this.AddPop.offsetHeight/2) + w.scrollTop;

        HideOverSels(this.hidepop);
        document.body.style.width="1002px";
        document.getElementsByTagName('html')[0].style.overflow="hidden";
        
        this.AddPop.Head = $("xq_addcode_Head");
        this.AddPop.Form = $("xq_addcode_xq");

        Event.observe(this.AddPop.Head,"mousedown",startDragLogin.callWith(this.AddPop.id));
        Event.observe(this.AddPop.Form,"submit",this.addcodesubmit.bind(this));
        Event.observe($("xq_add_close"),"click",this.addclose.bind(this));
        Event.observe($("xq_add_reset"),"click",this.addclose.bind(this));
    }
    ,hidemessagebox : function()
    {
        this.AddPop.Messagebox.hide();
    }
    ,showmessagebox : function()
    {
        this.AddPop.Messagebox.show();
    }
    ,Identcode : function(xqid,xqname,th,onup)
    {
        if(!login.state()) 
        {
            login.fun = function(){
                XQ.addIdentcode(xqid,xqname,th,onup);
                login.fun = null;
            };
            return;
        }
        
        webjs.loader.load("addXQ",function(){XQ.addIdentcode(xqid,xqname,th,onup);});
    }
    ,addIdentcode : function(xqid,xqname,th,onup)
	{
	    if(!this.AddPop) this.AddPop = this.createAddPop();
	    this.showIdentcodeHTML(xqid,xqname,onup);
	}
	,add : function(xqid,xqname,th,onup)
	{
	    if(!login.state()) 
        {
            login.fun = function(){
                XQ.addfun(xqid,xqname,th,onup);
                login.fun = null;
            };
            return;
        }
        
        webjs.loader.load("addXQ",function(){XQ.addfun(xqid,xqname,th,onup);});
	}
	,addcodesubmit: function()
	{
	    var f = this.AddPop.Form;
	    if(f.code.value.trim()=="")
        {
            alert("请输入身份识别卡号");
            f.code.focus();
            return false;
        }

        f.send.value = "提交中..";
        f.send.disabled = true;
        AlertDIV(f,"<img src=/images/loading_pic.gif border=0/><br>正在提交，请稍候......");
        var param = "code="+f.code.value;
        _sendx(this.ajax + "?t=addxqcode&id="+f.xqid.value+"",function(p,v)
        {
      
            if(v.length<100)   
            {
                if(v=="操作成功！")
                    location.reload();
                else alert(v);
            }else alert("数据处理出现异常，请稍候重试！");
             
            f.send.disabled = false;
            f.send.value = "提交";
            if($("alertDIV")) $("alertDIV").removeNode(true);
        }
        ,null,"POST",param);
        return false;
    }
	,addsubmit : function()
	{
	    var f = this.AddPop.Form;
	    var gid=0;
	    if(this.AddPop.Form.groupid[0].checked)
	    {
            if(f.poster.value.trim()=="")
            {
                alert("请填写您的真实姓名");
                f.poster.focus();
                return false;
            }
            if(f.tel.value.trim()=="")
            {
                alert("请填写您的联系方式");
                f.tel.focus();
                return false;
            }
            if (f.tel.value.trim()!="")
            {
                var reg=/1[3,5][1,2,3,4,5,6,7,8,9]\d{8}/; 
                if ( f.tel.value.match(reg)== null)
                { 
                   alert("请输入正确的手机号码！"); 
                   f.tel.focus(); return false;
                } 
            }    
            if(f.door.value.trim()=="")
            {
                alert("请填写门牌号已便认证顺利通过");
                f.door.focus();
                return false;
            }
            
            gid = this.AddPop.Form.groupid[0].value;
        }
        else if(this.AddPop.Form.groupid[1].checked) gid = this.AddPop.Form.groupid[1].value;
        else
        {
            alert("请选择加入该小区的身份");
            return false;
        }
        f.send.value = "提交中..";
        f.send.disabled = true;
        AlertDIV(f,"<img src=/images/loading_pic.gif border=0/><br>正在提交，请稍候......");
        var param = "poster="+f.poster.value+"&tel="+f.tel.value+"&door="+f.door.value+"&code="+f.code.value+"&groupid="+gid;
        _sendx(this.ajax + "?t=addxq&id="+f.xqid.value+"",function(p,v)
        {
            if(v.length<100)   
            {
                if(v=="操作成功！")
                    location.reload();
                else alert(v);
            }else alert("数据处理出现异常，请稍候重试！");
            f.send.disabled = false;
            f.send.value = "提交";
            if($("alertDIV")) $("alertDIV").removeNode(true);
        }
        ,null,"POST",param);
        return false;
    }
	,addfun : function(xqid,xqname,th,onup)
	{
	    if(!this.AddPop) this.AddPop = this.createAddPop();
	    this.showAddHTML(xqid,xqname,onup);
	}
	,addclose:function()
    {
        
        this.AddPop.Form.reset();
        this.AddPop.hide();
        HideOverSels(this.hidepop);
        this.hidepop.hide();
        document.body.style.width="1002px";
        document.getElementsByTagName('html')[0].style.overflow="auto";
        return false;
    }
	,out : function(xqid,th)
	{
	    if(login.state())
	    {
	        var conf=confirm('确定要退出吗？');
			if(!conf)
				return ;
	        th.value = "提交中..";
            th.disabled = true;
            _sendx(this.chk + "?act=out&xqid="+xqid,function(p,v)
            {
                if(v.length<100)   
                {
                    if(v=="操作成功！")
                        location.reload();
                    else alert(v);
                }else alert("数据处理出现异常，请稍候重试！");
            }
            ,null);
	    }
	}
	,setPhoto : function(xqid)
	{
	    var url = "/img.htm?xqid="+xqid;
	    var arr = window.open(url,"XQupload","left=100,top=150,width=440,height=180,scrollbars=no,help=no,scroll=no,status=no");
	    arr.focus();
	}
	,resetIMG : function(xqid)
	{
	    var conf = confirm("是否确认需要将小区图还原为默认？");
        if(!conf) return false;
        var pars="act=resetIMG&id="+xqid;
        _sendx(XQ.chk+'?'+pars+'&tmp='+getDataTime()
		    ,function(p,v)
		    {
                if(v.length<100)
                {
                    if(v=="操作成功！")
                    {
                        location.reload();
                    }
                    else alert(v);
                }else
                {
                    alert("数据处理出现异常，请稍候重试！");
                }
            }
		    ,null
		);
	}
	,manage : function(xqid)
	{
        if(login.state())
	    {
            _sendx(this.chk + "?act=setmanage&id="+xqid,function(p,v)
            {
                if(v.length<100)   
                {
                    if(v=="操作成功！")
                        location.reload();
                    else alert(v);
                }else alert("数据处理出现异常，请稍候重试！");
            }
            ,null);
	    }
    }
    ,editIntro : function(xqid,obj)
    {
        var o = (obj!=null)?$(obj):this;
    	var v = (o.innerText)?o.innerText:o.textContent;
    	o.old_value = v;
    	o.parentNode.innerHTML = "<form name=\""+xqid+"_hffrom\" onsubmit=\"return XQ.saveIntro(this)\">"
        +"<textarea id='_mt' style='border:1px dashed #0099ff;font-size:14px;' cols=\"25\" rows=\"2\" maxlength='300' />"+v+"<\/textarea>"
        +"<p><input name=\"xqid\" type=\"hidden\" value=\""+xqid+"\" \/>"
        +"   <input name=\"\" type=\"submit\" value=\"修改\" \/>"
        +"   <input name=\"\" type=\"button\" value=\"取消\" onclick=\"XQ.resetIntro('"+o.id+"');\" \/>最多3000个字符</p>"
        +"<\/form>";
    	$('_mt').focus();
    	$('_mt').select();
    	o.onclick="";
    }
    ,saveIntro : function(f)
    {
        var pc = f._mt.value.trim();
        var xqid = f.xqid.value.trim();
        if(pc.len()<1)
        {
            alert("对不起，内容不能为空！")
            f._mt.focus();
            return false;
        }
        if(pc.len()>6000)
        {
            alert("对不起，最多3000个字，现已输入"+(pc.len()/2)+"！")
            f._mt.focus();
            return false;
        }
        var pars = "act=editintro&xqid="+xqbh+"&l="+pc;
        f._mt.value = "";
        
        _sendx(XQ.chk+'?'+pars+'&tmp='+getDataTime()
		    ,function(p,v)
		    {
                if(v.length<100)
                {
                    if(v=="操作成功！")
                    {
                        $(p).innerHTML = pc;
                    }
                    else alert(v);
                }else
                {
                    XQ.resetIntro(p);
                    alert("数据处理出现异常，请稍候重试！");
                }
            }
		    ,'introMsg'
		   
		);
        return false;
    }
    ,resetIntro : function(obj)
    {
        var o = (obj!=null)?$(obj):this;
        o.innerHTML = o.old_value;
    }
    ,writeTopic :function(f)//发表话题
    {
        if(!login.state()) return false;
        var t = f.postTitle.value.trim();
        if(t.len()<1)
        {
            alert("对不起，标题不能为空！")
            f.postTitle.focus();
            return false;
        }
        if(t.len()>60)
        {
            alert("对不起，最多30个字，现已输入"+(t.len()/2)+"！")
            f.postTitle.focus();
            return false;
        }
        f.postMessage.value = XQ.Editor.getContent();
        var v = f.postMessage.value;
        if(v.len()<15)
        {
            alert("内容过短，无法提交！")
            return false;
        }
        
        var xqid = f.xqid.value;
        f.send.disabled = true;
        AlertDIV(f,"<img src=/images/loading_pic.gif border=0/><br>正在提交，请稍候......");
        var pars = "xqid="+xqid+"&title="+t+"&message="+v;
        _sendx(XQ.ajax+'?t=writetopic'
		    ,function(p,v)
		    {
                if(v.length<100)
                {
                    if(v=="操作成功！")
                    {
                        XQ.resetTopic();
                        return;
                    }
                    else alert(v);
                }
                else
                {
                alert(v);
                 //   alert("数据处理出现异常，请稍候重试！");
                }
                if($("alertDIV")) $("alertDIV").removeNode(true);
                f.send.disabled = false;
           }
		   ,f
		   ,"POST"
		   ,pars
		);
        return false;
    }
    ,resetFrom : function()
    {
        var f = $("writetopic");
        f.reset();
        ctl00_mainContent_content___Frame.location.reload();
        f.submit.disabled = false;
    }
    ,resetTopic : function()
    {
        //this.resetFrom();
        init();
        setTimeout("location = '#topiclist'",2000);
    }
    ,setHideAndShow : function(obj)
    {
        var o = $(obj+"_menu");
        if(o.visible()){
    		//Effect.BlindUp(o, {duration:0.5});
    		o.hide();
    	}else{
    		//Effect.BlindDown(o, {duration:0.5});
    		//o.show();
    		showMenu(obj, true, 0, 3);
    	}
    }
    ,viewInfo : function(u,l)
    {
        if($(u+"_menu").innerHTML.length>4)
        {
            XQ.setHideAndShow(u);
            return;
        }
        if(parseInt(l)<2)
        {
            var flag = confirm("您不是VIP用户，查看私密联系方式需要支付50金豆\n\n如果愿意支付请点击"
            + "“确定”，否则请点击“取消”");
            if(!flag) return false;
        }
        var pars = "act=userinfo&u=" + u;
        _sendx(this.chk+"?"+pars, function(p, v)
        {
            if(v.length<100)
            {
                $(u+"_menu").innerHTML = v;
                XQ.setHideAndShow(u);
            }
        }
        , u);

    }
    
};

XQ.AU = 
{
    get : function(uri,_d,par)
    {
        if($(_d))
        {
            AlertDIV(_d,"<img src=/images/loading_pic.gif border=0/><br>正在加载内容......");
		    var myAjax = new Ajax.Updater(
			_d, 
			uri, 
			{
				method: 'get', 
				parameters: par,
				evalScripts:true
			});
        }
    }
    ,getRevert : function(uri,_d,par)
    {
        //AlertDIV(_d);
        
		var pars = par+'&d=' + _d;
		_sendx(uri+'?'+pars+'&tmp='+getDataTime()
		    ,this.showResponse.bind(this)
		    ,_d
		);
    }
    ,showResponse : function(t,v)
    {
        $(t).innerHTML = v;
    }
    
};
//firstChild.data
XQ.Tools = 
{
    uri : "inc/topic_revert.aspx"
    ,revert : function(htid)
    {
        if(login.state())
	    {
            var _html = "<form name=\""+htid+"_hffrom\" onsubmit=\"return XQ.Tools.validate(this)\">"
                +"        <textarea name=\"plcontent\" cols=\"\" rows=\"\"><\/textarea>"
                +"        <p>"
                +"<input name=\"htid\" type=\"hidden\" value=\""+htid+"\" \/>"
                +"   <input name=\"\" type=\"submit\" value=\"回复\" \/>"
                +"   <input name=\"\" type=\"button\" value=\"取消\" onclick=\"XQ.Tools.resetHF("+htid+");\" \/> 最多回复400个字符"
                +"        <\/p>"
                +"<\/form>";
            $(htid+"_wthf").innerHTML = _html;
            $(htid+"_wthf").show();
            setTimeout("$('"+htid+"_hffrom').plcontent.focus();",100);
        }
    }
    ,spreadNode : function(id)
    {
        var con = $(id+"_content");
        var sortcon = $(id+"_sortcon");
        var the = $(id+"_the");
        if(con.visible()){
		    the.innerText = '[+展开话题]';
		    con.hide();
		    sortcon.show();
		    //Effect.BlindUp(o, {duration:0.5});
	    }else{
		    the.innerText = '[-收起话题]';
		    //Effect.BlindDown(o, {duration:0.5});
		    Effect.Squish(sortcon);
		    //sortcon.hide();
		    con.show();
		    
	    }
    }
    ,top : function(htid)
    {
        var pars = "act=immobility&id="+htid;
        _sendx(XQ.chk+'?'+pars+'&tmp='+getDataTime()
		    ,function(p,v)
		    {
		        if(v.length<100)
                {
                    if(v=="操作成功！")
                    {
                        init();
                    }
                    else alert(v);
                }else alert("数据处理出现异常，请稍候重试！");
		    }
		    ,htid
		);
    }
    ,del : function(htid,reid)
    {
        var conf=confirm('确定要删除吗？');
			if(!conf)
				return ;
        var pars = "act=del&id="+htid+"&reid="+reid;
        _sendx(XQ.chk+'?'+pars+'&tmp='+getDataTime()
		    ,function(p,v)
		    {
		        if(v.length<100)
                {
                    if(v=="操作成功！")
                    {
                        if(parseInt(reid)>0)
                            setTimeout("XQ.AU.getRevert(XQ.Tools.uri,'"+htid+"_hf','id="+htid+"');",10);
                        else
                            init();
                    }
                    else alert(v);
                }else alert("数据处理出现异常，请稍候重试！");
		    }
		    ,htid
		);
    }
    ,validate :function(f)
    {
        var pc = f.plcontent.value.trim();
        var htid = f.htid.value.trim();
        if(pc.len()<1)
        {
            alert("对不起，回复内容不能为空！")
            f.plcontent.focus();
            return false;
        }
        if(pc.len()>800)
        {
            alert("对不起，最多回复400个字，现已输入"+(pc.len()/2)+"！")
            f.plcontent.focus();
            return false;
        }
        var pars = "act=revert_topic&xqid="+xqbh+"&id="+htid+"&pl="+pc;
        //var par = "pl="+pc;
        f.plcontent.value = "";
        _sendx(XQ.chk+'?'+pars+'&tmp='+getDataTime()
		    ,this.upData.bind(this)
		    ,htid
		   
		);
        return false;
    }
    ,upData : function(t,v)
    {
        //alert(v);
        if(v.length<100)
        {
            if(v=="操作成功！")
            {
                this.resetHF(t);
                setTimeout("XQ.AU.getRevert(XQ.Tools.uri,'"+t+"_hf','id="+t+"');",10);
                if($(t+"_hfnum")) $(t+"_hfnum").firstChild.data = (parseInt($(t+"_hfnum").firstChild.data)+1);
            }
            else alert(v);
        }else alert("数据处理出现异常，请稍候重试！");
    }
    ,resetHF : function(htid)
    {
        $(htid+"_wthf").hide();
    }
    ,edit : function(htid)
    {
        var f = $("writetopic");
        f.htid.value = htid;
        f.title.value = $(htid+"_title").innerText;
        f.ctl00$mainContent$content.value = $(htid+"_content").innerHTML;
        ctl00_mainContent_content___Frame.location.reload();
    }
    ,demoChage : function(demoid)
    {
        var styleheader = $("demoheader");
        var stylenav = $("demonav");
        var stylecontent = $("democontent");
        var styleurl = "template/";
        styleheader.href = styleurl+"header/"+demoid+"/header.css";
        stylenav.href = styleurl+"nav/"+demoid+"/nav.css";
        stylecontent.href = styleurl+"content/"+demoid+"/content.css";
        AlertDIV(document.body,"<img src=/images/loading_pic.gif border=0/><br>正在加载样式包......");
        _sendx(XQ.ajax+'?t=demochage&demoid='+demoid+'&tmp='+getDataTime()
		    ,function(p,v)
		    {
		        webjs.loader.load("loadstyle",function(){
                    setTimeout(function(){if($("alertDIV")) $("alertDIV").removeNode(true);},100);
                });
		    }
		    ,null
		);
    }
};

XQ.Editor = {
    getContent : function(){//获取编辑器的内容值
        var p1=this;
        var ci;
        if(p1.editor){
            if(!p1.html){
                return p1.textArea.value;
            }
            var oEditor;
            if(p1.htmlMode.checked){
                oEditor=p1.textEditor;
                ci=oEditor.value;
                oEditor.focus();
            }
            else{
                //try{
                    oEditor=p1.htmlEditor.document.body;
                    ci=oEditor.innerHTML;
                    
                    i=ci.length;
                    var r=p1.htmlEditor.document.body.createTextRange();
                    if(p1.type=="draft"){
                        i=0;
                    }
                    r.moveStart("character",i);
                    r.collapse(true);
                    r.select();
                //}
                //catch(e){alert(e.message);
                //    ci=p1.temp;
                //}
            }
  
        }
        else{
            ci=p1.temp;
        }

        var re = /<\w[^>]* class="?MsoNormal"?/gi ;
        var re2 = /<\w[^>]* class="?xl"?/gi ;
        if ( re.test( ci ) )
        {
            alert("您要粘贴的内容好像是来自 MS Word，系统将清除 MS Word 格式后再粘贴！")
        }

        if ( re2.test( ci ) )
        {
            alert("您要粘贴的内容好像是来自 MS Excel，系统将清除 MS Excel 格式后再粘贴！")
        }
        ci = p1.cleanAndPaste( ci ) ;
        return ci;
    }
    /*编辑器相关*/
    ,fixEditor : function(Apc){
        if(!Apc){
            return;
        }
        if(Apc.name=="ifrHtmlEditor"){
            return;
        }
        var p1=this;
        var Ahw=Apc.document;
        if(document.all){
            p1.htmlEditor=Apc.frames["HtmlEditor"];
        }
        else{
            p1.htmlEditor=Apc.$("HtmlEditor").contentWindow;
        }
        p1.html = true;
        p1.htmlMode=Ahw.getElementsByName("switchMode")[0];
        p1.textEditor=Ahw.getElementById("sourceEditor");
        p1.textArea=Ahw.getElementById("dvtext");
        try{
            Event.observe(p1.htmlEditor.document,"keypress",Ais);
            if(!p1.html){
                p1.htmlEditor.parent.changeEditType(false , null);
            }
           
        }
        catch(e){
        } 
        p1.editor=true;
        try{
            if(typeof(setcontent)=='function')
                setTimeout("setcontent();",0);
            if($("postMessage") && $("postMessage").value.length>0) this.setEditor($("postMessage").value);
        }catch(e){}
        //setTimeout('MM.compose.timeout("editor")',0);
    }
    ,setEditor : function(ci){
        var p1=this;
         
        if(!ci){
       
            ci="";
        } 

        if(p1.htmlEditor.document.body.innerHTML!="")//判断编辑器是否已经存在内容，有则追加
          {
              oEditor=p1.htmlEditor.document.body;
                oEditor.innerHTML +=ci;
                oEditor.focus();
          }
          else
          {
             if(p1.editor){
              if(!p1.html){
           
                p1.textArea.value =ci;
                return;
            }
            var oEditor;
            if(p1.htmlMode.checked){
                oEditor=p1.textEditor;
                oEditor.value=ci;
                oEditor.focus();
            }
            else{
                oEditor=p1.htmlEditor.document.body;
                oEditor.innerHTML=ci;
                oEditor.focus();
            }
            
        }
        else{
            p1.temp=ci;
        }
        }
    }
    ,cleanAndPaste : function( html )
    {
        // Remove all SPAN tags
        html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
        // Remove Class attributes
        html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
        // Remove Style attributes
        html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
        // Remove Lang attributes
        html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
        // Remove XML elements and declarations
        html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
        // Remove Tags with XML namespace declarations: <o:p></o:p>
        html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
        // Replace the &nbsp;
        html = html.replace(/&nbsp;/, " " );
        // Transform <P> to <DIV>
        var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;// Different because of a IE 5.0 error
        
      
        html = html.replace( re, "<div>$2</div>" ) ;
        return html;
    }
    ,Submit : function()
    {
        if($("topicsubmit")) 
        {   
            XQ.writeTopic($("topicsubmit"));
        }
        if($("posttopicsubmit")) 
        {   
            XQ.writeTopic($("topicsubmit"));
        }
        if($("postphotosubmit"))
        {
            photo.wtphotoreply($("postphotosubmit"));
        }
    }
};


XQ.Map = {
    width:215,
    height:147,
    value:[],
    chage : function(xqid,obj,txtobj)
    {
        if(txtobj.innerText=="切换地图")
        {
            if(this.value[0]==null) this.value[0] = $(obj).innerHTML;
            if(this.value[1]==null)
            {
                this.getMap(xqid,obj);
            }
            else
            {
                $(obj).innerHTML = this.value[1];
            }
            txtobj.innerText = "切换图片";
        }
        else
        {
            if(this.value[1]==null) this.value[1] = $(obj).innerHTML;
            txtobj.innerText = "切换地图";
            $(obj).innerHTML = this.value[0];
        }
        AlertDIV($(obj),"正在切换，请稍候......");
        setTimeout(this.hide,500);
    },
    getMap : function(xqid,obj)
    {
        var sIframe='<iframe id="myMap" name="myMap" src="about:blank" frameborder="0" width="'+this.width+'" height="'+this.height+'" hidefocus scrolling=no></iframe>';
        $(obj).innerHTML=sIframe;
        _sendx(XQ.ajax + "?t=getmap",function(p,v)
        {
            var vl = v.split('|');
            var CID = vl[0];
            var tid = vl[1];
            var userTid = vl[2];
            var cityname = encodeURIComponent(vl[3]);
            var nid = vl[4];
            $("myMap").src = "http://searchbox.mapbar.com/publish/template/template1010/?CID="+CID+"&tid="+tid+"&userTid="+userTid+"&cityName="+cityname+"&nid="+nid+"&width="+p.width+"&height="+p.height+"&zoom=13&control=1&infopoi=0";
        }
        ,this);
    },
    hide : function()
    {
        if($("alertDIV")) $("alertDIV").removeNode(true);
    }
}


function HideOverSels(objID)
{
    var sels = document.getElementsByTagName('select'); 
    for (var i = 0; i < sels.length; i++) 
    {
         if(in_array(sels[i].name,['selprovince','selcity','selcounty'])) continue;
         if (Obj1OverObj2($(objID), sels[i]))
         {
            sels[i].style.visibility = 'hidden';  
         }
         else
         {
            sels[i].style.visibility = 'visible';
         }
    }
}
function getLeftPosition(Obj) 
{
    try
    {
        for (var sumLeft=0;Obj!=document.body;sumLeft+=Obj.offsetLeft,Obj=Obj.offsetParent);
        return sumLeft;
    }
    catch(e)
    {}
}
function getTopPosition(Obj) 
{
    try
    {
        for (var sumTop=0;Obj!=document.body;sumTop+=Obj.offsetTop,Obj=Obj.offsetParent);
        return sumTop;
    }
    catch(e)
    {}
}
function Obj1OverObj2(obj1, obj2)
{ 
  var result = true;
  if(!obj1.visible()) return false;
  var obj1Left = getLeftPosition(obj1) - document.body.scrollLeft; 
  var obj1Top = getTopPosition(obj1)  - document.body.scrollTop; 
  var obj1Right = obj1Left + obj1.offsetWidth; 
  var obj1Bottom = obj1Top + obj1.offsetHeight;
  var obj2Left = getLeftPosition(obj2) - document.body.scrollLeft; 
  var obj2Top = getTopPosition(obj2) - document.body.scrollTop; 
  var obj2Right = obj2Left + obj2.offsetWidth; 
  var obj2Bottom = obj2Top + obj2.offsetHeight;
  if (obj1Right <= obj2Left || obj1Bottom <= obj2Top || obj1Left >= obj2Right || obj1Top >= obj2Bottom) 
  {
     result = false; 
  }
  return result; 
}
//成员信息
function del(pid,xqid){
        var conf=confirm('确定要删除吗？');
			if(!conf)
				return ;
        var pars = "t=delmember&pid="+pid+"&xqid="+xqid;
          _sendx(ploy.ajax+"?"+pars,function(p,v)
		    {
		        if(v.length<100)
                { 
                        if(v=="删除成员成功！")
                    {
                  if(parseInt(pid)>0)
                            location.reload();
                        else
                            init();
                    }
                   else alert(v);
             
               }else alert("数据处理出现异常，请稍候重试！");
		    }
		    ,pid);
		
}