﻿// JScript 文件
function resizeimg(ImgD,iwidth,iheight) { 
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0){ 
        if(image.width/image.height>= iwidth/iheight){ 
           if(image.width>iwidth){ 
               ImgD.width=iwidth; 
               ImgD.height=(image.height*iwidth)/image.width; 
           }else{ 
                  ImgD.width=image.width; 
                  ImgD.height=image.height; 
                } 
               ImgD.alt=image.width+"×"+image.height; 
        } 
        else{ 
                if(image.height>iheight){ 
                       ImgD.height=iheight; 
                       ImgD.width=(image.width*iheight)/image.height; 
                }else{ 
                        ImgD.width=image.width; 
                        ImgD.height=image.height; 
                     } 
                ImgD.alt=image.width+"×"+image.height; 
            } 
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针 
　　　　　ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
　　　　　　/*ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开"; 
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放 
　　　　　 { 
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100; 
　　　　　　　　　　zoom += event.wheelDelta / 12; 
　　　　　　　　　　if (zoom> 0)　this.style.zoom = zoom + "%"; 
　　　　　　　　　　return false; 
　　　　　 }
　　　　　 */ 
　　　  } else { //如果不是IE 
　　　　　　　     ImgD.title = "点击图片可在新窗口打开"; 
　　　　　　   } 
    } 
}

function resizeimg1(ImgD,iwidth,iheight) { 
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0){ 
        if(image.width/image.height>= iwidth/iheight){ 
           if(image.width>iwidth){ 
               ImgD.width=iwidth; 
               ImgD.height=(image.height*iwidth)/image.width; 
           }else{ 
                  ImgD.width=iwidth; 
                  ImgD.height=iheight; 
                } 
               ImgD.alt=image.width+"×"+image.height; 
        } 
        else{ 
                if(image.height>iheight){ 
                       ImgD.height=iheight; 
                       ImgD.width=(image.width*iheight)/image.height; 
                }else{ 
                        ImgD.width=image.width; 
                        ImgD.height=image.height; 
                     } 
                ImgD.alt=image.width+"×"+image.height; 
            } 
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针 
　　　　　//ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
　　　　　　/*
　　　　　　ImgD.title = "请使用鼠标滚轮缩放图片"; 
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放 
　　　　　 { 
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100; 
　　　　　　　　　　zoom += event.wheelDelta / 12; 
　　　　　　　　　　if (zoom> 0)　this.style.zoom = zoom + "%"; 
　　　　　　　　　　return false; 
　　　　　 } 
　　　　　 */
　　　  } else { //如果不是IE 
　　　　　　　     //ImgD.title = "点击图片可在新窗口打开"; 
　　　　　　   } 
    }
}

        var obj;
		var o;
		var iWidth,iHeight;

		function ChangePic(src,width,height){
			o = new Image();
			o.src = src;
			iWidth=width; iHeight=height;
			obj = window.setTimeout("LoadPic()",800);
		}
		
		function LoadPic(){
			var img1 = document.getElementById("<%=img1.ClientID %>");alert(img1);
			if(o.complete){
			    //按比例缩小图片
    			if(o.height>iHeight || o.width>iWidth)
                {
                    if (o.height/iHeight>o.width/iWidth)
                    {
                        o.width=o.width*iHeight/o.height;
                        o.height=iHeight;
                    }
                    else
                    {
                        o.height=o.height*iWidth/o.width;
                        o.width=iWidth;
                    }
                }
                
			    
			    img1.style.display = "inline";
			    img1.src = o.src;
			    img1.width = o.width;
			    img1.height = o.height;
			    clearTimeout(obj);
			}
		}
		
		function ValidPicFormat()
        {   
            var v=document.all['<%=File1.ClientID %>'].value.toLowerCase();
            if(v != '')
            {
                if(v.indexOf('.jpg')==-1 && v.indexOf('.gif')==-1 && v.indexOf('.jpeg')==-1)
                {
                    alert('对不起,请选择你要上传的图片文件!');return false;
                }
            }  
        }  
