﻿/*
Title: Advent site - main javascript
Author: josh@josgherdes.com
*/

// Define global variables
var showVideo = {}; 

$(document).ready(function() {
    
    // Add the player div to the page
    $('body').append('<div id="playerContainer" style="display:none;">');
    $('#playerContainer').append('<div id="playerClose" style="display: block;"></div>');
    $('#playerContainer').append('<div id="playerContent">');
    $('#playerContent').append('<object id="player"></object>');
    
    // Method used to open youtube video in modal window  
    showVideo = function(playerUrl, autoplay) {
        
        // Set the width and height
        var width = 560;
        var height = 340;

        // Load the video on the player
        swfobject.embedSWF(
            playerUrl + '&rel=1&border=0&fs=1&autoplay=' + 
            (autoplay?1:0), 'player', width, height, '9.0.0', false, 
            false, {allowfullscreen: 'true', wmode: 'transparent'});
  
        // Setup blockui for player container
        $.blockUI({ 
            message: $('#playerContainer'),
            css: { 
            width: width + 'px', 
            height: height + 'px',
            top:  ($(window).height() - height) /2 + 'px', 
            left: ($(window).width() - width) /2 + 'px' 
            } 
        }); 
        
        // Add unblock events to the close button and background
        $('.blockOverlay').click($.unblockUI);
        $('#playerClose').click($.unblockUI);
    }
});