var fps=5;var loadMouseHandler=true;var thumbWindow=null;var adminWindow=null;var timer=null;var thumbs=null;var elev=0;var animwidth=0;var animheight=0;var prevmousex=0;var frame_load_count=0;var frames_loaded=false;var start_on_load=false;var stopLoad=false;var frameNumber=0;var animIncrement=1;var frames=new Array();var firstimage=new Image();var anim_area=new Object();var hs_area=new Object();var min_x_delta=4;function basename(c){var b=/^(.*\/)?(.*)/;var a=c.match(b);return a[2]}function makeThumb(b){var c=$("imgload").src;var d=basename(c);var a="/makethumb.php?ID="+prodID+"&thumb="+d;if(b==true){a=a+"&save=1"}thumbWindow=window.open(a,"thumbwin","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=400,left=10,top=10")}function popAdmin(){var a="/admin.php?ID="+prodID;adminWindow=window.open(a,"adminwin","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=400,left=10,top=10")}function popUp(URL,x,y,l,t){day=new Date();id=day.getTime();eval("page"+id+" = window.open(URL, '"+id+"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+x+",height="+y+",left="+l+",top="+t+"');")}function printanim(){var d=/^(.*\.)+(.*)/;var c=$("imgload").src;var e=basename(c);var b=e.match(d);var a=baseURL+prodID+"/zoom/100/"+e;popUp(a,800,600,0,0);anim_area.pan_on=true}function displayNextFrame(){var h=/^.*\/(\d{1,2})\/(\d{1,3})-(\d{1,3})\.([a-zA-Z]+)/;if(viewerType==0){return}var d=frameNumber+animIncrement;if(d>=frame_count){d=0}else{if(d<0){d=frame_count-1}}frameNumber=d;var a=frames[frameNumber].src;$("imgload").src=a;var g=a.match(h);var j=g[2]+"-"+g[3];var b=document.getElementById("hsdot");var e=document.getElementById("hsimg");var c=document.getElementById("hsinfo");b.style.visibility="hidden";for(var f=0;f<spots_size;f++){if((spots[f][0]==g[1])&&(spots[f][1]==j)){b.style.left=spots[f][2]+"px";b.style.top=spots[f][3]+"px";b.style.visibility="visible";e.src=spots[f][6];var l=spots[f][4];var k=spots[f][5];k+=2;l+=2;c.style.height=k+"px";c.style.width=l+"px"}}}function animationStart(a){if(viewerType==0){return}anim_area.pan_on=false;prevmousex=0;animIncrement=a;if(timer!=null){return}if(!frames_loaded){start_on_load=true}else{displayNextFrame();timer=setInterval(displayNextFrame,(1000/fps))}}function animationStop(){if(timer){clearInterval(timer)}timer=null;prevmousex=0}function repositionImage(){var b=firstimage.width;var a=firstimage.height;var c=anim_area.center_x-Math.round(b/2);var d=anim_area.center_y-Math.round(a/2);anim_area.img_pos_left=c;anim_area.img_pos_top=d;$("imgload").src=firstimage.src;$("imgload").style.left=c+"px";$("imgload").style.top=d+"px";if(debug){$("xval").innerHTML="anim_area.width: "+anim_area.dimensions.width+"\nanim_area.height: "+anim_area.dimensions.height+"\nwidth: "+b+"\nheight: "+a+"\nxoffset: "+c+"\nyoffset: "+d+"\nApp: "+navigator.appName+"\nVer: "+navigator.appVersion}}function countLoadedFrames(){frame_load_count++;if(frame_load_count==frame_count){min_x_delta=Math.ceil(144/frame_count);frames_loaded=true;if(start_on_load){animationStart()}else{anim_area.pan_on=true}}}function mouseHandler(b){var f=/^(\d*)px/;var e=Event.pointerX(b);var d=Event.pointerY(b);if(anim_area.prev_mouse_x===undefined){anim_area.prev_mouse_x=e;anim_area.prev_mouse_y=d}var c=e-anim_area.prev_mouse_x;var a=d-anim_area.prev_mouse_y;if(debug){$("xval").innerHTML="x: "+e+"\ny: "+d+"\ndeltax: "+c+"\ndeltay: "+a}switch(b.type){case"mousedown":animationStop();anim_area.pan_on_save=anim_area.pan_on;anim_area.pan_on=false;anim_area.drag_on=true;c=0;a=0;anim_area.prev_mouse_x=e;anim_area.prev_mouse_y=d;$("animarea").style.cursor="move";break;case"mouseup":if(Math.abs(c)<10){anim_area.pan_on=(anim_area.pan_on_save?false:true)}else{anim_area.pan_on=true}anim_area.drag_on=false;$("animarea").style.cursor="default";break;case"mousemove":if((anim_area.pan_on)&&(viewerType!=0)){if(Math.abs(c)>=min_x_delta){anim_area.prev_mouse_x=e;anim_area.prev_mouse_y=d;if(c>0){animIncrement=1}else{animIncrement=-1}displayNextFrame()}}else{if(anim_area.drag_on){anim_area.prev_mouse_x=e;anim_area.prev_mouse_y=d;anim_area.center_x+=c;anim_area.img_pos_left+=c;$("imgload").style.left=anim_area.img_pos_left+"px";anim_area.center_y+=a;anim_area.img_pos_top+=a;$("imgload").style.top=anim_area.img_pos_top+"px";hs_area.left+=c;hs_area.top+=a;$("hslayer").style.left=hs_area.left+"px";$("hslayer").style.top=hs_area.top+"px"}}break}Event.stop(b)}function stillimg(d){var e=true;var h=new String();var g=/^(\d{1,3})-(\d{1,3})\.([a-zA-Z]+)/;animationStop();if(prodID==thumbs[d][0]){e=false}prodID=thumbs[d][0];viewerType=thumbs[d][1];var c=basename(thumbs[d][2]);fullwid=thumbs[d][3];fullht=thumbs[d][4];frame_count=thumbs[d][5];max_elev=thumbs[d][6];var j=zoomFactor*0.01*fullwid;var i=zoomFactor*0.01*fullht;$("imgload").width=j;$("imgload").height=i;var f=anim_area.center_x-Math.round(fullwid/2);var a=anim_area.center_y-Math.round(fullht/2);anim_area.img_pos_left=f;anim_area.img_pos_top=a;$("imgload").style.left=f+"px";$("imgload").style.top=a+"px";h=baseURL+prodID+"/zoom/"+zoomFactor+"/"+c;firstimage.src=h;firstimage.onload=repositionImage;$("imgload").src=h;var b=c.match(g);frameNumber=b[2]/step;if(e){buildAnim()}}function buildAnim(){var a=new String();if(anim_area.dimensions===undefined){anim_area.dimensions=$("animarea").getDimensions();anim_area.center_x=Math.round(anim_area.dimensions.width/2);anim_area.center_y=Math.round(anim_area.dimensions.height/2);anim_area.pan_on=true;anim_area.drag_on=false;hs_area.left=0;hs_area.top=0}animationStop();if(loadMouseHandler){Event.observe($("animarea"),"mousemove",mouseHandler);Event.observe($("animarea"),"mousedown",mouseHandler);Event.observe($("animarea"),"mouseup",mouseHandler);loadMouseHandler=false}Position.absolutize("hslayer");Position.absolutize("hsinfo");if(viewerType>0){stopLoad=false;frame_load_count=0;var d=frameNumber*step;var c=frameNumber;for(var b=0;b<frame_count;b++){if(stopLoad){stopLoad=false;break}else{a=baseURL+prodID+"/zoom/"+zoomFactor+"/"+elev+"-"+d+"."+anim_ext;frames[c]=new Image();frames[c].src=a;frames[c].onload=countLoadedFrames;c=(c+1)%frame_count;d=(d+step)%(frame_count*step);if(b==0){firstimage.src=a;firstimage.onload=repositionImage}}}}}function zoomIn(){if(zoomFactor<100){stopLoad=true;zoomFactor+=5;var b=zoomFactor*0.01*fullwid;var a=zoomFactor*0.01*fullht;$("imgload").width=b;$("imgload").height=a;var c=anim_area.center_x-Math.round(b/2);var d=anim_area.center_y-Math.round(a/2);anim_area.img_pos_left=c;anim_area.img_pos_top=d;$("imgload").style.left=c+"px";$("imgload").style.top=d+"px";buildAnim()}}function zoomOut(){if(zoomFactor>5){stopLoad=true;zoomFactor-=5;var b=zoomFactor*0.01*fullwid;var a=zoomFactor*0.01*fullht;$("imgload").width=b;$("imgload").height=a;var c=anim_area.center_x-Math.round(b/2);var d=anim_area.center_y-Math.round(a/2);anim_area.img_pos_left=c;anim_area.img_pos_top=d;$("imgload").style.left=c+"px";$("imgload").style.top=d+"px";buildAnim()}}function tiltDown(){if(elev<max_elev){elev+=10;buildAnim()}}function tiltUp(){if(elev>0){elev-=10;buildAnim()}}function changeview(b){var c=b.value;var d="";for(var a=1;a<=5;a++){d="lvl"+a;$(d).style.display="none"}$(c).style.display="inline"}function showview(c){var d="";var b=c.substring(3);anim_area.pan_on=true;for(var a=1;a<=5;a++){d="lvl"+a;$(d).style.display="none"}$("descriptor").selectedIndex=Number(b-1);$(c).style.display="inline"}function resetImg(){$("imgload").src=firstimage.src;frameNumber=0;anim_area.center_x=Math.round(anim_area.dimensions.width/2);anim_area.center_y=Math.round(anim_area.dimensions.height/2);repositionImage();anim_area.pan_on=true}function measure(){animationStop()}function resizeThumbs(){var a=$("thumbbox").getHeight();a-=2;var c=$("thumbbox").immediateDescendants();for(var b=0;b<c.length;b++){if(c[b].hasClassName("snapshot")){c[b].setStyle({height:(a)})}}}function show_hsinfo(){$("hsinfo").style.visibility="visible"}function hide_hsinfo(){$("hsinfo").style.visibility="hidden"};