(function($){$.fn.galleryBox=function(settings){settings=jQuery.extend({olayBgColor:'#000',olayOpacity:0.8,imgResizeSpeed:600,initContentWidth:200,initContentHeight:200,contentWidth:300,contentHeight:400,timeoutTimer:false,keyToClose:'c',keyToPrev:'p',keyToNext:'n',imgArray:[],galArray:[],imgActive:0,galActive:0},settings);var jQueryObj=this;function _initialize(){_start(this,jQueryObj);return false;}
function _start(objClicked,jQueryObj){$('embed, object, select').css({'visibility':'hidden'});settings.imgArray.length=0;settings.galArray.length=0;settings.imgActive=0;settings.galActive=0;var thumpath='';gallname='';var myRE=/(\[(\w|\.|\/|\-|\:)+\])/g;if(jQueryObj.length==1){thuminfo=jQueryObj[i].rel.match(myRE);if(thuminfo.length>1)thumpath=thuminfo[1].substring(1,thuminfo[1].length-1);if(thuminfo.length>0)gallname=thuminfo[0].substring(1,thuminfo[0].length-1);settings.imgArray.push(new Array(new Array(objClicked.getAttribute('href'),thumpath,objClicked.getAttribute('title'))));settings.galArray.push(gallname);}else{for(var i=0;i<jQueryObj.length;i++){thumpath='';gallname='';thuminfo=jQueryObj[i].rel.match(myRE);if(thuminfo.length>1)thumpath=thuminfo[1].substring(1,thuminfo[1].length-1);if(thuminfo.length>0)gallname=thuminfo[0].substring(1,thuminfo[0].length-1);galkey=jQuery.inArray(gallname,settings.galArray);if(galkey<0){settings.imgArray.push(new Array(new Array(jQueryObj[i].getAttribute('href'),thumpath,jQueryObj[i].getAttribute('title'))));settings.galArray.push(gallname);}
else{settings.imgArray[galkey].push(new Array(jQueryObj[i].getAttribute('href'),thumpath,jQueryObj[i].getAttribute('title')));}
if(objClicked.getAttribute('href')==jQueryObj[i].getAttribute('href')){galkey=jQuery.inArray(gallname,settings.galArray);settings.imgActive=settings.imgArray[galkey].length-1;settings.galActive=galkey;}}}
_buildBox();_buildEvents();_buildBottomImg();_buildContentArea();_LoadImage();}
function _buildBox(){$('body').append('<div id="gallerybox-overlay"></div><div id="gallerybox-outter"><div id="gallerybox-topbox"><div id="gallerybox-title"><img src="'+_siteRoot+'images/close-top.gif" alt="X" />&nbsp;</div></div><div id="gallerybox-menubox-item"></div><div id="gallerybox-content-left"></div><div id="gallerybox-content-right"></div><div id="gallerybox-maintitle"><div id="project-title"></div><div id="project-url"></div></div><div id="gallerybox-content"><img id="gallerybox-image"/><div id="gallerybox-image-overlay"></div></div><!--<div id="gallarybox-description"></div>--><div id="gallerybox-bottombox"><div id="gallerybox-bottombox-in"></div></div></div>');for(var i=0;i<settings.galArray.length;i++)
$('#gallerybox-menubox-item').append('<a href="#" rel="'+i+'" title="'+settings.galArray[i].replace(/-/ig,' ')+'">'+settings.galArray[i].replace(/-/ig,' ')+'</a>');if($.browser.msie){$('#gallerybox-overlay').css({backgroundColor:settings.olayBgColor,opacity:settings.olayOpacity,width:$(document.body).width(),height:$(document.body).height()}).fadeIn();$('#gallerybox-bottombox').css({width:'98%'});}else{$('#gallerybox-overlay').css({backgroundColor:settings.olayBgColor,opacity:settings.olayOpacity,width:$(document).width(),height:$(document).height()}).fadeIn();}
$('#gallerybox-outter').css({width:$(window).width(),height:$(window).height(),top:$(window).scrollTop(),left:$(window).scrollLeft()});$('#gallerybox-bottombox').css({top:$('#gallerybox-outter').height()-($('#gallerybox-bottombox').height()+20)});settings.contentWidth=$('#gallerybox-outter').width()-380;settings.contentHeight=$('#gallerybox-outter').height()-($('#gallerybox-bottombox').height()+70);}
function _buildEvents(){$('#gallerybox-title').click(function(){_closeBox();});$('#gallerybox-overlay').click(function(){_closeBox();});$('#gallerybox-outter').click(function(event){if(event.target.id=='gallerybox-outter')_closeBox();else return false;});$('#gallerybox-image').load(function(event){_trasformBox();});$('#gallerybox-bottombox').mousemove(function(event){var position=$('#gallerybox-bottombox').position();var gwd=$('#gallerybox-bottombox').width();var iwd=$('#gallerybox-bottombox-in').width();if(iwd>gwd){var ratio=(100/gwd)*(event.clientX-position.left-10);var leftc=((iwd-gwd)/100)*ratio;$('#gallerybox-bottombox').scrollLeft(leftc);}});$(window).resize(function(){clearTimeout(settings.timeoutTimer);if($.browser.msie)
$('#gallerybox-overlay').css({width:$(document.body).width(),height:$(document.body).height()});else
$('#gallerybox-overlay').css({width:$(document).width(),height:$(document).height()});$('#gallerybox-outter').css({width:$(window).width(),height:$(window).height()});$('#gallerybox-bottombox').css({top:$('#gallerybox-outter').height()-($('#gallerybox-bottombox').height()+20)});settings.contentWidth=$('#gallerybox-outter').width()-380;settings.contentHeight=$('#gallerybox-outter').height()-($('#gallerybox-bottombox').height()+70);settings.timeoutTimer=setTimeout(function(){_LoadImage();},200);});$(window).scroll(function(){$('#gallerybox-outter').css({top:$(window).scrollTop(),left:$(window).scrollLeft()});});$('#gallerybox-outter').mousewheel(function(event,delta){return false;});$('#gallerybox-menubox').toggle(function(){$('#gallerybox-menubox-item').fadeIn('normal');},function(){$('#gallerybox-menubox-item').fadeOut('fast');});$('#gallerybox-menubox-item a').click(function(){_loadGallery(this);});$('#gallerybox-content-left').click(function(){if(settings.imgActive>0){settings.imgActive--;prv=$('a.gallerybox_b_img_s').prev();$('a.gallerybox_b_img_s').removeClass('gallerybox_b_img_s').addClass('gallerybox_b_img');prv.addClass('gallerybox_b_img_s');_LoadImage();}});$('#gallerybox-content-right').click(function(){if(settings.imgActive<settings.imgArray[settings.galActive].length-1){settings.imgActive++;nxt=$('a.gallerybox_b_img_s').next();$('a.gallerybox_b_img_s').removeClass('gallerybox_b_img_s').addClass('gallerybox_b_img');nxt.addClass('gallerybox_b_img_s');_LoadImage();}});}
function _buildBottomImg(){gallerybox_bottombox=$('#gallerybox-bottombox-in');$('a.gallerybox_b_img, a.gallerybox_b_img_s').remove();gallerybox_bottombox.css({width:60*settings.imgArray[settings.galActive].length+5});for(var i=0;i<settings.imgArray[settings.galActive].length;i++){if(settings.imgActive==i)
gallerybox_bottombox.append('<a href="javascript:void(0)" class="gallerybox_b_img_s" rel="'+i+'"><img width="100%" src="'+settings.imgArray[settings.galActive][i][1]+'" border="0"/></a>');else
gallerybox_bottombox.append('<a href="javascript:void(0)" class="gallerybox_b_img" rel="'+i+'"><img width="100%" src="'+settings.imgArray[settings.galActive][i][1]+'" border="0"/></a>');}
$('a.gallerybox_b_img, a.gallerybox_b_img_s').click(function(){settings.imgActive=parseInt(this.getAttribute('rel'));$('a.gallerybox_b_img_s').removeClass('gallerybox_b_img_s').addClass('gallerybox_b_img');this.className='gallerybox_b_img_s';_LoadImage();});}
function _buildContentArea(){topc=($('#gallerybox-outter').height()-(settings.initContentHeight+$('#gallerybox-bottombox').height()))/2;leftc=($('#gallerybox-outter').width()-settings.initContentWidth)/2
pstop=((settings.initContentHeight-112)/2)+topc;$('#gallerybox-maintitle').css({width:settings.initContentWidth,height:20,top:topc-25,left:leftc});$('#gallerybox-content').css({width:settings.initContentWidth,height:settings.initContentHeight,top:topc,left:leftc});$('#gallerybox-content-left').css({width:112,height:112,top:pstop,left:leftc,opacity:1});$('#gallerybox-content-right').css({width:112,height:112,top:pstop,left:(settings.initContentWidth+leftc-112),opacity:1});}
function _loadGallery(obj){$('#gallerybox-menubox').trigger('click');settings.galActive=parseInt(obj.getAttribute('rel'));settings.imgActive=0;$('#gallerybox-bottombox-in').empty();_buildBottomImg();_LoadImage();}
function _LoadImage(){$('#gallerybox-content,#gallerybox-image,#gallerybox-content-left,#gallerybox-content-right').stop();$('#gallerybox-image-overlay').fadeIn('slow',function(){$('#gallerybox-image').css({width:'',height:''});$('#gallerybox-image').attr('src',settings.imgArray[settings.galActive][settings.imgActive][0]);});var position=$('#gallerybox-content').position();pstop=(($('#gallerybox-content').height()-150)/2)+position.top;psleft=($('#gallerybox-content').width()/2)+position.left;$('#gallerybox-content-left').animate({top:pstop,left:psleft-75},500,function(){$('#gallerybox-content-left').hide()});$('#gallerybox-content-right').animate({top:pstop,left:psleft-75},500,function(){$('#gallerybox-content-right').hide()});var ProDesc=jQueryObj[settings.imgActive].parentNode.getElementsByTagName("div")[0].innerHTML;var WebsiteURL=jQueryObj[settings.imgActive].parentNode.getElementsByTagName("div")[1].innerHTML;if(WebsiteURL!='')
$('#project-url').html('<a href="'+WebsiteURL+'" onclick="_openWebsite(this);" rel="nofollow">Visit Site</a>');else
$('#project-url').html('')
$('#project-title').html(settings.imgArray[settings.galActive][settings.imgActive][2]);if(ProDesc!='')
$('#gallarybox-description').html(ProDesc);else
$('#gallarybox-description').html('Coming Soon...');}
function _trasformBox()
{var wd=$('#gallerybox-image').width();var hd=$('#gallerybox-image').height();var ratio=100;if(settings.contentWidth<wd&&settings.contentHeight<hd){ratio1=(100/wd)*settings.contentWidth;ratio2=(100/hd)*settings.contentHeight;if(ratio1<ratio2)ratio=ratio1;else ratio=ratio2;}
else if(settings.contentHeight<hd)ratio=(100/hd)*settings.contentHeight;else if(settings.contentWidth<wd)ratio=(100/wd)*settings.contentWidth;wd=(wd/100)*ratio;hd=(hd/100)*ratio;xtop=($('#gallerybox-outter').height()-(hd+$('#gallerybox-bottombox').height()))/2;xtop=xtop-30;yleft=($('#gallerybox-outter').width()-wd)/2;pstop=((hd-150)/2)+xtop;if(wd<0)wd=10;if(hd<0)hd=10;$('#gallerybox-content').animate({width:wd,height:hd,top:xtop-10,left:yleft},settings.imgResizeSpeed,function(){$('#gallerybox-image-overlay').fadeOut(function(){_trasformSideBox();});});$('#gallerybox-maintitle').css({width:wd+20,height:hd,top:xtop-30,left:yleft,'z-index':2000});$('#gallarybox-description').css({width:wd+20,height:100,top:xtop+hd+12,left:yleft});if(ratio<100)$('#gallerybox-image').css({width:wd,height:hd});}
function _trasformSideBox(){var position=$('#gallerybox-content').position();yleft=$('#gallerybox-content').width()+position.left+20;pstop=(($('#gallerybox-content').height()-150)/2)+position.top;psleft=($('#gallerybox-content').width()/2)+position.left;$('#gallerybox-maintitle').show();$('#gallarybox-description').show();if(settings.imgActive>0){$('#gallerybox-content-left').css({top:pstop,left:psleft-75,backgroundImage:"url("+settings.imgArray[settings.galActive][settings.imgActive-1][1]+")"}).show();$('#gallerybox-content-left').animate({top:pstop,left:position.left-170},settings.imgResizeSpeed);}
if(settings.imgActive<settings.imgArray[settings.galActive].length-1){$('#gallerybox-content-right').css({top:pstop,left:psleft-75,backgroundImage:"url("+settings.imgArray[settings.galActive][settings.imgActive+1][1]+")"}).show();$('#gallerybox-content-right').animate({top:pstop,left:yleft+45},settings.imgResizeSpeed);}}
function _closeBox(){$('#gallerybox-content,#gallerybox-image,#gallerybox-content-left,#gallerybox-content-right').stop();$('#gallerybox-outter').remove();$('#gallerybox-overlay').fadeOut(function(){$('#gallerybox-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
return this.unbind('click').click(_initialize);};})(jQuery);;(function($){$.event.special.mousewheel={setup:function(){var handler=$.event.special.mousewheel.handler;if($.browser.mozilla)
$(this).bind('mousemove.mousewheel',function(event){$.data(this,'mwcursorposdata',{pageX:event.pageX,pageY:event.pageY,clientX:event.clientX,clientY:event.clientY});});if(this.addEventListener)
this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=handler;},teardown:function(){var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)
this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=function(){};$.removeData(this,'mwcursorposdata');},handler:function(event){var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});})(jQuery);$(document).ready(function(){$("a[rel^='gallerybox']").galleryBox();});function _openWebsite(obj){window.open(obj,'','');}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)
if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}
