function initialize(){
    var html = $.ajax({
        type: "GET",
        url: 'incs.php',
        data: ({modulo: 'home', accion:'trailer'}),
        dataType: 'html',
        async: false
    }).responseText;
    $("#player_movie").attr('href',html+'.mp4');
    displayVideo("player_movie");

    callModulo('home', 'quotes');

    stack = $("#share ul").stackmenu();
    $("#share ul").toggleClass("invisible");
    $("#share .share_button").click(function(){stack.stackmenu("toggle");});

    $("div.home-text").mouseenter(hoverHomeText);

    $("div.home-text").mouseleave(hoverHomeText);

    $(".screenings").click(function(){
        location.href = 'noHome.html?modulo=screenings';
    }
            );
    $(".about_the_film").click(function(){
        location.href = 'noHome.html?modulo=about';
    }
            );

    $(".media").click(function(){
        location.href = 'noHome.html?modulo=media';
    }
            );

    $(".shop").click(function(){
        location.href = 'noHome.html?modulo=shop';
    }
            );
    $(".blog").click(function(){
        location.href = 'noHome.html?modulo=blog';
    }
            );
    $(".terms_and_conds").click(function(){
        location.href = 'noHome.html?modulo=footer&accion=terms';
    }
            );

    $(".privacy_policy").click(function(){
        location.href = 'noHome.html?modulo=footer&accion=privacy';
    }
            );
    $(".film_credits").click(function(){
        location.href = 'noHome.html?modulo=footer&accion=credits';
    }
            );


}
var stack;

function hoverHomeText(){
    $("p.author").toggleClass("author-hover");
    $("p.title").toggleClass("title-hover");
}

function callModulo(modulo, accion){
    var html = $.ajax({
        type: "GET",
        url: 'incs.php',
        data: ({modulo: modulo, accion:accion}),
        dataType: 'html',
        async: false
    }).responseText;
    $("#contenedor").empty().append(html);
}

function displayVideo(elemId){

    var movieStreamServer = "http://dt33yp24ghtie.cloudfront.net/";


    var link = $("#"+elemId);
    var href = link.attr('href');

    //Detect mobile device
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    var isiPhone = navigator.userAgent.match(/iphone/i) != null;
    var isiPod = navigator.userAgent.match(/ipod/i) != null;
    var isAndroid = navigator.userAgent.match(/android/i) != null;
    var isBlackBerry = navigator.userAgent.match(/blackberry/i) != null;

    if(isiPad || isiPhone || isiPod || isAndroid){

        var video = $("<video>");
        video.attr("controls","controls").attr("id","v1").attr("autoplay","autoplay");
        //                video.attr("poster","images/home.png");
        video.attr("height",parseInt(link.css("height"))).attr("width",parseInt(link.css("width")));
        var sourceAttr = movieStreamServer+link.attr("href");
        if(isAndroid){
            sourceAttr = movieStreamServer+"trailer.mp4";
        }
        var source = $("<source>");
        source.attr("src",sourceAttr);
        video.append(source);
        link.before(video);
        if(isAndroid){
            var bang = function() { this.play(); };
            document.getElementById("v1").addEventListener('click',bang,false);
        }
        link.remove();
    } else if (isBlackBerry){
        link.attr('href',movieStreamServer+link.attr("href"));
        link.text("View video");
        //Embeded video is not yet supported in 9800
        //var obj = $("<object>").attr("data","http://diveintohtml5.org/i/pr6.mp4").attr("type","video/mp4").attr("title","video");
        link.before(obj);
    }else{
        var src = link.attr("href");
        link.attr("href","mp4:"+src);
        flowplayer(elemId, "../flash/flowplayer.commercial-3.2.2.swf", {
            // product key from your account
            key: '#$0fef9484b6c431095de',
            // configure the required plugins
            "plugins":{
                "controls":{
                    "timeColor":"#ffffff",
                    "borderRadius":"0px",
                    "slowForward":true,
                    "bufferGradient":"none",
                    "backgroundColor":"rgba(0, 0, 0, 1)",
                    "volumeSliderGradient":"none",
                    "slowBackward":false,
                    "timeBorderRadius":20,
                    "time":true,
                    "progressGradient":"none",
                    "height":25,
                    "volumeColor":"rgba(0, 0, 0, 1)",
                    "tooltips":{
                        "marginBottom":5,
                        "volume":true,
                        "scrubber":true,
                        "buttons":false
                    },
                    "opacity":1,
                    "fastBackward":false,
                    "timeFontSize":12,
                    "bufferColor":"rgba(136, 193, 219, 0.7)",
                    "border":"0px",
                    "volumeSliderColor":"rgba(0, 0, 0, 1)",
                    "buttonColor":"#ffffff",
                    "mute":true,
                    "autoHide":{
                        "enabled":true,
                        "hideDelay":500,
                        "hideStyle":"fade",
                        "mouseOutDelay":500,
                        "hideDuration":400,
                        "fullscreenOnly":true
                    },
                    "backgroundGradient":"none",
                    "width":"100pct",
                    "sliderBorder":"1px solid rgba(128, 128, 128, 0.7)",
                    "display":"block",
                    "buttonOverColor":"#ffffff",
                    "fullscreen":true,
                    "timeBgColor":"rgb(0, 0, 0, 0)",
                    "scrubberBarHeightRatio":0.3,
                    "bottom":0,
                    "stop":false,
                    "zIndex":1,
                    "sliderColor":"#000000",
                    "scrubberHeightRatio":0.5,
                    "tooltipTextColor":"#ffffff",
                    "sliderGradient":"none",
                    "timeBgHeightRatio":0.4,
                    "volumeSliderHeightRatio":0.3,
                    "timeSeparator":" ",
                    "name":"controls",
                    "volumeBarHeightRatio":0.3,
                    "left":"50pct",
                    "tooltipColor":"#000000",
                    "playlist":false,
                    "durationColor":"#a3a3a3",
                    "play":true,
                    "fastForward":true,
                    "timeBorder":"0px solid rgba(0, 0, 0, 0.3)",
                    "progressColor":"rgba(48, 130, 201, 1)",
                    "scrubber":true,
                    "volume":true,
                    "builtIn":false,
                    "volumeBorder":"1px solid rgba(128, 128, 128, 0.7)"
                },
                // the RTMP plugin
                rtmp: {
                    url: 'flash/flowplayer.rtmp-3.2.1.swf',

                    // netConnectionUrl has our CloudFront domain name + 'cfx/st'
                    netConnectionUrl: 'rtmp://s2x1a1taxiuor3.cloudfront.net/cfx/st'
                }
            },
            clip: {
                // use the RTMP plugin
                provider: 'rtmp',
                scaling: 'fit'
            }
        });
    }
}
