// FancyZoom.js - v1.1 - http://www.fancyzoom.com
//
// Copyright (c) 2008 Cabel Sasser / Panic Inc
// All rights reserved.
// 
//     Requires: FancyZoomHTML.js
// Instructions: Include JS files in page, call setupZoom() in onLoad. That's it!
//               Any <a href> links to images will be updated to zoom inline.
//               Add rel="nozoom" to your <a href> to disable zooming for an image.
// 
// Redistribution and use of this effect in source form, with or without modification,
// are permitted provided that the following conditions are met:
// 
// * USE OF SOURCE ON COMMERCIAL (FOR-PROFIT) WEBSITE REQUIRES ONE-TIME LICENSE FEE PER DOMAIN.
//   Reasonably priced! Visit www.fancyzoom.com for licensing instructions. Thanks!
//
// * Non-commercial (personal) website use is permitted without license/payment!
//
// * Redistribution of source code must retain the above copyright notice,
//   this list of conditions and the following disclaimer.
//
// * Redistribution of source code and derived works cannot be sold without specific
//   written prior permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var includeCaption=true;var zoomTime=5;var zoomSteps=15;var includeFade=1;var minBorder=90;var shadowSettings="0px 5px 25px rgba(0, 0, 0, ";var zoomImagesURI="/fancyzoom/images-global/zoom/";var myWidth=0,myHeight=0,myScroll=0;myScrollWidth=0;myScrollHeight=0;var zoomOpen=false,preloadFrame=1,preloadActive=false,preloadTime=0,imgPreload=new Image();var preloadAnimTimer=0;var zoomActive=new Array();var zoomTimer=new Array();var zoomOrigW=new Array();var zoomOrigH=new Array();var zoomOrigX=new Array();var zoomOrigY=new Array();var zoomID="ZoomBox";var theID="ZoomImage";var zoomCaption="ZoomCaption";var zoomCaptionDiv="ZoomCapDiv";if(navigator.userAgent.indexOf("MSIE")!=-1){var browserIsIE=true}function setupZoom(){prepZooms();insertZoomHTML();zoomdiv=document.getElementById(zoomID);zoomimg=document.getElementById(theID)}function prepZooms(){if(!document.getElementsByTagName){return }var A=document.getElementsByTagName("a");for(i=0;i<A.length;i++){if(A[i].getAttribute("href")){if(A[i].getAttribute("href").search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)/gi)!=-1){if(A[i].getAttribute("rel")!="nozoom"){A[i].onclick=function(B){return zoomClick(this,B)};A[i].onmouseover=function(){zoomPreload(this)}}}}}}function zoomPreload(B){var A=B.getAttribute("href");if(imgPreload.src.indexOf(B.getAttribute("href").substr(B.getAttribute("href").lastIndexOf("/")))==-1){preloadActive=true;imgPreload=new Image();imgPreload.onload=function(){preloadActive=false};imgPreload.src=A}}function preloadAnimStart(){preloadTime=new Date();document.getElementById("ZoomSpin").style.left=(myWidth/2)+"px";document.getElementById("ZoomSpin").style.top=((myHeight/2)+myScroll)+"px";document.getElementById("ZoomSpin").style.visibility="visible";preloadFrame=1;document.getElementById("SpinImage").src=zoomImagesURI+"zoom-spin-"+preloadFrame+".png";preloadAnimTimer=setInterval("preloadAnim()",100)}function preloadAnim(A){if(preloadActive!=false){document.getElementById("SpinImage").src=zoomImagesURI+"zoom-spin-"+preloadFrame+".png";preloadFrame++;if(preloadFrame>12){preloadFrame=1}}else{document.getElementById("ZoomSpin").style.visibility="hidden";clearInterval(preloadAnimTimer);preloadAnimTimer=0;zoomIn(preloadFrom)}}function zoomClick(C,B){var A=getShift(B);if(!B&&window.event&&(window.event.metaKey||window.event.altKey)){return true}else{if(B&&(B.metaKey||B.altKey)){return true}}getSize();if(preloadActive==true){if(preloadAnimTimer==0){preloadFrom=C;preloadAnimStart()}}else{zoomIn(C,A)}return false}function zoomIn(B,A){zoomimg.src=B.getAttribute("href");if(B.childNodes[0].width){startW=B.childNodes[0].width;startH=B.childNodes[0].height;startPos=findElementPos(B.childNodes[0])}else{startW=50;startH=12;startPos=findElementPos(B)}hostX=startPos[0];hostY=startPos[1];if(document.getElementById("scroller")){hostX=hostX-document.getElementById("scroller").scrollLeft}endW=imgPreload.width;endH=imgPreload.height;if(zoomActive[theID]!=true){if(document.getElementById("ShadowBox")){document.getElementById("ShadowBox").style.visibility="hidden"}else{if(!browserIsIE){if(fadeActive.ZoomImage){clearInterval(fadeTimer.ZoomImage);fadeActive.ZoomImage=false;fadeTimer.ZoomImage=false}document.getElementById("ZoomImage").style.webkitBoxShadow=shadowSettings+"0.0)"}}document.getElementById("ZoomClose").style.visibility="hidden";if(includeCaption){document.getElementById(zoomCaptionDiv).style.visibility="hidden";if(B.getAttribute("title")&&includeCaption){document.getElementById(zoomCaption).innerHTML=B.getAttribute("title")}else{document.getElementById(zoomCaption).innerHTML=""}}zoomOrigW[theID]=startW;zoomOrigH[theID]=startH;zoomOrigX[theID]=hostX;zoomOrigY[theID]=hostY;zoomimg.style.width=startW+"px";zoomimg.style.height=startH+"px";zoomdiv.style.left=hostX+"px";zoomdiv.style.top=hostY+"px";if(includeFade==1){setOpacity(0,zoomID)}zoomdiv.style.visibility="visible";sizeRatio=endW/endH;if(endW>myWidth-minBorder){endW=myWidth-minBorder;endH=endW/sizeRatio}if(endH>myHeight-minBorder){endH=myHeight-minBorder;endW=endH*sizeRatio}zoomChangeX=((myWidth/2)-(endW/2)-hostX);zoomChangeY=(((myHeight/2)-(endH/2)-hostY)+myScroll);zoomChangeW=(endW-startW);zoomChangeH=(endH-startH);if(A){tempSteps=zoomSteps*7}else{tempSteps=zoomSteps}zoomCurrent=0;if(includeFade==1){fadeCurrent=0;fadeAmount=(0-100)/tempSteps}else{fadeAmount=0}zoomTimer[theID]=setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+hostX+", "+zoomChangeX+", "+hostY+", "+zoomChangeY+", "+tempSteps+", "+includeFade+", "+fadeAmount+", 'zoomDoneIn(zoomID)')",zoomTime);zoomActive[theID]=true}}function zoomOut(B,A){if(getShift(A)){tempSteps=zoomSteps*7}else{tempSteps=zoomSteps}if(zoomActive[theID]!=true){if(document.getElementById("ShadowBox")){document.getElementById("ShadowBox").style.visibility="hidden"}else{if(!browserIsIE){if(fadeActive.ZoomImage){clearInterval(fadeTimer.ZoomImage);fadeActive.ZoomImage=false;fadeTimer.ZoomImage=false}document.getElementById("ZoomImage").style.webkitBoxShadow=shadowSettings+"0.0)"}}document.getElementById("ZoomClose").style.visibility="hidden";if(includeCaption&&document.getElementById(zoomCaption).innerHTML!=""){document.getElementById(zoomCaptionDiv).style.visibility="hidden"}startX=parseInt(zoomdiv.style.left);startY=parseInt(zoomdiv.style.top);startW=zoomimg.width;startH=zoomimg.height;zoomChangeX=zoomOrigX[theID]-startX;zoomChangeY=zoomOrigY[theID]-startY;zoomChangeW=zoomOrigW[theID]-startW;zoomChangeH=zoomOrigH[theID]-startH;zoomCurrent=0;if(includeFade==1){fadeCurrent=0;fadeAmount=(100-0)/tempSteps}else{fadeAmount=0}zoomTimer[theID]=setInterval("zoomElement('"+zoomID+"', '"+theID+"', "+zoomCurrent+", "+startW+", "+zoomChangeW+", "+startH+", "+zoomChangeH+", "+startX+", "+zoomChangeX+", "+startY+", "+zoomChangeY+", "+tempSteps+", "+includeFade+", "+fadeAmount+", 'zoomDone(zoomID, theID)')",zoomTime);zoomActive[theID]=true}}function zoomDoneIn(A,B){zoomOpen=true;A=document.getElementById(A);if(document.getElementById("ShadowBox")){setOpacity(0,"ShadowBox");shadowdiv=document.getElementById("ShadowBox");shadowLeft=parseInt(A.style.left)-13;shadowTop=parseInt(A.style.top)-8;shadowWidth=A.offsetWidth+26;shadowHeight=A.offsetHeight+26;shadowdiv.style.width=shadowWidth+"px";shadowdiv.style.height=shadowHeight+"px";shadowdiv.style.left=shadowLeft+"px";shadowdiv.style.top=shadowTop+"px";document.getElementById("ShadowBox").style.visibility="visible";fadeElementSetup("ShadowBox",0,100,5)}else{if(!browserIsIE){fadeElementSetup("ZoomImage",0,0.8,5,0,"shadow")}}if(includeCaption&&document.getElementById(zoomCaption).innerHTML!=""){zoomcapd=document.getElementById(zoomCaptionDiv);zoomcapd.style.top=parseInt(A.style.top)+(A.offsetHeight+15)+"px";zoomcapd.style.left=(myWidth/2)-(zoomcapd.offsetWidth/2)+"px";zoomcapd.style.visibility="visible"}if(!browserIsIE){setOpacity(0,"ZoomClose")}document.getElementById("ZoomClose").style.visibility="visible";if(!browserIsIE){fadeElementSetup("ZoomClose",0,100,5)}document.onkeypress=getKey}function zoomDone(A,B){zoomOpen=false;zoomOrigH[B]="";zoomOrigW[B]="";document.getElementById(A).style.visibility="hidden";zoomActive[B]==false;document.onkeypress=null}function zoomElement(zoomdiv,theID,zoomCurrent,zoomStartW,zoomChangeW,zoomStartH,zoomChangeH,zoomStartX,zoomChangeX,zoomStartY,zoomChangeY,zoomSteps,includeFade,fadeAmount,execWhenDone){if(zoomCurrent==(zoomSteps+1)){zoomActive[theID]=false;clearInterval(zoomTimer[theID]);if(execWhenDone!=""){eval(execWhenDone)}}else{if(includeFade==1){if(fadeAmount<0){setOpacity(Math.abs(zoomCurrent*fadeAmount),zoomdiv)}else{setOpacity(100-(zoomCurrent*fadeAmount),zoomdiv)}}moveW=cubicInOut(zoomCurrent,zoomStartW,zoomChangeW,zoomSteps);moveH=cubicInOut(zoomCurrent,zoomStartH,zoomChangeH,zoomSteps);moveX=cubicInOut(zoomCurrent,zoomStartX,zoomChangeX,zoomSteps);moveY=cubicInOut(zoomCurrent,zoomStartY,zoomChangeY,zoomSteps);document.getElementById(zoomdiv).style.left=moveX+"px";document.getElementById(zoomdiv).style.top=moveY+"px";zoomimg.style.width=moveW+"px";zoomimg.style.height=moveH+"px";zoomCurrent++;clearInterval(zoomTimer[theID]);zoomTimer[theID]=setInterval("zoomElement('"+zoomdiv+"', '"+theID+"', "+zoomCurrent+", "+zoomStartW+", "+zoomChangeW+", "+zoomStartH+", "+zoomChangeH+", "+zoomStartX+", "+zoomChangeX+", "+zoomStartY+", "+zoomChangeY+", "+zoomSteps+", "+includeFade+", "+fadeAmount+", '"+execWhenDone+"')",zoomTime)}}function getKey(A){if(!A){theKey=event.keyCode}else{theKey=A.keyCode}if(theKey==27){zoomOut(this,A)}}function fadeOut(A){if(A.id){fadeElementSetup(A.id,100,0,10)}}function fadeIn(A){if(A.id){fadeElementSetup(A.id,0,100,10)}}var fadeActive=new Array();var fadeQueue=new Array();var fadeTimer=new Array();var fadeClose=new Array();var fadeMode=new Array();function fadeElementSetup(D,F,C,B,E,A){if(fadeActive[D]==true){fadeQueue[D]=new Array(D,F,C,B)}else{fadeSteps=B;fadeCurrent=0;fadeAmount=(F-C)/fadeSteps;fadeTimer[D]=setInterval("fadeElement('"+D+"', '"+fadeCurrent+"', '"+fadeAmount+"', '"+fadeSteps+"')",15);fadeActive[D]=true;fadeMode[D]=A;if(E==1){fadeClose[D]=true}else{fadeClose[D]=false}}}function fadeElement(B,D,A,C){if(D==C){clearInterval(fadeTimer[B]);fadeActive[B]=false;fadeTimer[B]=false;if(fadeClose[B]==true){document.getElementById(B).style.visibility="hidden"}if(fadeQueue[B]&&fadeQueue[B]!=false){fadeElementSetup(fadeQueue[B][0],fadeQueue[B][1],fadeQueue[B][2],fadeQueue[B][3]);fadeQueue[B]=false}}else{D++;if(fadeMode[B]=="shadow"){if(A<0){document.getElementById(B).style.webkitBoxShadow=shadowSettings+(Math.abs(D*A))+")"}else{document.getElementById(B).style.webkitBoxShadow=shadowSettings+(100-(D*A))+")"}}else{if(A<0){setOpacity(Math.abs(D*A),B)}else{setOpacity(100-(D*A),B)}}clearInterval(fadeTimer[B]);fadeTimer[B]=setInterval("fadeElement('"+B+"', '"+D+"', '"+A+"', '"+C+"')",15)}}function setOpacity(C,A){var B=document.getElementById(A).style;if(navigator.userAgent.indexOf("Firefox")!=-1){if(C==100){C=99.9999}}B.filter="alpha(opacity="+C+")";B.opacity=(C/100)}function linear(B,A,D,C){return D*B/C+A}function sineInOut(B,A,D,C){return -D/2*(Math.cos(Math.PI*B/C)-1)+A}function cubicIn(B,A,D,C){return D*(B/=C)*B*B+A}function cubicOut(B,A,D,C){return D*((B=B/C-1)*B*B+1)+A}function cubicInOut(B,A,D,C){if((B/=C/2)<1){return D/2*B*B*B+A}return D/2*((B-=2)*B*B+2)+A}function bounceOut(B,A,D,C){if((B/=C)<(1/2.75)){return D*(7.5625*B*B)+A}else{if(B<(2/2.75)){return D*(7.5625*(B-=(1.5/2.75))*B+0.75)+A}else{if(B<(2.5/2.75)){return D*(7.5625*(B-=(2.25/2.75))*B+0.9375)+A}else{return D*(7.5625*(B-=(2.625/2.75))*B+0.984375)+A}}}}function getSize(){if(self.innerHeight){myWidth=window.innerWidth;myHeight=window.innerHeight;myScroll=window.pageYOffset}else{if(document.documentElement&&document.documentElement.clientHeight){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;myScroll=document.documentElement.scrollTop}else{if(document.body){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;myScroll=document.body.scrollTop}}}if(window.innerHeight&&window.scrollMaxY){myScrollWidth=document.body.scrollWidth;myScrollHeight=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){myScrollWidth=document.body.scrollWidth;myScrollHeight=document.body.scrollHeight}else{myScrollWidth=document.body.offsetWidth;myScrollHeight=document.body.offsetHeight}}}function getShift(B){var A=false;if(!B&&window.event){A=window.event.shiftKey}else{if(B){A=B.shiftKey;if(A){B.stopPropagation()}}}return A}function findElementPos(A){var C=0;var B=0;do{C+=A.offsetLeft;B+=A.offsetTop}while(A=A.offsetParent);return Array(C,B)};function insertZoomHTML(){var K=document.getElementsByTagName("body").item(0);var g=document.createElement("div");g.setAttribute("id","ZoomSpin");g.style.position="absolute";g.style.left="10px";g.style.top="10px";g.style.visibility="hidden";g.style.zIndex="525";K.insertBefore(g,K.firstChild);var S=document.createElement("img");S.setAttribute("id","SpinImage");S.setAttribute("src",zoomImagesURI+"zoom-spin-1.png");g.appendChild(S);var J=document.createElement("div");J.setAttribute("id","ZoomBox");J.style.position="absolute";J.style.left="10px";J.style.top="10px";J.style.visibility="hidden";J.style.zIndex="499";K.insertBefore(J,g.nextSibling);var T=document.createElement("img");T.onclick=function(n){zoomOut(this,n);return false};T.setAttribute("src",zoomImagesURI+"spacer.gif");T.setAttribute("id","ZoomImage");T.setAttribute("border","0");T.setAttribute("style","-webkit-box-shadow: "+shadowSettings+"0.0)");T.style.display="block";T.style.width="10px";T.style.height="10px";T.style.cursor="pointer";J.appendChild(T);var P=document.createElement("div");P.setAttribute("id","ZoomClose");P.style.position="absolute";if(browserIsIE){P.style.left="-1px";P.style.top="0px"}else{P.style.left="-15px";P.style.top="-15px"}P.style.visibility="hidden";J.appendChild(P);var Q=document.createElement("img");Q.onclick=function(n){zoomOut(this,n);return false};Q.setAttribute("id","ZoomCloseImg");Q.setAttribute("src",zoomImagesURI+"closebox.png");Q.setAttribute("width","30");Q.setAttribute("height","30");Q.setAttribute("border","0");Q.style.cursor="pointer";P.appendChild(Q);if(!document.getElementById("ZoomImage").style.webkitBoxShadow&&!browserIsIE){var O=document.createElement("div");O.setAttribute("id","ShadowBox");O.style.position="absolute";O.style.left="50px";O.style.top="50px";O.style.width="100px";O.style.height="100px";O.style.visibility="hidden";O.style.zIndex="498";K.insertBefore(O,J.nextSibling);var R=document.createElement("table");R.setAttribute("border","0");R.setAttribute("width","100%");R.setAttribute("height","100%");R.setAttribute("cellpadding","0");R.setAttribute("cellspacing","0");O.appendChild(R);var D=document.createElement("tbody");R.appendChild(D);var N=document.createElement("tr");N.style.height="25px";D.appendChild(N);var k=document.createElement("td");k.style.width="27px";N.appendChild(k);var d=document.createElement("img");d.setAttribute("src",zoomImagesURI+"zoom-shadow1.png");d.setAttribute("width","27");d.setAttribute("height","25");d.style.display="block";k.appendChild(d);var j=document.createElement("td");j.setAttribute("background",zoomImagesURI+"zoom-shadow2.png");N.appendChild(j);var C=document.createElement("img");C.setAttribute("src",zoomImagesURI+"spacer.gif");C.setAttribute("height","1");C.setAttribute("width","1");C.style.display="block";j.appendChild(C);var i=document.createElement("td");i.style.width="27px";N.appendChild(i);var a=document.createElement("img");a.setAttribute("src",zoomImagesURI+"zoom-shadow3.png");a.setAttribute("width","27");a.setAttribute("height","25");a.style.display="block";i.appendChild(a);inRow2=document.createElement("tr");D.appendChild(inRow2);var h=document.createElement("td");h.setAttribute("background",zoomImagesURI+"zoom-shadow4.png");inRow2.appendChild(h);var B=document.createElement("img");B.setAttribute("src",zoomImagesURI+"spacer.gif");B.setAttribute("height","1");B.setAttribute("width","1");B.style.display="block";h.appendChild(B);var f=document.createElement("td");f.setAttribute("bgcolor","#ffffff");inRow2.appendChild(f);var A=document.createElement("img");A.setAttribute("src",zoomImagesURI+"spacer.gif");A.setAttribute("height","1");A.setAttribute("width","1");A.style.display="block";f.appendChild(A);var e=document.createElement("td");e.setAttribute("background",zoomImagesURI+"zoom-shadow5.png");inRow2.appendChild(e);var m=document.createElement("img");m.setAttribute("src",zoomImagesURI+"spacer.gif");m.setAttribute("height","1");m.setAttribute("width","1");m.style.display="block";e.appendChild(m);var M=document.createElement("tr");M.style.height="26px";D.appendChild(M);var c=document.createElement("td");c.style.width="27px";M.appendChild(c);var Y=document.createElement("img");Y.setAttribute("src",zoomImagesURI+"zoom-shadow6.png");Y.setAttribute("width","27");Y.setAttribute("height","26");Y.style.display="block";c.appendChild(Y);var b=document.createElement("td");b.setAttribute("background",zoomImagesURI+"zoom-shadow7.png");M.appendChild(b);var l=document.createElement("img");l.setAttribute("src",zoomImagesURI+"spacer.gif");l.setAttribute("height","1");l.setAttribute("width","1");l.style.display="block";b.appendChild(l);var Z=document.createElement("td");Z.style.width="27px";M.appendChild(Z);var X=document.createElement("img");X.setAttribute("src",zoomImagesURI+"zoom-shadow8.png");X.setAttribute("width","27");X.setAttribute("height","26");X.style.display="block";Z.appendChild(X)}if(includeCaption){var F=document.createElement("div");F.setAttribute("id","ZoomCapDiv");F.style.position="absolute";F.style.visibility="hidden";F.style.marginLeft="auto";F.style.marginRight="auto";F.style.zIndex="501";K.insertBefore(F,J.nextSibling);var H=document.createElement("table");H.setAttribute("border","0");H.setAttribute("cellPadding","0");H.setAttribute("cellSpacing","0");F.appendChild(H);var L=document.createElement("tbody");H.appendChild(L);var I=document.createElement("tr");L.appendChild(I);var W=document.createElement("td");W.setAttribute("align","right");I.appendChild(W);var G=document.createElement("img");G.setAttribute("src",zoomImagesURI+"zoom-caption-l.png");G.setAttribute("width","13");G.setAttribute("height","26");G.style.display="block";W.appendChild(G);var V=document.createElement("td");V.setAttribute("background",zoomImagesURI+"zoom-caption-fill.png");V.setAttribute("id","ZoomCaption");V.setAttribute("valign","middle");V.style.fontSize="14px";V.style.fontFamily="Helvetica";V.style.fontWeight="bold";V.style.color="#ffffff";V.style.textShadow="0px 2px 4px #000000";V.style.whiteSpace="nowrap";I.appendChild(V);var U=document.createElement("td");I.appendChild(U);var E=document.createElement("img");E.setAttribute("src",zoomImagesURI+"zoom-caption-r.png");E.setAttribute("width","13");E.setAttribute("height","26");E.style.display="block";U.appendChild(E)}};
