

google.setOnLoadCallback(function() {


	// restore active menu, when user quit the naviguation menubar
	 restoreActiveMenu();
	 
	// change menu background, and application list, when a family is choosen by user
	 setActiveMenu();


	// change menu background, and application list, when a family is choosen by user
	 footerMenu();


	// show popin
	if(popin) { toggleOverlay(popin);}





	$("img[rel!='display']").lazyload({
		placeholder : "/images/interface/fonds/grey.gif",       
		effect      : "fadeIn"
	});


	$("#jsocial").jsocial({highlight: true,
							buttons: "facebook,twitter,mail,digg,technorati,delicious,yahoo,google,blogmarks,live,stumbleupon", 
							imagedir: "/images/jsocial/small/", 
							imageextension: "gif", 
							blanktarget: true,
							shorturl: "http://tinyurl.com/26ezwvu"});
							

	$("#jsocialhome").jsocial({highlight: true,
							buttons: "facebook,twitter", 
							imagedir: "/images/jsocial/big/", 
							imageextension: "png", 
							blanktarget: true,
							shorturl: "http://tinyurl.com/26ezwvu"});
							
							
							
							
							
	// STATS
	trackExternalLinks();
});







function footerMenu() {
	$('#footer2 .viewmore').click(function() {
		var checkElement = $(this).next();
		checkElement.css({'display':'block'});
		$(this).css({'display':'none'});

	});
}




// restore active menu, when user quit the naviguation menubar
function restoreActiveMenu() {
	 $('#content').mouseenter(function() {
	 	
	 	// If the good menu is selected, dont move anything
		var animate = (!$("#"+activeMenu).hasClass("actif")) ? true : false;
		
	 	// Remove actif class on all tabs
		$('#menu-familles li').each(function(elt) {	$(this).removeClass("actif");});

	
	 	// restore the good tab selected + submenu list ... 
	 	$("#"+activeMenu).addClass("actif");
		if(animate) {
			var num = ($("#"+activeMenu).attr('id')).replace(/menu-/ig, "");
			$('#menu-logiciels').fadeTo(100,0.33).css({'top':-((num-1)*32)}).fadeTo(320,1);
		}

	 });


}

function trackExternalLinks() {
	$("a[rel*='external']").each(function() {
	  var $a = $(this);
	  var href = $a.attr('href');
	 
	  // see if the link is external
	 // if ( (href.match(/^http/)) && (! href.match(document.domain)) ) {
	 
	    // if so, add the GA tracking code
	    $a.click(function() {
		$a.attr("target","_tab");
		href = href.replace('http://',''); // cleanup for nice GA reports
		//pageTracker._trackPageview('/outgoing/' + href);
		_gaq.push(['_trackPageview','/outgoing/' + href]);
	    });
	  //}
	 
	});
}

// change menu background, and application list, when a family is choosen by user
function setActiveMenu() {
	 $('#menu-familles li').each(function(el) {

		  $(this).click(function(el2) {
        			
					var num = ($(this).attr('id')).replace(/menu-/ig, "");
					
					// switch menu
					$('#menu-logiciels').fadeTo(100,0.33).css({'top':-((num-1)*32)}).fadeTo(320,1);
					$('#menu-familles li').each(function(elt) {
						$(this).attr("class","");
					});
					
					$(this).attr("class","actif");

				return false;					

				
			});
		});	
      	
}


							
    

