﻿// 等比例显示图片
var flag=false; 
function DrawImage(ImgD,nHeight,nWidth){ 
   var image=new Image(); 
       image.src=ImgD.src; 
   if(image.width>0 && image.height>0){ 
      flag=true; 
      if(image.width/image.height>= nWidth/nHeight){ 
         if(image.width>nWidth){ 
           ImgD.width=nWidth; 
           ImgD.height=(image.height*nWidth)/image.width; 
         }else{ 
           ImgD.width=image.width; 
           ImgD.height=image.height; 
         } 
         ImgD.alt=image.width+"x"+image.height; 
      } 
      else{ 
         if(image.height>nHeight){ 
          ImgD.height=nHeight; 
          ImgD.width=(image.width*nHeight)/image.height; 
         }else{ 
          ImgD.width=image.width; 
          ImgD.height=image.height; 
         } 
         ImgD.alt=image.width+"x"+image.height; 
       } 
    } 
} 

function GetImageSize(aImgName) {
   var image=new Image(); 
       image.src=aImgName;
	var nWidth = image.width;
	var nHeight = image.height;
	   
   return ("width:"+nWidth+"px; height:"+nHeight+"px")
}
   
   
   
   
		 // 显示层的函数
		   var topLayer="page_newbook"; // 初始化顶层,此项仅在页面初次装入时作用
		   
		   function showLayer(newTop) {
			   document.all(topLayer).className = "pageHide";
			   document.all(newTop).className = "pageShow";
			   topLayer = newTop;
		   }
		   
		    function showLayer1(newTop,fbtn) {
			   var i,origLength;
			   var origLength = document.all.length;   //隐藏其他层
			   var oDiv=document.getElementById('page_BookSeries');
			   if (oDiv!=null) {
				   oDiv.style.display = 'none';
     			   document.getElementById('btn0').style.backgroundColor = '#FFC';
			   }
			   document.getElementById('page_BookContext').style.display = 'none';
			   document.getElementById('page_BookContent').style.display = 'none';
			   document.getElementById('page_BookDown').style.display = 'none';
			   document.getElementById('page_BookAdvice').style.display = 'none';
			   document.getElementById('btn1').style.backgroundColor = '#FFC';
			   document.getElementById('btn2').style.backgroundColor = '#FFC';
			   document.getElementById('btn3').style.backgroundColor = '#FFC';
			   document.getElementById('btn4').style.backgroundColor = '#FFC';
			   var vDiv = document.getElementById(newTop);
			   if(vDiv!=null){
				   vDiv.style.display = 'block';
			   }
			   var vBtn = document.getElementById(fbtn);
			   if(vBtn!=null){
				   vBtn.style.backgroundColor = '#CCC';
			   }
		   }
		   
		   
			  // 翻页算法
	       function displayCount(aTB,aSelectID,aOpr) {	
		       
			   var i,origLength,nOrd,aNewLayer,vSelect;
			   
			   vSelect = document.getElementById(aSelectID);  //获取 翻页下拉列表框 ID
			   
			   
			   switch (aOpr){    //根据操作符,选择相应操作
				   case '+':   // 向后翻页
				       if (vSelect.selectedIndex<vSelect.length-1)   
						   vSelect.selectedIndex++;					 
				       break;
				   case '-':   //向前翻页
				       if (vSelect.selectedIndex>0) 
						   vSelect.selectedIndex--;					 
				       break;
				   //转到手工指定页
			   }
			   
			   nOrd = vSelect.value;			   
			   aNewLayer = aTB+nOrd+'0';  //aTB&nPageCount&"0			   
			   nOrd = Number(nOrd);  
		
    	
			   origLength = document.all.length;   //隐藏其他层
			   for (i = 0; i < origLength; i++) {
				    if (document.all[i].name==aTB) 
						 document.all[i].style.display = 'none';						
				}
			   var iDiv = document.getElementById(aNewLayer);	//显示当前层		   
			   iDiv.style.display = 'block';	
		   }  
		   	   
		  
	
