//公用 JavaScript 函数
function w(vd)
{
  var ob=document.getElementById(vd);
  if(ob.style.display=="block" || ob.style.display=="")
  {
     ob.style.display="none";
     var ob2=document.getElementById('s'+vd);
    // ob2.className = "mtitle";
  }
  else
  {
    ob.style.display="block";
    var ob2=document.getElementById('s'+vd);
    //ob2.className = "mtitle2";
  }
}
function k(vd)
{
  var ob=document.getElementById(vd);
  if(ob.style.display=="block")
  {
     ob.style.display="none";
     var ob2=document.getElementById('s'+vd);
     //ob2.style.background="#ff9900";
    //ob2.style.color="#ffffff";
  }
  else
  {
    ob.style.display="block";
    var ob2=document.getElementById('s'+vd);
    //ob2.style.background="#dddddd";
  }
}
//点击展开/关闭
function  zhankai(id) {
  var div=document.getElementById(id);
  div.style.display=(div.style.display=="")?"none":"";
  div.onMouseOver=function() {
    div.style.display="block";
  }
  div.onMouseOut=function() {
    div.style.display="none";
  }
  div.onclick=function() {
    div.style.display="none";
  }
}

//按钮删除确认
function getconfirm(str){
    var str;
    if (confirm(str)==true){
       return true;
    }else{
       return false;
    }
}
//预览并打印函数
function preview(oper){
     if (oper < 10){
      bdhtml = window.document.body.innerHTML;//获取当前页的html代码
      sprnstr = "<!--start_print"+oper+"-->";//设置打印开始区域
      eprnstr = "<!--end_print"+oper+"-->";//设置打印结束区域
      prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html

      prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
      window.document.body.innerHTML=prnhtml;
      window.print();
      //window.document.body.innerHTML=bdhtml;
    } else{
      window.print();
    }
}
//图片等比例缩放<img src="XXXX" alt="自动缩放后的效果"  onload="javascript:DrawImage(this,"200","200");" />
function DrawImage(ImgD,FitWidth,FitHeight){
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
         if(image.width/image.height>= FitWidth/FitHeight){
             if(image.width>FitWidth){
                 ImgD.width=FitWidth;
                 ImgD.height=(image.height*FitWidth)/image.width;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             }
         } else{
             if(image.height>FitHeight){
                 ImgD.height=FitHeight;
                 ImgD.width=(image.width*FitHeight)/image.height;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             } 
        }
     }
 }
