/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';
/*end dom flickering =) */

jQuery(window).load(function(){
	jQuery('#main,#branding').show();
	jQuery('#catalog').masonry({
    	itemSelector: '.item',
  		columnWidth: 10,
  		isAnimated: true
  	});
  	jQuery('#gallery').masonry({
    	itemSelector: 'a',
  		columnWidth: 10,
  		isAnimated: true
  	});
  	//Main Menu Navigation Drop Down Background Fix
	jQuery("#access ul.menu li:has(ul)").hover(function() {
		jQuery(this).addClass('dropdown');
	});
	jQuery('#access ul.menu li ul').css({
		display: "none",
		left: "150px"
	});
	jQuery('#access ul.menu li').hover(function() {
	jQuery(this)
		.find('ul')
		.stop(true, true)
		.slideDown('fast');
	}, function() {
	jQuery(this)
		.find('ul')
		.stop(true,true)
		.fadeOut('fast');
	});
	//jQuery('body.home h1#site-title').center();
});

jQuery(window).load(function() 
{
	jQuery('#catalog img').addClass('loaded');

	var v = jQuery("#catalog img"), cur = 0;
	for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
	function fadeInNextIMG() {
		v.eq(cur++).fadeTo(500, 1);
		if(cur != v.length) setTimeout(fadeInNextIMG, 200);
	}
	fadeInNextIMG(); 
});

jQuery.fn.center = function () {
    this.css("position","fixed");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

/*
jQuery(function() {
	var offset = jQuery("#branding").offset();
	var topPadding = 0;
	jQuery(window).scroll(function() {
	    if (jQuery(window).scrollTop() > offset.top) {
	        jQuery("#branding").stop().animate({
	            marginTop: jQuery(window).scrollTop() - offset.top + topPadding
	        });
	    } else {
	        jQuery("#branding").stop().animate({
	            marginTop: 0
	        });
	    };
	});
});
*/
	

