var slideshowSettings={slideshowID:'slideshow',timeout:5000,transition:'fade',transitionSpeed:1200,showTitle:true,showDescription:true},gallerySettings={thumbImageHeight:100,thumbBGColor:'#333',inactiveThumbStyles:{opacity:0.6},activeThumbStyles:{opacity:1},showTitle:false,showDescription:false};var nobullit={init:function(){this.attachStylesheet('css/main.js.css');this.slideshow.init();this.gallery.init()},slideshow:{settings:this.settings,init:function(){this.attachSlideshowControls();this.prepareSlideshow()},attachSlideshowControls:function(){$('#'+slideshowSettings.slideshowID).append('<div style="height:350px;" />').find('> li').hide().find('img').each(function(){var slideShowItem=$(this).parent().get(0).nodeName.toLowerCase()==='a'?$(this).parent():this;$(slideShowItem).appendTo('#'+slideshowSettings.slideshowID+' > div')});$('#'+slideshowSettings.slideshowID).append('<a href="#" id="'+slideshowSettings.slideshowID+'-next">NEXT</a><a href="#" id="'+slideshowSettings.slideshowID+'-last">LAST</a>'+(slideshowSettings.showTitle||slideshowSettings.showDescription?('<div id="'+slideshowSettings.slideshowID+'-description"><div>'+(slideshowSettings.showTitle?'<h3/>':'')+(slideshowSettings.showDescription?'<p/>':'')+'</div></div>'):'')).find('> li').hide()},prepareSlideshow:function(){function onAfter(curr,next,opts){var title=$(next).attr('alt')?$(next).attr('alt'):$('img:eq(0)',next).attr('alt'),description=$('#'+slideshowSettings.slideshowID+' li:eq('+opts.currSlide+') p:eq(0)').text();if(title&&title!==''){$('#'+slideshowSettings.slideshowID+'-description h3').html(title)}if(description&&description!==''){$('#'+slideshowSettings.slideshowID+'-description p').html(description)}$('#'+slideshowSettings.slideshowID+'-description').slideDown()}function onBefore(curr,next,opts){$('#'+slideshowSettings.slideshowID+'-description').slideUp()}$('#'+slideshowSettings.slideshowID+' > div:eq(0)').cycle({fx:slideshowSettings.transition||'fade',timeout:slideshowSettings.timeout||4000,prev:'#'+slideshowSettings.slideshowID+'-last',next:'#'+slideshowSettings.slideshowID+'-next',after:onAfter,before:onBefore,speed:slideshowSettings.transitionSpeed||1000})}},gallery:{init:function(){var gallery=this;$(window).load(function(){gallery.prepareGallery()})},prepareGallery:function(){var $gallery=$('#gallery'),contentWidth=$('#content').width(),widerThanContent=true,clickCount=0;if(!$gallery.get(0)){return}if(!$('#'+slideshowSettings.slideshowID).get(0)){$('<div/>').attr({id:slideshowSettings.slideshowID}).append('<a href="#" id="'+slideshowSettings.slideshowID+'-next">NEXT</a><a href="#" id="'+slideshowSettings.slideshowID+'-last">LAST</a>'+(gallerySettings.showTitle||gallerySettings.showDescription?('<div id="'+slideshowSettings.slideshowID+'-description"><div>'+(gallerySettings.showTitle?'<h3/>':'')+(gallerySettings.showDescription?'<p/>':'')+'</div></div>'):'')).insertBefore('#content-wrapper')}var slideshow=$('#'+slideshowSettings.slideshowID);$gallery.css({height:'110px',overflow:'hidden',width:(function(){var width=0;$('li',$gallery).each(function(){$(this).css({width:'auto',backgroundColor:gallerySettings.thumbBGColor,height:gallerySettings.thumbImageHeight||100});$('p',this).hide();width+=($(this).width()+parseInt($(this).css('borderLeftWidth').replace('px',''),10)+parseInt($(this).css('borderRightWidth').replace('px',''),10)+parseInt($(this).css('marginLeft').replace('px',''),10)+parseInt($(this).css('marginRight').replace('px',''),10))});if(width<contentWidth){widerThanContent=false}return width})()+'px'}).wrap('<div id="gallery-wrap"/>');if(widerThanContent){$('<a href="#" id="carousel-back">BACK</a>').click(function(){$('#gallery-wrap').stop().animate({scrollLeft:'-=400px'},900);return false}).prependTo('#content');$('<a href="#" id="carousel-forward">FORWARD</a>').click(function(){$('#gallery-wrap').stop().animate({scrollLeft:'+=400px'},900);return false}).appendTo('#content');$('#gallery-wrap').css({width:contentWidth-90+'px'})}$('li > a',$gallery).each(function(i){$('<img src="'+$(this).attr('href')+'" />').load(function(){$(this).data('loaded',true)}).appendTo(slideshow);$(this).click((function(i){return function(){$(slideshow).cycle(i);return false}})(i)).find('img').css(gallerySettings.inactiveThumbStyles)});function applyThumbStyle(i){$('li > a img',$gallery).css(gallerySettings.inactiveThumbStyles);$('li > a:eq('+i+') img',$gallery).css(gallerySettings.activeThumbStyles)}function onBefore(curr,next,opts){var height=$(next).height();$(next).css({width:$(next).width(),left:'50%',marginLeft:'-'+($(next).width()/2)+'px',height:height}).animate({top:'30px'});$(slideshow).animate({height:(height+60)+'px'});applyThumbStyle(clickCount===0?0:opts.nextSlide);if(opts.currSlide!==opts.nextSlide){$('#'+slideshowSettings.slideshowID+'-description').slideUp()}var nextSlide=$('li:eq('+(clickCount===0?0:opts.nextSlide)+')',$gallery),offsetLeft=$('li:eq(0)',$gallery).offset().left-nextSlide.offset().left;offsetLeft=parseInt((offsetLeft).toString().replace('-',''),10)-(422-(nextSlide.width()/2));$('#gallery-wrap').stop().animate({scrollLeft:offsetLeft+'px'},900);clickCount++}function onAfter(curr,next,opts){var title=$('li:eq('+opts.currSlide+') img:eq(0)',$gallery).attr('alt'),description=$('li:eq('+opts.currSlide+') p:eq(0)',$gallery).html();if(title&&title!==''){$('#'+slideshowSettings.slideshowID+'-description').find('h3').html(title)}if(description&&description!==''){$('#'+slideshowSettings.slideshowID+'-description').find('p').html(description)}$('#'+slideshowSettings.slideshowID+'-description').slideDown()}function showLoader(){$('<div id="gallery-loader"><div><strong>PLEASE WAIT, IMAGES ARE LOADING. (<span>0 of _</span> so far)</strong></div></div>').appendTo(slideshow)}function updateLoader(loaded,all){$('#gallery-loader span').html(loaded+' of '+all)}function hideLoader(){$('#gallery-loader').fadeOut(function(){$(this).remove()})}function checkIfImagesAreLoaded(){var images=$('img',slideshow),loadedImages=0;showLoader();function check(){$(images).each(function(i){if($(this).data('loaded')===true){loadedImages++}});if(loadedImages===images.length){hideLoader();beginSlideshow()}else{updateLoader(loadedImages,images.length);loadedImages=0;setTimeout(function(){check()},400)}}check()}function beginSlideshow(){$(slideshow).cycle({slideExpr:'img',fx:'fade',timeout:0,prev:'#'+slideshowSettings.slideshowID+'-last',next:'#'+slideshowSettings.slideshowID+'-next',after:onAfter,before:onBefore,speed:gallerySettings.transitionSpeed})}checkIfImagesAreLoaded()}},attachStylesheet:function(href){return $('<link href="'+href+'" rel="stylesheet" type="text/css" />').insertAfter('title')}};$(function(){nobullit.init()});