﻿// google analytics tracking script
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19986848-1']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

// mouseovers for icons in nav A and nav B
function mcdheaderWorldwideSpanMouseOver() {
    document.getElementById("mcdheaderWorldwideImage").src = "/_layouts/images/mcdInternet/homepage_map-rollover.png";
}
function mcdheaderWorldWideSpanMouseOut() {
    document.getElementById("mcdheaderWorldwideImage").src = "/_layouts/images/mcdInternet/homepage_map.png";
}
function mcdSocialMedia_NavA_SwapImage(img_name, img_src) {
    document[img_name].src = img_src;
}

// page printing functionality
function PrintThisPage() {
    try {
        var header = $("<div style='border-bottom:2px solid #c5c4c4'><img src='/_layouts/images/mcdInternet/mcd_logo.png'/></div>");

        $('div.mcdcustomBody').clone().prepend(header).jqprint();
    }
    catch(e) {}
}

// lightbox modal dialog launching functionality
function LaunchDialog(url, windowTitle, html, includePrintLink, width, height) {
    try {
        var dialogProps = { url: url, title: windowTitle, html: html, createPrintLink: includePrintLink, width: width, height: height };
        var delegate = Function.createDelegate(dialogProps, ShowModalDialogBox);

        ExecuteOrDelayUntilScriptLoaded(delegate, "sp.ui.dialog.js");
    }
    catch(e) {}
}

function ShowModalDialogBox() {
    try {
        if (this != undefined) {
            var options = SP.UI.$create_DialogOptions();

            options.title = this.title;

            // Either url or html (either in form of text or html element) must be specified. If both are specified then url takes precedence
            if(this.url != undefined)
                options.url = this.url;

            if (this.html != undefined) {
                var div = document.createElement("div");
                div.style.padding = "5px";
                var strPrintDiv = "";

                if (this.createPrintLink != undefined) {
                    if(this.createPrintLink == true)
                        strPrintDiv = "<div style='text-align:right; padding-bottom:3px; cursor:pointer' onclick='javascript:window.print();'>Print Page</div>";
                }

                div.innerHTML = strPrintDiv + this.html;

                options.html = div;
            }

            if (this.content != undefined)
                options.html = this.content;

            if (this.width != undefined)
                options.width = this.width;

            if (this.height != undefined)
                options.height = this.height;

            SP.UI.ModalDialog.showModalDialog(options);
        }
    }
    catch(e) {}
}       
