jQuery.noConflict();

jQuery(document).ready(function() {
    // Auto sized Frames
    jQuery('a.fancy_iframe_auto').fancybox({
        'transitionIn'	: 'fade',
        'transitionOut'	: 'fade',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack',
        'autoScale'     : false,
        'height'        : 558,
        'width'         : 800,
        'titleShow'     : false,
        'type'          : 'iframe',
        'padding'       : 15,
        'onComplete' : function() {
            jQuery('#fancybox-frame').load(function() {
                winHeight = jQuery(window).height();
                winWidth = jQuery(window).width();
                
                contentHeight = jQuery(this).contents().find('table').height();
                contentWidth = jQuery(this).contents().find('table').width();
                
                if(contentHeight > (winHeight - 200)) {
                    contentHeight = winHeight - 200;
                    alert(contentHeight);
                }
                if(contentWidth > (winWidth - 500)) {
                    contentWidth = winWidth - 500;
                }
            
                jQuery('#fancybox-wrap').height(contentHeight+33);
                jQuery('#fancybox-wrap').width(contentWidth+33);
                
                jQuery('#fancybox-content').height(contentHeight+3);
                jQuery('#fancybox-content').width(contentWidth+3);
                
                jQuery.fancybox.center();
            });
        }
    });
});
