var poppy;

poppy = {
	browser_width : 0,
	content : '', 
	
	init : function() {
		jQuery('body').addClass("JS");
		
		jQuery('.wrapper').css(
			"paddingTop", ((jQuery('body').height() - 570) /2)
		);
		
		poppy.browser_width = jQuery('html,body').width();
		poppy.content = jQuery('#content');
		
		if(jQuery('body').hasClass("HomePage")){
			poppy.portfolio.init();
		}
	},
	portfolio : {
		items : null,
		init : function() {
			poppy.portfolio.items = poppy.content.find('li > a');
			
			poppy.portfolio.items.hover(function() {
					jQuery(this).find("img").animate({opacity:0.6}, 170);
				}, function() {
					jQuery(this).find("img").animate({opacity:0.4}, 170);
				});
			poppy.portfolio.items.click(function() {
				var clicked = jQuery(this);
				poppy.portfolio.items.filter(".active").find("img").animate({opacity:0.4}, 200).parent().removeClass("active");
				
				var scrollTo = clicked.offset().left -((poppy.browser_width - clicked.width())/2);
				var speed = jQuery('html,body').scrollLeft();
				speed = speed - scrollTo;
				speed = Math.abs(speed);
				jQuery('html,body').animate({
						scrollLeft: scrollTo
					}, speed*2);
				clicked.find("img").animate({
						opacity:1
					}, speed).parent().addClass("active");
					
				return false;
			});
		}
	}
};

jQuery.noConflict();
jQuery(document).ready(function() {
	poppy.init();
});
