//ZOOM FEATURE
//window.onload = initZoom; 

function findDOM(objectId) {
	if (document.getElementById) {
		return (document.getElementById(objectId));}
	if (document.all) {
		return (document.all[objectId]);}
}
function zoom(type,imgx,iWidthIn,iHeightIn) {
	imgd = findDOM(imgx);
	//alert(imgd.width + ", " + imgd.height);
	if (type=="+" && imgd.width >= iWidthIn) {
		imgd.width = 2*imgd.width;
		imgd.height = 2*imgd.height;
	}
	if (type=="-" && imgd.width > iWidthIn) {
		imgd.width = imgd.width/2;
		imgd.height = imgd.height/2;
	}
} 


var zoomClass = "zoom";
var normalWidth = new Array();
var normalHeight = new Array();
var getZoom = new Array();

function initZoom() {
	var allImgs = new Array();
	allImgs = document.body.getElementsByTagName('IMG');
	for ( i = 0; i < allImgs.length; i++ ) {
		if (allImgs[i].className.toLowerCase() == zoomClass.toLowerCase())
		getZoom[getZoom.length] = allImgs[i];
	} 
	
	for (i=0; i < getZoom.length; i++) {
		normalWidth[i] = getZoom[i].width;
		normalHeight[i] = getZoom[i].height;
		getZoom[i].width = normalWidth[i]; 
		getZoom[i].height = normalHeight[i];

		if (document.addEventListener) {
			getZoom[i].addEventListener('click', zoomImg, false);
		} else {
			getZoom[i].onclick = zoomImg;
		} 

	} 

}


function zoomImg(e) {
	if (e) {
		ctrlPress = e.ctrlKey;
		shiftPress = e.shiftKey;
		altPress = e.altKey;
	} else {
		ctrlPress = event.ctrlKey;
		shiftPress = event.shiftKey;
		altPress = event.altKey;
	} 

	for (i=0;i<getZoom.length;i++) {
		if (this == getZoom[i])	imgToZoom = i;
	}
	if (altPress) { 
		getZoom[imgToZoom].width = normalWidth[imgToZoom];
		getZoom[imgToZoom].height = normalHeight[imgToZoom];
	} else if (ctrlPress || shiftPress) { // zoom out
		if (getZoom[imgToZoom].width > normalWidth[imgToZoom]) {
			getZoom[imgToZoom].width -= normalWidth[imgToZoom];
			getZoom[imgToZoom].height -= normalHeight[imgToZoom];
		} 
	} else {		
                getZoom[imgToZoom].width += normalWidth[imgToZoom];
		getZoom[imgToZoom].height += normalHeight[imgToZoom];
	}
}
