﻿/*
 * Fonctions pour splash screen
 */
 
function instantHideSplash(target) {
  $('html').css('overflow','scroll'); /*pour ie6*/ 
  $('#trame').hide(0);
  enableshowSplash(target);
}
function hideSplash(target) {
  target.animate({left: "-138"}, 500, 'linear', function(){
    target.addClass('closed');
    $('#trame').fadeOut(50);
    $('html').css('overflow','auto'); /*pour ie6*/  
    enableshowSplash(target);
  });
}
function showSplash(target) {
  $('a.toggle').unbind('mouseover');
  $('a.toggle').unbind('mouseout');
  target.animate({left: "50%"}, 500, 'linear', function(){
    target.removeClass('closed');
    enablehideSplash(target);
    $('#trame').fadeIn(50);
  });
}
function enablehideSplash(target) {
    $('a.toggle').unbind('click');
    $('a.toggle, #trame').click(function(){hideSplash(target);});
}
function enableshowSplash(target) {
    $('a.toggle, #trame').unbind('click');
    $('a.toggle').mouseover(function () {
      target.animate({left: "-123"}, 100);
    });
    $('a.toggle').mouseout(function () {
      target.animate({left: "-138"}, 100);
    });
    $('a.toggle').click(function(){showSplash(target);});
}
 

$(document).ready(function(){
  $("body").addClass('js-enabled');
  /* insertion éléments flash */
  if(document.getElementById('banniere_1')){
      var flashvars = {};
      var params = {
        bgColor: '#e5d2b9', 
        wmode: 'transparent'
      }
      var attributes = {};
      swfobject.embedSWF("/flash/intro.swf", "banniere_1", "340", "480", "8.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);
  }

  /* ---- coins arrondis ---- */
  $("h3").corner("bevel");
  $("ul#footer-nav").corner("bevel cc:#65767E");
  $("ul.corner").corner("bottom 9px cc:#65777E");
  $("ul.corner").corner("top 9px cc:#65777E");

  /* gestion splash */
	if($('#splash').length > 0){
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		  $("body","html").css({height: "100%", width: "98%"});
		  if (document.getElementById("HideSelect") === null) {//iframe to hide select elements in ie6
      $("html").css("overflow","hidden");
			$("body").append("<iframe id='HideSelect'></iframe><div id='trame'></div>");
		  }
		}else{//all others
		  if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='trame'></div>");
		  }
		}
    $('#splash').prepend('<p id="js-toggle-splash"><a href="#" class="toggle">Fermer</a></p>');
    
    if($('#splash').hasClass('closed')) {
      instantHideSplash($('#splash'));
    } else {      
      enablehideSplash($('#splash'));
    }
	}
	/*--------------------------*/

});
