if(!window.main) main=new Object(); ImageZoomRunning = false; zoomStretch = "BOTH"; //"HORIZONTAL", "VERTICAL" /******************************************************************* * * Function : zoomIn * * Description : This function is based on the turn_on() function * of animate2.js (animated rollovers from www.roy.whittle.com). * Each zoom object is given a state. * OnMouseOver the state is switched depending on the current state. * Current state -> Switch to * =========================== * null -> OFF. * OFF -> ZOOM_IN * ZOOM_OUT -> ZOOM_IN * ZOOM_IN_OUT-> ZOOM_IN *****************************************************************/ zoomIn = function(img, zoomStep, maxZoom) { if(img) { if(!zoomStep) { if(zoomStretch == "VERTICAL") zoomStep = img.height/10; else zoomStep = img.width/10; } if(!maxZoom) { if(zoomStretch == "VERTICAL") maxZoom = img.height; else maxZoom = img.width; } if(img.state == null) { img.state = "OFF"; img.index = 0; img.orgWidth = img.width; img.orgHeight = img.height; img.zoomStep = zoomStep; img.maxZoom = 20; } if(img.state == "OFF") { img.state = "ZOOM_IN"; start_zooming(); } else if( img.state == "ZOOM_IN_OUT" || img.state == "ZOOM_OUT") { img.state = "ZOOM_IN"; } } } /******************************************************************* * * Function : zoomOut * * Description : This function is based on the turn_off function * of animate2.js (animated rollovers from www.roy.whittle.com). * Each zoom object is given a state. * OnMouseOut the state is switched depending on the current state. * Current state -> Switch to * =========================== * ON -> ZOOM_OUT. * ZOOM_IN -> ZOOM_IN_OUT. *****************************************************************/ zoomOut = function(img) { if(img) { if(img.state=="ON") { img.state="ZOOM_OUT"; start_zooming(); } else if(img.state == "ZOOM_IN") { img.state="ZOOM_IN_OUT"; } } } /******************************************************************* * * Function : start_zooming * * Description : This function is based on the start_animating() function * of animate2.js (animated rollovers from www.roy.whittle.com). * If the timer is not currently running, it is started. * Only 1 timer is used for all objects *****************************************************************/ function start_zooming() { if(!ImageZoomRunning) ImageZoomAnimation(); } setZoom = function(img) { if(zoomStretch == "HORIZONTAL") { img.width = img.orgWidth + img.index; img.height = img.orgHeight; } else if(zoomStretch == "VERTICAL") { img.width = img.orgWidth; img.height = img.orgHeight + img.index; } else { img.width = img.orgWidth + img.index; } } /******************************************************************* * * Function : ImageZoomAnimation * * Description : This function is based on the Animate function * of animate2.js (animated rollovers from www.roy.whittle.com). * Each zoom object has a state. This function * modifies each object and (possibly) changes its state. *****************************************************************/ function ImageZoomAnimation() { ImageZoomRunning = false; for(i=0 ; i 0) img.index-=img.zoomStep; else img.index = 0; setZoom(img); if(img.index == 0) img.state="OFF"; else ImageZoomRunning = true; } } } /*** Check to see if we need to animate any more frames. ***/ if(ImageZoomRunning) setTimeout("ImageZoomAnimation()", 20); }