﻿/*
===========================================
//自动调整图片大小
//使用方法  <img onload="tiaozheng(this,180,160)">
===========================================
*/
function ImgReSize(tempimg,t_width,t_heigth){
   var image=new Image();
   image.src=tempimg.src;
   var MaxWidth=t_width;
   var MaxHeight=t_heigth; 
   if(image.width>0 && image.height>0){
	 flag=true;
	 if(image.width/image.height>= MaxWidth/MaxHeight){
		if(image.width>MaxWidth){ 
		   tempimg.width=MaxWidth;
		   tempimg.height=(image.height*MaxWidth)/image.width;
		}
		else{
		   tempimg.width=image.width; 
		   tempimg.height=image.height;
		}
	 }
	 else{
		if(image.height>MaxHeight){ 
		   tempimg.height=MaxHeight;
		   tempimg.width=(image.width*MaxHeight)/image.height;     
		}
		else{
		   tempimg.width=image.width; 
		   tempimg.height=image.height;
		}
	  }
   }
}
/*
===========================================
//判断浏览器是否是类型
===========================================
*/
function IsIE(){
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    if (window.ActiveXObject)
        Sys.ie = ua.match(/msie ([\d.]+)/)[1]
    else if (document.getBoxObjectFor)
        Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
    else if (window.MessageEvent && !document.getBoxObjectFor)
        Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
    else if (window.opera)
        Sys.opera = ua.match(/opera.([\d.]+)/)[1]
    else if (window.openDatabase)
        Sys.safari = ua.match(/version\/([\d.]+)/)[1];
    else
        Sys.other = "Other";
    if(Sys.ie) 
       return true;
    else
       return false; 
}
