﻿function $(obj) {return document.getElementById(obj);}
function Ob(obj){return $(obj);}

function SetViewStatSpan(val,field)
{
    try{
        if(field=="Clicks"&&$("ClickSpan")!=null)
        {
            $("ClickSpan").innerHTML = val ;
        }
        
        if(field=="Views"&&$("ViewsSpan")!=null)
        {
            $("ViewsSpan").innerHTML = val ;
        }
    }catch(e)
    {
        alert(e);
    }
}

function ShowContactView(id,divid)
{
    Ob(HideContactDiv).className = "show";
    Ob(SelfLinkDiv).className = "hide";
    Ob("ViewsSpan").innerHTML = parseInt(Ob("ViewsSpan").innerHTML) + 1;
    
    var ajaxGetView = "http://news.sz5.cn/app/ajaxstat.aspx?p=" + id + "_4_1_2_2"; //更新浏览次数
    //window.open(ajaxGetView);
    var VS = Ob("ViewsSpan");
    var d = document.createElement("DIV");
    var htmlstr = "<iframe style='display:none;' src='"+ ajaxGetView +"'></iframe>";
    d.innerHTML = htmlstr ;
    document.appendChild(d);
}

var timerID;

function SetCopyRights()
{
    var divcp = $("copyright");
    
    if(typeof(divcp) =="undefined") return ;
    if(typeof(cID) =="undefined") return;
    if(typeof(cFromUrl) =="undefined") return;
    var cDomain = cFromUrl ;
    if(cFromUrl.indexOf('http://')!=-1)
    {
     var turl = cFromUrl.substr(7);
     if(turl.indexOf('/')!=-1)
        cDomain= "http://" + turl.substr(0,turl.indexOf('/'));
    }
    var str = "<span style='font-size:12px;'>本文来源：<a href='"+ cDomain +"' target=_blank>"+ cDomain +"</a> ";
    str = str + " <br /> <span style='color:red;'>如您发现此文系侵犯版权、隐私、谣言或非法信息等，请 <a href='javascript:DelContent("+ cID +")'>(点此删除)</a></span></span>";
    divcp.innerHTML = str;
    
    if(timerID!=null)
    {
        window.clearInterval(timerID);
    }
}

function DelContent(id)
{
    var d = document.createElement("DIV");
    var htmlstr = "<iframe style='display:none;' src='"+ location.href +"?IsExpired=1'></iframe>";
    d.innerHTML = htmlstr ;
    document.appendChild(d);
    
    window.setTimeout("location.href='/';",3000);
}

/**********设置广告*********/

//var bannerTID = window.setInterval("SetContentAd()",500);
var bannerAdScript = "";

//window.setTimeout("SetContentAd()",1000);

function SetContentAd()
{
    //ChgHTML("TopBannerAdDiv","PreBannerID");
    //ChgHTML("ContentTopIncDiv","PreContentTopID");
    //ChgHTML("ContentMiddleIncDiv","PreContentMiddleID");
    //ChgHTML("ContentBottomIncDiv","PreContentBottomID");
    ChgHTML("ContentRightTopIncDiv","PreContentRTopID");
    ChgHTML("ContentRightBottomIncDiv","PreContentRBottomID");
}

function ChgHTML(idshow,idpre)
{
    var ShowDiv = $(idshow);
    var PreDiv = $(idpre);
    if(ShowDiv!=null&&PreDiv!=null)
    {
        ShowDiv.innerHTML = PreDiv.innerHTML;
        PreDiv.innerHTML = "";
    }
}

if (document.readyState=="complete")
{
        SetContentAd();
}
else
{
    document.onreadystatechange = function()
    {
        if (document.readyState == "complete")
        {
                SetContentAd();
        }
    }
}

/*
<div id="AdPreLoadDiv">
    //<div id="PreBannerID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreBannerID"></script></div>
    <div id="PreContentTopID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentTopID"></script></div>
    <div id="PreContentTopID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentTopID"></script></div>
    <div id="PreContentMiddleID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentMiddleID"></script></div>    
    <div id="PreContentBottomID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentBottomID"></script></div>
    <div id="PreContentRTopID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentRTopID"></script></div>
    <div id="PreContentRBottomID"><script language="javascript" src="http://app.zman.cn/app/GGAdJS.aspx?AdCode=PreContentRBottomID"></script></div>
</div>
*/

/*****************************吟唱 i *************************************/

/*对IE意外的浏览器，不支持的，创建 createStyleSheet 函数*/
if(typeof document.createStyleSheet === 'undefined') 
{
    document.createStyleSheet = (function() {
      function createStyleSheet() {
        var element = document.createElement('style');
        element.type = 'text/css';
        document.getElementsByTagName('head')[0].appendChild(element);
        var sheet = document.styleSheets[document.styleSheets.length - 1];
        if(typeof sheet.addRule === 'undefined')
          sheet.addRule = function(selectorText, cssText, index) {
            if(typeof index === 'undefined')
              index = this.cssRules.length;
            this.insertRule(selectorText + ' {' + cssText + '}', index);
          };
        return sheet;
      }
      return createStyleSheet;
    })();
}

function CreateITagStyle()
{
    try
    {
        var sheet = document.createStyleSheet();
        sheet.addRule("i","display:none;");
    }
    catch(e)
    {alert(e);}
}

var isHideITag =false ;
function HideITag()
{
    if(isHideITag == true) { return ;}
    CreateITagStyle();
	//document.getElementById("btndiv").style.display = "none";
	isHideITag = true ;
}


function CreateHideButton()
{
    var btndiv = document.createElement("div");
    btndiv.id = "btndiv";
    btndiv.innerHTML = "<div class='btndiv'><input type='button' id='hidebtn' class='btnhide' value='点我显示正常内容' onclick='HideITag();' /></div>";
    document.body.appendChild(btndiv);
    var lef = (document.body.scrollWidth/2) - 150;
    document.getElementById("btndiv").style.left = parseInt(lef)+"px";
}

function CreateHideDiv()
{
    var divpage = document.getElementById("page");
    if(typeof(divpage)=="undefined")
    {
        //CreateHideButton();
        window.setTimeout("CreateHideDiv();",500);
        return;
    }
    divpage.attachEvent('onmousemove',HideITag);
}

window.setTimeout("CreateHideDiv();",500);

//window.setTimeout("eval(\"window.attachEvent('onresize',HideITag);\")",300);
//window.setTimeout("eval(\"window.document.body.attachEvent('onmousemove',HideITag);\")",500);
//window.setTimeout("eval(\"window.onresize = HideITag;\")",300);
//window.setTimeout("eval(\"window.document.body.onmousemove = HideITag;\")",500);