﻿/*按比例生成缩略图*/
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
}
//获取根据id控件
function em(id) { 
    return document.getElementById(id)
}
//产品参数多列显示
function s(a, max) {
    for (i = 1; i <= max; i++) {
        if (a != i) {
            em('c' + i).style.display = 'none';
            em('t' + i).className = 'bcolor';
        }
        else {
            em('c' + i).style.display = '';
            em('t' + a).className = 'bnone';
        }
    }
}
//弹出新窗口
function OpenWin(url, width, height) {
    window.open(url, "武汉岩海公司|神州测桩论坛", 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes');
}
//打开DIV
function OpenDiv(id) {
    var cx, cy;
    cx = document.body.scrollLeft + event.clientX;   //获取当前鼠标位置的X坐标
    //cy = document.body.scrollTop + event.clientY;   //获取当前鼠标位置的Y坐标
    if (typeof window.pageYOffset != 'undefined') {
        cy = window.pageYOffset;
    }
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
        cy = document.documentElement.scrollTop;
    }
    else if (typeof document.body != 'undefined') {
        cy = document.body.scrollTop;
    }
    cy += event.clientY;
    cy += 20;
    em(id).style.top = cy;
    em(id).style.left = cx;    
    em(id).style.width = 500;
    em(id).style.display = "block";
}
//关闭DIV
function CloseDiv(id) {
    em(id).style.display = "none";
}
//判断返回查询输入
function checkSearch() {
    if (document.Search.Keyword.value == "") { alert("请输入关键词"); return false; }
    if (document.getElementById("Range").value == "Void") { alert("请选择搜索分类"); return false; }
}
//判断返回登录输入
function checkLogin() {
    if (document.formLogin.LoginName.value == "" || document.formLogin.LoginPassword.Value == "") return false
}

function overtb(this_s) {
    this_s.style.background = '#f2f8fa';
}
function overtb2(this_s) {
    this_s.style.background = '#cdebf8';
}
function outtb(this_s) {
    this_s.style.background = '';
}

