var WEBROOT = 'http://www.theatretelus.com/';


$(document).ready(function(){


	// Remplacement du header
	$('#header').flash(
		{ src: WEBROOT+'images/theatre-telus.swf',
		  width: 1050,
		  height: 130 },
		{ version: 8 }
	);


	// Remplacement des H2
    $('h2').flash(
        { 
            src: WEBROOT+'images/helvetica-neue-md.swf', 
            flashvars: { 
                css: [
                    '* { color: #2F2F2F; }'
                ].join(' ')
            }
        },
        { version: 7 },
        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();
			htmlOptions.wmode = 'transparent';
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );


	// Remplacement des H3
    $('h3.sifr').flash(
        { 
            src: WEBROOT+'images/helvetica-neue-md.swf', 
            flashvars: { 
                css: [
                    '* { color: #2f2f2f; }'
                ].join(' ')
            }
        },
        { version: 7 },
        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');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );



	// Expand/Collapse
	var onglet_ouvert = '';
	$('.show_specs').click(function() {
    	var mediaObject = $(this).attr("rel");
		
		if( $(this).attr("rel") == onglet_ouvert )
		{
			$('#specs_'+mediaObject).fadeOut("slow");
			onglet_ouvert = '';
		}
		else
		{
			$('.cache').fadeOut("fast");
			
			$('#specs_'+mediaObject).fadeIn("slow");
			onglet_ouvert = $(this).attr("rel");
		}
		return false;
   	});

	
	
	$('#btn_courriel').click(function() {
    	var nobug = true;
		var _HTML = "";
		var _MSG = "";
		var tableau = new Array(true,"","");
		
		/// CHAMPS À VÉRIFIER
		est_la("courriel", tableau, "Veuillez indiquer votre adresse courriel/", "courriel");
		est_courriel_valide("courriel", tableau, "Votre adresse courriel ne semble pas valide/", "courriel");

		///	VALIDATION DU TABLEAU
		if(tableau[0] != false)
		{
			var _COURRIEL =$("#courriel").val();
			var _LANGUE =$(this).attr("langue");

			$.ajax({
				type: "POST",
				url: WEBROOT+"includes/abonnement.php",
				data: "&courriel="+ _COURRIEL ,
			
				success: function( msg )
				{
					switch( msg )
					{
						case "Existe":
							alert( "Cette adresse courriel fait partie de notre liste." );
							break;
						case "Erreur":
							alert( "Une erreure s'est produite, veuillez recommencer." );
							break;
						case "Succes":
							$("#courriel").val( "Merci!" );
							break;
					}
				}
			});
		}
		else
		{
			_CELL = tableau[1].split("/");
			for( var i = 0; i < _CELL.length; i++ )
				_MSG += _CELL[i];
						
			alert( _MSG );
		}
	
		return false;
   	});
	
	
});