$(function(){

function fullscreen(options){

	if($('.fullscreen').length > 0){
	
	var options = $.extend({
		animate : true
	},options);

	$('html, body').css({overflow : 'hidden'});

	var w = $(window).width();
	var h = $(window).height();

	var el = $('.fullscreen');

	var ew = el.outerWidth();
	var eh = el.outerHeight();

	var ratio = ew / eh;

	var newwidth;
	var newheight;
	var thisleft;
	var thistop;

	if(ew > eh){

		// we'd want the image to stretch longways
		newheight = w/ratio;
		newwidth = w;

		if(newheight > h){
			// now we want it to stretch heightyways
			newheight = h;
			newwidth = h*ratio;
		}


	} else {

		// we'd want the image to stretch longways
		newheight = h;
		newwidth = h*ratio;

		if(newwidth > h){
			// now we want it to stretch heightyways
			newheight = w/ratio;
			newwidth = w;
		}


	}

	// center


		thisleft = (w-newwidth)/2;

		thistop = (h-newheight)/2;

		if(thisleft < 0){
			thisleft = 0;
		}

		if(thistop < 0){
			thistop = 0;
		}


	var cssoptions = {
		width : newwidth+'px',
		height : newheight+'px',
		left : thisleft+'px',
		top : thistop+'px'
	};


	if(options.animate == true){

		el.stop(true).fadeTo(1,1).animate(cssoptions);

	} else {

		el.css({
			display : 'none'
		});

		el.css(cssoptions).fadeIn(4000);

	}

	$(window).unbind('resize', fullscreen).bind('resize', fullscreen);

	}

} // close do fullscreen

$.fn.verticalcenter = function (options){
	
	var options = $.extend({
		animate : true
	}, options);
	
	var h = $(window).height();
	var w = $(window).width();
	
		
	this.each(function(){
		var el = $(this);
		var th = el.outerHeight();
		var tw = el.outerWidth();
		
		var thistop = (h - th)/2;
		
		var cssoptions = {
			top : thistop+'px'
		};
		
		if(options.animate == false){
			el.css(cssoptions);
		} else {
			el.stop(true).animate(cssoptions);
		}
		
	});
};

function vertcent(){
$('.splash_top').verticalcenter();
}


$(window).load(function(){

	fullscreen({animate : false});
	
	if($('.splash_top').length >0){
		$('.splash_top').verticalcenter({animate : false});
		$(window).unbind('resize', vertcent).bind('resize', vertcent);
	}
	
});


$('.shopdropdownlink').hover(function(){
	$('.shopdropdown').stop(true).fadeIn(function(){
		$('.shopdropdown').fadeTo(0,1);	
	});
},function(){
	$('.shopdropdown').stop(true).fadeOut(function(){
		$('.shopdropdown').fadeTo(0,1);	
	});
});

}); // close docready