﻿var eventIdforClient = "";

var lib = {};

lib.url = document.scripts;
lib.url = lib.url[lib.url.length-1].src.substring(0,lib.url[lib.url.length-1].src.lastIndexOf("/")+1);

lib.ori = lib.url.replace("templet/default/files/","");

lib.$ = function(e){
    var o = document.getElementById(e);
    if(o) return o;
    o = document.getElementsByName(e);
    if(o.tagName == undefined) return null;
    return o;
}

lib.euid = {};
lib.euid.toString = function(){
    var euid = "";
    for(var i=0;i<32;i++){
        euid += Math.floor(Math.random() * 16.0).toString(16);
    }
    return euid;
}

lib.load = function(e){
    if(window.attachEvent){
        window.attachEvent("onload",e);
    }else{
        window.addEventListener('load',e,false);
    }
}

lib.$event = function(o,e,r){
    if(arguments.length==1){
        lib.$event(window,"load",arguments[0]);
    }else{
        if(window.attachEvent){
            if(typeof(o)=="string") o = lib.$(o);
            try{if(o!=null){
                if(typeof(r)=="string"){
                    o.attachEvent("on"+e,function(){eval(r)});
                }else if(typeof(r)=="function"){
                    o.attachEvent("on"+e,r);
                }
            }}catch(err){}
        }else{
            if(typeof(o)=="string") o = lib.$(o);
            try{if(o!=null){
                if(typeof(r)=="string"){
                    o.addEventListener(e,function(){eval(r)},false);
                }else if(typeof(r)=="function"){
                    o.addEventListener(e,r,false);
                }
            }}catch(err){}
        }
    }
}

lib.ajax = function(url,method,content,async){
  var rper = false;
  var hper = this;
  try{
    rper = new XMLHttpRequest;
  }catch(e){
    try{
      rper = new ActiveXObject("MSXML2.XMLHTTP");
    }catch(e2){
      try{
        rper = new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e3){
        rper = false;
      }
    }
  }
  if(!rper) return false;
  this.method = method || "GET";
  this.url = url || "";
  this.async = async || true;
  this.content = content || "";
  this.collect = function(rxer){return;}
  this.connect = function(){
    if(!this.method||!this.url||!this.async) return false;
    rper.open(this.method,this.url,this.async);
    if(this.method=="POST") rper.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    rper.onreadystatechange = function(){
      if(rper.readyState==4){
        if(rper.status==200){
          hper.collect(rper);
        }
      }
    }
    if(this.method=="POST") rper.send(this.content);
    else rper.send(null);
  }
}

lib.tab = function(key,count,index,style,mouse){
    var StartIndex = null;
    var StyleIndex = style == null ? "" : style + "_";
    var EventMouse = mouse || false;
    for(var i=0;i<count;i++){
        if(lib.$(key + "_eval_" + i)!=null){
            if(StartIndex==null) StartIndex = i;
            lib.$(key + "_eval_" + i).onclick = function(){
                for(var r=0;r<count;r++){
                    if(lib.$(key + "_eval_" + r)!=this){
                        if(lib.$(key + "_text_" + r)!=null)
                           lib.$(key + "_text_" + r).className = StyleIndex + "ovlabel";
                        lib.$(key + "_eval_" + r).className = StyleIndex + "ovevent";
                    }else{
                        if(lib.$(key + "_text_" + r)!=null)
                           lib.$(key + "_text_" + r).className = StyleIndex + "onlabel";
                        lib.$(key + "_eval_" + r).className = StyleIndex + "onevent";
                    }
                }
                if(this.eval!=null) eval(this.eval);
                if(this.back!=null){
                    if(lib.$(key + "_eval_" + this.back)!=null){
                        lib.$(key + "_eval_" + this.back).click();
                    }
                }
            }
            if(EventMouse==true){
                lib.$(key + "_eval_" + i).onmouseover = function(){
                    this.click();
                }
            }else{
                if(lib.$(key + "_eval_" + i).turn!=null){
                    if(lib.$(key + "_eval_" + i).className==StyleIndex + "ovevent"){
                        lib.$(key + "_eval_" + i).onmouseover = function(){
                            this.className = StyleIndex + "oeevent";
                        }
                        lib.$(key + "_eval_" + i).onmouseout = function(){
                            this.className = StyleIndex + "ovevent";
                        }
                    }
                }
            }
        }
    }
    var StartClick = index || StartIndex || 0;
    if(lib.$(key + "_eval_" + StartClick)!=null) lib.$(key + "_eval_" + StartClick).click();
}

lib.display = function(e){
    for(var i=0;i<e.length;i++){
        lib.$(e[i][0]).style.display = e[i][1] == true ? "block" : "none";
    }
}

lib.enabled = function(e){
    for(var i=0;i<e.length;i++){
        lib.$(e[i][0]).disabled = e[i][1] == false;
    }
}

lib.dialog = function(dlid,clid,mlid,width,height,left,otop){
    if(lib.$(dlid)!=null&&lib.$(clid)!=null){
        if(width!=null) lib.$(dlid).style.width = width;
        if(height!=null) lib.$(dlid).style.height = height;
        if(left!=null){
            if(left=="center"){
                lib.$(dlid).style.left = (document.body.offsetWidth - lib.$(dlid).offsetWidth) / 2;
                if(otop!=null){
                    lib.$(dlid).style.top = (document.body.offsetHeight - lib.$(dlid).offsetHeight) / otop;
                }else{
                    lib.$(dlid).style.top = (document.body.offsetHeight - lib.$(dlid).offsetHeight) / 2;
                }
            }else{
                lib.$(dlid).style.left = left;
                if(otop!=null) lib.$(dlid).style.top = otop;
            }
        }else{
            if(otop!=null) lib.$(dlid).style.top = otop;
        }
        lib.$event(clid,"mousedown",function(){
            lib.$(dlid).o = true;
            lib.$(dlid).y = event.clientY - lib.$(dlid).offsetTop;
            lib.$(dlid).x = event.clientX - lib.$(dlid).offsetLeft;
            document.onselectstart = function(){return false};
            if(lib.$(mlid)!=null){
                lib.$(dlid).style.filter = "alpha(opacity=60)";
                lib.$(mlid).style.display = "block";
                lib.$(mlid).style.width = lib.$(dlid).offsetWidth;
                lib.$(mlid).style.height = lib.$(dlid).offsetHeight;
                lib.$(mlid).style.top = lib.$(dlid).offsetTop;
                lib.$(mlid).style.left = lib.$(dlid).offsetLeft;
            }
        });
        lib.$event(document,"mousemove",function(){
            var direct = lib.$(dlid).o || false;
            if(direct==true){
                if(lib.$(mlid)!=null){
                    lib.$(mlid).style.left = event.clientX - lib.$(dlid).x;
                    lib.$(mlid).style.top = event.clientY - lib.$(dlid).y;
                }else{
                    lib.$(dlid).style.left = event.clientX - lib.$(dlid).x;
                    lib.$(dlid).style.top = event.clientY - lib.$(dlid).y;
                }
            }
        });
        if(lib.$(mlid)!=null){
            lib.$event(mlid,"mouseup",function(){
                lib.$(dlid).o = false;
                document.onselectstart = function(){return true};
                lib.$(dlid).style.filter = "";
                lib.$(dlid).style.left = event.clientX - lib.$(dlid).x;
                lib.$(dlid).style.top = event.clientY - lib.$(dlid).y;
                lib.$(mlid).style.display = "none";
            });
        }else{
            lib.$event(clid,"mouseup",function(){
                lib.$(dlid).o = false;
                document.onselectstart = function(){return true};
            });
        }
    }
}

lib.like = function(id,ele){
    var ajax = new lib.ajax(lib.ori + "comment.aspx?format=praise&id=" + id + "&euid=" + lib.euid);
        ajax.collect = function(r){
            var echo = 0;
            try{
                echo = parseInt(r.responseText);
            }catch(e){
                echo = 0;
            }
            if(echo==1){
                alert("参数错误,没有指定您要称赞的信息!");
            }else if(echo==2){
                alert("操作失败,您已经对指定信息称赞过了!");
            }else if(echo==3){
                alert("操作失败,指定信息不存在或已经被删除!");
            }else if(echo==4){
                alert("完成操作,谢谢您的称赞!");
                var rint = 0;
                try{
                    rint = parseInt(ele.innerText);
                }catch(e){
                    rint = 0
                }
                if(ele!=null) ele.innerText = rint + 1;
            }else{
                alert("操作失败,执行过程中发生未知错误!");
            }
        }
        ajax.connect();
}

lib.votes = function(id,el){
    var li = document.getElementsByName(el);
    if(li.length<1){
        alert("参数错误,请选择您要投票的选项!");
    }else{
        var ck = [];
        for(var i=0;i<li.length;i++){
            if(li[i].checked) ck[ck.length] = li[i].value;
        }
        if(ck.length<1){
            alert("参数错误,请选择您要投票的选项!");
        }else{
            var code = lib.$("forvotecode").value;
            var url = "comment.aspx?format=votes&id=" + id + "&ids=" + ck.toString() + "&chk=" + code;
            if(eventIdforClient.length==0||office["投票编码"]==true){
                url += "&euid=" + lib.euid;
            }else{
                url += "&euid=" + eventIdforClient + "&duid=" + lib.euid;
            }
                //url += "&chk=" + code;// + "&euid=" + lib.euid;
            var ajax = new lib.ajax(url);
            ajax.collect = function(r){
            var echo = 0;
            try{
                echo = parseInt(r.responseText);
            }catch(e){
                echo = 0;
            }
            if(echo==1){
                alert("参数错误,没有指定您要投票的选项!");
            }else if(echo==2){
                alert("操作失败,您已经参与过投过票了!");
            }else if(echo==3){
                alert("操作失败,指定选项不存在或已经被删除!");
            }else if(echo==4){
                alert("完成操作,谢谢您宝贵的一票!");
                for(var i=0;i<ck.length;i++){
                var rint = 0;
                try{
                    rint = parseInt(lib.$("SVT" + ck[i]).innerText);
                }catch(e){
                    rint = 0
                }
                lib.$("SVT" + ck[i]).innerText = rint + 1;
                }
            }else if(echo==5){
                alert("操作失败,请填写正确的验证答案!");
            }else if(echo==6){
                alert("对不起,该项目已经停止投票!");
            }else{
                alert("操作失败,执行过程中发生未知错误!");
            }
            }
            ajax.connect();
        }
    }
}

lib.image = function(ele,ini,txt){
    // lib.image(e,[c,w,h,ih,a,t],[[i],[u],[t]]);
    var dini = ini.slice(0,0);
    var eini = ini.slice(0);
        dini.push(lib.url + "image.swf");
    ini = dini.concat(eini);
    var code  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
        code += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
        code += 'width="'+ ini[2] +'" height="'+ (ini[3] + ini[4]) +'">';
        code += '<param name="movie" value="' + ini[0] + '">';
        code += '<param name="quality" value="high"><param name="bgcolor" value="' + ini[1] + '">';
        code += '<param name="menu" value="false"><param name=wmode value="opaque">';
        code += '<param name="FlashVars" value="pics=' + txt[0].join("|");
        code += '&links=' + txt[1].join("|") + '&texts=' + txt[2].join("|");
        code += '&borderwidth=' + ini[2] + '&borderheight=' + ini[3];
        code += '&textheight=' + ini[4] + '&text_align=' + ini[5] + '&interval_time=' + ini[6] + '">';
        code += '<embed src="' + ini[0] + '" wmode="opaque" FlashVars="pics=' + txt[0].join("|");
        code += '&links=' + txt[1].join("|") + '&texts=' + txt[2].join("|") + '&borderwidth=' + ini[2];
        code += '&borderheight=' + ini[3] + '&textheight=' + ini[4] + '&text_align=' + ini[5];
        code += '&interval_time=' + ini[6] + '" menu="false" bgcolor="' + ini[1] + '" quality="high" ';
        code += 'width="' + ini[2] + '" height="' + (ini[3] + ini[4]) + '" allowScriptAccess="sameDomain" ';
        code += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        code += '</object>';
    if(lib.$(ele)!=null) lib.$(ele).innerHTML = code;
}

lib.media = function(ele,url,width,height,count,model,only){
    var r = /^\$(.*?)\$$/;
    if(url.length<5||r.test(url)){
        if(lib.$(ele)!=null&&ele!="mediapoint"){
            lib.$(ele).style.display = "none";
        }
    }else{
        if(!width) width = "100%";
        if(!height) height = "100%";
        if(!count) count = 1;
        if(!model) model = "full";
        if(!only) only = "MPlayer";
        var mh  = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="' + only + '" width="' + width + '" height="' + height + '">';
            mh += '<param name="URL" value="' + url + '"><param name="rate" value="1"><param name="balance" value="0">';
            mh += '<param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="' + count + '">';
            mh += '<param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1">';
            mh += '<param name="baseURL" value><param name="volume" value="50"><param name="mute" value="0">';
            mh += '<param name="uiMode" value="' + model + '"><param name="stretchToFit" value="0"><param name="windowlessVideo" value="0">';
            mh += '<param name="enabled" value="-1"><param name="enableContextMenu" value="0"><param name="fullScreen" value="0">';
            mh += '<param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value>';
            mh += '<param name="captioningID" value><param name="enableErrorDialogs" value="0"></object>';
        if(lib.$(ele)!=null){
            lib.$(ele).innerHTML = mh;
            if(model=="none"){
                lib.$(only).onmouseover = function(){
                    lib.$(only).uiMode = "full";
                }
                lib.$(only).onmouseout = function(){
                    lib.$(only).uiMode = "none";
                }
            }
        }
    }
}

lib.CheckMedia = function(e,url,type){
    var r = /^\$(.*?)\$$/;
    if(url.length>4&&r.test(url)==false){
        if(lib.$(e)!=null) lib.$(e).className = "ismedia";
    }
}
lib.CreatMedia = function(e,url,ini){
    var r = /^\$(.*?)\$$/;
    if(url.length>4&&r.test(url)==false){
        if(lib.$(e)!=null){
            if(lib.$(e).parentElement!=null) lib.$(e).parentElement.style.display = "block";
            lib.media(e,url,ini);
        }
    }
}

lib.flash = function(ele,url,width,height,query){
    if(!width) width = "100%";
    if(!height) height = "100%";
    var code  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
        code += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
        code += 'width="'+ width +'" height="'+ height +'">';
        code += '<param name="movie" value="' + url + '">';
        code += '<param name="quality" value="high">';
        code += '<param name="menu" value="false"><param name=wmode value="opaque">';
        if(query!=null){
            code += '<param name="FlashVars" value="' + query + '">';
        }
        code += '<embed src="' + url + '" wmode="opaque" quality="high" ';
        if(query!=null){
            code += 'FlashVars="' + query + '" ';
        }
        code += 'width="' + width + '" height="' + width + '" allowScriptAccess="sameDomain" ';
        code += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        code += '</object>';
    if(lib.$(ele)!=null) lib.$(ele).innerHTML = code;
}

lib.childalpha = function(e){
    var o = lib.$(e).getElementsByTagName("img");
    for(var i=0;i<o.length;i++){
        var e = o[i];
        if(e.className=="alphaer"){
            e.onmouseover = function(){
                lib.alpha(this,true,50);
            }
            e.onmouseout = function(){
                lib.alpha(this,false,100);
            }
        }
    }
}

lib.alpha = function(e,v,i){
    if(e==null){
        var o = document.getElementsByTagName("img");
        for(var i=0;i<o.length;i++){
            var e = o[i];
            if(e.className=="alphaer"){
                e.onmouseover = function(){
                    lib.alpha(this,true,60);
                }
                e.onmouseout = function(){
                    lib.alpha(this,false,100);
                }
            }
        }
    }else{
        if(v==true){
            if(i<100){
                i += 10;
                e.style.filter = "alpha(opacity=" + i + ")";
                window.setTimeout(function(){lib.alpha(e,true,i)},5);
            }
        }else{
            if(i>60){
                i -= 10;
                e.style.filter = "alpha(opacity=" + i + ")";
                window.setTimeout(function(){lib.alpha(e,false,i)},5);
            }
        }
    }
}

lib.openerlink = [];
lib.changelink = function(e){
    var o = e == null ? document.getElementsByTagName("a") : lib.$(e).getElementsByTagName("a");
    if(o.length>0){
        var r = /(.*?)content\.aspx\?/;
        for(var i=0;i<o.length;i++){
            if(r.test(o[i].href)==true){
                if(office["弹出窗口"]==true){
                    o[i].target = "_self";
                    var index = lib.openerlink.length;
                    lib.openerlink[index] = o[i].href;
                    lib.openerlink[index] = lib.openerlink[index].replace(/style\=\.file/g,"");
                    o[i].href = "javascript:lib.openlink(" + index + ");";
                }else{
                    o[i].href = o[i].href.replace(/style\=\.file/g,"");
                    o[i].target = "contentconnect";
                    o[i].onclick = function(){
                        if(lib.$("MediaPointPlayer")!=null) try{lib.$("MediaPointPlayer").controls.pause()}catch(e){};
                    }
                }
            }
        }
    }
}

lib.openlink = function(e){
    var linker = window.open(lib.openerlink[e],"contentconnect"); linker.focus();
    if(lib.$("MediaPointPlayer")!=null) try{lib.$("MediaPointPlayer").controls.pause()}catch(e){};
}

lib.openwurl = function(url){
    var linker = window.open(url,"contentconnect"); linker.focus();
    if(lib.$("MediaPointPlayer")!=null) try{lib.$("MediaPointPlayer").controls.pause()}catch(e){};
}

lib.directurl = function(url,target){
    try{
        var e = lib.$("fordirectconnection");
        if(e==null){
            e = document.createElement("a");
            e.id = "fordirectconnection";
            document.body.appendChild(e);
        }
        if(url.substring(0,1)=="$"){
            e.href = url.substring(1,url.length);
            e.target = target || "_blank";
        }else{
            e.href = url;
            e.target = target || "_self";
        }
        e.click();
    }catch(err){
        try{
            if(url.substring(0,1)=="$"){
                window.open(url.substring(1,url.length));
            }else{
                window.location.href(url);
            }
        }catch(err1){
            window.location.href(url);
        }
    }
}

lib.openpaper = function(date){
    if(lib.$("inpaper")!=null){
        var y = date.replace(/(\d+)\-(\d+)\-(\d+)(.*)/g,"$1");
        var m = date.replace(/(\d+)\-(\d+)\-(\d+)(.*)/g,"$2");
        var d = date.replace(/(\d+)\-(\d+)\-(\d+)(.*)/g,"$3");
        if(m.length==1) m = "0" + m; if(d.length==1) d = "0" + d;
        var eurl = lib.ori + "epaper.aspx?y=" + y + "&m=" + m + "&d=" + d + "&f=node_2.htm";
        lib.$("inpaper").src = eurl;
    }
}

lib.papererror = function(){
    if(lib.$("inpaper")!=null){
        lib.$("inpaper").src = lib.ori + "error.html";
    }
}

lib.findinit = function(){
    if(lib.$("defaultkeyword")!=null){
        lib.$("defaultkeyword").onfocus = function(){
            if(this.value=="关键字") this.value = "";
        }
        lib.$("defaultkeyword").onblur = function(){
            if(this.value=="") this.value = "关键字";
        }
    }
    if(lib.$("mediakeyword")!=null){
        lib.$("mediakeyword").onfocus = function(){
            if(this.value=="关键字") this.value = "";
        }
        lib.$("mediakeyword").onblur = function(){
            if(this.value=="") this.value = "关键字";
        }
    }
    if(lib.$("tulibChar1")!=null){
        lib.$("tulibChar1").options.add(new Option("所有户型",""));
        var o = office["宜居频道"]["居室空间"];
        for(var i=0;i<o.length;i++){
            lib.$("tulibChar1").options.add(new Option(o[i],o[i]));
        }
    }
    if(lib.$("tulibChar2")!=null){
        lib.$("tulibChar2").options.add(new Option("所有小区",""));
        var o = office["宜居频道"]["所在小区"];
        for(var i=0;i<o.length;i++){
            lib.$("tulibChar2").options.add(new Option(o[i],o[i]));
        }
    }
    if(lib.$("titleChannel")!=null){
        lib.$("titleChannel").options.add(new Option("宜居频道","1"));
        lib.$("titleChannel").options.add(new Option("所有频道","0"));
        lib.$("titleChannel").onchange = function(){
            if(lib.$("labelChannel")!=null){
                if(this.value=="1"){
                    lib.enabled([["labelChannel",true]]);
                    if(lib.$("labelibrary")!=null){
                        lib.$("labelibrary").action = lib.ori + "channel.aspx";
                    }
                }else{
                    lib.enabled([["labelChannel",false]]);
                    if(lib.$("labelibrary")!=null){
                        lib.$("labelibrary").action = lib.ori + "default.aspx";
                    }
                }
            }
        }
    }
    if(lib.$("labelChannel")!=null){
        for(var i=0;i<iChannel.length;i++){
            var r = iChannel[i];
            if(r.Model!=""&&r.Model!="兼容频道"&&(r.Connect==""||r.Connect=="#")){
                lib.$("labelChannel").options.add(new Option(r.Name,r.Id));
            }
        }
        lib.$("labelChannel").onchange = function(){
            if(this.value=="24"&&lib.$("tfb_eval_0")!=null){
                try{
                    this.selectedIndex = 0;
                    lib.$("tfb_eval_0").click();
                }catch(e){}
            }
        }
    }
}

lib.charenlarge = function(o,t){
    if(o==""){
        lib.enabled([["mediaPhrase1",false]]);
        lib.$("mediaPhrase1").style.display = "none";
        lib.$("mediaEvent1").style.display = "none";
    }else{
        lib.$("mediaPhrase1").style.display = "block";
        lib.$("mediaEvent1").style.display = "block";
        lib.$("mediaEvent1").title = "点击弃用该关键字";
        lib.$("mediaEvent1").onclick = function(){
            if(this.className=="ond"){
                this.className = "out";
                this.title = "点击续用该关键字";
                lib.enabled([["mediaPhrase1",false]]);
            }else{
                this.className = "ond";
                this.title = "点击弃用该关键字";
                lib.enabled([["mediaPhrase1",true]]);
            }
        }
    }
    if(t==""){
        lib.enabled([["mediaPhrase2",false]]);
        lib.$("mediaPhrase2").style.display = "none";
        lib.$("mediaEvent2").style.display = "none";
    }else{
        lib.$("mediaPhrase2").style.display = "block";
        lib.$("mediaEvent2").style.display = "block";
        lib.$("mediaEvent2").title = "点击弃用该关键字";
        lib.$("mediaEvent2").onclick = function(){
            if(this.className=="ond"){
                this.className = "out";
                this.title = "点击续用该关键字";
                lib.enabled([["mediaPhrase2",false]]);
            }else{
                this.className = "ond";
                this.title = "点击弃用该关键字";
                lib.enabled([["mediaPhrase2",true]]);
            }
        }
    }
    if(o==""&&t==""){
        lib.$("mediakeyword").className = "inp";
    }else{
        lib.$("mediakeyword").className = "key";
    }
}

lib.charlibrary = function(){
    if(lib.$("charlibrary")!=null&&office["热门搜索"]!=null){
        var charlibraryhtml = "&nbsp;热门搜索:&nbsp;";
        for(var i=0;i<office["热门搜索"].length;i++){
            charlibraryhtml += "&nbsp;<a href='#' onclick='lib.charinitial(this);return false;'>" + office["热门搜索"][i] + "</a>&nbsp;";
        }
        lib.$("charlibrary").innerHTML = charlibraryhtml;
    }
}
lib.charinitial = function(e){
    if(lib.$("defaultkeyword")!=null){
        lib.$("defaultkeyword").value = e.innerText;
        if(lib.$("defaultlibrary")!=null){
            lib.$("defaultlibrary").submit();
        }
    }
}

lib.meteorological = function(e){
    if(e.length>2){
        var chars = "&nbsp;<a href='http://weather.tq121.com.cn/detail.php?city=%C8%F0%B0%B2' target='_blank'>";
            chars += "瑞安天气</a>&nbsp;" + e[2] + "&nbsp;" + e[0] + "&nbsp;温度" + e[1];
        lib.$("meteorological").innerHTML = chars;
    }else{
        lib.$("meteorological").innerHTML = "<font color='red'>&nbsp;远程服务器连接失败.无法加载天气信息!</font>";
    }
}

lib.blanklink = function(e){
    var url = e.url == null ? "" : e.url;
    if(url!=""&&url!="#"&&url!="$Channel.Connect$"&&url!="$[Channel.Connect]$"&&url!=lib.ori+"default.aspx"){
        e.target = "_blank";
    }
}

lib.encrypt = function(t){
    return escape(t);
}

lib.currently = [];
lib.imagepoint = function(id,file,edit,theme){
    var ori = file || "channel.aspx";
    var url = lib.ori + ori + "?style=";
    if(theme==null){
        url += "popular";
    }else{
        url += theme;
    }
    if(edit!=null&&lib.currently[2]!=null){
        url += "&id=" + lib.currently[2];
    }else{
        if(id!=null){ if(id!=""&&id!="0"){ url += "&id=" + id} };
    }
    if(lib.currently[0]!=null) url += "&model=" + lib.currently[0];
    if(lib.currently[1]!=null) url += "&parent=" + lib.currently[1];
    var ajax = new lib.ajax(url + "&euid=" + lib.euid);
        ajax.collect = function(r){
            eval(r.responseText);
        }
        ajax.connect();
}

lib.mediapoint = function(o,w,h){
    lib.$("mediatitle").innerHTML = "&nbsp;<a href='" + office[o]["直播链接"] + "'>" + office[o]["直播标题"] + "</a>";
    lib.$("medialabel").innerHTML = office[o]["直播简介"];
    lib.media("mediapoint",office[o]["直播视频"],w,h,0,"none","MediaPointPlayer");
}

lib.comment = function(c,n,u,t,w,h,l){
    var editor = new FCKeditor(c);
        editor.BasePath = lib.ori + "support/";
        editor.ToolbarSet = t || "Basic";
        editor.FileManager = l || "";
        editor.Width = w || "100%";
        editor.Height = h || "120";
        editor.ReplaceTextarea();
    if(n!=null){
        if(lib.$(n)!=null){
            if(u=="") u = "游客";
            if(u=="$[Company.Company]$") u = "游客";
            lib.$(n).value = u;
        }
    }
    lib.clearcomment = function(){
        FCKeditorAPI.GetInstance(c).SetHTML("");
    }
}
lib.clearcomment = function(){}

lib.commentlink = function(id){
    window.open(lib.ori + "content.aspx?style=comment&id=" + id);
}

lib.checkblogurl = function(e){
    if(e.url!=''&&!/\$(.*?)\$/.test(e.url)){
        //e.style.cursor = "hand";
        e.title = "进入该设计师的博客";
        e.style.filter='alpha(opacity=100)';
        e.onmouseover = function(){
            e.style.filter='alpha(opacity=100)';
        }
        e.onmouseout = function(){
            e.style.filter='alpha(opacity=50)';
        }
        e.innerHTML = "<a href='" + e.url + "' target='_blank'></a>";
    }
}

lib.charlight = function(o,oo,ooo){
    var t = lib.$("charlight").innerHTML;
    var d = false;
    if(o!=null){
        if(o.length>0){
            d = true;
            var key = o.replace(/\%/g," ").replace(/\+/g," ").split(" "); 
            var t = lib.$("charlight").innerHTML;
            for (var i=0; i<key.length; i++) { 
                var r = eval("/" + key[i] + "/g");
                t = t.replace(r,"<span style='color:#ff0000;font-weight:bold;'>" + key[i] + "</span>");
            }
        }
    }
    if(oo!=null){
        if(oo.length>0){
            d = true;
            var key = oo.replace(/\%/g," ").replace(/\+/g," ").split(" "); 
            for (var i=0; i<key.length; i++) { 
                var r = eval("/" + key[i] + "/g");
                t = t.replace(r,"<span style='color:#ff8000;font-weight:bold;'>" + key[i] + "</span>");
            }
        }
    }
    if(ooo!=null){
        if(ooo.length>0){
            d = true;
            var key = ooo.replace(/\%/g," ").replace(/\+/g," ").split(" "); 
            for (var i=0; i<key.length; i++) { 
                var r = eval("/" + key[i] + "/g");
                t = t.replace(r,"<span style='color:#88b500;font-weight:bold;'>" + key[i] + "</span>");
            }
        }
    }
    if(d==true) lib.$("charlight").innerHTML = t;
}

lib.defaultlinkInnerText = function(t,h){
    lib.load(function(){
        if(lib.$("defaultconnect")!=null){
            if(h!=null){
                lib.$("defaultconnect").innerHTML = "<font color='#ff0000;'>" + t + "</font>";
            }else{
                lib.$("defaultconnect").innerHTML = t;
            }
        }
    });
}

lib.childChannelink = function(url,txt,hot,ope){
    lib.load(function(){
        if(lib.$("childchannelink")!=null){
            if(ope!=null){
                if(ope==true){
                    ope = " target='_blank'";
                }else{
                    ope = "";
                }
            }else{
                ope = "";
            }
            if(hot!=null){
                if(hot==true){
                    lib.$("childchannelink").innerHTML += "|&nbsp;<span><a href='" + url + "'" + ope + "><font color='#ff0000;'>" + txt + "</font></a></span>";
                }else{
                    lib.$("childchannelink").innerHTML += "|&nbsp;<span><a href='" + url + "'" + ope + ">" + txt + "</a></span>";
                }
            }else{
                lib.$("childchannelink").innerHTML += "|&nbsp;<span><a href='" + url + "'" + ope + ">" + txt + "</a></span>";
            }
        }
    });
}

lib.blogcaption = function(el,fb,cp,co){
    if(fb==""||/\$(.*?)\$/.test(fb)){
        if(cp==""||/\$(.*?)\$/.test(cp)){
            fb = co + "的博客";
        }else{
            fb = cp + "的博客";
        }
    }
    lib.$(el).innerHTML = fb;
}

lib.connectInitial = function(){
    if(lib.$("meteorological")!=null){
        var ajax = new lib.ajax(lib.ori + "weather.aspx?" + lib.euid);
        ajax.collect = function(r){
            try{eval(r.responseText)}catch(e){}
        }
        ajax.connect();
    }
    if(lib.$("inpaper")!=null){
        var ajax = new lib.ajax(lib.ori + "epurl.aspx?" + lib.euid);
        ajax.collect = function(r){
            try{eval(r.responseText)}catch(e){}
        }
        ajax.connect();
    }
}

lib.load(function(){
    lib.changelink();
    lib.findinit();
    lib.charlibrary();
    setTimeout("lib.connectInitial()",500);
    //lib.alpha();
});



