﻿// Goodwill Industries of Central Indiana custom jQuery function for the modal video window
// flashembed is required

(function ($) {

    $.fn.gwVideoModal = function () {

        var args = arguments[0] || {};
        var url = args.url;             // the url of the flash movie
        var bgColor = args.bgColor;         // the background color of the background fade in
        var fadeTo = args.fadeTo;          // the amount to fade to 0.0 to 1.0. ex. 0.6
        var width = args.width;           // the width of the shadow box
        var height = args.height;          // the height of the shadow box

        $('body').append('<div id="gwBG" style="position: fixed;display: none;z-index:9998;top:0;left:0;width: 100%;height: 100%;background:#' + bgColor + ';"></div>'); // lets create the background div

        $('#gwBG').fadeTo('slow', fadeTo, function () {  // now we fade it in
            $('body').append('<div id="gwShadBox" style="position:fixed;display:none;z-index:9999;top:150px;left:50%;margin-left:-' + width / 2 + 'px;width: ' + width + 'px;height: ' + height + 'px;padding: 25px 0 5px 0;background: #000 url(http://media.goodwillindy.org/js/plugins/gwVideoModal/images/topEdge.jpg) repeat-x top left"></div>'); //create the video shadow box
            $('#gwShadBox').fadeIn().flashembed({ src: url, wmode: 'opaque' }); // now we fade it in and display the flash element
            //$('#gwShadBox').append('<a style="position:absolute;top:-12px;right:-12px;width:25px;height:25px;line-height:25px;text-align:center;background:#000;border:1px solid #fff;cursor:pointer;color:#fff;font-weight:bold">X</a>'); // the close button
            $('#gwShadBox').append('<a href="#" style="position:absolute;top:-20px;right:-20px" title="Close Video"><img src="http://media.goodwillindy.org/js/plugins/gwVideoModal/images/close.png" style="border:none" /></a>'); // the close button
        });

        $('#gwBG,#gwShadBox a').live('click', function () { // now if we click on the div, lets fade it out and disappear it ;)
            $('#gwShadBox').fadeOut(function () {
                $('#gwBG').fadeOut();
            }).html('');
        });

    };

})(jQuery);
