/**
 * EUVS
 * Javascript file for Discover category
 */

$(document).ready(function() {

    // COVERS
	var splash_xml = '';
	if($('body').hasClass('dhome')) splash_xml = 'splash-xml';
	else if($('body').hasClass('cocktailstories')) splash_xml = 'cs-splash-xml';
	else if($('body').hasClass('mbtb')) splash_xml = 'mbtb-splash-xml';
	
    if($('#splash').length) $('#splash').flash(
        { src: '/flash/discover-splash.swf',
          width: 935,
          height: 365,
		  wmode : 'transparent',
		  flashvars : {
				path :  '/' + ($('body').hasClass('en') ? 'en' : 'fr') + '/discover/' + splash_xml
		  }
		},
        { version: 8 }
    );

    // IMAGE REPLACEMENT
    FLIR.init( { path: '/facelift/' } );
    $('#subnav ul li').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesmediumcond',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.cocktailstories .col.last .links span em,.mbtb .col.last .links span em').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesmedium',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.cocktailstories .col.last .links span a,.mbtb .col.last .links span a').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesmedium',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.mbtb #wrapper h1').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesblackcond',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.dhome #wrapper h2,.cocktailstories #rubs h2,.mbtb #rubs h2').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesthin',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.mbtb #wrapper .playerheader h2').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesthin',
            mode: 'wrap',
            resizeBox: true
        }));
    });
    $('.dhome #wrapper h3,.cocktailstories #rubs h3,.mbtb #rubs h3').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesbold',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('.dhome #wrapper h4,.cocktailstories #rubs h4,.mbtb #rubs h4').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesthin',
            mode: 'wrap',
            realFontHeight: true,
            resizeBox: true
        }));
    });
    $('#footmore h6').each( function() {
        FLIR.replace(this, new FLIRStyle({
            cFont: 'vonnesbook',
            realFontHeight: true,
            resizeBox: true
        }));
    });

    // Man behind the bottle
    /*$(".mbtb #transcript .content").hide();
    $("#transcript .toggle").click(function(){
        $("#transcript .content").toggle();
        var togtext = ($("#transcript h3 .tog").text() == '+') ? '–' : '+';
        $("#transcript h3 .tog").text(togtext);
        return false;
    });
    $(".mbtb #bookmarks .toggle").click(function(){
        $("#bookmarks .content").toggle();
        var togtext = ($("#bookmarks h3 .tog").text() == '+') ? '–' : '+';
        $("#bookmarks h3 .tog").text(togtext);
        return false;
    });*/

	
	// Recreation
	if($('.recreation #content').length) {
		var referer = $('.recreation #content a.back').attr('href');
		$('.recreation #content').flash(
			{ src: '/flash/quizz.swf',
			  flashvars : {pBase_script : '/' + $('html').attr('lang') +'/discover/recreation/', referer : referer },
			  width: $(window).width(),
			  height: $(window).height() - $('#footer').height() - 22 },
			{ version: 8 }
		);
		$(window).resize(function(){
			var height = $(window).height() - $('#footer').height() - 22;
			var width = $(window).width();
			$('.recreation #content embed').height(height);
			$('.recreation #content embed').width(width);
		});	
	}

	// Cocktail Stories

	var flashvars = {};
	
	if($('body.martini').length) {
		flashvars =  {
			path : '/video/cocktailstories/martini.mp4',
			color : '0x1DA1DE',
			image : '/video/cocktailstories/martini.jpg'
		};
	}
	else if($('body.daiquiri').length) {
		flashvars =  {
			path : '/video/cocktailstories/daiquiri.mp4',
			color : '0xE37000',
			image : '/video/cocktailstories/daiquiri.jpg'
		};
	}
	else if($('body.blackthorn').length) {
		flashvars =  {
			path : '/video/cocktailstories/blackthorn.mp4',
			color : '0xCC391C',
			image : '/video/cocktailstories/blackthorn.jpg'
		};
	}
    if($('.cocktailstories .video .player').length) $('.cocktailstories .video .player').flash(
        { src: '/flash/player-cocktailstories.swf',
          width: 720,
          height: 406,
          allowFullscreen: true,
		  wmode : 'transparent',
		  scale : 'noscale',
		  salign : 'lt',
		  allowScriptAccess : 'always',
          flashvars: flashvars
		},
        { version: 8 }
    );

	$('.video .tools #share').hide();
	$('.video .tools .share').click(function() {
		$('.video .tools #share').toggle();
	});

	// Man Behind The Bottle

	/*if($('body.mariani').length) {
		flashvars =  {
			path : '/video/mbtb/mariani/video.mp4',
			color : '0x8FA554',
			image : '/video/mbtb/mariani/cover.jpg'
		};
	}

	else*/ if($('body.ramazzotti').length) {
/*
		// Version avec xml + timeline
		flashvars =  {
			path : '/video/mbtb/ramazzotti/config.xml',
			color : '0xDF312A',
			image : '/video/mbtb/ramazzotti/cover.jpg'
		};
*/
		flashvars =  {
			path : '/video/mbtb/ramazzotti/video.mp4',
			color : '0xDF312A',
			image : '/video/mbtb/ramazzotti/cover.jpg'
		};
	}

	else if($('body.jameson').length) {
		flashvars =  {
			path : '/video/mbtb/jameson/video.mp4',
			color : '0x69A38F',
			image : '/video/mbtb/jameson/cover.jpg'
		};
	}

	if($('.mbtb .player').length && !$('body.mariani').length) $('.mbtb .player').flash(
        { src: '/flash/player-mbtb.swf',
          width: 935,
          height: 400,
          allowFullscreen: true,
          allowFullscreen: true,
		  wmode : 'transparent',
		  scale : 'noscale',
		  salign : 'lt',
		  allowScriptAccess : 'always',
          flashvars: flashvars
		  },
        { version: 8 }
    );

});