(function(c){var r=c.browser.msie&&7>c.browser.version;c(document.body);var m=c(m);c.fn.jqzoom=function(a){return this.each(function(){"a"==this.nodeName.toLowerCase()&&new jqzoom(this,a)})};jqzoom=function(a,m){var p=null;if(p=c(a).data("jqzoom"))return p;var g=this,b=c.extend({},c.jqzoom.defaults,m||{});g.el=a;a.rel=c(a).attr("rel");a.zoom_active=!1;a.zoom_disabled=!1;a.largeimageloading=!1;a.largeimageloaded=!1;a.scale={};a.timer=null;a.mousepos={};a.mouseDown=!1;c(a).css({"outline-style":"none",
"text-decoration":"none"});var k=c("img:eq(0)",a);a.title=c(a).attr("title");a.imagetitle=k.attr("title");var q=0<c.trim(a.title).length?a.title:a.imagetitle,d=new function(b){var e=this;this.node=b[0];this.findborder=function(){var a=0,a=b.css("border-top-width");btop="";var c=0,c=b.css("border-left-width");bleft="";if(a)for(i=0;3>i;i++){var d=[],d=a.substr(i,1);if(!1==isNaN(d))btop=btop+""+a.substr(i,1);else break}if(c)for(i=0;3>i&&!isNaN(c.substr(i,1));i++)bleft+=c.substr(i,1);e.btop=0<btop.length?
eval(btop):0;e.bleft=0<bleft.length?eval(bleft):0};this.fetchdata=function(){e.findborder();e.w=b.width();e.h=b.height();e.ow=b.outerWidth();e.oh=b.outerHeight();e.pos=b.offset();e.pos.l=b.offset().left+e.bleft;e.pos.t=b.offset().top+e.btop;e.pos.r=e.w+e.pos.l;e.pos.b=e.h+e.pos.t;e.rightlimit=b.offset().left+e.ow;e.bottomlimit=b.offset().top+e.oh};this.node.onerror=function(){alert("Problems while loading image.");throw"Problems while loading image.";};this.node.onload=function(){e.fetchdata();0==
c(".zoomPad",a).length&&g.create()};return e}(k),j=new function(){var f=this;this.node=c("<div/>").addClass("zoomPup");this.append=function(){c(".zoomPad",a).append(c(this.node).hide());if("reverse"==b.zoomType)this.image=new Image,this.image.src=d.node.src,c(this.node).empty().append(this.image)};this.setdimensions=function(){this.node.w=parseInt(b.zoomWidth/a.scale.x)>d.w?d.w:parseInt(b.zoomWidth/a.scale.x);this.node.h=parseInt(b.zoomHeight/a.scale.y)>d.h?d.h:parseInt(b.zoomHeight/a.scale.y);this.node.top=
(d.oh-this.node.h-2)/2;this.node.left=(d.ow-this.node.w-2)/2;this.node.css({top:0,left:0,width:this.node.w+"px",height:this.node.h+"px",position:"absolute",display:"none",borderWidth:"1px"});if("reverse"==b.zoomType)this.image.src=d.node.src,c(this.node).css({opacity:1}),c(this.image).css({position:"absolute",display:"block",left:-(this.node.left+1-d.bleft)+"px",top:-(this.node.top+1-d.btop)+"px"})};this.setcenter=function(){this.node.top=(d.oh-this.node.h-2)/2;this.node.left=(d.ow-this.node.w-2)/
2;this.node.css({top:this.node.top,left:this.node.left});"reverse"==b.zoomType&&c(this.image).css({position:"absolute",display:"block",left:-(this.node.left+1-d.bleft)+"px",top:-(this.node.top+1-d.btop)+"px"});n.setposition()};this.setposition=function(e){a.mousepos.x=e.pageX;a.mousepos.y=e.pageY;var f=e=0,e=a.mousepos.x+d.bleft-d.pos.l-(this.node.w+2)/2,f=a.mousepos.y+d.btop-d.pos.t-(this.node.h+2)/2;a.mousepos.x-this.node.w/2<d.pos.l?e=d.bleft-1:a.mousepos.x+this.node.w/2>d.pos.r&&(e=d.w+d.bleft-
this.node.w-1);a.mousepos.y-this.node.h/2<d.pos.t?f=d.btop-1:a.mousepos.y+this.node.h/2>d.pos.b&&(f=d.h+d.btop-this.node.h-1);this.node.left=e;this.node.top=f;this.node.css({left:e+"px",top:f+"px"});"reverse"==b.zoomType&&(c.browser.msie&&7<c.browser.version&&c(this.node).empty().append(this.image),c(this.image).css({position:"absolute",display:"block",left:-(this.node.left+1-d.bleft)+"px",top:-(this.node.top+1-d.btop)+"px"}));n.setposition()};this.hide=function(){k.css({opacity:1});this.node.hide()};
this.show=function(){"innerzoom"!=b.zoomType&&(b.lens||"drag"==b.zoomType)&&this.node.show();"reverse"==b.zoomType&&k.css({opacity:b.imageOpacity})};this.getoffset=function(){var a={};a.left=f.node.left;a.top=f.node.top;return a};return this},l=new function(){var f=this;this.node=c("<div class='zoomWindow'><div class='zoomWrapper'><div class='zoomWrapperTitle'></div><div class='zoomWrapperImage'></div></div></div>");this.ieframe=c('<iframe class="zoomIframe" src="javascript:\'\';" marginwidth="0" marginheight="0" align="bottom" scrolling="no" frameborder="0" ></iframe>');
this.setposition=function(){this.node.leftpos=0;this.node.toppos=0;if("innerzoom"!=b.zoomType)switch(b.position){case "left":this.node.leftpos=0<d.pos.l-d.bleft-Math.abs(b.xOffset)-b.zoomWidth?0-b.zoomWidth-Math.abs(b.xOffset):d.ow+Math.abs(b.xOffset);this.node.toppos=Math.abs(b.yOffset);break;case "top":this.node.leftpos=Math.abs(b.xOffset);this.node.toppos=0<d.pos.t-d.btop-Math.abs(b.yOffset)-b.zoomHeight?0-b.zoomHeight-Math.abs(b.yOffset):d.oh+Math.abs(b.yOffset);break;case "bottom":this.node.leftpos=
Math.abs(b.xOffset);this.node.toppos=d.pos.t-d.btop+d.oh+Math.abs(b.yOffset)+b.zoomHeight<screen.height?d.oh+Math.abs(b.yOffset):0-b.zoomHeight-Math.abs(b.yOffset);break;default:this.node.leftpos=d.rightlimit+Math.abs(b.xOffset)+b.zoomWidth<screen.width?d.ow+Math.abs(b.xOffset):0-b.zoomWidth-Math.abs(b.xOffset),this.node.toppos=Math.abs(b.yOffset)}this.node.css({left:this.node.leftpos+"px",top:this.node.toppos+"px"});return this};this.append=function(){c(".zoomPad",a).append(this.node);this.node.css({position:"absolute",
display:"none",zIndex:5001});if("innerzoom"==b.zoomType){this.node.css({cursor:"default"});var e=0==d.bleft?1:d.bleft;c(".zoomWrapper",this.node).css({width:d.w+"px",borderWidth:e+"px"});c(".zoomWrapperImage",this.node).css({width:"100%",height:d.h+"px"})}else c(".zoomWrapper",this.node).css({width:Math.round(b.zoomWidth)+"px"}),c(".zoomWrapperImage",this.node).css({width:"100%",height:Math.round(b.zoomHeight)+"px"});c(".zoomWrapperTitle",this.node).css({width:"100%",position:"absolute"});c(".zoomWrapperTitle",
this.node).hide();b.title&&0<q.length&&c(".zoomWrapperTitle",this.node).html(q).show();f.setposition()};this.hide=function(){switch(b.hideEffect){case "fadeout":this.node.fadeOut(b.fadeoutSpeed,function(){});break;default:this.node.hide()}this.ieframe.hide()};this.show=function(){switch(b.showEffect){case "fadein":this.node.fadeIn();this.node.fadeIn(b.fadeinSpeed,function(){});break;default:this.node.show()}if(r&&"innerzoom"!=b.zoomType)this.ieframe.width=this.node.width(),this.ieframe.height=this.node.height(),
this.ieframe.left=this.node.leftpos,this.ieframe.top=this.node.toppos,this.ieframe.css({display:"block",position:"absolute",left:this.ieframe.left,top:this.ieframe.top,zIndex:99,width:this.ieframe.width+"px",height:this.ieframe.height+"px"}),c(".zoomPad",a).append(this.ieframe),this.ieframe.show()}},n=new function(){var f=this;this.node=new Image;this.loadimage=function(a){o.show();this.url=a;this.node.style.position="absolute";this.node.style.border="0px";this.node.style.display="none";this.node.style.left=
"-5000px";this.node.style.top="0px";document.body.appendChild(this.node);this.node.src=a};this.fetchdata=function(){var b=c(this.node),h={};this.node.style.display="block";f.w=b.width();f.h=b.height();f.pos=b.offset();f.pos.l=b.offset().left;f.pos.t=b.offset().top;f.pos.r=f.w+f.pos.l;f.pos.b=f.h+f.pos.t;h.x=f.w/d.w;h.y=f.h/d.h;a.scale=h;document.body.removeChild(this.node);c(".zoomWrapperImage",a).empty().append(this.node);j.setdimensions()};this.node.onerror=function(){alert("Problems while loading the big image.");
throw"Problems while loading the big image.";};this.node.onload=function(){f.fetchdata();o.hide();a.largeimageloading=!1;a.largeimageloaded=!0;if("drag"==b.zoomType||b.alwaysOn)j.show(),l.show(),j.setcenter()};this.setposition=function(){var b=-a.scale.x*(j.getoffset().left-d.bleft+1),f=-a.scale.y*(j.getoffset().top-d.btop+1);c(this.node).css({left:b+"px",top:f+"px"})};return this},o=new function(){this.append=function(){this.node=c("<div/>").addClass("zoomPreload").css("visibility","hidden").html(b.preloadText);
c(".zoomPad",a).append(this.node)};this.show=function(){this.node.top=(d.oh-this.node.height())/2;this.node.left=(d.ow-this.node.width())/2;this.node.css({top:this.node.top,left:this.node.left,position:"absolute",visibility:"visible"})};this.hide=function(){this.node.css("visibility","hidden")};return this};c(a).bind("click",function(a){a.preventDefault();return!1});if(0>c.inArray(c.trim(b.zoomType),["standard","drag","innerzoom","reverse"]))b.zoomType="standard";c.extend(g,{create:function(){if(0==
c(".zoomPad",a).length)a.zoomPad=c("<div/>").addClass("zoomPad"),k.wrap(a.zoomPad);0==c(".zoomPup",a).length&&j.append();0==c(".zoomWindow",a).length&&l.append();0==c(".zoomPreload",a).length&&o.append();(b.preloadImages||"drag"==b.zoomType||b.alwaysOn)&&g.load();g.init()},init:function(){if("drag"==b.zoomType)c(".zoomPad",a).mousedown(function(){a.mouseDown=!0}),c(".zoomPad",a).mouseup(function(){a.mouseDown=!1}),document.body.ondragstart=function(){return!1},c(".zoomPad",a).css({cursor:"default"}),
c(".zoomPup",a).css({cursor:"move"});"innerzoom"==b.zoomType&&c(".zoomWrapper",a).css({cursor:"crosshair"});c(".zoomPad",a).bind("mouseenter mouseover",function(b){k.attr("title","");c(a).attr("title","");a.zoom_active=!0;d.fetchdata();a.largeimageloaded?g.activate(b):g.load()});c(".zoomPad",a).bind("mouseleave",function(){g.deactivate()});c(".zoomPad",a).bind("mousemove",function(e){if(e.pageX>d.pos.r||e.pageX<d.pos.l||e.pageY<d.pos.t||e.pageY>d.pos.b)return j.setcenter(),!1;a.zoom_active=!0;a.largeimageloaded&&
!c(".zoomWindow",a).is(":visible")&&g.activate(e);a.largeimageloaded&&("drag"!=b.zoomType||"drag"==b.zoomType&&a.mouseDown)&&j.setposition(e)});var f=[],e=0,h=[],h=c("a").filter(function(){var b=RegExp("gallery[\\s]*:[\\s]*'"+c.trim(a.rel)+"'","i"),d=c(this).attr("rel");if(b.test(d))return this});if(0<h.length){var l=h.splice(0,1);h.push(l)}h.each(function(){if(b.preloadImages){var a=c.extend({},eval("("+c.trim(c(this).attr("rel"))+")"));f[e]=new Image;f[e].src=a.largeimage;e++}c(this).click(function(a){h.each(function(){c(this).removeClass("zoomThumbActive")});
a.preventDefault();g.swapimage(this);return!1})})},load:function(){if(!1==a.largeimageloaded&&!1==a.largeimageloading){var b=c(a).attr("href");a.largeimageloading=!0;n.loadimage(b)}},activate:function(){clearTimeout(a.timer);j.show();l.show()},deactivate:function(){switch(b.zoomType){case "drag":break;default:k.attr("title",a.imagetitle),c(a).attr("title",a.title),b.alwaysOn?j.setcenter():(l.hide(),j.hide())}a.zoom_active=!1},swapimage:function(b){a.largeimageloading=!1;a.largeimageloaded=!1;var d=
{},d=c.extend({},eval("("+c.trim(c(b).attr("rel"))+")"));if(d.smallimage&&d.largeimage){var h=d.smallimage,d=d.largeimage;c(b).addClass("zoomThumbActive");c(a).attr("href",d);k.attr("src",h);j.hide();l.hide();g.load()}else throw alert("ERROR :: Missing parameter for largeimage or smallimage."),"ERROR :: Missing parameter for largeimage or smallimage.";return!1}});k[0].complete&&(d.fetchdata(),0==c(".zoomPad",a).length&&g.create());c(a).data("jqzoom",g)};c.jqzoom={defaults:{zoomType:"standard",zoomWidth:300,
zoomHeight:300,xOffset:10,yOffset:0,position:"right",preloadImages:!0,preloadText:"Loading zoom",title:!0,lens:!0,imageOpacity:0.4,alwaysOn:!1,showEffect:"show",hideEffect:"hide",fadeinSpeed:"slow",fadeoutSpeed:"2000"},disable:function(a){c(a).data("jqzoom").disable();return!1},enable:function(a){c(a).data("jqzoom").enable();return!1},disableAll:function(){},enableAll:function(){}}})(jQuery);jQuery.noConflict();
