
function get_weather(){
	$.ajax({
	  	url: '/weather/',
	  	dataType: 'json',
	  	success: function(s){
			if('#weatherConditions'){
				$('#weatherConditions').html(s.conditions+' / '+s.temp+'&deg;<small>f</small>');
			}
		}
	});
}

(function ($) {
	$.event.special.load = {
		add: function (hollaback) {
			if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
				if ( this.complete || this.readyState === 4 ) {
					hollaback.handler.apply(this);
				}else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
					$(this).trigger('error');
				}else {
					$(this).bind('load', hollaback.handler);
				}
			}
		}
	};
}(jQuery));

function load_slides(){

	var total_imgs = $('.main-image').length;
	var total_loaded = 0;
	var total_cached = 0;

	$('.main-image').load(function(){
		total_loaded++;
		if(total_imgs == total_loaded){
			$('#image-preloader').fadeOut(400);
			$('#featured-slideshow').orbit({
				animation: 'fade',
				animationSpeed: 800,
				advanceSpeed: 4000,
				startClockOnMouseOut: true,
				startClockOnMouseOutAfter: 3000,
				directionalNav: false,
				captions: true,
				captionAnimationSpeed: 800,
				timer: true
			});
		}
	});

}

function load_fancybox(){
	
	$("a.fancy").fancybox();
	
}

function fix_nav(){
	$('#nav-wrap').height($('#block-wrap').height());
}

$(window).load(function() {
	fix_nav();
	load_slides();
	get_weather();
	load_fancybox();
});

