﻿

function resizeElement(o) 
{ 
  var zoom = 100;
  
  if(o){
	  zoom  = parseInt(o.style.zoom, 10) || 100; 
	  zoom += event.wheelDelta / 12; 
	  
	  if (zoom > 0){
		o.style.zoom = zoom + '%'; 
	  }else{
		o.style.zoom = '100%';
	  }

  }
}

function restoreElement(o) 
{ 
  if(o){
	o.style.zoom = '100%';
  }
}

function resizeImg() 
{ 
	var e = window.event;  
	var o = e.srcElement; 

	if(o){
		if(String(o.tagName).toLowerCase()=='img' && e.ctrlKey){ 
			restoreElement(o);
			resizeFrame();
			return false;
		}else if(String(o.tagName).toLowerCase()=='img'){
			resizeElement(o);
			resizeFrame();
			return false;
		}
	}

} 

function setImgAlt(o) 
{ 
	var all = null;
	var i   = 0;

	if(o){
		all = o.all;
		if(all){
			for(i=0;i<all.length;i++){
				o = all(i);
				if(String(o.tagName).toLowerCase()=='img' ){ 
					o.alt = "鼠标滚轮缩放图片!!!\nCTRL+鼠标滚轮恢复图片原始大小.";
				}
			}
		}
	}
} 


function initMouseWheelResizeImg(o) 
{ 
	if(o){
		setImgAlt(o);
		o.onmousewheel = resizeImg; 
	}

} 

// weak !!!
function resizeFrame()
{
	parent.document.all('RightFrame').height=parent.RightFrame.document.body.scrollHeight + 20;
}


/*
//example


initMouseWheelResizeImg(DIV);

*/
