//******************************
//JS for zooming a picture
//copyright ACS Solutions, Leipzig (Germany) 2007
//******************************

function Zoom()
{

	this.containerWidth = 480;
	this.containerHeight = 590;
	this.rasterItemWidth = 200;
	this.rasterItemHeight = 200;	
	this.minZoom = 0;
	this.maxZoom = 9;	
	this.zoom = this.minZoom;
	this.reZoom = false; //user zoom's while manuscript already zoomed
	this.oldXPosAbs = 0;
	this.oldYPosAbs = 0;
	this.PosXStart = 0;
	this.PosYStart = 0;
	this.zoomFaktor = 0.8;
	this.deltaMove = 70;
	this.imageHandler = "../handler/manuscriptImage.ashx"
	//imagemap - show the manuscript
	this.imgMap = null;
	//hidden imagemap for preloading images after zoom
	this.imgMapPreLoad = null;
	//empty imagemap, after zoom imageparts will be append after loading, replace zoomed Imagemap with this new.
	this.newMap = null;
	this.rasterItemsToLoad = new Array();
	this.loadingLayer = null;
	this.aktXRaster = Math.ceil(this.containerWidth/this.rasterItemWidth);
	this.rasterX = this.aktXRaster+2;
	this.aktYRaster = Math.ceil(this.containerHeight/this.rasterItemHeight);
	this.rasterY = this.aktYRaster+2;
	
	//dimension of manuscript in current zoom step
	this.manuscriptZoomWidth = 0;
	this.manuscriptZoomHeight = 0;
	
	this.manuscriptWidth = 0;
	this.manuscriptHeight = 0;
	this.imageSizeUrl = "../handler/getManuscriptDimension.ashx"
	this.loadDimension = false;
	
	this.loadNewImgMap = false;
	this.relPosXFaktorStart = (this.PosXStart-1)/(this.rasterX-2);
	this.relPosYFaktorStart = (this.PosYStart-1)/(this.rasterY-2);
	this.move = false;
	this.setImageMapAfterMove = false;
	this.file = null;
	this.light = 0;
	this.enabled = true;
	
	this.isDragged = false;
	this.DragStartX = 0;		
	this.DragStartY = 0;
	this.DragStartXcoord = 0;		
	this.DragStartYcoord = 0;
	
	this.tmpX = this.rasterItemWidth;
	this.tmpY = this.rasterItemHeight;

	
	//current image type: 0 - standard light, 1 - raking light, 2 - multispectral light
	this.currImageTyp = 0;
}

Zoom.prototype.resize = function(x,y)
{
	this.containerWidth = x;
	this.containerHeight = y;
	
	this.imgContainer.style.width = this.containerWidth+"px";
	this.imgContainer.style.height = this.containerHeight+"px";
	
	this.loadingLayer.style.width = this.containerWidth +"px";
	this.loadingLayer.style.height = this.containerHeight +"px";
	
	if(this.file!=null)
	{
	oldRasterX = this.rasterX;
	oldRasterY = this.rasterY;	
		
	this.aktXRaster = Math.ceil(this.containerWidth/this.rasterItemWidth);
	this.rasterX = this.aktXRaster+2;
	this.aktYRaster = Math.ceil(this.containerHeight/this.rasterItemHeight);
	this.rasterY = this.aktYRaster+2;
	

	
	this.imgMap.style.width = this.rasterX*this.rasterItemWidth+"px";
	this.imgMap.style.height = this.rasterY*this.rasterItemHeight+"px";
	

//    this.navContainer.innerHTML = "";
//    this.setNav();
    
    zoomTB.resetMiniWindow();
	var rasterXDiff = this.rasterX - oldRasterX;
	var rasterYDiff = this.rasterY - oldRasterY;
	
	var myImgCollection = this.imgMap.getElementsByTagName("img");
	var myImgCopyCollection = this.imgMapPreLoad.getElementsByTagName("img");
	
	
	
	if(rasterXDiff > 0)
	{
		for( j = 0 ; j < oldRasterY ; j++)
		{
			for( i = 0 ; i < rasterXDiff ; i++)
			{
				if(j<oldRasterY-1)
					this.imgMap.insertBefore(this.createRasterImg(),myImgCollection[(j+1)*oldRasterX+rasterXDiff*j+i]);
				else
					this.imgMap.appendChild(this.createRasterImg());
			    //myImgCollection[(j+1)*oldRasterX+rasterXDiff*j+i].src ="/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+oldRasterX-1+i)+"_"+(this.PosYStart+j-1)+"_"+this.zoom+".jpg";
				myImgCollection[(j+1)*oldRasterX+rasterXDiff*j+i].src =this.imageHandler+"?image="+this.file[this.light]+"&x="+(this.PosXStart+oldRasterX-1+i)+"&y="+(this.PosYStart+j-1)+"&z="+this.zoom;
				myImgCollection[(j+1)*oldRasterX+rasterXDiff*j+i].style.width = this.rasterItemWidth+"px";
				myImgCollection[(j+1)*oldRasterX+rasterXDiff*j+i].style.height = this.rasterItemHeight+"px";
				this.imgMapPreLoad.appendChild(this.createRasterImg());
			}
		}
	}
	else
	{
		for(j = oldRasterY ; j > 0 ; j--)
		{
			for( i = 1 ; i <= Math.abs(rasterXDiff) ; i++)
			{
				this.imgMap.removeChild(myImgCollection[j*oldRasterX-i]);
				this.imgMapPreLoad.removeChild(myImgCopyCollection[j*oldRasterX-i]);
			}
		}
	}
	
	if(rasterYDiff > 0)
	{
		for(k = 0 ; k < rasterYDiff*this.rasterX ; k++)
		{
			this.imgMap.appendChild(this.createRasterImg());
			this.imgMapPreLoad.appendChild(this.createRasterImg());
			//myImgCollection[this.rasterX*oldRasterY+k].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+k-1)+"_"+(this.PosYStart+oldRasterY-1)+"_"+this.zoom+".jpg";
			myImgCollection[this.rasterX*oldRasterY+k].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(this.PosXStart+k-1)+"&y="+(this.PosYStart+oldRasterY-1)+"&z="+this.zoom;
			myImgCollection[this.rasterX*oldRasterY+k].style.width = this.rasterItemWidth+"px";
			myImgCollection[this.rasterX*oldRasterY+k].style.height = this.rasterItemHeight+"px";
		}
	}
	else
	{	
		for(k = 0 ; k < Math.abs(rasterYDiff)*this.rasterX ; k++)
		{
				this.imgMap.removeChild(myImgCollection[myImgCollection.length-1]);
				this.imgMapPreLoad.removeChild(myImgCopyCollection[myImgCopyCollection.length-1]);		
		}	
	}
    }
//	mulitspec = $("containerMultispec");
//	multispec.changeImageSize(x);
//	mulitspec.style.width = x +"px";
//	mulitspec.style.height = y +"px";
}

Zoom.prototype.init = function(imgMap,imgMapCopy,navContainer, zoomBar, file)	
{	
	if(file!='')
	{
	    this.file = new Array();
	    this.file[0] = file+"_p.jpg";
	    this.file[1] = file+"_k.jpg";
	    this.file[2] = file;
    }
    else
        this.file = null;
        
	this.imgContainer = $("manuscript");
	this.imgContainer.style.width = this.containerWidth+"px";
	this.imgContainer.style.height = this.containerHeight+"px";
	this.imgContainer.style.overflow = "hidden";
	this.imgContainer.style.border = "8px solid white";
	this.imgContainer.style.zIndex = "10";
	this.imgContainer.style.position = "relative";
	
	this.imgMapContainer = $(imgMap);
	this.imgMapCopyContainer = $(imgMapCopy);
	
	this.imgMap = this.imgMapContainer.getElementsByTagName("div")[0];
	this.imgMapPreLoad = this.imgMapCopyContainer.getElementsByTagName("div")[0];
	
	this.imgMap.innerHTML = "";
	this.imgMapPreLoad.innerHTML = "";

	for(i=0;i<(this.rasterX*this.rasterY);i++)
	{
		this.imgMap.appendChild(this.createRasterImg());
	}
	
	for(i=0;i<(this.rasterX*this.rasterY);i++)
	{
		this.imgMapPreLoad.appendChild(this.createRasterImg());
	}	

	this.imgMapPreLoad.style.display = "none";	
	this.imgMap.style.marginLeft = - this.rasterItemWidth+"px";
	this.imgMap.style.marginTop = - this.rasterItemHeight+"px";
	this.imgMap.style.zIndex = "0";
	this.imgMap.style.position = "absolute";
	this.imgMap.style.top="0px";

	this.imgMap.style.width = this.rasterX*this.rasterItemWidth+"px";
	this.imgMap.style.height = this.rasterY*this.rasterItemHeight+"px";	
	this.imgMap.style.left="0px";

	if(file!=='')
	{		   
		this.setLoading(true);
		this.loadInit = true;
		this.checkForInitReady(0);
		this.setImageMap(this.imgMap);

//		this.navContainer = $(navContainer);
//		this.navContainer.innerHTML = "";
		
	    //Event.observe(this.imgContainer, "click", function(event){zoom.doZoom(1,event); return false;});
	    //Event.observe(this.imgContainer, "contextmenu", function(event){zoom.doZoom(-1,event);  Event.stop(event);});
	    

	    Event.observe(this.imgContainer, "contextmenu", function(event){zoom.dragStop(event);  Event.stop(event);});
   	    Event.observe(this.imgContainer, "dblclick", function(event){zoom.doZoom(1,event);});

        this.imgContainer.onmousedown = zoom.dragStart;
        this.imgContainer.onmouseup = zoom.dragStop;
        this.imgContainer.onmousemove = zoom.drag;

		A_SLIDERS[0].f_setValue(this.zoom)

//		this.setNav();x
		zoomTB.parentNode = this.imgContainer;
		this.getImageSize();
		zoomTB.setMiniWindow();
		//zoomTB.setInfoWindow();
		zoomTB.setNav();
		$("sl0base").setStyle({display:'block'});

	}
	else
		this.setLoading(false);
}

Zoom.prototype.getImageSize = function()
{
    if(this.file!=null)
    {
        var params = "file=" + this.file[0] + "&z=" + this.zoom;
        this.loadDimension = true;
	    var myAjax = new Ajax.Request(
		    this.imageSizeUrl, 
		    {
			    method: 'get',
			    asynchronous: false,
			    parameters: params,
			    onComplete: zoom.setImageSize
	    });
    }
}

Zoom.prototype.setImageSize = function(request)
{
    var reqObj = eval('(' + request.responseText + ')');
	zoom.manuscriptZoomWidth = reqObj.w;
    zoom.manuscriptZoomHeight = reqObj.h;
    if(zoom.zoom==0)
    {
        zoom.manuscriptWidth = reqObj.w;
	    zoom.manuscriptHeight = reqObj.h;
    }
    zoom.loadDimension = false;
}


Zoom.prototype.setLoading = function(loadIcon)
{
	var loadingDiv = document.createElement("div");
	loadingDiv.style.width = this.containerWidth + "px";
	loadingDiv.style.height = this.containerHeight + "px";
	loadingDiv.style.position = "absolute";
	loadingDiv.style.zIndex = "10";
	loadingDiv.style.backgroundColor = "#EEEEEE";
	if(loadIcon)
	{
		loadingImg = document.createElement("img");
		loadingImg.src = "../media/images/zoom/loading_icon.gif";
		loadingImg.style.marginTop = this.containerHeight/2 - 8+"px";
		loadingImg.style.marginLeft = this.containerWidth/2 - 8+"px";
		loadingDiv.appendChild(loadingImg);
	}
	this.loadingLayer = loadingDiv;
	this.imgContainer.appendChild(loadingDiv);
}

Zoom.prototype.checkForInitReady = function(pos)
{
	var imgCollection = this.imgMap.getElementsByTagName("img");
	if(imgCollection.length>pos)
	{
	    if(this.isImageLoaded(imgCollection[pos]) ||  imgCollection[pos].src == '')
		    window.setTimeout("zoom.checkForInitReady("+(pos+1)+")",10)
	    else
		    window.setTimeout("zoom.checkForInitReady("+(pos)+")",10)    
	}
	else
	{
		this.imgContainer.removeChild(this.loadingLayer);
		this.loadInit = false;
	}
}

Zoom.prototype.isImageLoaded = function(img) 
{
    if (img.complete == undefined) {
      if (img.getAttribute('completed') == undefined) {
        img.setAttribute('completed', false);
        img.onload = function() { img.setAttribute('completed', true); };
      }

      return img.getAttribute('completed');
    }
    return img.complete;
}


Zoom.prototype.setNav = function()	
{	
	this.navContainer.style.height = this.containerHeight + "px";
	this.navContainer.style.width = this.containerWidth + "px";
	this.navContainer.style.zIndex = "5";
	this.navContainer.style.position = "absolute";
	
	var navTop = document.createElement("div");
	navTop.style.height = "20px";
	navTop.style.textAlign = "center";
	if(!Prototype.Browser.IE)
	{
		var imgTop = document.createElement("img");
		navTop.style.backgroundImage = "url('../media/images/zoom/bg_nav.png')";
		imgTop.src = "../media/images/zoom/nav_top.png";
	}	
	else
	{
		var imgTop = document.createElement("div");
		imgTop.style.width = "10px";
		imgTop.style.height = "11px";
		imgTop.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='../media/images/zoom/nav_top.png')";
		navTop.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../media/images/zoom/bg_nav.png', sizingMethod='scale')";
	}
	imgTop.style.marginTop = navTop.style.height.replace("px","")/2 - 5+"px";
	navTop.appendChild(imgTop);
	this.navContainer.appendChild(navTop);

	var navRight = document.createElement("div");
	navRight.style.height = this.containerHeight-40+"px";
	navRight.style.width = "20px";
	navRight.style.textAlign = "center";
	if(!document.all)
	{
		var imgRight = document.createElement("img");
		imgRight.src = "../media/images/zoom/nav_right.png";
		navRight.style.cssFloat = "right";
		navRight.style.backgroundImage = "url('../media/images/zoom/bg_nav.png')";
	}
	else
	{
		var imgRight = document.createElement("div");
		imgRight.style.width = "10px";
		imgRight.style.height = "11px";
		imgRight.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='../media/images/zoom/nav_right.png')";	
		navRight.style.styleFloat = "right";
		navRight.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../media/images/zoom/bg_nav.png', sizingMethod='scale')";
	}
	imgRight.style.marginTop = navRight.style.height.replace("px","")/2-5+"px"; 
	navRight.appendChild(imgRight);	
	this.navContainer.appendChild(navRight);
	
	var navLeft = document.createElement("div");
	navLeft.style.height = this.containerHeight-40+"px";
	navLeft.style.width = "20px";
	navLeft.style.textAlign = "center";
	if(!document.all)
	{
		var imgLeft = document.createElement("img");
		imgLeft.src = "../media/images/zoom/nav_left.png";	
		navLeft.style.backgroundImage = "url('../media/images/zoom/bg_nav.png')";
	}
	else
	{
		var imgLeft = document.createElement("div");
		imgLeft.style.width = "10px";
		imgLeft.style.height = "11px";
		imgLeft.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='../media/images/zoom/nav_left.png')";		
		navLeft.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../media/images/zoom/bg_nav.png', sizingMethod='scale')";
	}
	imgLeft.style.marginTop = navLeft.style.height.replace("px","")/2-5+"px"; 
	navLeft.appendChild(imgLeft);		
	this.navContainer.appendChild(navLeft);
	
	var navBottom = document.createElement("div");
	navBottom.style.height = "20px";
	navBottom.style.textAlign = "center";	
	navBottom.style.clear = "both";
	if(!document.all)
	{
		var imgBottom = document.createElement("img");
		imgBottom.src = "../media/images/zoom/nav_bottom.png";		
		navBottom.style.backgroundImage = "url('../media/images/zoom/bg_nav.png')";
	}
	else
	{
		var imgBottom = document.createElement("div");
		imgBottom.style.width = "10px";
		imgBottom.style.height = "11px";
		imgBottom.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='../media/images/zoom/nav_bottom.png')";			
		navBottom.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../media/images/zoom/bg_nav.png', sizingMethod='scale')";
	}
	imgBottom.style.marginTop = navBottom.style.height.replace("px","")/2-5+"px"; 
	navBottom.appendChild(imgBottom);		
	this.navContainer.appendChild(navBottom);
}

Zoom.prototype.createRasterImg = function()	
{
	var rasterImg = document.createElement("img");
	if(document.all)
		rasterImg.setAttribute("className","man_img");
	else
		rasterImg.setAttribute("class","man_img");
	rasterImg.style.width = this.rasterItemWidth+"px";
	rasterImg.style.height = this.rasterItemHeight+"px";
	rasterImg.style.zIndex = 15;

	return rasterImg;
}

Zoom.prototype.changeManuscriptLight = function(type, obj) {

    linking.deselectWord();
    linking.removeMarker();

    ph.resetRaster();
    ph.lastSelectedParts = "";

    this.currImageType = type;
    this.light = type;
    if (!this.move && !this.loadNewImgMap && !this.loadInit /*&& !(type==2 && !multispec.status) */) {
        linking.removeMarker();

        for (i = 0; i < obj.parentNode.getElementsByTagName("span").length; i++)
            $(obj.parentNode.getElementsByTagName("span")[i]).removeClassName("head_element_active");

        $(obj).addClassName("head_element_active");


        if (type == 2) {

            //		    this.imgContainer.style.display = "none";	
            //		    var multispecContainer = multispec.show();
            //		    multispecContainer.style.width = this.imgContainer.style.width;
            //		    multispecContainer.style.height = this.imgContainer.style.height;
            //		    multispecContainer.style.overflow = this.imgContainer.style.overflow;
            //		    multispecContainer.style.border = this.imgContainer.style.border;
            //		    multispecContainer.style.zIndex = this.imgContainer.style.zIndex;
            //		    multispecContainer.style.position = this.imgContainer.style.position;
        }
        else {
            //            multispec.hide();
            this.imgContainer.style.display = "block";
            if (this.file != null) {

                this.imgMap.style.top = "0px";
                this.imgMap.style.left = "0px";
                this.imgMap.innerHTML = "";

                for (i = 0; i < (this.rasterX * this.rasterY); i++) {
                    this.imgMap.appendChild(this.createRasterImg());
                }

                this.zoom = this.minZoom;
                this.PosXStart = 0;
                this.PosYStart = 0;
                this.oldXPosAbs = 0;
                this.oldYPosAbs = 0;
                this.relPosXFaktorStart = (this.PosXStart - 1) / (this.rasterX - 2);
                this.relPosYFaktorStart = (this.PosYStart - 1) / (this.rasterY - 2);
                this.setLoading(true);
                this.loadInit = true;
                this.setImageMap(this.imgMap);
                this.checkForInitReady(0);

                A_SLIDERS[0].f_setValue(this.zoom)

                this.getImageSize();
                zoomTB.resetMiniWindow();
                zoomTB.resetMiniWindowImage();
                if (this.light == 0)
                    linking.enabled = true;
                else
                    linking.enabled = false;
            }
            else {
                this.setLoading(false);
            }
        }
    }
}


//load imges to an imagemap 
//@param - element witch contains the imagemap raster
Zoom.prototype.setImageMap = function(imgMap)
{
	var imgCollection = imgMap.getElementsByTagName("img");
	var img = 0;
	var xPos = this.PosXStart;
	var yPos = this.PosYStart;
	for(i=0;i<this.rasterY;i++)
	{
		for(j=0;j<this.rasterX;j++)
		{
			
			//imgCollection[img].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+j-1)+"_"+(this.PosYStart+i-1)+"_"+this.zoom+".jpg";
			imgCollection[img].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(xPos+j-1)+"&y="+(yPos+i-1)+"&z="+this.zoom;
			imgCollection[img].style.width = this.rasterItemWidth+"px";
			imgCollection[img].style.height = this.rasterItemHeight+"px";
			img +=1;
		}
	}
}

//load new imgemap parts at one of the four sides of the imagemap
//for exmaple: klick top; append imagemap parts at the top of the imagemap and remove the parts at the bottom of the map
//				so, there is always a raster with fixed number of parts
//@param direction (top, left, right, bottom)
//@param deltaMove 
Zoom.prototype.setImageMapMove =  function(dir,deltaMove)
{	
    if(!this.setImageMapAfterMove)
    {
        
        this.setImageMapAfterMove = true;
        if(!this.loadNewImgMap)
        {
	        var imgCollection = this.imgMap.getElementsByTagName("img");
	        var map = this.imgMap;
	        var imgCollectionPreLoad = null;
	        var mapPreLoad = null;	        
	    }
	    else
	    {
	        var imgCollection = this.newMap.getElementsByTagName("img");
	        var map = this.newMap;
	        var imgCollectionPreLoad = this.imgMapPreLoad.getElementsByTagName("img");
	        var mapPreLoad = this.imgMapPreLoad;
	    }    
    	    	
	    var xPos = this.PosXStart;
	    var yPos = this.PosYStart;
    	
	    if(dir=="top")
	    {
		    //absolute(marginTop+top) < deltaMove
		    if(this.isDragged || Math.abs(parseInt(map.style.marginTop.replace("px",""))+parseInt(map.style.top.replace("px",""))) < deltaMove)
		    {
			    for(var j=0;j<Math.ceil(deltaMove/this.rasterItemHeight);j++)
			    {
			      // if(!this.isDragged)
				        map.style.top = map.style.top.replace("px","")*1-this.rasterItemHeight+"px";

				    for(var i=0;i<this.rasterX;i++)
				    {
					    map.insertBefore(this.createRasterImg(),imgCollection[i]);
					    map.removeChild(imgCollection[imgCollection.length-1]);

                        //moving during reload imagMap
                        if(mapPreLoad != null)
                        {
					        mapPreLoad.insertBefore(this.createRasterImg(),imgCollectionPreLoad[i]);
					        mapPreLoad.removeChild(imgCollectionPreLoad[imgCollectionPreLoad.length-1]);					    
					    }
    					
					    //imgCollection[i].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+i-1)+"_"+(this.PosYStart-2)+"_"+this.zoom+".jpg";
					    imgCollection[i].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(xPos+i-1)+"&y="+(yPos-2)+"&z="+this.zoom;
					    imgCollection[i].style.width = this.rasterItemWidth+"px";
					    imgCollection[i].style.height = this.rasterItemHeight+"px";
				    }
                    //moving during reload imagMap
			        if(this.loadNewImgMap)
			        {   
			    	    for(var k=this.rasterItemsToLoad.length-1 ; k >= 0 ; k--)
				        {  

				            this.rasterItemsToLoad[k] += this.rasterX;
				            if(this.rasterItemsToLoad[k]*1 >= imgCollection.length*1)
				            {
				                this.rasterItemsToLoad.pop();  
				             }  
				        }
					}
				    this.PosYStart -= 1;
				    yPos = this.PosYStart
			    }
		    }
	    }
	    if(dir=="bottom")
	    {
		    //absolute(absolute(marginTop+Top)+containerHeight-imageMapHeight) < deltaMove
		    if(Math.abs(Math.abs(parseInt(map.style.marginTop.replace("px",""))+parseInt(map.style.top.replace("px","")))+parseInt(this.containerHeight)-parseInt(map.style.height.replace("px",""))) < deltaMove )
		    {
			    for(j=0;j<Math.ceil(deltaMove/this.rasterItemHeight);j++)
			    {
			     //  if(!this.isDragged)
				        map.style.top = map.style.top.replace("px","")*1+this.rasterItemHeight+"px";
				    
				    for(i=0;i<this.rasterX;i++)
				    {
					    map.appendChild(this.createRasterImg());
					    map.removeChild(imgCollection[0]);
					    
					    //moving during reload imagMap
                        if(mapPreLoad != null)
                        {
					        mapPreLoad.appendChild(this.createRasterImg());
					        mapPreLoad.removeChild(imgCollectionPreLoad[0]);					    
					    }
    					
					    //imgCollection[imgCollection.length-1].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+i-1)+"_"+(this.PosYStart+this.rasterY-1)+"_"+this.zoom+".jpg";
					    imgCollection[imgCollection.length-1].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(xPos+i-1)+"&y="+(yPos+this.rasterY-1)+"&z="+this.zoom;
					    imgCollection[imgCollection.length-1].style.width = this.rasterItemWidth+"px";
					    imgCollection[imgCollection.length-1].style.height = this.rasterItemHeight+"px";		
				    }
				    //moving during reload imagMap
			        if(this.loadNewImgMap)
			        {       
			    	    for(var k=0 ; k < this.rasterItemsToLoad.length ; k++)
				        {  
				            this.rasterItemsToLoad[k] -= this.rasterX;
				            if(this.rasterItemsToLoad[k]*1 < this.rasterX)
				            {
				                this.rasterItemsToLoad.shift();  
				             } 
				        }
					}				    				    
				    this.PosYStart += 1;
				    yPos = this.PosYStart
			    }
		    }
	    }    	
	    if(dir=="left")
	    {
		    //absolute(marginLeft+left) < deltaMove
		    if(Math.abs(parseInt(map.style.marginLeft.replace("px",""))+parseInt(map.style.left.replace("px",""))) < deltaMove)
		    {
			    for(j=0;j<Math.ceil(deltaMove/this.rasterItemWidth);j++)
			    {
			    //   if(!this.isDragged)
				        map.style.left = map.style.left.replace("px","")*1-this.rasterItemWidth+"px";
		      
				    for(i=0;i<this.rasterY;i++)
				    {
					    map.insertBefore(this.createRasterImg(),imgCollection[i*this.rasterX]);
					    map.removeChild(imgCollection[(i+1)*this.rasterX]);

                        //moving during reload imagMap
                        if(mapPreLoad != null)
                        {
					        mapPreLoad.insertBefore(this.createRasterImg(),imgCollectionPreLoad[i*this.rasterX]);
					        mapPreLoad.removeChild(imgCollectionPreLoad[(i+1)*this.rasterX]);					    
					    }					    
    					
					    //imgCollection[i*this.rasterX].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart-2)+"_"+(this.PosYStart+i-1)+"_"+this.zoom+".jpg";
					    imgCollection[i*this.rasterX].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(xPos-2)+"&y="+(yPos+i-1)+"&z="+this.zoom;
					    imgCollection[i*this.rasterX].style.width = this.rasterItemWidth+"px";
					    imgCollection[i*this.rasterX].style.height = this.rasterItemHeight+"px";		
				    }
                    
                    //moving during reload imagMap
			        if(this.loadNewImgMap)
			        {  
			    	   for(var k=this.rasterItemsToLoad.length-1 ; k >= 0 ; k--)
				        {  
				            this.rasterItemsToLoad[k] += 1;
				            if(this.rasterItemsToLoad[k]%this.rasterX == 0)
				            {
				                this.rasterItemsToLoad.splice(k,1);  
				             } 
				        }
					}	
				    
				    this.PosXStart -= 1;
				    xPos = this.PosXStart;
			    }
		    }
	    }
	    if(dir=="right")
	    {
		    //absolute(absolute(marginLeft+Left)+containerWidth-imageMapWidth) < deltaMove
		    if(Math.abs(Math.abs(parseInt(map.style.marginLeft.replace("px",""))+parseInt(map.style.left.replace("px","")))+parseInt(this.containerWidth)-parseInt(map.style.width.replace("px",""))) < deltaMove )
		    {
			    for(j=0;j<Math.ceil(deltaMove/this.rasterItemWidth);j++)
			    {
			  //     if(!this.isDragged)
				        map.style.left = map.style.left.replace("px","")*1+this.rasterItemWidth+"px";
			    
				    for(i=0;i<this.rasterY;i++)
				    {
					    if(i<(this.rasterY-1))
						    map.insertBefore(this.createRasterImg(),imgCollection[(i+1)*this.rasterX]);
					    else
						    map.appendChild(this.createRasterImg());
					    map.removeChild(imgCollection[i*this.rasterX]);

                        //moving during reload imagMap
                        if(mapPreLoad != null)
                        {
                            if(i<(this.rasterY-1))
					            mapPreLoad.insertBefore(this.createRasterImg(),imgCollectionPreLoad[(i+1)*this.rasterX]);
					        else
					            mapPreLoad.appendChild(this.createRasterImg());
					        mapPreLoad.removeChild(imgCollectionPreLoad[(i)*this.rasterX]);					    
					    }	
    					
					    //imgCollection[(i+1)*this.rasterX-1].src = "/codex/website/manuscriptimages/Q57_1r_B155_p/"+(this.PosXStart+this.rasterX-1)+"_"+(this.PosYStart+i-1)+"_"+this.zoom+".jpg";
					    imgCollection[(i+1)*this.rasterX-1].src = this.imageHandler+"?image="+this.file[this.light]+"&x="+(xPos+this.rasterX-1)+"&y="+(yPos+i-1)+"&z="+this.zoom;
					    imgCollection[(i+1)*this.rasterX-1].style.width = this.rasterItemWidth+"px";
					    imgCollection[(i+1)*this.rasterX-1].style.height = this.rasterItemHeight+"px";
				    }
                    //moving during reload imagMap
			        if(this.loadNewImgMap)
			        {  
			    	   for(var k=this.rasterItemsToLoad.length-1 ; k >= 0 ; k--)
				        {  
				            this.rasterItemsToLoad[k] -= 1;
				            if(this.rasterItemsToLoad[k]%this.rasterX == 0)
				            {
				                this.rasterItemsToLoad.splice(k,1);  
				             } 
				        }
					}	
				    
				    this.PosXStart += 1;
				   xPos = this.PosXStart;
			    }
		    }
	    }
	    this.setImageMapAfterMove = false;
    }
    else
        window.setTimeout("zoom.setImageMapMove('"+dir+"',"+deltaMove+")",100);
}


//moves (sliding) the imagemap in one of the four directions 
Zoom.prototype.moveImage = function(dir1, dir2 ,pixel, count)
{

 	var scrollStep = Math.round(pixel/20);
	if(dir1=="x")
	{
		if(dir2=="left")
		{
			if(this.imgMap!=null)this.imgMap.style.left = this.imgMap.style.left.replace("px","")*1+pixel/scrollStep+"px";
			if(this.loadNewImgMap) this.newMap.style.left = this.newMap.style.left.replace("px","")*1+pixel/scrollStep+"px";

		}
		if(dir2=="right")
		{
			if(this.imgMap!=null)this.imgMap.style.left = this.imgMap.style.left.replace("px","")*1-pixel/scrollStep+"px";
			if(this.loadNewImgMap) this.newMap.style.left =this.newMap.style.left.replace("px","")*1-pixel/scrollStep+"px";
		}
	}
	if(dir1=="y")
	{
		if(dir2=="top")
		{
			if(this.imgMap!=null)this.imgMap.style.top = this.imgMap.style.top.replace("px","")*1+pixel/scrollStep+"px";
			if(this.loadNewImgMap) this.newMap.style.top = this.newMap.style.top.replace("px","")*1+pixel/scrollStep+"px"

		}
		if(dir2=="bottom")
		{

			if(this.imgMap!=null)this.imgMap.style.top = this.imgMap.style.top.replace("px","")*1-pixel/scrollStep+"px";
			if(this.loadNewImgMap) this.newMap.style.top = this.newMap.style.top.replace("px","")*1-pixel/scrollStep+"px";
		}		
	}	
	if(count<(scrollStep-1))
		window.setTimeout("zoom.moveImage('"+dir1+"','"+dir2+"',"+pixel+","+(count+1)+")", 1);
	else
	{
		this.move = false;
		zoomTB.setClippingBorder();
		if(workspace.physDescShow)ph.generateRaster();
		//linking.createMarker()
	}
}


//zooms (sliding) the imagemap
Zoom.prototype.moveZoom = function(inOut, x ,y, xposInImageMap, yposInImageMap, countSteps)
{
	this.move = true;
	var imgCollection = this.imgMap.getElementsByTagName("img");
	var img = 0;
	var scrollStep = 5;
	if(inOut=="in")	
	{
		newWidthDiff = Math.ceil(this.rasterItemWidth*this.rasterX*(1/this.zoomFaktor-1));
		newHeightDiff = Math.ceil(this.rasterItemHeight*this.rasterY*(1/this.zoomFaktor-1));
		xClick = -x+(this.rasterItemWidth*this.aktXRaster/2)*this.zoomFaktor
		yClick = -y+(this.rasterItemHeight*this.aktYRaster/2)*this.zoomFaktor		

	}
	else
	{		
		newWidthDiff = Math.ceil(this.rasterItemWidth*this.rasterX*(this.zoomFaktor-1));
		newHeightDiff = Math.ceil(this.rasterItemHeight*this.rasterY*(this.zoomFaktor-1));
		xClick = (this.rasterItemWidth*this.aktXRaster/2)*(1/this.zoomFaktor)-x;
		yClick = (this.rasterItemHeight*this.aktYRaster/2)*(1/this.zoomFaktor)-y;
	
	}
	
	//get the real position of the click on the image map; click - top/left - marginTop/marginLeft
	//e.g. click on x=150 => 150 - (-50) - (100) = 300
	if(yposInImageMap==0 && xposInImageMap==0)
	{
		xposInImageMap = xClick - parseInt(this.imgMap.style.left.replace("px","")) - parseInt(this.imgMap.style.marginLeft.replace("px",""));
		yposInImageMap = yClick - parseInt(this.imgMap.style.top.replace("px","")) - parseInt(this.imgMap.style.marginTop.replace("px",""));
	}

	var xDiff = -xClick+((this.rasterItemWidth*this.aktXRaster)/2)-newWidthDiff*(xposInImageMap)/(this.rasterItemWidth*this.rasterX);
	var yDiff = -yClick+((this.rasterItemHeight*this.aktYRaster)/2)-newHeightDiff*(yposInImageMap)/(this.rasterItemHeight*this.rasterY);

	this.imgMap.style.width = this.imgMap.style.width.replace("px","")*1+1 +(newWidthDiff/scrollStep)+"px";
	this.imgMap.style.height = this.imgMap.style.height.replace("px","")*1+1  +(newHeightDiff/scrollStep)+"px";
	
	for(i=0;i<this.rasterY;i++)
	{
		for(j=0;j<this.rasterX;j++)
		{
			imgCollection[img].style.width = imgCollection[img].style.width.replace("px","")*1+(newWidthDiff/(this.rasterX*scrollStep))+"px";
			imgCollection[img].style.height = imgCollection[img].style.height.replace("px","")*1+(newHeightDiff/(this.rasterY*scrollStep))+"px";
			img +=1;
		}
	
	}
	
	this.imgMap.style.top = this.imgMap.style.top.replace("px","")*1+(yDiff/scrollStep)+"px";
	this.imgMap.style.left = this.imgMap.style.left.replace("px","")*1+(xDiff/scrollStep)+"px";
	
	if(countSteps<(scrollStep-1))
	{
		window.setTimeout("zoom.moveZoom('"+inOut+"',"+x+","+y+","+xposInImageMap+","+yposInImageMap+","+(countSteps+1)+")", 100);
	}
	else
	{

		this.loadNewImgMap = true;

		
		var rasterCount = this.imgMap.getElementsByTagName("img").length;
	    //var doRaster = new Array();
	    for(var j = 0; j < rasterCount; j++)
	         this.rasterItemsToLoad.push(j);
	        //doRaster.push(j);
	   	
	   	this.move = false;     
	    //this.setNewImageMap(doRaster.join(","),this.zoom);		
	    this.setNewImageMap(this.zoom);		

		this.getImageSize();
		zoomTB.setClippingBorder();
		if(workspace.physDescShow)ph.generateRaster();
	}	
}


Zoom.prototype.setNewImageMap = function(zoom)
{
		var mapCloneImg = this.imgMapPreLoad.getElementsByTagName("img");
		//var rasterItems = doRaster.split(",");
		
		//zooming during loading
		if(!this.reZoom)
		{
		    //check if all images will be append to new image map
		    if(( this.rasterItemsToLoad.length)>0)
		    {
		        //no new zooming will be happend during loading
			    if((this.zoom == zoom))
			    {
			        for(var i = 0; i <  this.rasterItemsToLoad.length; i++)
			        {
			            //zooming during loading
			            if(!this.reZoom)
			            {
			                if(!this.setImageMapAfterMove)
			                {
					            var pos = parseInt( this.rasterItemsToLoad[i]);
				                if((mapCloneImg[pos]!=null && this.isImageLoaded(mapCloneImg[pos])) || mapCloneImg[pos].src=='')
				                {
					                this.imgMapPreLoad.insertBefore(this.createRasterImg(),mapCloneImg[pos]);
					                var oldNode = this.newMap.childNodes[pos];
					                this.newMap.replaceChild(mapCloneImg[(pos+1)],oldNode);
					                this.rasterItemsToLoad.splice(i,1);
				                }
				             }
				             else
				             {
				                window.setTimeout("zoom.setNewImageMap("+zoom+")",10);
				                return;
				             }
				        }
				        else
				        {
				            this.reZoom = false;
				            return;
				        }
				    }
				    window.setTimeout("zoom.setNewImageMap("+zoom+")",10);
				    return;
			    }
			    else
				    this.newMap.innerHTML = "";
		    }	
		    else
		    {	
			    this.imgMapContainer.removeChild(this.imgMap);
			    this.imgMap = this.newMap;
			    this.newMap = null;			
			    this.loadNewImgMap = false;
			    this.imgMap.style.zIndex = 0;
			    //linking.createMarker()
		    }
        }
        else
        {
            this.reZoom = false;
            return;
        }		    
}

//move the imagemap
//Helper for single steps, to call on function from other JS-file
//Step1: setImageMmapMove - reorder imageMap Parts
//@param direction (top,left,right,bottom)
Zoom.prototype.moveHelper = function(direction, deltaMove)
{

		this.move = true;
		var dir2 = "";
		var deltaMove = Math.ceil(deltaMove/20)*20;

		this.setImageMapMove(direction,deltaMove);
		if(direction == "left" )
		{
			dir2 = "x";
			this.oldXPosAbs -= (Math.pow(this.zoomFaktor, this.zoom)*(deltaMove/this.manuscriptWidth));
		}
		else if(direction == "right")
		{
			dir2 = "x";
			this.oldXPosAbs += (Math.pow(this.zoomFaktor, this.zoom)*(deltaMove/this.manuscriptWidth));
		}
		else if(direction == "top")
		{
			dir2 = "y";
			this.oldYPosAbs -= (Math.pow(this.zoomFaktor, this.zoom)*(deltaMove/this.manuscriptHeight));
		}
		else if(direction == "bottom")
		{
			dir2 = "y";
			this.oldYPosAbs += (Math.pow(this.zoomFaktor, this.zoom)*(deltaMove/this.manuscriptHeight));
		}
		this.moveImage(dir2,direction,deltaMove,0);
		
		linking.deselectWord();
}

//zoom by moving the slider
Zoom.prototype.doZoomBySlider = function(step)
{

    if(!this.reZoom && !this.move)
    {

        if(this.loadNewImgMap)
        {
            this.reZoom = true;
		    this.imgMapContainer.removeChild(this.imgMap);
		    this.imgMap = this.newMap;
		    this.newMap = null;			
		    this.loadNewImgMap = false;
		    this.imgMap.style.zIndex = 0;
		    window.setTimeout("zoom.doZoomBySlider("+step+")",10);
		    return;      
        }
        linking.removeMarker();
        var xClick = this.containerWidth/2;
        var yClick = this.containerHeight/2;
        this.doZoomByStep(step,xClick,yClick,false);
    }
    else
        window.setTimeout("zoom.doZoomBySlider("+step+")",10);
}


//zooming to a zoomstep
Zoom.prototype.doZoomByStep = function(step,xClick,yClick,zoomMove)
{
     
	var xClickAbs = parseFloat(this.oldXPosAbs) + Math.pow(this.zoomFaktor, this.zoom)*(xClick/this.containerWidth);
	var yClickAbs = parseFloat(this.oldYPosAbs) + Math.pow(this.zoomFaktor, this.zoom)*(yClick/this.containerHeight);

	var xPosAbs = xClickAbs - (Math.pow(this.zoomFaktor, step)/2);
	var yPosAbs = yClickAbs - (Math.pow(this.zoomFaktor, step)/2);
	    
	var xFactorMWidthRaster = this.manuscriptWidth/(this.rasterItemWidth*(this.rasterX-2));
	var yFactorMWidthRaster = this.manuscriptHeight/(this.rasterItemHeight*(this.rasterY-2));	
	
	this.aktXRaster = Math.pow((1/this.zoomFaktor),step)*(this.rasterX-2);
	this.aktYRaster = Math.pow((1/this.zoomFaktor),step)*(this.rasterY-2);
	
	this.PosXStart = Math.round(xPosAbs*this.aktXRaster*xFactorMWidthRaster);
	this.PosYStart = Math.round(yPosAbs*this.aktYRaster*yFactorMWidthRaster);	

    var oldZoom = this.zoom;
	this.zoom = step;
	
    this.newMap = this.imgMap.cloneNode(false);
    this.newMap.style.zIndex = "3";
    this.newMap.style.top = "0px";
    this.newMap.style.left = "0px";
    
    var rasterCount = this.imgMap.getElementsByTagName("img").length;
    for(var i=0; i < rasterCount;i++)
        this.newMap.appendChild(this.createRasterImg());
    this.imgMap.parentNode.appendChild(this.newMap);

    this.loadNewImgMap = true;
	this.setImageMap(this.imgMapPreLoad);

    var inout = ((oldZoom < step) ? 'in' : 'out');
    //moving during zoom
	if(zoomMove)
	{
	    if(oldZoom < step)
	    {
	        zoomXStart = (this.oldXPosAbs*xFactorMWidthRaster*this.aktXRaster-this.PosXStart)*(1/this.aktXRaster)*this.manuscriptWidth*Math.pow((1/this.zoomFaktor),(this.zoom-1))*(1/xFactorMWidthRaster);
	        zoomYStart = (this.oldYPosAbs*yFactorMWidthRaster*this.aktYRaster-this.PosYStart)*(1/this.aktYRaster)*this.manuscriptHeight*Math.pow((1/this.zoomFaktor),(this.zoom-1))*(1/yFactorMWidthRaster);
        }
        else
        {
			zoomXStart = (1/this.zoomFaktor)*(this.oldXPosAbs*xFactorMWidthRaster*this.aktXRaster-this.PosXStart)*(1/this.aktXRaster)*this.manuscriptWidth*Math.pow((1/this.zoomFaktor),(this.zoom))*(1/xFactorMWidthRaster);
			zoomYStart = (1/this.zoomFaktor)*(this.oldYPosAbs*yFactorMWidthRaster*this.aktYRaster-this.PosYStart)*(1/this.aktYRaster)*this.manuscriptHeight*Math.pow((1/this.zoomFaktor),(this.zoom))*(1/yFactorMWidthRaster);
        }
	    this.moveZoom(inout,zoomXStart,zoomYStart,0,0,0);
	}
    
    this.oldXPosAbs = this.PosXStart/(this.aktXRaster*xFactorMWidthRaster);
	this.oldYPosAbs = this.PosYStart/(this.aktYRaster*yFactorMWidthRaster);			
	
	//zoom by slider
	if(!zoomMove)
	{
	    this.move = false;
	    //var doRaster = new Array();
	    for(var j = 0; j < rasterCount; j++)
	        this.rasterItemsToLoad.push(j);
	        //doRaster.push(j);
	    
	    //this.setNewImageMap(doRaster.join(","),step);
	    this.setNewImageMap(step);
	    this.getImageSize();
	    zoomTB.setClippingBorder();
	    if(workspace.physDescShow)ph.generateRaster();	
    }
}

//zoom by clicking
Zoom.prototype.doZoom = function(inout,event)
{

	linking.deselectWord();
	
	event = event || window.event;

	var xClick = Event.pointerX(event) - this.imgContainer.offsetLeft-10;		
	var yClick = Event.pointerY(event) - this.imgContainer.offsetTop-10;
	
	var eventElem = Event.element(event);
	
	while(eventElem.id!= "miniWindow" && eventElem.parentNode!=null) eventElem = eventElem.parentNode;
	//!this.loadNewImgMap && 
	if(!this.move && eventElem.id != "miniWindow" && this.file!=null)
	{

		if(this.enabled)
		{	        
            if(!this.loadNewImgMap)
			{
                var step = this.zoom+inout;
                if((this.minZoom <= step) && (step <= this.maxZoom))
                {
                    A_SLIDERS[0].f_setValue(step)
                    this.doZoomByStep(step, xClick, yClick, true);
                }
             }
		}
		else
			linking.manuscriptClick(xClick,yClick);
	}

}


Zoom.prototype.dragStart = function(event)
{
    event = event || window.event;
	if(zoom.enabled && !zoom.move)
	{	   
        if(Event.element(event).id!="sl0slider")
        {   
            zoom.imgContainer.style.cursor = "url(../media/hand_closed.cur), move;";
                   
            if(zoom.loadNewImgMap)
            {
                zoom.DragStartX = Event.pointerX(event) - parseFloat(zoom.newMap.style.left.replace("px",""));		
	            zoom.DragStartY = Event.pointerY(event) - parseFloat(zoom.newMap.style.top.replace("px",""));
            }
            else
            {
                zoom.DragStartX = Event.pointerX(event) - parseFloat(zoom.imgMap.style.left.replace("px",""));		
                zoom.DragStartY = Event.pointerY(event) - parseFloat(zoom.imgMap.style.top.replace("px",""));
            }

       	
            zoom.DragStartXcoord = Event.pointerX(event);		
            zoom.DragStartYcoord = Event.pointerY(event);	
            zoom.isDragged = true; 
          
            linking.deselectWord();
            linking.deselectTranslation();
   	        linking.removeMarker();

            return false;      
        }
	}
	else if(Event.element(event).parentNode.id!='nav_arrows' && !workspace.physDescShow)
	{
        var xClick = Event.pointerX(event) - zoom.imgContainer.offsetLeft-10;		
        var yClick = Event.pointerY(event) - zoom.imgContainer.offsetTop-10;
		linking.manuscriptClick(xClick,yClick);   
	} 
}

Zoom.prototype.dragStop = function(event)
{
    event = event || window.event;
    if(zoom.isDragged && !this.move)
    {
        zoom.isDragged = false;
        
        var deltaMoveX = Event.pointerX(event)- zoom.DragStartXcoord;
        var deltaMoveY = Event.pointerY(event)- zoom.DragStartYcoord;
        
        zoom.oldXPosAbs -= (Math.pow(zoom.zoomFaktor, zoom.zoom)*(deltaMoveX/zoom.manuscriptWidth));
        zoom.oldYPosAbs -= (Math.pow(zoom.zoomFaktor, zoom.zoom)*(deltaMoveY/zoom.manuscriptHeight));    
        zoomTB.setClippingBorder();
	    if(workspace.physDescShow)
	        ph.generateRaster();	        
        zoom.imgContainer.style.cursor = "url(../media/hand_open.cur),pointer";
     }
}

Zoom.prototype.drag = function(event)
{
    event = event || window.event;
    
    if(zoom.isDragged)
    {
        
        zoom.imgMap.style.left = (Event.pointerX(event)- zoom.DragStartX)+"px";
        zoom.imgMap.style.top = (Event.pointerY(event)- zoom.DragStartY)+"px";
       // zoom.imgContainer.style.cursor = "url(../media/hand_closed.cur), move;";        
        
        var myMap = null;
        if(zoom.loadNewImgMap)
        {
            zoom.newMap.style.left = (Event.pointerX(event)- zoom.DragStartX)+"px";
            zoom.newMap.style.top = (Event.pointerY(event)- zoom.DragStartY)+"px";
            zoom.imgMap.innerHTML = "";
            myMap = zoom.newMap;
        }
        else
        {
            myMap = zoom.imgMap;
        }

        var deltaX = Event.pointerX(event)- zoom.DragStartXcoord;
        var deltaY = Event.pointerY(event)- zoom.DragStartYcoord;

        if(!zoom.setImageMapAfterMove && zoom.rasterItemHeight < parseInt(myMap.style.top.replace("px","")))
        {
		    zoom.DragStartY += zoom.rasterItemHeight;	           
            zoom.setImageMapMove("top",zoom.rasterItemHeight);
        }
        if(!zoom.setImageMapAfterMove && zoom.rasterItemWidth < parseInt(myMap.style.left.replace("px","")))
        {
            zoom.DragStartX += zoom.rasterItemWidth;	
            zoom.setImageMapMove("left",zoom.rasterItemWidth);
        }
        if(!zoom.setImageMapAfterMove && -zoom.rasterItemHeight > parseInt(myMap.style.top.replace("px","")))
        {
			zoom.DragStartY -= zoom.rasterItemHeight;	            
            zoom.setImageMapMove("bottom",zoom.rasterItemHeight);
        }
        if(!zoom.setImageMapAfterMove && -zoom.rasterItemWidth > parseInt(myMap.style.left.replace("px","")))
        {
            zoom.DragStartX -= zoom.rasterItemWidth;	     
            zoom.setImageMapMove("right",zoom.rasterItemWidth);
        }   
            
    return false;
    }
}


/*
Zoom.prototype.wheel = function(event)
{
	var delta = 0;

	// ie event handler
	if (!event) 
		event = window.event;
	
	// ie Opera
	if (event.wheelDelta) 
	{
		delta = event.wheelDelta/120;
		// Opera korrektur
		if (window.opera)
		{
			delta = -delta;
		}
		// mozilla
		} 
		else if (event.detail) 
		{
			delta = -event.detail/3;
		}

		// wenn gescrollt wird tue dies
		if (delta){
			setZoom(delta);
		}

	// mozilla scrolling verhindern
	if (event.preventDefault){
	event.preventDefault();
	}

	// ie opera scrolling verhindern
	event.returnValue = false;
}

Zoom.prototype.dowheel = function()
{
	// scroll listener hinzufügen
	if (window.addEventListener){
	// mozilla
	window.addEventListener('DOMMouseScroll', Zoom.wheel, false);
	}
	// ie opera
	window.onmousewheel = document.onmousewheel = wheel;
}

Zoom.prottype.stopwheel = function()
{
	// scroll listener hinzufügen
	if (window.removeEventListener){
	// mozilla
	window.removeEventListener('DOMMouseScroll', Zoom.wheel, false);
	}

	// ie opera
	window.onmousewheel = document.onmousewheel = '';
}



*/

zoom = new Zoom();



