$(function(){
	$g.onload();
	
})


$g = {
	
	params : {
		nav_class : 'selected_menu',
		page_type : ''
	},

	
	onload : function(){
		$g.target_blank();
		$g.page_type();
		$g.menu_haut();
		$g.show_overlay();
		//$g.code_download();
		if ($('.partition').size() > 0) $g.load_demo();
	},
	
	// on recupere le type de page ..
	page_type : function(){
		if( window.location.pathname +"" =="/") return $p.page_type ='home';
		a = window.location+'';
		if (a.indexOf('.fr/-') != -1 ) return $p.page_type ='rubrique';

	},

	// les liens ouvre une nouvelle page
	target_blank : function(){
		$('a').click(function(){
			a = $(this).attr('href');
			if (!a) return;
			if (a.indexOf('http') == 0 && a.indexOf('eolians') == -1)
				$(this).attr('target','_blank');
		})
	},
	
	// on ajoute une class en fonction de la page selectionne
	menu_haut : function(){
		a = window.location+'';
		// pour les rubrique
		if (a.indexOf('.fr/-') != -1 ){
			b = window.location.pathname +"";
			b = b.substring(1);
			$("#nav").find("a[href='"+b+"']").addClass($p.nav_class);
		}
		// page d'accueil
		if( window.location.pathname +"" =="/") $("#nav").find("a[href='http://www.eolians.fr/']").addClass($p.nav_class);
		
	},
	
	load_demo : function(){
		$('.partition').each(function(i){
			$('.conteneur_partition:eq(' + i + ')').append($(this));
		})
	},
	
	show_overlay : function(){
		$('.show_overlay').click(function(){
			$(this).find('img').overlay().load();
		})
	},
	
	code_download : function(){
		$('.code_download').find("a").addClass('pop_up_code');
		$('a.pop_up_code').overlay({ 
			 
	        expose: 'darkred', 
	        effect: 'apple', 
	 
	        onBeforeLoad: function() { 
	 
	            // grab wrapper element inside content 
	            var wrap = this.getContent().find(".contentWrap"); 
	 
	            // load the page specified in the trigger 
	            wrap.load(this.getTrigger().attr("href")); 
	        } 
	 
	    }); 
	}
	
}
	
$p = $g.params;	
	

