// Modal function
var openSmart = function(source, w, h){
    if (!w) {
        w = 400;
    };
    if (!h) {
        h = 300;
    };
	iW = w-30;
	iH = h-50;
	var sModal = $('<div></div>')
		.addClass('sModal-overlay')
		.appendTo('body');
	var sModalInner = $('<div></div')
		.addClass('sModal-window')
		.html('<iframe width="' + iW + '" height="' + iH + '" frameborder="0" scrolling="no" allowtransparency="true" src="' + source + '"></iframe>')
		.appendTo('.sModal-overlay');
	
	sModal.dialog({
        modal: true,
        position: 'center',
        draggable: true,
        resizable: true,
        width: w,
        height: h
    });
		
	$('<div></div>').appendTo(document.body)
		.addClass('ui-widget-overlay')
			.css({
				width: $(document).width(),
				height: $(document).height()
			});
	
	$('.ui-dialog-titlebar-close').click(function(){
        sModal.dialog('close');
		$('div.ui-widget-overlay').remove();
    });
		
};
