/**
* CNPP JavaScript stuff.
* @author CNPP
*/
var CNPP = {
	
	/**
	* Initialize on document ready.
	*/
	initOnDocumentReady: function() {	
		
		// context
		var ctxContent = jQuery("#content");
		var ctxPage = jQuery("#page")
		
		// exhibits
		if (jQuery(ctxPage).hasClass("page") || jQuery(ctxPage).hasClass("page_work") || jQuery(ctxPage).hasClass("page_stuff")) {
			CNPP.initExhibits(ctxContent);
		}
		
		// sketches
		if (jQuery(ctxPage).hasClass("page_sketches")) {
			//CNPP.initSketches(ctxContent);
		}
		
		// links
		CNPP.initLinks(ctxContent);
	},

	/**
	* Initializes the exhibits.
	*/
	initExhibits: function(ctx) {
		
		// exhibits
		jQuery(".exhibits",ctx).each(function(i,exhibits){
			
			// masonry
			jQuery(exhibits).addClass("loading");
			jQuery(exhibits).imagesLoaded( function(){
			  jQuery(exhibits).masonry({
			    itemSelector : '.exhibit'
			  });
			});
			
		});
		
	},
	
	/**
	* Initializes the exhibits.
	*/
	initSketches: function(ctx) {
		
		// exhibits
		jQuery(".exhibits",ctx).each(function(i,exhibits){
			
			// lazy load
			jQuery("img",exhibits).lazyload({
			     placeholder : "http://cecinestpasparis.net/ndxz-studio/site/cnpp/skin/img/grey.gif",
			 	 effect : "fadeIn"
			 });
			
		});
		
	},

	
	/**
	* Initializes the links.
	*/
	initLinks: function(ctx) {
		
		// email
		SEmail.initialize();
	}
	
}
jQuery(document).ready(function(){
	CNPP.initOnDocumentReady();
});


