$(document).ready(function () {
       
    /****************************************************************
    *  JQuery FancyBox Functions                                    *
    ****************************************************************/
    $("a.fancy").fancybox({
        'width': '50%',
        'height': '50%',
        'autoScale': false,
        'titleShow': true,
        'transitionIn': 'elastic',
        'transitionOut': 'fade',
        'type': 'iframe'
    });

    $("a.iframe").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'fade',
        'titleShow': true,
        'width': 680,
        'height': 495
    });

    if (location.hash) {
        $(location.hash).click();
    }

    $('a.fb_dynamic').each(function () {
        var dWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=', ''));
        var dHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=', ''));
        $(this).fancybox({
            'showCloseButton': false,
            'hideOnOverlayClick': false,
            'hideOnContentClick': false,
            'width': dWidth,
            'height': dHeight,
            'autoScale': false,
            'titleShow': true,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'onClosed': function () {
                parent.location.reload(true);;
            }
        });
    });

    $('a.fb_dynamic_percentage').each(function () {
        var dWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=', ''));
        var dHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=', ''));
        $(this).fancybox({
            'hideOnOverlayClick': false,
            'hideOnContentClick': false,
            'width': '' + dWidth + '%',
            'height': '' + dHeight + '%',
            'autoScale': false,
            'titleShow': true,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe'
        });
    });
});
