﻿window.onload = function(){
    var h1 = document.getElementById("leftmain").offsetHeight;
    var h2 = document.getElementById("rightmain").offsetHeight;

    if(h1 > h2){
        document.getElementById("leftmain").style.height = h1+"px";
        document.getElementById("rightmain").style.height =h1+"px"  ;
        document.getElementById("leftnr2").style.height =(h1-33)+"px";
        }
    else{
        document.getElementById("leftmain").style.height = h2+"px";
        document.getElementById("rightmain").style.height = h2+"px";
        document.getElementById("leftnr2").style.height = (h2-33)+"px";
        }
    }


     //图片缩放
    function show_img(imgid){
        var temp_img = new Image();
        temp_img.src = imgid.src;
        
        if(temp_img.width < temp_img.height){
            imgid.className = "img2";
            
            }
    }
    
    
      
//图片等比例缩放
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; 
} 
} 
} 
}

//图片等比例缩放2
function ReSizeImg(Img,width,height)
{
    var image=new Image(); 
    image.src=Img.src; 
    //width=236;//预先设置的所期望的宽的值
    //height=170;//预先设置的所期望的高的值
    if(image.width>width||image.height>height)    //现有图片只有宽或高超了预设值就进行js控制
    {
        w=image.width/width;
        h=image.height/height;
        if(w>h)
        {
            //比值比较大==>宽比高大
            //定下宽度为width的宽度
            Img.width=width;
            //以下为计算高度
            Img.height=image.height/w;
        }
        else
        {
            //高比宽大
            //定下宽度为height高度
            Img.height=height;
            //以下为计算高度
            Img.width=image.width/h;
        }
    }
}