﻿function copyToClipboard(txt) 
{
     if(window.clipboardData) 
     {
         window.clipboardData.clearData();
         window.clipboardData.setData("Text", txt);
     } 
     else if(navigator.userAgent.indexOf("Opera") != -1) 
     {
          window.location = txt;
     }
     else if (window.netscape) 
     {
          try 
          {
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          } 
          catch (e) 
          {
               alert("你使用的FF浏览器,复制功能被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");
          }
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var str = new Object();
          var len = new Object();
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = txt;
          str.data = copytext;
          trans.setTransferData("text/unicode",str,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
     }
     alert(" 下面的信息复制到剪贴板 :\n\n" + txt);
}

function CopyUrl()//复制url
{
    var url=document.URL;//当前页的url
    copyToClipboard(url);
}

function addCookie()
{
    if (document.all)
    {
        window.external.addFavorite('http://www.syinfo.com.cn','沈阳房产信息网');
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel('沈阳房产信息网', 'http://www.syinfo.com.cn', "");
    }
}

function setHomepage()
{
    if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage('http://www.syinfo.com.cn');

    }
    else if (window.sidebar)
    {
        if(window.netscape)
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e)
            {
                alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage','http://www.syinfo.com.cn');
    }
}

Date.prototype.pattern=function(fmt) {        
    var o = {        
    "M+" : this.getMonth()+1, //月份        
    "d+" : this.getDate(), //日        
    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时        
    "H+" : this.getHours(), //小时        
    "m+" : this.getMinutes(), //分        
    "s+" : this.getSeconds(), //秒        
    "q+" : Math.floor((this.getMonth()+3)/3), //季度        
    "S" : this.getMilliseconds() //毫秒        
    };        
    var week = {        
    "0" : "\u65e5",        
    "1" : "\u4e00",        
    "2" : "\u4e8c",        
    "3" : "\u4e09",        
    "4" : "\u56db",        
    "5" : "\u4e94",        
    "6" : "\u516d"       
    };        
    if(/(y+)/.test(fmt)){        
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));        
    }        
    if(/(E+)/.test(fmt)){        
        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "\u661f\u671f" : "\u5468") : "")+week[this.getDay()+""]);        
    }        
    for(var k in o){        
        if(new RegExp("("+ k +")").test(fmt)){        
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));        
        }        
    }        
    return fmt;        
}      

function Issue(type,id,objtype)
{
    var islogin=getCookie("IsLogin");
    var comeurl=document.URL;
    if(islogin!=null&&islogin!="")
    {
        var url="";
        switch(type)
        {
            case 1:
                url="issue/house/add.aspx";
                break;
            case 2:
                url="issue/house/add.aspx?selltype=1";
                break;
            case 3:
                url="issue/demands/add.aspx?detype=2";
                break;
            case 4:
                url="issue/demands/add.aspx";
                break;
            case 5:
                url="issue/bighouse/add.aspx";
                break;
            case 6://门市
                url="issue/otherhouse/add.aspx";
                break;
            case 7://厂房
                url="issue/workshop/add.aspx";
                break;          
            case 8://求租求购门市
                url="issue/otherhouse/add.aspx?type=1";
                break;
            case 9://求租求购厂房
                url="issue/workshop/add.aspx?type=1";
                break;          
        }
        url="http://www.syinfo.com.cn/"+url;
        if(id!=null&&id!=0)
        {
            if(objtype==null)
            {
                var uchar=(url.indexOf("?")>0?"&":"?");
                url+=uchar+"stageid="+id;
            }
            else if(objtype==1)
            {
                var uchar=(url.indexOf("?")>0?"&":"?");
                url+=uchar+"subzoneid="+id;
            }
        }
        window.open(url);
    }
    else
    {
        setSession(type,objtype,id);
        var loginurl=RootInfo+"user/login.aspx";
        window.open(loginurl);
    }
    return false;
}

function setSession(type,objtype,id)
{
    id=(id)?id:0;
    objtype=(objtype)?objtype:0;
    var para="type=111&ispost=1&issuetype="+type+"&objtype="+objtype+"&objid="+id+"&time="+new Date().toTimeString();
    AjaxMethod(RootInfo+"inc/Ajax.aspx",para,"GET",Null);
}

function Null(obj)
{
    obj=null;
    delete obj;
}

function getEvent() //同时兼容ie和ff的写法
{  
    if(document.all)   
    {
        return window.event;     //如果是IE，直接返回大家熟悉的event
    }
    func=getEvent.caller;  // getEvent为函数名

    //一直循环判断有没有拿到事件，没有再找上一个Caller，知道找到事件（对应IE的event） 

    while(func!=null)
    {  
        var arg0=func.arguments[0];
        if(arg0)
        {
            if((arg0.constructor==Event  || arg0.constructor ==MouseEvent)  || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) //判断是不是事件绿色部分为事件名，具体情况具体分析，比如键盘事件就是KeybroadEvent
            {  
                return arg0; //返回事件
            }
        }
        func=func.caller; //上一个Caller
    }
    return null;
}

/*startList = function() 
{
    quickRoot = document.getElementById("quick").getElementsByTagName("li");
    for (i=0; i<quickRoot.length; i++) 
    {
        node = quickRoot[i];

        node.onmouseover=function() 
        {
            this.setAttribute("class","over");
            this.setAttribute("className","over");
        }
        node.onmouseout=function() 
        {
            this.setAttribute("class","");
            this.setAttribute("className","");
        }
    }
}
window.onload=startList;*/

function ulMover()
{
    var obj=document.getElementById("ul_issue");
    obj.style.display="block";
}

function ulMout()
{
    var obj=document.getElementById("ul_issue");
    obj.style.display="none";
}