﻿    function showPopup(element){
        var calloutWidth = $(element).attr("popupWidth");
        if(calloutWidth == null) {
            calloutWidth = "650px";
        }
        var calloutHeight = $(element).attr("popupHeight");
        if(calloutHeight == null) {
            calloutHeight = "500px";
        }
        
        $("embed[pluginspage*='quicktime']").hide(1);
        
        var iframeHeight = (calloutHeight.split('px')[0] - 90) + 'px';
       
        $("<div id='popupBox'><table cellspacing='0' style='width:" + calloutWidth + ";height:" + calloutHeight + ";' class='nopad' border='0'><tr><td class='popup_tl'></td><td class='popup_tm'></td><td class='popup_tr'></td></tr><tr><td class='popup_ml'></td><td class='popup_bg'><div style='float:right; position:relative; left:25px; top:-25px'><a style='cursor:pointer' class='popupClose'>X</a></div><div class='popupContent' style='height:" + (iframeHeight) + "'></div></td><td class='popup_mr'></td></tr><tr><td class='popup_bl'></td><td class='popup_bm'></td><td class='popup_br'></td></tr></table></div>").appendTo('body');
        
        var boxTop = ($(window).height() / 2) - ($('#popupBox').height() / 2) + $(window).scrollTop();
        $('#popupBox').css('top', boxTop);
        
        var boxLeft = ($(window).width() / 2) - ($('#popupBox').width() / 2) + $(window).scrollLeft(); 
        $('#popupBox').css('left', boxLeft);
        
        $('.popupContent').html( "<iframe border='0' frameborder='0' style='height:100%; width:100%; margin:0px; padding:0px; border:0px' src='" + $(element).attr("href") + "?layout=clean'></iframe>");
        $('#popupBox').fadeIn('fast');
        
		$(".popupClose").unbind("click").bind('click',function(){
            $("embed[pluginspage*='quicktime']").show(1);
            $('#popupBox').remove();
            return false;
		});
		
        return false;
    }
    
    $(document).ready(function() {
		$("a[@class='popup']").unbind("click").bind('click',function(){
		    return showPopup(this);
		});
    });