
var theId = "";
var flashvars1 = {};
var flashvars2 = {};
var flashvars3 = {};
var flashvars4 = {};
var params = { wmode: 'transparent', allowfullscreen: 'true' };
var attributes = {};
var imgTemp;

$(document).ready(function () {
    imgTemp = $("#img_temp");
//    $(".box_content_left").find('a').click(function () {
//        initModalVideo(theId);
//    });
//    $("#top_interior_left_content").find('a').click(function () {
//        theId = $("#top_interior_left_content a:first").attr('id');
//        initModalVideo(theId);
//    });
});

function initModalVideo(theId) {
	$("body").append("<div class='dark_rounded' id='modalVideoContainer'><div class='pp_top'><div class='pp_left'></div><div class='pp_middle'></div><div class='pp_right'></div></div><div id='modalVideoContent'><div id='modalVideo'></div><a style='display:none' class='pp_close' href='javascript:void(0);'>Close</a></div><div class='pp_bottom'><div class='pp_left'></div><div class='pp_middle'></div><div class='pp_right'></div></div></div>");
    $("body").append("<div id='theOverlay'></div>");

    $("#theOverlay").height($(document).height());
    $("#theOverlay").width($(document).width());
    $("#theOverlay").css('background-color', '#000000');

    $("#modalVideoContainer").css({ 'height': 100, 'width': 100, 'left': getLeft(100), 'top': getTop(100) });
    $("#modalVideoContent").css({ 'height': 50 });
    $("#modalVideoContainer").delay(600).animate({ 'height': 400, 'width': 838, 'left': getLeft(840), 'top': getTop(400) }, 300, function () { });
    $("#modalVideoContent").delay(600).animate({ 'height': 400, 'width': 798 }, 300, function () {
        $('.pp_close').show();
        
        playCareerVideo(theId);
    });
}

function getLeft(theWidth) {
    var w = $(window).width();
    var w2 = theWidth + 40;
    var w3 = (w - w2) / 2;
    return w3;
}

function getTop(theHeight) {
    var h = $(window).height();
    var h2 = theHeight + 40;
    var h3 = (h - h2) / 2;
    return h3;
}

function playCareerVideo(theId) {
    if (theId == "") {
        $("#modalVideo").append(imgTemp);
        $(imgTemp).show();
    } else {
        swfobject.embedSWF("../flash/UltimateFLVPlayer.swf?videoPath=../video/MLB.flv", "modalVideo", "798", "360", "10.0.0", "", flashvars2, params, attributes);
    }
    closeCareerVideo();
}

function closeCareerVideo(){
    $("#modalVideoContent").find(".pp_close").click(function () {
        $("#modalVideoContainer").fadeTo(1000, 0).remove();
        $("#theOverlay").delay(1000).remove();
    });
    $("#theOverlay").click(function () {
        $("#modalVideoContainer").fadeTo(1000, 0).remove();
        $("#theOverlay").delay(1000).remove();
    });
}
