﻿
/****** (START) Social Media Marketing Control ************/

 var addthis_config = {
                data_track_clickback: true,
                services_exclude: 'twitter',
            };

function fb_comments(sender, url) {
    var FBGraphURL = "https://graph.facebook.com/?ids=" + escape(url) + "&callback=?";
    $.getJSON(FBGraphURL, function (data) {
        var commentsCount = 0;
        if (data[url].comments) {
            commentsCount = data[url].comments;
        }
        $("#" + sender).innerHTML = commentsCount;
    });
}

/****** (END) Social Media Marketing Control ************/


/***** (START) FancyBox  **************/

$(document).ready(function () {

    $(".hiddenPopupClicker").each(
        function () {
            var fancybox_iframe = $('.hiddenPopupClicker');
            if (fancybox_iframe.length > 0) {
                fancybox_iframe.each(function (index) {
                    // Inline frame width param
                    if ($(this).attr('href').match(/width=[0-9]+/i)) {
                        var fWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=', ''));
                    } else {
                        var fWidth = '70%';
                    }
                    // Inline frame height param
                    if ($(this).attr('href').match(/height=[0-9]+/i)) {
                        var fHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=', ''));
                    } else {
                        var fHeight = '70%';
                    }
                    if (window.console && window.console.log) {
                        console.log('fWidth #' + index + ': ' + fWidth);
                        console.log('fHeight #' + index + ': ' + fHeight);
                    }

                    
                    $(this).fancybox({
                        'padding': 0,
                        'zoomOpacity': true,
                        'zoomSpeedIn': 500,
                        'zoomSpeedOut': 500,
                        'overlayOpacity': 0.75,
                        'hideOnContentClick': false,
                        'hideOnOverlayClick': true,
                        'overlayShow': true,
                        'modal': false,
                        'titlePosition': 'outside',
                        'titleShow': false,
                        'speedIn': 500,
                        'speedOut': 500,
                        'transitionIn': 'elastic',
                        'transitionOut': 'elastic',
                        'autoScale': false,
                        'autoDimensions': false,
                        'width': fWidth,
                        'height': fHeight,
                        'enableEscapeButton': true,
                        'orig': this
                    });
                });
            }
        });
});


/***(START) Added by kapil for Social Media Control Cookie ********/
function ShowHideSocialMediaControl(Url) {
    var result = confirm('Are you sure you want to close this panel?');
    if (result) {
        window.location.href = Url;
    }
}
/***(END) Added by kapil for Social Media Control Cookie ********/

$(document).ready(function () {
    if (typeof addthis === 'undefined' || addthis == null) {
        return;
    }
    addthis.init();
});
