//Image zoom in/out script- by javascriptkit.com
//Visit JavaScript Kit (http://www.javascriptkit.com) for script
//Credit must stay intact for use

var zoomfactor = 0.08; //Enter factor (0.05=5%)

function zoomIn(imgID) {
	if (!document.all && !document.getElementById) return;
	var img = document.getElementById(imgID);
	clearInt(imgID);
	var height = img.height;	
	var width = img.width;
	img.h = img.getAttribute('h')
	img.w = img.getAttribute('w')

	if ( !img.h ) {
		img.h = height;
		img.w = width;

		img.h = height;
		img.w = width;
		img.height = height;
		img.width = width;
	}
//	alert(img.h + " " + img.w);
//	alert(img.h + " " + img.height);

	img.zoomInInterval = window.setInterval("zoomHelper('"+ imgID + "',1)",50);
//	alert(imgID);
};



function zoomOut(imgID,allAtOnce) {
//	alert(imgID);

	clearInt(imgID);
	if (!document.all && !document.getElementById) return;
	var img = document.getElementById(imgID);
	img.h = img.getAttribute('h')
	img.w = img.getAttribute('w')

	if ( !img.h ) {
		var height = img.height;	
		var width = img.width;

		img.h = height;
		img.w = width;

		img.h = height;
		img.w = width;
		img.height = height;
		img.width = width;
	}

//	alert(img.h + " " + img.height);
	
//	alert("zoomhelper('"+ imgID + "',-1)");
	if (allAtOnce) {
		img.height = height/1.2;
		img.width = width/1.2;			
	} else {
		img.zoomOutInterval = window.setInterval("zoomHelper('"+ imgID + "',-1)",50);
	}
};


function zoomHelper(imgID,prefix){
	//alert(imgID);
	
	var img = document.getElementById(imgID);
	var height = img.height;	
	var width = img.width;
	
	height += prefix * zoomfactor * img.h;	
	width += prefix * zoomfactor * img.w;

	var currZoom = img.h/height;
	if ( currZoom > 1.2 ) {
		clearInt(imgID);
		height = img.h / 1.2;
		width = img.w / 1.2;
	} else if ( currZoom < 1.0 ) {
		clearInt(imgID);
		height = img.h;
		width = img.w;
	};

	img.height = height;
	img.width = width;
	
};


function clearInt(imgID) {
	if (!document.all && !document.getElementById) return;
	var img = document.getElementById(imgID);

	if (img.zoomOutInterval) {
		window.clearInterval(img.zoomOutInterval);
	}

	if (img.zoomInInterval) {
		window.clearInterval(img.zoomInInterval);
	}
}