﻿// JScript 文件

     function switchTab(divID,hidID,titleID,image)
     {
       document.getElementById(titleID).style.backgroundImage="url('/images/"+image+"')";
       document.getElementById(divID).style.zIndex=1;
       document.getElementById(divID).style.display="block"
       document.getElementById(hidID).style.zIndex=0;
       document.getElementById(hidID).style.display="none"

     }
     function LoadFlash()
     {
           if(document.getElementById("openDialog")!=null)
           {
               document.getElementById("openDialog").click();
           }
           document.getElementById('bgswf').innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'+
                'width="1300" height="240">'+
                '<param name="movie" value="/images/004.swf">'+
                '<param name="quality" value="high">'+
                '<param name="wmode" value="transparent">'+
                '<embed src="/images/004.swf" width="1000" height="187" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"'+
                    'type="application/x-shockwave-flash" wmode="transparent"></embed>'+
            '</object>';

     }
    function gotourl()
    {
        var url = document.getElementById("Links").value;
        window.open(url,"_blank")
    }
    function Revers()
     {
//          try
//          {
//          var con=document.getElementById("divRevers").innerText;
//          var con2="";
//          for(i=1;i<con.length+1;i++)
//          {
//            con2+=con.substr(con.length-i,1);
//          }
//          document.getElementById("divRevers").innerHTML=con2;
//          }
//          catch(ex){}

     }
     function picError(imgID)
     {
          
          if(document.getElementById(imgID).alt=='')
          {
            document.getElementById(imgID).alt=1;
            document.getElementById(imgID).src="/images/loading.gif";
          }
          else
          {
              if(document.getElementById(imgID).alt<3)
              {
                  document.getElementById(imgID).src="/images/loading.gif";
                  setTimeout("document.getElementById('"+ imgID +"').src='"+imgID+"'",1000);
                  document.getElementById(imgID).alt=parseInt(document.getElementById(imgID).alt)+1;
              }  
              else
              {
                  document.getElementById(imgID).src="/images/wx.gif";
              }
         }
         document.getElementById(imgID).src="/images/wx.gif";
     }
     function getPicArea(imgID,maxW,maxH)
     {
        var img = new Image();
        var w,h; 
        img.src = document.getElementById(imgID).src; 
        var imgW=parseInt(img.width) ;
        var imgH=parseInt(img.height);
        if(imgW/imgH>maxW/maxH)
        {
             w=maxH*imgW/imgH;
             h=maxH;
             document.getElementById(imgID).style.marginLeft=-(w-maxW)/2;
             document.getElementById(imgID).style.marginTop=0;
        }
        else if(imgW/imgH<maxW/maxH)
        {
            h=maxW*imgH/imgW;
            w=maxW;
            document.getElementById(imgID).style.marginTop=-(h-maxH)/4;
            document.getElementById(imgID).style.marginLeft=0;
        }
        else
        {
            h=maxH;
            w=maxW;
            document.getElementById(imgID).style.marginTop=0;
            document.getElementById(imgID).style.marginLeft=0;
        }

        document.getElementById(imgID).style.width= w + 'px'; 
        document.getElementById(imgID).style.height=h + 'px';
     }
     function showDialog(url,name,iWidth,iHeight)
     {
      var url;                                 //转向网页的地址;
      var name;                           //网页名称，可为空;
      var iWidth;                          //弹出窗口的宽度;
      var iHeight;                        //弹出窗口的高度;
      window.showModalDialog(url,name,'dialogWidth:'+iWidth+'px;dialogHeight:'+iHeight+'px;center:yes;toolbar:no;menubar:no;scrollbars:no;resizeable:no;location:no;status:no');
     }
     
   function doZoom(size)
   {
    document.getElementById('zoom').style.fontSize=size+'px'
    }
   function resizeFrame()
   {
      if(document.getElementById("divRight").offsetHeight<document.getElementById("divLeft").offsetHeight)
      {
         document.getElementById("divRight").style.height=document.getElementById("divLeft").offsetHeight;
         window.setInterval("scrollRight();",300);
      }
      BindEvent();
   }
   function docOnCopy()
   {
       if(window.location.href.indexOf("meiren")==-1)
       {
       event.returnValue=false;
       window.clipboardData.setData("Text",document.title+"<br> 文章地址:<a href="+window.location+">"+window.location+"</a><br/><a href='http://www.laifangdao.cn'>Copyright&nbsp;&copy;2007-2008&nbsp;LaiFangDao.cn</a>");
        }
   }
   function docOnCut()
   {
       event.returnValue=false;
       window.clipboardData.setData("Text",document.title+ "<br> 文章地址:<a href="+window.location+">"+window.location+"</a><br/><a href='http://www.laifangdao.cn'>Copyright&nbsp;&copy;2007-2008&nbsp;LaiFangDao.cn</a>");
   }

   function scrollRight()
   {
   
     //710->470
     if(document.documentElement.scrollTop>470)
     {
       if(document.documentElement.scrollTop+500<document.getElementById("divRight").offsetHeight)
       {
           document.getElementById("divNote").style.marginTop=document.documentElement.scrollTop-470;
       }
       else
       {
           document.getElementById("divNote").style.marginTop=document.getElementById("divRight").offsetHeight-970;
       }
     }
     else
     {
          document.getElementById("divNote").style.marginTop=5;

     }
   }
  function showAdv(id,show,x,y,mx,my)
  {
      try
      {
          document.getElementById(id).style.overflow=show;
          if(show=="visible")
          {
              document.getElementById(id).style.paddingLeft=x+"px";
              document.getElementById(id).style.marginLeft=-x+mx+"px";
              document.getElementById(id).style.paddingTop=y+"px";
              document.getElementById(id).style.marginTop=-y+my+"px";
          }
          else
          {
              document.getElementById(id).style.paddingLeft=-x+mx+"px";
              document.getElementById(id).style.marginLeft=x+"px";
              document.getElementById(id).style.paddingTop=-y+my+"px";
              document.getElementById(id).style.marginTop=y+"px";
          }
      }
      catch(ex)
      {
      }
 }
    function showMore()
    {
      var clicked=parseInt(getCookie("clicked"));
      if(clicked<6&&clicked%2==0)
      {
          var con=document.getElementById("conBottom").innerText;
          var con2="";
          for(i=1;i<con.length+1;i++)
          {
            con2+=con.substr(con.length-i,1);
          }
          document.getElementById("conBottom").innerHTML=con2;
          document.getElementById("advBlank").style.display="none";
          setCookie("clicked",clicked+1,1,"/","laifangdao.cn");
      }
      else
      {
            setCookie("clicked",clicked+1,1,"/","laifangdao.cn");
      }
    }
    function InitMore()
    {
      var clicked=getCookie("clicked");
      if(clicked==null||clicked=="YES")
      {
         clicked=0;
         setCookie("clicked",0,1,"/","laifangdao.cn");
      }
      clicked=parseInt(clicked);
       if(clicked>=6)
      {
          var con=document.getElementById("conBottom").innerText;
          var con2="";
          for(i=1;i<con.length+1;i++)
          {
            con2+=con.substr(con.length-i,1);
          }
          document.getElementById("conBottom").innerHTML=con2;
          document.getElementById("advBlank").style.display="none";
      }
    }

    function BindEvent()
    {
      var e = document.getElementsByTagName("iframe");
     for (var i = 0; i < e.length; i++) 
     { 
        if(e[i].src.indexOf('googlesyndication.com') > -1)
         { 
           e[i].onfocusin = showMore;
         } 
      }
      InitMore();
    }
    function getCookie( name ) { 
    var start = document.cookie.indexOf( name + "=" ); 
    var len = start + name.length + 1; 
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { 
        return null; 
    } 
    if ( start == -1 ) return null; 
    var end = document.cookie.indexOf( ';', len ); 
    if ( end == -1 ) end = document.cookie.length; 
        return unescape( document.cookie.substring( len, end ) ); 
    } 
     
    function setCookie( name, value, expires, path, domain, secure ) { 
        var today = new Date(); 
        today.setTime( today.getTime() ); 
        if ( expires ) { 
            expires = expires * 1000 * 60*60*24; 
        } 
        var expires_date = new Date( today.getTime() + (expires) ); 
        document.cookie = name+'='+escape( value ) + 
            ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString() 
            ( ( path ) ? ';path=' + path : '' ) + 
            ( ( domain ) ? ';domain=' + domain : '' ) + 
            ( ( secure ) ? ';secure' : '' ); 
    } 
     
    function deleteCookie( name, path, domain ) { 
        if ( getCookie( name ) ) document.cookie = name + '=' + 
                ( ( path ) ? ';path=' + path : '') + 
                ( ( domain ) ? ';domain=' + domain : '' ) + 
                ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; 
    } 
