// run jQuery in no conflict mode to prevent from conflicts with another libraries that use $ dollar symbol
jQuery.noConflict();

// Below function initializes all javascript functionality when DOM is ready
jQuery(document).ready(function(){

	// add javascript-ready class to body to indicate if javascript is turned on on client side :)
	jQuery('html').addClass('javascript-ready');
	
	// run AJAX on portfolio pages
	portfolio_ajax();
	
	
	// preload images with .preload class on their parent
	jQuery('.preload').preloadImages({
		showSpeed      :   500,   // how fast will pre-loaded images show
		easing         :   'easeOutQuad'    // easing
	});
	
	
	// preload slider images and run Nivo slider when everything's loaded
	// check http://nivo.dev7studios.com/ for more options of Nivo slider
	jQuery('#slider').preloadSlider({
		callback: function(){
			jQuery('#slider').nivoSlider({
				effect         :   'random',   // choose slider effect
				slices         :   12,   // number of slices in homepage slider
				directionNavHide:  false,   // leave this as false, it's overridden by custom function
				controlNav     :   false,   // leave it as false
				captionOpacity :   0   // leave it as 0
			});
			showSliderControls();
		},
		showSpeed       :   700
	});
	
	// drop down menu
	jQuery('#nav').menuDropdown({
		style           :   'above',   // set menu style: 'dropDown' or 'above'
		effect          :   'fade',   // set how dropdown menu will show: 'fade', 'slideToggle' or 'show'
		showSpeed       :   350,   // how fast will dropdown show
		hideSpeed       :   250,   // how fast will dropdow hide
		opacity         :   1   // sub-menu opacity
	});
	
	// add image overlay (the + inside a circle) to fancybox images
	jQuery('a[rel^=fancybox]').showImageOverlay({
		showSpeed       :   450,   // how fast will ovarlay show
		hideSpeed       :   250,   // how fast will ovarlay hide
		opacity         :   .2,   // overlay opacity
		easing          :   'easeOutQuad'   // easing
	});
	
	// AJAX contact form
	contactForm();
	
	// nice button rollovers
	hideButton(".button-over");
	
	// tooltip for footer social icons
	footerTooltip();
	
	// run fancybox on links with rel="fancybox" attribute, ckeck http://fancybox.net/ for option reference
	jQuery("a[rel^=fancybox]").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	500, 
		'speedOut'		:	350,
		'easingIn'      :   'easeOutBack',
		'easingOut'     :   'easeInBack',
		'overlayShow'	:	false
	});
	
	// fix Internet Explorer
	fixIE();
});

(function($){
	$.fn.preloadSlider = function(options){
	
		var defaults = {
			showSpeed: 700,
			easing: 'easeOutQuad',
			callback: ''
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function(){
			var pageLoaded;
			var container = $(this);
			var images = new Array();
			var imagesToLoad;
			var imagesLoaded = 0;
			$(this).find('img').each(function(){
				images.push(this);
			});
			imagesToLoad = images.length;
			
			container.operations = {
				initSlider: function(calledByImage){
					if (calledByImage == true) { imagesLoaded ++; }
					if (imagesLoaded == images.length && pageLoaded == true){
						$(images).each(function(){
							$(this).css({ "display": "block" })
						});
						(options.callback)();
					}
				}
			}
			
			$(window).load(function(){
				pageLoaded = true;
				container.operations.initSlider(false);
			})
			
			for ( var i = 0; i < images.length; i ++) {
				var image = images[i];
				
				$(image).css({ "visibility": "hidden", "opacity": "0" });
				if (i == 0) {
					$(image).css({ "z-index": "10" });
				}
				else {
					$(image).css({ "z-index": "0", "display": "none" });
				}
				$(image).bind('error load', function(){
					imagesToLoad --;
					if (imagesToLoad == 0) {
						$(images).each(function(){
							$(container).css({ "background-image": "none" });
							$(this).css({ "visibility": "visible" }).animate({ opacity: "1" }, {duration:options.showSpeed, easing:options.easing, complete:function(){container.operations.initSlider(true);}});
						});
					}
				}).each(function(){
					if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) { $(this).trigger('load'); }
				});
			}
		});
	
	}
})(jQuery);

(function($){
	$.fn.preloadImages = function(options){
	
		var defaults = {
			showSpeed: 500,
			easing: ''
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function(){
			var container = $(this);
			var image = container.find('img');
			
			$(image).css({ "visibility": "hidden", "opacity": "0" });
			$(image).bind('load error', function(){
				$(this).css({ "visibility": "visible" }).animate({ opacity:"1" }, {duration:options.showSpeed, easing:options.easing}).parent(container).removeClass('preload');
			}).each(function(){
				if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) { $(this).trigger('load'); }
			});
		});
	}
})(jQuery);

(function($){
	$.fn.showImageOverlay = function(options){
		
		var defaults = {
			showSpeed: 500,
			hideSpeed: 300,
			opacity: .2,
			easing: ''
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function(){
			var linkElem = $(this),
			overlayElem = '',
			overlay = $('<span class="overlay"></span>').appendTo(linkElem);
			
			linkElem.css({ "display": "block" });
			$(overlay).css({ "opacity": "0", "visibility": "visible" })
			
			linkElem.hover(
				function(){
					overlay.stop().animate({ opacity:options.opacity }, { queue:false, duration:options.showSpeed, easing:options.easing });
				},
				function(){
					overlay.stop().animate({ opacity:0 }, { queue:false, duration:options.hideSpeed, easing:options.easing });
				}		
			);
		});
	}
})(jQuery);

(function($){
	$.fn.menuDropdown = function(options){
	
		var defaults = {
			style: 'above',
			showSpeed: 300,
			easing: '',
			hideSpeed: 150,
			effect: 'fade',
			opacity: 1
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function(){
			var menu = $(this);
			
			menu.find('a').removeAttr('title');
			menu.find('ul').css({ "display": "none", "opacity": options.opacity });
			if (options.style == 'above' && !($.browser.msie && $.browser.version.substr(0,1)<7)){
				menu.find('li').css({ "position": "static" });
				menu.addClass('above');
			}
			else {
				menu.addClass('drop-down');
			}
			menu.find('li').hover(
				function(){
					var target = $(this).find('ul:first');
					if(options.effect == 'fade'){
						target.css({ "visibility": "visible", "display": "block", "opacity": "0" });
					}
					else {
						target.css({ "visibility": "visible", "display": "none" });
					}
					if (options.effect == 'fade'){
						target.stop().animate({ opacity:options.opacity }, { queue:false, duration:options.showSpeed, easing:options.easing });
					}
					else if (options.effect == 'slideToggle'){
						target.slideToggle(options.showSpeed, options.easing);
					}
					else if (options.effect == 'show'){
						target.show(options.showSpeed, options.easing);
					}
				},
				function(){
					var target = $(this).find('ul:first');
					if (options.hideSpeed <= 0){
						target.css({ "visibility": "hidden" });
					}
					else if (options.effect == 'fade'){
						target.stop().animate({ opacity:"0" }, { queue:false, duration:options.hideSpeed, easing:options.easing, complete:function(){
							target.css({ "visibility": "hidden", "display":"none" });
						} });
					}
					else if (options.effect == 'slideToggle'){
						target.slideToggle(options.hideSpeed, options.easing, function(){
							target.css({ "visibility": "hidden" });
						});
					}
					else if (options.effect == 'show'){
						target.hide(options.hideSpeed, options.easing, function(){
							target.css({ "visibility": "hidden" })
						});
					}
				}
			);
		});	
	}
})(jQuery);

function showSliderControls(){
	if(!(jQuery.browser.msie) || (jQuery.browser.msie && jQuery.browser.version == 6)){
		jQuery('#slider.nivoSlider .nivo-caption, #slider.nivoSlider .nivo-imageLink, #slider.nivoSlider .nivo-directionNav a').each(function(){
			var element = jQuery(this)
			jQuery(this).css({ "opacity":"0" }).css({ "bottom":"-44px" });
			jQuery('#slider').hover(
				function(){
					if (jQuery(element).is('.nivo-caption')) {
						jQuery(element).stop().animate( { bottom:"0", opacity:"1" }, { queue:false, duration:450, easing:"easeOutSine" } );
					}
					else {
						jQuery(element).stop().animate( { bottom:"-1px", opacity:"1" }, { queue:false, duration:450, easing:"easeOutSine" } );
					}
				},
				function(){
					jQuery(element).stop().animate( { bottom:"-44px", opacity:"0" }, { queue:false, duration:450, easing:"easeInSine" } );
				}
			)
		});
	}
	else{
		jQuery('#slider.nivoSlider .nivo-caption, #slider.nivoSlider .nivo-imageLink, #slider.nivoSlider .nivo-directionNav a').each(function(){
			var element = jQuery(this)
			jQuery('.nivo-caption').css({ "opacity":"1", "padding-top":"1px", "background-position":"left bottom", "background-color":"#ededed", "background-image":"none", "border-top":"1px solid #ffffff" });
			jQuery(this).css({ "bottom":"-44px" });
			jQuery('#slider').hover(
				function(){
					if (jQuery(element).is('.nivo-caption')) {
						jQuery(element).stop().animate( { bottom:"0", opacity:".8" }, { queue:false, duration:450, easing:"easeOutSine" } );
					}
					else {
						jQuery(element).stop().animate( { bottom:"-1px", opacity:"1" }, { queue:false, duration:450, easing:"easeOutSine" } );
					}
				},
				function(){
					jQuery(element).stop().animate( { bottom:"-44px", opacity:"0" }, { queue:false, duration:450, easing:"easeInSine" } );
				}
			)
		});
	}
}

function hideButton(elem){
	if (!(jQuery.browser.msie)) {
		jQuery(elem).css({ "opacity":"1" });
		jQuery(elem).hover(
			function(){jQuery(this).stop().animate( { opacity:"0" }, { queue:false, duration:250 } );},
			function(){jQuery(this).stop().animate( { opacity:"1" }, { queue:false, duration:350 } );}
		);
	}
}

function footerTooltip(){
	if(jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7){
	}else{
		jQuery("#footer #social a img").each(function(){
												  
			var linkTitle = jQuery(this).parent('a').attr('title');
		
			var linkElem = jQuery(this).parent('a')
		
			jQuery('<span class="tooltip"><span class="tooltip-content"></span></span>').appendTo(linkElem);
		
			jQuery(linkElem).removeAttr('title').children('span.tooltip').children('span.tooltip-content').text(linkTitle);
		
			jQuery(this).hover(
				function(){jQuery(linkElem).children('span.tooltip').css( { "opacity" : "0", "display" : "block" } ).stop().animate( { opacity:"1" }, { queue:false, duration:500 } )},
				function(){jQuery(linkElem).children('span.tooltip').stop().animate( { opacity:"0" }, { queue:false, duration:250, complete:function(){jQuery(linkElem).children('span.tooltip').css({"display":"none"});} } );}
				);
		});
	}
}

function portfolio_ajax(){
	
	var ready = false;
	var mainHeight = jQuery("#sidebar").height();
	var linkElems = new Array();
	var counter = 0;
	var startingItem;
	
	function hideContainers(item, isAjax){
		jQuery(".post-container").each(function(){
			var elem = jQuery(this);
			if (!(jQuery.browser.msie && jQuery.browser.version == 8)){
				jQuery(elem).fadeOut(400);
			}
			else {
				jQuery(elem).find('h2, h3, h4, h5, h6').each(function(){
					jQuery(this).css({ "visibility":"hidden" });														  
				});
				var elems = jQuery('.post-container .framed-image, .post-container .inner-frame, .post-container .inner-frame a');
				jQuery(elems).each(function(){
					jQuery(this).css({ "opacity":"1" });
					jQuery(this).animate({ opacity:"0" }, { queue:false, duration:400 });
				});
				jQuery(elem).fadeOut(400);
			}
		});
		jQuery(".portfolio-list li").each(function(){
			jQuery(this).removeClass('current');
		});
		if (isAjax == true){
			jQuery(item).addClass('loading');
		}
	}
	
	function makeContainer(id){
		var postContainer = '<div id="' + id + '" class="post-container"></div>';
		jQuery("#main.portfolio").append(postContainer);
		jQuery('#' + id).css({ "display":"none" });
	}
	

	function ajaxLoad(id, url, item){
		jQuery('#' + id).load('' + url + ' #the-content', function(){
			Cufon.replace('#main h2', {hover: true});
			Cufon.replace('#main h3', {hover: true});
			Cufon.replace('#main h4', {hover: true});
			Cufon.replace('#main h5', {hover: true});
			Cufon.replace('#main h6', {hover: true});
			Cufon.replace('#main .post .date', {hover: true});
			jQuery('.preload').preloadImages({
				showSpeed: 500,
				easing: 'easeOutQuad'
			});
			jQuery('#' + id + ' a[rel^=fancybox]').showImageOverlay({
				showSpeed: 450,
				hideSpeed: 250,
				opacity: .2,
				easing: 'easeOutQuad'
			});
			jQuery('#' + id + ' a[rel^=fancybox]').fancybox({
				'transitionIn'	:	'elastic',
				'transitionOut'	:	'elastic',
				'speedIn'		:	500, 
				'speedOut'		:	350,
				'easingIn'      :   'easeOutBack',
				'easingOut'     :   'easeInBack',
				'overlayShow'	:	false
			});
			showCurrentContainer(id, item);
		});
	}
	
	function showCurrentContainer(id, item){
		jQuery(item).removeClass('loading').removeClass('not-loaded').addClass('current').addClass('loaded');
		if(jQuery.browser.msie && jQuery.browser.version == 7){jQuery('#' + id).css({'visibility':'hidden','display':'block'});}
		var postHeight = jQuery('#' + id).height();
		if(jQuery.browser.msie && jQuery.browser.version == 7){jQuery('#' + id).css({'visibility':'visible','display':'none'});}


		if ( postHeight > mainHeight ){
			jQuery("#main.portfolio").animate({ height:postHeight }, { queue:true, duration:800, easing:"easeOutCirc"});
		}
		else {
			jQuery("#main.portfolio").animate({ height:mainHeight }, { queue:true, duration:800, easing:"easeOutCirc"});
		}
		if (jQuery.browser.msie && jQuery.browser.version == 8){
			jQuery('#' + id).find('h2, h3, h4, h5, h6').each(function(){
				jQuery(this).css({ "visibility":"visible" });														  
			});
			var elems = jQuery('#' + id).find('.framed-image, .inner-frame, .inner-frame a');
			jQuery(elems).each(function(){
				jQuery(this).css({ "opacity":"0" });
				jQuery(this).animate({ opacity:"1" }, { queue:false, duration:800 });
			});
		}
		jQuery('#' + id).fadeIn(800, function(){ready = true});
	}
	
	function loadItem(item, isAjax, isFirst){
		var currentItem = item;
		var currentIndex = jQuery.inArray(item, linkElems);
		var URLToLoad = jQuery(item).children("a").attr('href');
		var postContainerID = 'post-' + currentIndex;
		var content;
		
		if (isAjax == false && isFirst == false){
			hideContainers(null, false);
			showCurrentContainer(postContainerID, item);
		}
		else if (isAjax == false && isFirst == true){
			content = jQuery("#main.portfolio").html();
			hideContainers(currentItem, false);
			makeContainer(postContainerID);
			jQuery('#' + postContainerID).html(content);
			showCurrentContainer(postContainerID, currentItem);
		}
		else if (isAjax == true){
			hideContainers(currentItem, true);
			makeContainer(postContainerID);
			ajaxLoad(postContainerID, URLToLoad, currentItem);
		}
	}
	

	function init(){
		jQuery(".portfolio-list li").each(function(){
			linkElems.push(this);
		});
		jQuery(".portfolio-list li").addClass('not-loaded');
		
		for (var j = 0; j < linkElems.length; j++){
			if (jQuery(linkElems[j]).is('.not-loaded') && !(jQuery(linkElems[j]).is('.current'))){
				counter++;
			}
			else if (jQuery(linkElems[j]).is('.current')){
				startingItem = linkElems[j];
			}
		}
	
		if (counter == linkElems.length){
			loadItem(linkElems[0], true, false);
		}
		else {
			loadItem(startingItem, false, true);
		}
	
		for (var i = 0; i < linkElems.length; i++){
			jQuery(linkElems[i]).click(function(){
				if (ready == false){
					return false;
				}
				else {
					ready = false;
					if (jQuery(this).is('.not-loaded')){
						loadItem(this, true, false)
						return false;
					}
					else if (jQuery(this).is('.loaded')){
						if (jQuery(this).is('.current')){
							ready = true;
							return false;
						}
						else {
							loadItem(this, false, false);
							return false;
						}
					}
			
				}
			
			});
		}
	}
	
	init();
}

function contactForm(){
	
	jQuery('#ajaxResponse').css({ "display": "none" });
    var paraTag = jQuery('#contact-form input#submit').parent('span');
    jQuery(paraTag).children('input').remove();
    jQuery(paraTag).append('<input type="button" name="submit" id="submit" class="button-over" value="Submit" tabindex="4" />');

    jQuery('#contact-form input#submit').click(function() {
        jQuery('#contact-form .textarea').append('<span id="loader-icon"></span>').show(200);

        var name = jQuery('input#name').val();
        var email = jQuery('input#email').val();
        var subject = jQuery('input#subject').val();
        var comments = jQuery('textarea#message').val();

        jQuery.ajax({
            type: 'post',
            url: 'sendEmail.php',
            data: 'name=' + name + '&email=' + email + '&subject=' + subject + '&comments=' + comments,

            success: function(results) {
				jQuery('#ajaxResponse').hide(200, function(){
					jQuery('#loader-icon').remove();
					jQuery('#ajaxResponse').html(results).show(500);
					}					
				);				
            }
        });
    });
}

function fixIE(){
		if (jQuery.browser.msie && jQuery.browser.version < 7){
			jQuery('#bottombar .bottombar-widget:first-child').css({ "background-image":"none", "padding-left":"0" });
		}
		if (jQuery.browser.msie && jQuery.browser.version < 8){
			jQuery('a[rel^=fancybox]').live('mouseenter', function(){
				var target = jQuery(this);
				var overlay = jQuery(target).find('.overlay');
				var image = jQuery(target).find('img');
				var imageHeight = jQuery(image).attr('height');
		
				var targetHeight = imageHeight + 'px';
		
				jQuery(target).css({ "height": targetHeight });
				jQuery(overlay).css({ "height": targetHeight, "background": "#ffffff url(images/blue/image-overlay.png) no-repeat center center" });
			});
		}
}

// -------------------- PLUGINS -------------------

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
 
 



/*
 * jQuery Nivo Slider v1.9
 * http://nivo.dev7studios.com
 *
 * Copyright 2010, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * April 2010 - controlNavThumbs option added by Jamie Thompson (http://jamiethompson.co.uk)
 * March 2010 - manualAdvance option added by HelloPablo (http://hellopablo.co.uk)
 *
 *
 * LICENSE:
 *
 * Copyright (c) 2010 Gilbert Pellegrom
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(9($){$.1h.1i=9(1T){b 4=$.2b({},$.1h.1i.21,1T);K g.F(9(){b 3={e:0,n:\'\',T:0,u:\'\',H:l,1f:l,1O:l};b 5=$(g);5.1Q(\'7:3\',3);5.f(\'2h\',\'2i\');5.w(\'1X\');5.x(\'1X\');5.1c(\'1i\');b d=5.2f();d.F(9(){b o=$(g);6(!o.J(\'D\')){6(o.J(\'a\')){o.1c(\'7-2e\')}o=o.1n(\'D:1m\')}b 13=o.w();6(13==0)13=o.t(\'w\');b 18=o.x();6(18==0)18=o.t(\'x\');6(13>5.w()){5.w(13)}6(18>5.x()){5.x(18)}o.f(\'S\',\'1z\');3.T++});6(4.16>0){6(4.16>=3.T)4.16=3.T-1;3.e=4.16}6($(d[3.e]).J(\'D\')){3.n=$(d[3.e])}k{3.n=$(d[3.e]).1n(\'D:1m\')}6($(d[3.e]).J(\'a\')){$(d[3.e]).f(\'S\',\'1v\')}5.f(\'Y\',\'W(\'+3.n.t(\'M\')+\') Q-R\');23(b i=0;i<4.h;i++){b E=1d.2a(5.w()/4.h);6(i==4.h-1){5.P($(\'<A B="7-c"></A>\').f({29:(E*i)+\'12\',w:(5.w()-(E*i))+\'12\'}))}k{5.P($(\'<A B="7-c"></A>\').f({29:(E*i)+\'12\',w:E+\'12\'}))}}5.P($(\'<A B="7-L"><p></p></A>\').f({S:\'1z\',y:4.20}));6(3.n.t(\'1a\')!=\'\'){$(\'.7-L p\',5).1B(3.n.t(\'1a\'));$(\'.7-L\',5).1y(4.q)}b j=0;6(!4.1g){j=1o(9(){C(5,d,4,l)},4.1j)}6(4.V){5.P(\'<A B="7-V"><a B="7-25">2d</a><a B="7-27">2k</a></A>\');6(4.1N){$(\'.7-V\',5).24();5.1W(9(){$(\'.7-V\',5).2c()},9(){$(\'.7-V\',5).24()})}$(\'a.7-25\',5).1s(\'1u\',9(){6(3.H)K l;X(j);j=\'\';3.e-=2;C(5,d,4,\'1r\')});$(\'a.7-27\',5).1s(\'1u\',9(){6(3.H)K l;X(j);j=\'\';C(5,d,4,\'1q\')})}6(4.G){b 1l=$(\'<A B="7-G"></A>\');5.P(1l);23(b i=0;i<d.22;i++){6(4.1L){b o=d.1w(i);6(!o.J(\'D\')){o=o.1n(\'D:1m\')}1l.P(\'<a B="7-1t" 1x="\'+i+\'"><D M="\'+o.t(\'M\').2g(4.1R,4.1S)+\'"></a>\')}k{1l.P(\'<a B="7-1t" 1x="\'+i+\'">\'+i+\'</a>\')}}$(\'.7-G a:1w(\'+3.e+\')\',5).1c(\'1b\');$(\'.7-G a\',5).1s(\'1u\',9(){6(3.H)K l;6($(g).2j(\'1b\'))K l;X(j);j=\'\';5.f(\'Y\',\'W(\'+3.n.t(\'M\')+\') Q-R\');3.e=$(g).t(\'1x\')-1;C(5,d,4,\'1t\')})}6(4.1Z){$(2m).2z(9(1A){6(1A.1V==\'2w\'){6(3.H)K l;X(j);j=\'\';3.e-=2;C(5,d,4,\'1r\')}6(1A.1V==\'2y\'){6(3.H)K l;X(j);j=\'\';C(5,d,4,\'1q\')}})}6(4.1U){5.1W(9(){3.1f=N;X(j);j=\'\'},9(){3.1f=l;6(j==\'\'&&!4.1g){j=1o(9(){C(5,d,4,l)},4.1j)}})}5.2A(\'7:U\',9(){3.H=l;$(d).F(9(){6($(g).J(\'a\')){$(g).f(\'S\',\'1z\')}});6($(d[3.e]).J(\'a\')){$(d[3.e]).f(\'S\',\'1v\')}6(j==\'\'&&!3.1f&&!4.1g){j=1o(9(){C(5,d,4,l)},4.1j)}4.1M.1p(g)})});9 C(5,d,4,14){b 3=5.1Q(\'7:3\');6((!3||3.1O)&&!14)K l;4.1K.1p(g);6(!14){5.f(\'Y\',\'W(\'+3.n.t(\'M\')+\') Q-R\')}k{6(14==\'1r\'){5.f(\'Y\',\'W(\'+3.n.t(\'M\')+\') Q-R\')}6(14==\'1q\'){5.f(\'Y\',\'W(\'+3.n.t(\'M\')+\') Q-R\')}}3.e++;6(3.e==3.T){3.e=0;4.1P.1p(g)}6(3.e<0)3.e=(3.T-1);6($(d[3.e]).J(\'D\')){3.n=$(d[3.e])}k{3.n=$(d[3.e]).1n(\'D:1m\')}6(4.G){$(\'.7-G a\',5).2B(\'1b\');$(\'.7-G a:1w(\'+3.e+\')\',5).1c(\'1b\')}6(3.n.t(\'1a\')!=\'\'){6($(\'.7-L\',5).f(\'S\')==\'1v\'){$(\'.7-L p\',5).28(4.q,9(){$(g).1B(3.n.t(\'1a\'));$(g).1y(4.q)})}k{$(\'.7-L p\',5).1B(3.n.t(\'1a\'))}$(\'.7-L\',5).1y(4.q)}k{$(\'.7-L\',5).28(4.q)}b i=0;$(\'.7-c\',5).F(9(){b E=1d.2a(5.w()/4.h);$(g).f({x:\'O\',y:\'0\',Y:\'W(\'+3.n.t(\'M\')+\') Q-R -\'+((E+(i*E))-E)+\'12 0%\'});i++});6(4.m==\'1G\'){b 1J=2x 2u("1H","10","1I","19","1C","Z","1D","1k");3.u=1J[1d.2l(1d.1G()*(1J.22+1))];6(3.u==2n)3.u=\'1k\'}3.H=N;6(4.m==\'2v\'||4.m==\'1H\'||3.u==\'1H\'||4.m==\'10\'||3.u==\'10\'){b r=0;b i=0;b h=$(\'.7-c\',5);6(4.m==\'10\'||3.u==\'10\')h=$(\'.7-c\',5).17();h.F(9(){b c=$(g);c.f(\'1E\',\'O\');6(i==4.h-1){I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q,\'\',9(){5.11(\'7:U\')})},(s+r))}k{I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q)},(s+r))}r+=1e;i++})}k 6(4.m==\'2p\'||4.m==\'1I\'||3.u==\'1I\'||4.m==\'19\'||3.u==\'19\'){b r=0;b i=0;b h=$(\'.7-c\',5);6(4.m==\'19\'||3.u==\'19\')h=$(\'.7-c\',5).17();h.F(9(){b c=$(g);c.f(\'26\',\'O\');6(i==4.h-1){I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q,\'\',9(){5.11(\'7:U\')})},(s+r))}k{I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q)},(s+r))}r+=1e;i++})}k 6(4.m==\'1C\'||4.m==\'2q\'||3.u==\'1C\'||4.m==\'Z\'||3.u==\'Z\'){b r=0;b i=0;b v=0;b h=$(\'.7-c\',5);6(4.m==\'Z\'||3.u==\'Z\')h=$(\'.7-c\',5).17();h.F(9(){b c=$(g);6(i==0){c.f(\'1E\',\'O\');i++}k{c.f(\'26\',\'O\');i=0}6(v==4.h-1){I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q,\'\',9(){5.11(\'7:U\')})},(s+r))}k{I(9(){c.z({x:\'s%\',y:\'1.0\'},4.q)},(s+r))}r+=1e;v++})}k 6(4.m==\'1D\'||3.u==\'1D\'){b r=0;b i=0;$(\'.7-c\',5).F(9(){b c=$(g);b 1F=c.w();c.f({1E:\'O\',x:\'s%\',w:\'O\'});6(i==4.h-1){I(9(){c.z({w:1F,y:\'1.0\'},4.q,\'\',9(){5.11(\'7:U\')})},(s+r))}k{I(9(){c.z({w:1F,y:\'1.0\'},4.q)},(s+r))}r+=1e;i++})}k 6(4.m==\'1k\'||3.u==\'1k\'){b i=0;$(\'.7-c\',5).F(9(){$(g).f(\'x\',\'s%\');6(i==4.h-1){$(g).z({y:\'1.0\'},(4.q*2),\'\',9(){5.11(\'7:U\')})}k{$(g).z({y:\'1.0\'},(4.q*2))}i++})}}};$.1h.1i.21={m:\'1G\',h:15,q:2t,1j:2s,16:0,V:N,1N:N,G:N,1L:l,1R:\'.1Y\',1S:\'2r.1Y\',1Z:N,1U:N,1g:l,20:0.8,1K:9(){},1M:9(){},1P:9(){}};$.1h.17=[].17})(2o);',62,162,'|||vars|settings|slider|if|nivo||function||var|slice|kids|currentSlide|css|this|slices||timer|else|false|effect|currentImage|child||animSpeed|timeBuff|100|attr|randAnim||width|height|opacity|animate|div|class|nivoRun|img|sliceWidth|each|controlNav|running|setTimeout|is|return|caption|src|true|0px|append|no|repeat|display|totalSlides|animFinished|directionNav|url|clearInterval|background|sliceUpDownLeft|sliceDownLeft|trigger|px|childWidth|nudge||startSlide|reverse|childHeight|sliceUpLeft|title|active|addClass|Math|50|paused|manualAdvance|fn|nivoSlider|pauseTime|fade|nivoControl|first|find|setInterval|call|next|prev|live|control|click|block|eq|rel|fadeIn|none|event|html|sliceUpDown|fold|top|origWidth|random|sliceDownRight|sliceUpRight|anims|beforeChange|controlNavThumbs|afterChange|directionNavHide|stop|slideshowEnd|data|controlNavThumbsSearch|controlNavThumbsReplace|options|pauseOnHover|keyCode|hover|1px|jpg|keyboardNav|captionOpacity|defaults|length|for|hide|prevNav|bottom|nextNav|fadeOut|left|round|extend|show|Prev|imageLink|children|replace|position|relative|hasClass|Next|floor|window|undefined|jQuery|sliceUp|sliceUpDownRight|_thumb|3000|500|Array|sliceDown|37|new|39|keypress|bind|removeClass'.split('|'),0,{}))
