$(document).ready (function () {
    $("body").prepend ('<div id="dialog">Loading ...</div> ');

    $( "#dialog" ).dialog({
        autoOpen: false,
        width: 1100,
        height: 600
    });

    $(".popup").click (function () { 
        window.console.log ("Click");

        var     url = $(this).attr("href");
        var     theDialog = $("#dialog");

        //write the iframe code to the above element
        theDialog.html ("<iframe class='popup' width='100%' height='100%' src='" + url + "'>");
        theDialog.dialog("option","width", $(window).width() * 0.9);
        theDialog.dialog( "open" ); 
        //theDialog.dialog ({ height: 800, width: 900, modal: true });

        return false;
    });
    
    //Resize the dialog when the screen is resized
    $(window).resize(function() {
    	var theDialog = $("#dialog");
    	if(theDialog.dialog( "isOpen" )){
    		theDialog.dialog("option","width", $(window).width() * 0.9);
    	}
    });

    window.console.log ("Hello");
});

