jQuery(
function($){$.fn.DWBGallery=function(opt){return this.each(function(){function _success(result,status){if(status=='success'){try{var xmlDoc=result.documentElement;insertThumbnails(xmlDoc);thumbDisplacement();}catch(e){alert(e);}}};function insertMainImage(item,img,dim){var _contWidth=gWidth,_contHeight=gHeight-tHeight-40;$('*',imgContainer).remove();dim.height=dim.height*_contWidth/dim.width;dim.width=_contWidth;if(dim.height>_contHeight){dim.width=dim.width*_contHeight/dim.height;dim.height=_contHeight;}imgContainer.show().animate({width:dim.width,height:dim.height},function(){var _title=Utf8.decode($("title",item).text()),_desc=Utf8.decode($("description",item).text()),_author=Utf8.decode($("author",item).text()),_caption=_title+((_desc.length>0)?': ':'')+_desc+((_author.length>0)?' - '+_author:'');$(img).appendTo(this).attr({width:dim.width-10,height:dim.height-10,border:0,title:''}).wrap('<a href="'+$(img).attr('src')+'" title="'+_caption+'"></a>');insertTooltips($('a',this).lightBox());});};function insertThumbnails(xml){$("item",xml).each(function(index){var _item=this,_title=Utf8.decode($("title",this).text());$('<img title="'+_title+'" />').appendTo(thumbSlide).load(function(){var _width=$(this).width()*tHeight/$(this).height();$(this).attr({width:_width,height:tHeight}).show();$(this).hover(function(evt){var _new_width=_width+_width*0.10,_new_height=tHeight+tHeight*0.10,pos=$(this).attr({width:_new_width,height:_new_height}).position();$(this).after('<img src="/demos/image-gallery/dwb_image_gallery/images/shadow.png" class="thumbnail-shadow" style="width:'+_new_width+'px; left:'+pos.left+'px; top:'+(pos.top+_new_height)+'px;" />');},function(evt){$('.thumbnail-shadow',g).remove();$(this).attr({width:_width,height:tHeight});}).click(function(){insertMainImage(_item,$(this).clone(),{'width':_width,'height':tHeight});});insertTooltips(this);if(index==0){$(this).trigger('click');}}).attr('src',Utf8.decode($("location",this).text()));});};function insertTooltips(elem){var xOffset=-10,yOffset=15;$(elem).hover(function(e){this.t=this.title;this.title='';if(this.t&&this.t.length>0){this.top=(e.pageY+yOffset);this.left=(e.pageX+xOffset);$('body').append('<div id="vtip"><img id="vtipArrow" />'+this.t+'</div>');$('div#vtip #vtipArrow').attr("src",'/demos/image-gallery/dwb_image_gallery/images/vtip_arrow.png');$('div#vtip').css("top",this.top+"px").css("left",this.left+"px").fadeIn("slow");if($('div#vtip').width()>gWidth){$('div#vtip').width(gWidth);}}},function(){this.title=this.t;$("div#vtip").fadeOut("slow").remove();}).mousemove(function(e){this.top=(e.pageY+yOffset);this.left=(e.pageX+xOffset);$("div#vtip").css("top",this.top+"px").css("left",this.left+"px");});};function thumbDisplacement(){var lastImg=thumbSlide.find('img:last-child');thumbContainer.mousemove(function(e){var tWidth=lastImg[0].offsetLeft+lastImg.outerWidth();var left=(e.pageX-thumbContainer.offset().left)*(tWidth-gWidth)/gWidth;thumbContainer.scrollLeft(left);});};opt=opt||{};var tHeight=(opt.thumbnail_height)?opt.thumbnail_height:50,g=$(this);if(opt.db&&g.length>0){var imgContainer=$('<div class="image-container"></div>').appendTo(g),thumbContainer=$('<div class="thumbnail-container"></div>').appendTo(g),thumbSlide=$('<div class="thumbnail-slide"></div>').appendTo(thumbContainer),gHeight=g.height(),gWidth=g.width();$.get(opt.db,_success);}});};});var Utf8={decode:function(utftext){utftext=utftext.replace(/&amp;/gi,"&");var string="",i=0,c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}return string;}}