var image_to_zoom;
var imageIndex=0;
//var images=Array('images/image1.jpg','images/image2.jpg');
var origiWidth;
var origiHeight;
var stepPx=2;
var stepTime=40;

function startZoom() {
//	loadImages(images);
//	if (document && document.getElementById) {
		if (image_to_zoom=document.getElementById('IMAGE1')) {
			origiWidth=image_to_zoom.width;
			origiHeight=image_to_zoom.height;
			firstZoom();
		}
//	}
}

var divv;
function firstZoom() {
	zoom(origiWidth,origiHeight,origiWidth,origiWidth*1.5);
}

function zoom(view_width,view_height,zoom_width,max_width) {
	image_to_zoom.width=zoom_width;
	image_to_zoom.style.left=-(zoom_width-view_width)+'px';
	image_to_zoom.style.clip='rect('+(0)+'px, '+(zoom_width)+'px, '+view_height+'px, '+(zoom_width-view_width)+'px)';
//	image_to_zoom.style.clip='rect('+(0)+'px, '+(view_width)+'px, '+view_height+'px, '+(0)+'px)';
	if (zoom_width<max_width) {
		zoom_width+=stepPx;
		setTimeout("zoom("+view_width+","+view_height+","+zoom_width+","+max_width+")",stepTime);
	} else {
		imageIndex++;
		/*
		if (imageIndex>=images.length) {
			imageIndex=0;
		}
		*/
		//image_to_zoom.src=images[imageIndex];
		//firstZoom();
	}
}

function loadImages() {
	for(i=0;i<images.length;i++) {
		image=new Image();
		image.src=images[i];
	}
}

var dc = function(tag) {return document.createElement(tag);};

function addEvent(element, ev, handler) {
	var doHandler = function(e) {
		return handler(e||window.event);
	}
	if (element.addEventListener) { 
		element.addEventListener(ev, doHandler, false); 
	} else if (element.attachEvent) { 
		element.attachEvent("on" + ev, doHandler); 
	}
}

function loadImage(zoomImg) {
	var zoomWidth = zoomImg.offsetWidth;
	var zoomHeight = zoomImg.offsetHeight;

	var ctrWidth = origiWidth;
	var ctrHeight = origiHeight;

	var ratioW = zoomWidth / origiWidth;
	var ratioH = zoomHeight / origiHeight;

	var markerWidth = Math.round(ctrWidth / ratioW);
	var markerHeight = Math.round(ctrHeight / ratioH);

	document.body.removeChild(zoomImg);
	divv.appendChild(zoomImg);

	// sorry
	var isIE = !!document.all && !!window.attachEvent && !window.opera;

	zoomImg.style.width = "960px";
	zoomImg.style.left = -(9000)+"px";
	zoomImg.style.top = -(100)+"px";
};
