(function($){jQuery.fn.imagesLoaded=function(b){var c=this.filter('img'),len=c.length;c.bind('load',function(){if(--len<=0){b.call(c,this)}}).each(function(){if(this.complete||this.complete===undefined){var a=this.src;this.src='#';this.src=a}})}})(jQuery);

/*
 CJ Flashy Slideshow
*/
(function($){jQuery.fn.cjFlashySlideShow=function(c){var e={preset:null,xBlocks:12,yBlocks:3,minBlockSize:3,delay:3000,direction:'left',style:'normal',translucent:false,sloppy:false};var g={version:'1.1.3',elem:null,imgs:[],block_dim_x:0,block_dim_y:0,sec_y:0,sec_x:0,current_img:0,current_blocks:0,current_direction:'left',total_blocks:0,loaded:0};function RandRange(a,b,f){var v=a+(Math.random()*(b-a));return typeof f=='undefined'?Math.round(v):v.toFixed(f)}function getNextImage(n){if(parseInt(n,10)+1<g.imgs.length){return g.imgs[n+1].src}else{return g.imgs[0].src}}function resetBlocks(){var a=getNextImage(g.current_img);jQuery(g.elem).find('div#cjFlashyTransitionTop div.cjFlashyTransitionBlock').each(function(){if(e.direction==='random'){var d=['top','left','bottom','right'];e.current_direction=d[RandRange(0,d.length-1)];if(e.current_direction==='top'){jQuery(this)[0]._start_top=e.minBlockSize*-1;jQuery(this)[0]._start_left=parseInt((g.block_dim_x*jQuery(this)[0]._x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}else if(e.current_direction==='left'){jQuery(this)[0]._start_top=parseInt((g.block_dim_y*jQuery(this)[0]._y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(this)[0]._start_left=e.minBlockSize*-1}else if(e.current_direction==='bottom'){jQuery(this)[0]._start_top=jQuery(g.elem).height()+e.minBlockSize;jQuery(this)[0]._start_left=parseInt((g.block_dim_x*jQuery(this)[0]._x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}else if(e.current_direction==='right'){jQuery(this)[0]._start_top=parseInt((g.block_dim_y*jQuery(this)[0]._y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(this)[0]._start_left=jQuery(g.elem).width()+e.minBlockSize}else{jQuery(this)[0]._start_top=parseInt((g.block_dim_y*jQuery(this)[0]._y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(this)[0]._start_left=parseInt((g.block_dim_x*jQuery(this)[0]._x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}}jQuery(this).css({'top':jQuery(this)[0]._start_top+'px','left':jQuery(this)[0]._start_left+'px','width':e.minBlockSize+'px','height':e.minBlockSize+'px','background-image':'url('+a+')','opacity':jQuery(this)[0]._opacity})})}function handleBlocksDone(){g.current_blocks++;if(g.current_blocks===g.total_blocks){var a=getNextImage(g.current_img);jQuery(g.elem).find('div#cjFlashyTransitionBottom').css({'background-image':'url('+a+')','background-attachment':'scroll'});g.current_blocks=0;g.current_img++;if(g.current_img>g.imgs.length-1){g.current_img=0}resetBlocks();if(jQuery(g.elem)[0]._timer!==null){clearTimeout(jQuery(g.elem)[0]._timer)}jQuery(g.elem)[0]._timer=setTimeout(animateBlocks,e.delay)}}function animateBlocks(){jQuery(g.elem).find('div#cjFlashyTransitionTop div.cjFlashyTransitionBlock').each(function(){var a=jQuery(this)[0];jQuery(a).animate({"top":parseInt(((g.block_dim_y*a._y)+(g.block_dim_y/2)-(e.minBlockSize/2))+(e.sloppy?RandRange(0,e.minBlockSize)-(e.minBlockSize/2):0),10)+"px","left":parseInt(((g.block_dim_x*a._x)+(g.block_dim_x/2)-(e.minBlockSize/2))+(e.sloppy?RandRange(0,e.minBlockSize)-(e.minBlockSize/2):0),10)+"px"},e.sloppy?RandRange(350,1250):650,'linear',function(){jQuery(a).animate({'top':a._end_top+'px','left':a._end_left+'px','width':(g.block_dim_x*2)+'px','height':(g.block_dim_y*2)+'px','opacity':1},e.sloppy?RandRange(250,850):650,function(){handleBlocksDone()})})})}function correctOffset(){jQuery(g.elem).find('div#cjFlashyTransitionTop div.cjFlashyTransitionBlock').each(function(){jQuery(this).css({'background-position':(jQuery(g.elem).offset().left-jQuery(window).scrollLeft())+'px '+(jQuery(g.elem).offset().top-jQuery(window).scrollTop())+'px'})})}function createBlocks(){var x,y,next_img=getNextImage(g.current_img);for(y=0;y<e.yBlocks;y++){for(x=0;x<e.xBlocks;x++){var a=jQuery(g.elem).find('div#cjFlashyTransitionTop');jQuery(a).append('<div id="cjFlashyTransitionBlock_'+y+'_'+x+'" class="cjFlashyTransitionBlock">');a=jQuery(g.elem).find('div#cjFlashyTransitionTop div#cjFlashyTransitionBlock_'+y+'_'+x);jQuery(a)[0]._x=x;jQuery(a)[0]._y=y;jQuery(a)[0]._end_top=parseInt(((g.block_dim_y*y)-(g.block_dim_y/2)),10);jQuery(a)[0]._end_left=parseInt(((g.block_dim_x*x)-(g.block_dim_x/2)),10);if(e.direction==='random'){var d=['top','left','bottom','right'];e.current_direction=d[RandRange(0,d.length-1)]}if(e.current_direction==='top'){jQuery(a)[0]._start_top=e.minBlockSize*-1;jQuery(a)[0]._start_left=parseInt((g.block_dim_x*x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}else if(e.current_direction==='left'){jQuery(a)[0]._start_top=parseInt((g.block_dim_y*y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(a)[0]._start_left=e.minBlockSize*-1}else if(e.current_direction==='bottom'){jQuery(a)[0]._start_top=jQuery(g.elem).height()+e.minBlockSize;jQuery(a)[0]._start_left=parseInt((g.block_dim_x*x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}else if(e.current_direction==='right'){jQuery(a)[0]._start_top=parseInt((g.block_dim_y*y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(a)[0]._start_left=jQuery(g.elem).width()+e.minBlockSize}else{jQuery(a)[0]._start_top=parseInt((g.block_dim_y*y)+(g.block_dim_y/2)-(e.minBlockSize/2),10);jQuery(a)[0]._start_left=parseInt((g.block_dim_x*x)+(g.block_dim_x/2)-(e.minBlockSize/2),10)}jQuery(a)[0]._opacity=e.translucent?RandRange(0.1,0.5,2):1;jQuery(a).css({'position':'absolute','top':jQuery(a)[0]._start_top+'px','left':jQuery(a)[0]._start_left+'px','display':'block','width':e.minBlockSize+'px','height':e.minBlockSize+'px','margin':'0px','padding':'0px','background-image':'url('+next_img+')','background-repeat':'no-repeat','background-position':jQuery(g.elem).offset().left+'px '+jQuery(g.elem).offset().top+'px','background-attachment':'fixed','opacity':jQuery(a)[0]._opacity});if(e.style==='rounded'){jQuery(a).css({'-moz-border-radius':jQuery(g.elem).height()+'px','-webkit-border-radius':jQuery(g.elem).height()+'px'})}}}jQuery(window).scroll(function(){correctOffset()});jQuery(window).resize(function(){correctOffset()})}function init(){switch(e.preset){case"cubism":e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/100);e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/100);e.minBlockSize=Math.round(jQuery(g.imgs[0]).width()/100)*25;e.direction="random";e.translucent=true;e.sloppy=true;e.delay=3000;break;case"rain":e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/75);e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/75);e.minBlockSize=2;e.style="rounded";e.direction='top';e.translucent=false;e.sloppy=true;e.delay=1250;break;case"blinds":e.xBlocks=1;e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/15);e.minBlockSize=0;e.style="normal";e.direction='top';e.translucent=false;e.sloppy=false;e.delay=3000;break;case"blinds2":e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/15);e.yBlocks=1;e.minBlockSize=0;e.style="normal";e.direction='top';e.translucent=false;e.sloppy=false;e.delay=3000;break;case"transport":e.xBlocks=1;e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/10);e.minBlockSize=0;e.style="normal";e.direction='top';e.translucent=true;e.sloppy=true;e.delay=1250;break;case"transport2":e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/10);e.yBlocks=1;e.minBlockSize=0;e.style="normal";e.direction='top';e.translucent=true;e.sloppy=true;e.delay=1250;break;case"bricks":e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/100);e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/100);e.minBlockSize=3;e.style="normal";e.direction='left';e.translucent=false;e.sloppy=false;e.delay=3000;break;default:e.xBlocks=Math.round(jQuery(g.imgs[0]).width()/100);e.yBlocks=Math.round(jQuery(g.imgs[0]).height()/100);e.minBlockSize=3;e.style="normal";e.direction='top';e.translucent=false;e.sloppy=false;e.delay=3000;break}e.yBlocks=typeof e.yBlocks!=="number"?3:e.yBlocks<0?1:e.yBlocks;e.xBlocks=typeof e.xBlocks!=="number"?3:e.xBlocks<0?1:e.xBlocks;e.minBlockSize=typeof e.minBlockSize!=="number"?5:e.minBlockSize<0?0:e.minBlockSize;if(jQuery(g.elem).width()>jQuery(g.elem).height()&&e.minBlockSize>jQuery(g.elem).width()){e.minBlockSize=jQuery(g.elem).width()}else if(e.minBlockSize>jQuery(g.elem).height()){e.minBlockSize=jQuery(g.elem).height()}e.delay=typeof e.delay!=="number"?3000:e.delay<0?0:e.delay;if(e.style!=='rounded'){e.style='normal'}e.translucent=typeof e.translucent!=="boolean"?false:e.translucent;e.sloppy=typeof e.sloppy!=="boolean"?false:e.sloppy;if(e.direction!=='top'&&e.direction!=='left'&&e.direction!=='bottom'&&e.direction!=='right'&&e.direction!=='random'&&e.direction!=='none'){e.direction='left'}else if(e.direction==='random'){var d=['top','left','bottom','right'];e.current_direction=d[RandRange(0,d.length-1)]}else{e.current_direction=e.direction}g.block_dim_x=Math.ceil(jQuery(g.elem).width()/e.xBlocks);g.block_dim_y=Math.ceil(jQuery(g.elem).height()/e.yBlocks);g.offset_x=parseInt((parseInt(jQuery(g.elem).css("width"),10)-(g.block_dim_x*e.xBlocks))/2,10);g.offset_y=parseInt((parseInt(jQuery(g.elem).css("height"),10)-(g.block_dim_y*e.yBlocks))/2,10);g.total_blocks=e.xBlocks*e.yBlocks;g.current_img=0;g.current_blocks=0;jQuery(g.elem).append('<div id="cjFlashyTransitionBottom">');jQuery(g.elem).find('div#cjFlashyTransitionBottom').css({'position':'absolute','top':'0px','left':'0px','display':'block','width':jQuery(g.elem).css("width"),'height':jQuery(g.elem).css("height"),'margin':'0px','padding':'0px','background-image':'url("'+g.imgs[g.current_img].src+'")','background-repeat':'no-repeat','background-attachment':'scroll','z-index':1,'overflow':'hidden'});jQuery(g.elem).append('<div id="cjFlashyTransitionTop">');jQuery(g.elem).find('div#cjFlashyTransitionTop').css({'position':'absolute','top':g.offset_y+'px','left':g.offset_x+'px','display':'block','width':g.block_dim_x*e.xBlocks+'px','height':g.block_dim_y*e.yBlocks+'px','margin':'0px','padding':'0px','z-index':2,'overflow':'hidden'});createBlocks();jQuery(g.elem)[0]._timer=setTimeout(animateBlocks,e.delay)}if(c){jQuery.extend(e,c)}return this.each(function(){g.elem=this;g.imgs=jQuery(this).find("img");if(g.elem&&g.imgs.length>0){g.loaded=0;jQuery(g.imgs).each(function(){jQuery(this).imagesLoaded(function(){g.loaded++;if(g.loaded===g.imgs.length){init()}})})}})}})(jQuery);
