﻿// JScript 文件
//添加当前页到网络收藏夹中
    function addtoNetFavorite(path){
        javascript:d=document;
        t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');
         void(vivi=window.open(path+'eFav/addTo.aspx?title='+escape(d.title)+'&amp;url='+escape(d.location.href)+'&amp;info='+escape(t),'PostBookmark','scrollbars=no,width=480,height=420,left=75,top=20,status=no,resizable=yes'));
        //vivi.focus();
    }
	/*发送给好友 */
    function doSendToFriend(path){
        javascript:d=document;
        t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');
         void(vivi=window.open(path+'msg/sendTo.aspx?title='+escape(d.title)+'&amp;url='+escape(d.location.href)+'&amp;info='+escape(t),'PostBookmark','scrollbars=no,width=480,height=420,left=75,top=20,status=no,resizable=yes'));
       // vivi.focus();
    }

    //放大、缩小正文
 	function doZoom(size){
		document.getElementById('PrintContent').style.fontSize=size+'px'
	setTailPosition()
	}
    //打印正文
	function doPrint(){
	var str="<html>";
	var article;
	var css;
	var strAdBegin="<!--NewsAd_BEGIN-->";
	var strAdEnd="<!--NewsAd_END-->";
	var strFontSize='【<A href="javascript:doZoom(16)">大</A> <A href="javascript:doZoom(14)">中</A> <A href="javascript:doZoom(12)">小</A>】'
	//var strdoPrint="doPrint()";
	var strTmp;
	
		css="<style>"
		+"body{font-family:宋体}"
		+"td,.f12{font-size:12px;line-height:22px;}"
		+"img{border:1px;}"
		+".f24 {font-size:24px;}"
		+".f14 {font-size:14px;}"
		+".title14 {font-size:14px;line-height:130%}"
		+".l17 {line-height:170%;}"
		+".title {line-height:170%;font-size:16px;}"
		+"caption {width:100%;}"
		+".fullTable {width:100%;}"
		+".artClass {clear:both;padding:1px; height:14px;}"
        +".artClass span{float:right; color:#838383;}"
        +".artClass h4{font-size:14px; float:left; font-weight:200; padding:1px 2px 1px 10px; color:#000; font-weight:bolder;color:#003E7B;}"
        +".artClassList{ clear:both; margin:0px 2px 1px; padding:3px; background-color:#ffffff; border:1px solid  #ADCCDA; }"
        +".inputLabel{font-weight:bolder;}" 
        +"CAPTION{font-weight:bolder;line-height:170%;}" 
		+"hr {height:1px;}"
		+".content {font-size: 14px;text-align:left;text-indent:2em;line-height:22px;vertical-align: top;}"
		+".title {font-size: 16px;text-align:center;text-indent:2em;line-height:24px;vertical-align: top;font-weight: bold;}"
		+".subInfo {font-size: 14px;text-align:center;line-height:24px;}"
		+"</style>"
		+"<style media='print'>"
		+".Noprint { DISPLAY: none; FONT-SIZE: 12pt; FONT-FAMILY: '宋体' }"
		+"</style>";
		
		str +=	css;
		
 

		str +=	'<meta http-equiv="content-type" content="text/html; charset=gb2312">';
		str +=	'<title>'+document.title+'</title>';
		str +=	'<script type=\'text/javascript\' src=\'/inc/ArticleView.js\'></script>';
		str +=	"<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
		str +=	"<center><table width=640 border=0 cellspacing=0 cellpadding=0 ><tr><td height=34 width=150></td><td valign=bottom><font color=#0000ff></td><td align=right valign=bottom ><div class='Noprint'><a href='javascript:history.back()'>返回</a>　<a href='javascript:window.print()'>打印</a></div></td></tr></table>";
		str +=	"<table width=640 border=0 cellpadding=0 cellspacing=20 bgcolor=#ffffff><tr><td>";
		//str +=	css;

		article=document.getElementById('PrintContent').innerHTML;
		if(article.indexOf(strAdBegin)!=-1){
			str +=article.substr(0,article.indexOf(strAdBegin));
			strTmp=article.substr(article.indexOf(strAdEnd)+strAdEnd.length, article.length);
		}else{
			strTmp=article
		}
		str +=strTmp
		//str += window.location.href
		str +=	"</td></tr></table></center>";
		str +=	"</body></html>";
		document.write(str);
		document.close();

	}
	
var currentpos,timer;
function initialize(){
	timer=setInterval("scrollwindow()",50);
}
function sc(){
	clearInterval(timer);
}
function scrollwindow(){
	currentpos=document.body.scrollTop;
	window.scroll(0,++currentpos);
	if (currentpos != document.body.scrollTop){
		sc();
	}
}
document.onmousedown=sc
document.ondblclick=initialize
//双击自动滚屏代码结束
function CheckForm()
		{
		if(document.Form1.Name.value=="")
		{
		alert("姓名不能为空！")
		document.Form1.Name.focus()
		  return(false)
	 	 }
	   

   if(document.Form1.content.value=="")
   {
		alert("内容不为空！")
		document.Form1.content.focus()
		  return(false)
	  }
	 }

//友情链接弹出窗口处理
function OpenLinkNew(select){
	if(select.options[select.selectedIndex].value!='') {
 		window.open(select.options[select.selectedIndex].value, '_blank');
	}
}
function OpenLink(select){
	if(select.options[select.selectedIndex].value!='') {
 		window.location=select.options[select.selectedIndex].value;
	}
}
//End

function doSearch() {if (window.RegExp && window.encodeURIComponent)
 {
 var q=encodeURIComponent(document.f1.q.value);
 var sType=encodeURIComponent(document.f1.sType.value);
 var jq;
 
 if (document.f1.jq[1].checked==true){
   jq=encodeURIComponent(1);
    }
    else{jq=encodeURIComponent(0);}
    
document.f1.action="/search.aspx?t=" + sType +"&q="+ q +"&jq="+ jq
document.f1.submit();
//alert( document.f1.action);
}}

//文章搜索
function doArtSearch() {if (window.RegExp && window.encodeURIComponent)
 {
 var title=encodeURIComponent(document.all.title.value);
 var content=encodeURIComponent(document.all.content.value);
 var tagname=encodeURIComponent(document.all.tagname.value);
 var t;
 
 if (document.all.search_type.checked==true){
   t=encodeURIComponent(1);
    }
    else{t=encodeURIComponent(0);}
    
window.open("/Article/search.aspx?t=" + t +"&title="+ title +"&content="+ content +"&tagname="+ tagname ,"搜索" )
}}

//文章搜索
function doArtSearchMe() {if (window.RegExp && window.encodeURIComponent)
 {
 var title=encodeURIComponent(document.all.search_title.value);
 var content=encodeURIComponent(document.all.search_content.value);
 var tagname=encodeURIComponent(document.all.search_tagname.value);
 var t;
 
 if (document.all.search_type.checked==true){
   t=encodeURIComponent(1);
    }
    else{t=encodeURIComponent(0);}
window.open("/Article/search.aspx?t=" + t +"&title="+ title +"&content="+ content +"&tagname="+ tagname ,"搜索" )
window.close();
// 无效？window.location.replace("/Article/search.aspx?t=" + t +"&title="+ title +"&content="+ content +"&tagname="+ tagname )
}}


 function DrawImage(ImgD){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= 680/510){
     if(image.width>680){  
     ImgD.width=680;
     ImgD.height=(image.height*680)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>510){  
     ImgD.height=510;
     ImgD.width=(image.width*510)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt="图片大小:"+image.width+"×"+image.height;
     }
    }
   /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
   } 
   
 function DrawImage(ImgD,wid,bili){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>=bili){
     if(image.width>wid){  
     ImgD.width=wid;
     ImgD.height=(image.height*wid)/image.width;
   }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     //ImgD.alt="aasas"+image.width+"×"+image.height;
     }
    else{
     if(image.height<wid/bili){  
     ImgD.height=wid/bili;
     ImgD.width=(image.width*wid/bili)/image.height;     
    ImgD.width=wid;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt="图片大小:"+image.width+"×"+image.height;
     }
    }
   /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
   } 


 function DrawImageWH(ImgD,wid,hei)
 {
   var image=new Image();
   var bi=wid/hei;
   image.src=ImgD.src;
   var obi=image.width/image.height;
   if (obi>=bi && image.width>wid){
       flag=true;
         ImgD.width=wid;
         ImgD.height=(image.height*wid)/image.width;
       }
    else{
        if (obi<bi && image.height>hei){
        flag=true;
        ImgD.height=hei;
        ImgD.width=(image.width*hei)/image.height;
        } 
     else{
        ImgD.height=image.height;
        ImgD.width=image.width;
        } 
             
    }
    ImgD.alt="图片大小:"+ImgD.width+"×"+ImgD.height;
} 



 function DrawImageW(ImgD,wid)
 {
   var image=new Image();
   image.src=ImgD.src;
   var obi=image.width/image.height;
   if (image.width>wid){
         ImgD.width=wid;
         ImgD.height=(image.height*wid)/image.width;
   }
    ImgD.alt="图片大小:"+image.width+"×"+image.height;
} 


 function DrawImageH(ImgD,hei)
 {
   var image=new Image();
   image.src=ImgD.src;
   var obi=image.width/image.height;
   if (image.height>hei){
         ImgD.height=hei;
         ImgD.height=(image.width*hei)/image.height;
   }
    ImgD.alt="图片大小:"+image.width+"×"+image.height;
} 


function getHitCount(msgID){var req =new ActiveXObject("Microsoft.XMLHTTP"); 
req.open("GET","/GetHits.ashx?type=a&cs=1&ID="+artID.value, true); 
    req.onreadystatechange = function()
{　 
    if (req.readyState == 4) 
        { 　
             if (req.status == 200) 
                 { msgID.innerText = req.responseXML.documentElement.tagName; }
         }
         }
         req.send(null);
  } 
 
/*  检查必填项   如：文章评论*/
function CheckFormNeed(id,msg)
{
if(document.getElementById(id).value=='')
    {
    if (msg=='') msg='必填项不能为空！';
    alert(msg);
    return false;}
    return true;
}
 function imgautozoom(me){
var zoom=parseInt(me.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) me.style.zoom=zoom+'%';return false; 
 }
