// jquery.generalSite.js Gamache et Nadeau
// www.numerique.ca

$(function(){
		
	  var flashvars = {};
	
	  var params = {
		allowfullscreen: "true",
		wmode: "opaque"
	  };
	
	  var attributes = {};
	
	  swfobject.embedSWF("/Flash/projetComplete2011-06-01.swf", "flashAccueil", "410", "380", "9.0.0", "", flashvars, params, attributes);
	  
	  
	  //gestion de la taille du texte
	  
	  var tailleTexteNormal=1;
	  var tailleTexteMoyen=1.25;
	  var tailleTexteGrand=1.5;
	  
	  $('#btnsTailleTexte').css('display','block');
	  
	  if($.cookie('tailleTexte') != null && Number($.cookie('tailleTexte'))){
	      $('#containerContenu,#sousMenu').css('font-size',$.cookie('tailleTexte')+'em');
	  }
	  
	  $('#btnTailleTexteNormal').click(function(){
	      $('#containerContenu,#sousMenu').css('font-size',tailleTexteNormal+'em');
		  
		  $('h2.sIFR-replaced *').not('.sIFR-alternate').remove();
		  $('h2.sIFR-replaced').each(function(){
		      $(this).html($(this).find('.sIFR-alternate').html())
			  $(this).removeAttr('class');
		  })
		  if(typeof sIFR == "function"){
			  sIFR.replaceElement("h2", named({sFlashSrc: "JS/avantgardebook.swf", sColor: "#6B6647", sWmode: "opaque"}));
		  };
		  
		  $.cookie('tailleTexte',tailleTexteNormal,{ path: '/', expires: null });
		  return false
	  })
	  $('#btnTailleTexteMoyen').click(function(){
	      $('#containerContenu,#sousMenu').css('font-size',tailleTexteMoyen+'em');
		  
		  $('h2.sIFR-replaced *').not('.sIFR-alternate').remove();
		  $('h2.sIFR-replaced').each(function(){
		      $(this).html($(this).find('.sIFR-alternate').html())
			  $(this).removeAttr('class');
		  })
		  if(typeof sIFR == "function"){
			  sIFR.replaceElement("h2", named({sFlashSrc: "JS/avantgardebook.swf", sColor: "#6B6647", sWmode: "opaque"}));
		  };
		  
		  $.cookie('tailleTexte',tailleTexteMoyen,{ path: '/', expires: null });
		  return false
	  })
	  $('#btnTailleTexteGrand').click(function(){
	      $('#containerContenu,#sousMenu').css('font-size',tailleTexteGrand+'em');
		  
		  $('h2.sIFR-replaced *').not('.sIFR-alternate').remove();
		  $('h2.sIFR-replaced').each(function(){
		      $(this).html($(this).find('.sIFR-alternate').html())
			  $(this).removeAttr('class');
		  })
		  if(typeof sIFR == "function"){
			  sIFR.replaceElement("h2", named({sFlashSrc: "JS/avantgardebook.swf", sColor: "#6B6647", sWmode: "opaque"}));
		  };
		  
		  $.cookie('tailleTexte',tailleTexteGrand,{ path: '/', expires: null });
		  return false
	  })
	  
	  /* Gestion menuPrincipal */
	  /* Par Phil Turcotte */
	  /* www.numerique.ca */
	  
	  function rollOver() {
	  	  $(this).addClass("selected");
		  $(this).children('ul').show();
		  $(this).children('ul').css("visibility","visible");
	  }
	  
	  function rollOut() {
	  	  $(this).removeClass("selected");
		  $(this).children('ul').hide();
		  $(this).children('ul').css("visibility","hidden");
	  }
	  
	  $("#menuPrincipal li").each(function () {
		  if ($(this).find('ul').length > 0) {
			if ($(this).parent().is("#menuPrincipal")) {
				$(this).addClass("premierNiveau");
			} else {
				$(this).addClass("deuxiemeNiveau");
			}
		  }
	  });
	  
	  $('#menuPrincipal li.premierNiveau ul').hide();
	  $('#menuPrincipal li.premierNiveau ul').css("visibility","hidden");
	  
	  $('#menuPrincipal li.premierNiveau').bind("mouseenter",rollOver);
	  $('#menuPrincipal li.premierNiveau ul li.deuxiemeNiveau').bind("mouseenter",rollOver);
	  
	  $('#menuPrincipal li.premierNiveau').bind("mouseleave",rollOut);
	  $('#menuPrincipal li.premierNiveau ul li.deuxiemeNiveau').bind("mouseleave",rollOut);
	  
	  $('#menuPrincipal ul a').click(function() {
		  $('#menuPrincipal ul').hide();
      });
	  
	  $('#menuPrincipal li.premierNiveau').children(':first-child').click(function() {
		  $(this).parent().triggerHandler("mouseleave");
	  });
});

