function initSifr(){
	
	$('span.flash').each(function(){
		var _src = $(this).html();
		$(this).flash({
		    src: _src,
		    width: 970,
		    height: 470,
		    allowFullScreen: true,
		    wmode: "opaque",
		    title: " "
		});
	});
	
	
	/*var _srcBg = $('div#background').html();
	$('div#background').flash({
		    src: _srcBg,
		    width: "100%",
		    height: "100%",
		    allowFullScreen: false,
		    wmode: "opaque"
	});
	$('div#background .alt').hide();*/
	
	
    $('#conteneur #contenu .panel .description h2').flash(
        {
        	  wmode : 'transparent',
            src: 'interface/swf/soho_regular.swf', 
            flashvars: { 
                css: [
                    '* { color: #000000; }',
                ].join(' ')
            }
        },
        { version: 9 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.height = $alt.height();
            htmlOptions.width = $alt.width();
            //$alt.addClass('alt');
            $alt.hide();
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );
	
    $('#conteneur #menu ul#principal li span, #conteneur #menu ul#secondaire li').flash(
        {
        	  wmode : 'transparent',
            src: 'interface/swf/soho_regular.swf', 
            flashvars: { 
                css: [
                    '* { color: #000000; }',
                ].join(' ')
            }
        },
        { version: 9 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.height = $alt.height();
            htmlOptions.width = $alt.width();
            //$alt.addClass('alt');
            $alt.hide();
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );
}

function initNavigation(){
	$("div#contenu").codaSlider();
	$("#conteneur #menu ul#principal li").each(function(){
		$(this).bind("mouseenter mouseleave", function(e){
			$(this).children("ul").toggle();
    		});
    });
    
    $('a.modal').nyroModal({
    				bgColor: '#000000', 
				width: 800, // Largeur par défaut Si null, sera calculé automatiquement
  				height: 600,
  				opacity: 1
	});

/*hover(function(){
			$(this).children("ul").show();
		},function(){
			$(this).children("ul").hide();
		});
	});*/
}

	
function initToggleDescr(){
	$("#conteneur #contenu #navigation #affichage").click(function(){
		if($(this).hasClass("reduit")){
			$("#conteneur #contenu .panel").each(function(){
				var H = $(this).children(".description").height()-20;
				$(this).children(".description").animate({ 
			        bottom: "-"+H
			      }, 300);
			});
			$(this).removeClass("reduit").addClass("affiche");
		} else {
			$("#conteneur #contenu .panel").each(function(){
				$(this).children(".description").animate({ 
			        bottom: "5px"
			      }, 300);
			});
			$(this).removeClass("affiche").addClass("reduit");
		}
	});
}

function initKwicks(){ 
	  $('body#index .kwicks').kwicks({  
	    max : 750,  
	    spacing : 5,
	    duration: 1000,
	    easing: 'easeOutSine'
	  });   
	  $('body#index .kwicks li').click(function(){
	    var url = $(this).attr("rel");
	    window.location.replace(url);
	  });
}


$(document).ready(function(){
	initSifr();
	initNavigation();
	initToggleDescr();
	initKwicks();
});