/*
*Include minified plugins
*/

/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
; (function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);
; (function ($) { var a = 'serialScroll', b = '.' + a, c = 'bind', C = $[a] = function (b) { $.scrollTo.window()[a](b) }; C.defaults = { duration: 1e3, axis: 'x', event: 'click', start: 0, step: 1, lock: 1, cycle: 1, constant: 1 }; $.fn[a] = function (y) { y = $.extend({}, C.defaults, y); var z = y.event, A = y.step, B = y.lazy; return this.each(function () { var j = y.target ? this : document, k = $(y.target || this, j), l = k[0], m = y.items, o = y.start, p = y.interval, q = y.navigation, r; if (!B) m = w(); if (y.force) t({}, o); $(y.prev || [], j)[c](z, -A, s); $(y.next || [], j)[c](z, A, s); if (!l.ssbound) k[c]('prev' + b, -A, s)[c]('next' + b, A, s)[c]('goto' + b, t); if (p) k[c]('start' + b, function (e) { if (!p) { v(); p = 1; u() } })[c]('stop' + b, function () { v(); p = 0 }); k[c]('notify' + b, function (e, a) { var i = x(a); if (i > -1) o = i }); l.ssbound = 1; if (y.jump) (B ? k : w())[c](z, function (e) { t(e, x(e.target)) }); if (q) q = $(q, j)[c](z, function (e) { e.data = Math.round(w().length / q.length) * q.index(this); t(e, this) }); function s(e) { e.data += o; t(e, this) }; function t(e, a) { if (!isNaN(a)) { e.data = a; a = l } var c = e.data, n, d = e.type, f = y.exclude ? w().slice(0, -y.exclude) : w(), g = f.length, h = f[c], i = y.duration; if (d) e.preventDefault(); if (p) { v(); r = setTimeout(u, y.interval) } if (!h) { n = c < 0 ? 0 : n = g - 1; if (o != n) c = n; else if (!y.cycle) return; else c = g - n - 1; h = f[c] } if (!h || d && o == c || y.lock && k.is(':animated') || d && y.onBefore && y.onBefore.call(a, e, h, k, w(), c) === !1) return; if (y.stop) k.queue('fx', []).stop(); if (y.constant) i = Math.abs(i / A * (o - c)); k.scrollTo(h, i, y).trigger('notify' + b, [c]) }; function u() { k.trigger('next' + b) }; function v() { clearTimeout(r) }; function w() { return $(m, l) }; function x(a) { if (!isNaN(a)) return a; var b = w(), i; while ((i = b.index(a)) == -1 && a != l) a = a.parentNode; return i } }) } })(jQuery);


/**
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};





/*
* Custom event handlers on dom ready
*/

/*cookie notice
$(function () {
$.cookie("cookie_test", "test cookie", { path: "/" })
if ($.cookie("cookie_test")) {
if (!$.cookie("optTracking")) {
$(".cookieNotice").show();
$.cookie("optTracking", "enabled", { path: "/", expires: 365 })
}
}
$(".cookieClose a").click(function (e) {
e.preventDefault();
$(".cookieNotice").hide();
})
});*/

/*search enable*/
$(function () {
    $("#top .search").show();
})

$(document).ready(function () {
    // confirmation email
    if ($("div[id*='uiHtmlMailTemplate']").length) {
        var toolBarOptions = "li[id*='Ribbon.EditingTools.CPInsert.Content'], li[id*='Ribbon.EditingTools.CPEditTab.Styles'], li[id*='Ribbon.EditingTools.CPInsert.WebParts'], li[id*='Ribbon.EditingTools.CPInsert.Media'], li[id*='Ribbon.EditingTools.CPEditTab.Markup'], li[id*='Ribbon.WebPartInsert.Media'], li[id*='Ribbon.WebPartInsert.WebParts'], li[id*='Ribbon.EditingTools.CPEditTab.Font'] span[id*='Ribbon.EditingTools.CPEditTab.Font-Large-0-0'], li[id*='Ribbon.EditingTools.CPEditTab.Font'] span[id*='Ribbon.EditingTools.CPEditTab.Font-Large-0-1-1']";
        setInterval(function () {
            $("div[id*='uiHtmlMailTemplate']:visible").find("span[id*='ms-rterangecursor-start']").length ?
            $("#Ribbon").find(toolBarOptions).hide() :
            $("#Ribbon").find(toolBarOptions).show();
        }, 1);
    }

    // map link margin
    $("a.lightbox.mapLink:hidden").parents("td[id*='WebPart']").css("padding", "0");

    //cookie banner
    if ($(".cookieNotice").length > 0) {
        if (isCookieTrackingEnabled()) {
            $(".disableCookieContainer").show();
            $(".enableCookieContainer").hide();
        } else {
            $(".disableCookieContainer").hide();
            $(".enableCookieContainer").show();
        }
        if (!$.cookie("optTracking")) {
            $(".cookieNotice").show();
            $.cookie("optTracking", "enabled", { path: "/", expires: 365 });
        }

        $(".cookieNotice .cookieBannerClose").click(function (e) {
            e.preventDefault();
            $(".cookieNotice").hide();
        });

        $(".cookieEnableTracking").click(function (e) {
            e.preventDefault();
            $.cookie("optTracking", "enabled", { path: "/", expires: 365 });
            $(".disableCookieContainer").show();
            $(".enableCookieContainer").hide();
        });

        $(".cookieDisableTracking").click(function (e) {
            e.preventDefault();
            $.cookie("optTracking", "disabled", { path: "/", expires: 365 });
            $(".disableCookieContainer").hide();
            $(".enableCookieContainer").show();
        });
    }

    // search box
    var searchDefaultValue = $("div.search .searchDefaultValue").text();
    var searchField = $("div.search input");
    var searchButton = $("div.search a");
    if (searchField.val() == '') {
        searchField.val(searchDefaultValue);

    }
    searchButton.click(function () {
        if (searchField.val() == searchDefaultValue) {
            searchField.val('');
            searchField.focus();
        }
    });
    searchField.focus(function () {
        if (searchField.val() == searchDefaultValue) {
            searchField.val('');
        }
    });
    searchField.blur(function () {
        if (searchField.val() == '') {
            searchField.val(searchDefaultValue);
        }
    });

    //create history back link
    $('.goBack').click(function () {
        history.back();
    });
    if ($('#nav ul>li.selected').length <= 0) {
        $('#nav ul>li:first').addClass('selected');
    }
    $('#main div.sitePath span span:nth-child(n+3)').addClass('on');

    /*
    if($('#top .serviceNav ul:last li').length <= 0){
    $('#top .serviceNav div.navSplit').addClass('skip');
    }
    */

    /* Temp Disabled */
    /*
    $.sifr({
    path: '/Style%20Library/VELUX/Includes/',
    font: 'VeluxGothic', 
    save: true
    });
    $('.spot h1, .spot h2, div.teaser h2').sifr({  });
    */

    $('#content .spot>ul>li.hasPopUpLinks>a').toggle(
      function () {
          $(this).parent('li').addClass('on');
      },
      function () {
          $(this).parent('li').removeClass('on');
      }
    );


    $('a.buttonBack').attr('href', 'javascript:history.back(-1);');

    $('#main a.printButton').attr('href', 'javascript:window.print();');

    $('#main .sitePath a.contact').attr('href', '#');
    $('#main .sitePath a.contact').click(function () {
        var sender = $(this);
        $('#main .sitePath div.recBox').slideToggle('fast', function () {
            if ($(this).is(":visible")) {
                trackIconEvent(sender, "sendRecommendation");
            }
        });
    });

    $('#main .sitePath div.recBox a.addRecipient').click(function () {
        var email = $(this).parent().find('input').attr('value');
        var $error = $(this).next('div.error');
        if (valEmail(email)) addRecipient($(this));
    });

    $('#main .sitePath div.recBox input.valEmail').blur(function () {
        doInputField($(this));
    });


    $('#main .sitePath div.recBox div.submit input').click(function () {
        $('#main .sitePath div.recBox input.valEmail').each(function () {
            myState = doInputField($(this));
        });
        return myState;
        //$('#main .sitePath div.recBox textarea').attr('value',$('#main .sitePath div.recBox input').eq(0).attr('value'));
    });


    $('#main .faqList dt').click(function () {
        var faqId = $(this).attr("faqId");
        var faqQuestion = $(this).html();
        $(this).next().slideToggle('fast', function () {
            if ($(this).is(":visible")) {
                if (faqId == 0) {
                    return;
                }

                var separator = (window.location.search.length < 1) ? "?" : "&";
                var faqParamId = window.location.search + separator + "faqitem=" + faqId;

                try {
                    if (isCookieTrackingEnabled()) {
                        dcsMultiTrack("DCS.dcsuri", window.location.pathname, 'DCS.dcsqry', faqParamId, 'WT.ti', faqQuestion);
                    }
                }
                catch (e) { }
            }
        });
    });

    $('#main .flashObject').each(function () {
        if ($(this).find('.SWFHeight').html() && $(this).find('.SWFWidth').html())
            $(this).flash(
    	    {
    	        src: $(this).find('.SWFFile').attr('href'),
    	        height: $(this).find('.SWFHeight').html(),
    	        width: $(this).find('.SWFWidth').html(),
    	        wmode: 'transparent',
    	        flashvars: { url1: $(this).find('.XMLFile').attr('href') }
    	    },
    	    { version: 8 }
    	);
        else if ($(this).find('.SWFHeight').html())
            $(this).flash(
    	    {
    	        src: $(this).find('.SWFFile').attr('href'),
    	        height: $(this).find('.SWFHeight').html(),
    	        wmode: 'transparent',
    	        flashvars: { url1: $(this).find('.XMLFile').attr('href') }
    	    },
    	    { version: 8 }
    	);
        else if ($(this).find('.SWFWidth').html())
            $(this).flash(
    	    {
    	        src: $(this).find('.SWFFile').attr('href'),
    	        width: $(this).find('.SWFWidth').html(),
    	        wmode: 'transparent',
    	        flashvars: { url1: $(this).find('.XMLFile').attr('href') }
    	    },
    	    { version: 8 }
    	);
        else
            $(this).flash(
    	    {
    	        src: $(this).find('.SWFFile').attr('href'),
    	        wmode: 'transparent',
    	        flashvars: { url1: $(this).find('.XMLFile').attr('href') }
    	    },
    	    { version: 8 }
    	);

    });

    $('#main .teaserSpotFlash').each(function () {
        $(this).flash({
            src: $(this).attr('flashURL'),
            width: $(this).attr('flashWidth'),
            height: $(this).attr('flashHeight'),
            wmode: 'transparent'
        });
    });

    $('#content .pgThumbs .thumb').click(function () {
        showGalleryItem($(this));
    });
    $('#content .pgThumbs .thumb').hover(
    	function () {
    	    $(this).addClass('over');
    	},
      function () {
          $(this).removeClass('over');
      }
    );

    $('#content .simpleGallery .pgThumbs .pgScroll').serialScroll({
        items: '.thumb',
        prev: '#content .simpleGallery .pgPrev',
        next: '#content .simpleGallery .pgNext',
        duration: 300,
        cycle: false,
        onBefore: function (e, elem, $pane, $items, pos) {
            var itemSize = ($pane.width() > 600) ? 7 : 5;
            if ($items.length - pos < itemSize) {
                return false;
            }
        }
    });

    $('iframe').parent('.ms-WPBody').css('overflow', 'hidden');

    $('#main table.customLayoutGrey > tr:nth-child(even), #main table.customLayoutGrey tbody > tr:nth-child(even), #main table.customLayoutBlue > tr:nth-child(even), #main table.customLayoutBlue tbody > tr:nth-child(even), #main table.customLayoutPurple > tr:nth-child(even), #main table.customLayoutPurple tbody > tr:nth-child(even)').addClass('odd');
    //$('#main table.customLayoutGrey > tr:first-child, #main table.customLayoutGrey tbody > tr:first-child, #main table.customLayoutBlue > tr:first-child, #main table.customLayoutBlue tbody > tr:first-child, #main table.customLayoutPurple > tr:first-child, #main table.customLayoutPurple tbody > tr:first-child').addClass('th');

    $('#main .sitePath a.printButton').click(function () {
        trackIconEvent($(this), "print");
    });

    $('#main .sitePath a.generatePdf').attr('href', '#');
    $('#main .sitePath a.generatePdf').click(function () {
        var currentUrl = window.location.href;
        var bookmarkIndex = currentUrl.indexOf("#");
        if (bookmarkIndex > -1) {
            currentUrl = currentUrl.substring(0, bookmarkIndex);
        }

        var separator = currentUrl.indexOf("?") == -1 ? "?" : "&";
        window.location.href = currentUrl + separator + "printPdf=1";

        trackIconEvent($(this), "pdf")
    });
});

var VELUX = VELUX || {};

// validate input numbers only
function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}

function doInputField($input) {
    var $recBox = $('#main .sitePath div.recBox');
    var email = $input.attr('value');
    var index = $('#main .sitePath div.recBox input.valEmail').index($input);

    var $error = $recBox.find('div.error').eq(index);

    if (valEmail(email)) {
        $error.addClass('skip');
        if (index > 0) addRecipientMail(email);
        return true;
    }
    else {
        $error.removeClass('skip');
        return false;
    }
}

function addRecipient($recipient) {
    $recipientLine = $recipient.parent().clone();
    $recipient.parent().find('input').attr({ value: '' });

    $recipientLine.find('input').attr({ disabled: 'disabled' });
    $recipientLine.find('a.addRecipient').attr('class', 'clearRecipient').click(function () {
        clearRecipient($(this));

    });
    $recipient.parent().before($recipientLine);
}

function clearRecipient($recipient) {
    $recipient.parent().remove();
    delRecipientMail($recipient.parent().find('input').attr('value'));

}

function addRecipientMail(mail) {
    $recipients = $('#main .sitePath div.recBox input').eq(0);
    currentRecipients = $recipients.attr('value');

    if (currentRecipients.indexOf(mail) == -1) {
        currentRecipients += mail + ';'
        $recipients.attr('value', currentRecipients);
    }
}

function delRecipientMail(mail) {
    $recipients = $('#main .sitePath div.recBox input').eq(0);
    currentRecipients = $recipients.attr('value');

    currentRecipients = currentRecipients.replace(mail + ';', '')
    $recipients.attr('value', currentRecipients);
}

function showGalleryItem($item) {

    var $thumbs = $('#content .pgThumbs');
    var $index = $thumbs.find('.thumb').index($item);

    var $img = $('#content img.pgView'); // .photoGallery
    var $link = $('#content a.pgLink'); // .photoGallery
    var $desc = $('#content div.pgHTML');
    var $data = $('#content div.pgData>div');

    $item.siblings('.on').removeClass('on');
    $item.addClass('on');

    $img.attr({ src: $item.find('img').attr('longdesc'), alt: $item.find('img').attr('alt'), title: $item.find('img').attr('alt') });

    if ($link != null) {
        $link.attr({ href: $item.find('a').attr('href') });
        $link.attr('target', $item.find('a').attr('target'));
    }

    if ($desc != null && $data != null) {
        $desc.html($data.eq($index).html());
    }
}

function valEmail(email) {
    var pattern = /^([a-åA-å0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    return pattern.test(email);
}

try {
    document.execCommand('BackgroundImageCache', false, true);
}
catch (e) { }

function trackIconEvent(sender, iconName) {
    var pageUrl = sender.attr("pageUrl");
    var pageTitle = sender.attr("pageTitle");

    if (typeof (pageUrl) == 'undefined' || typeof (pageTitle) == 'undefined') {
        return;
    }

    var separator = (window.location.search.length < 1) ? "?" : "&";
    var query = window.location.search + separator + "icon=" + iconName;

    try {
        if (isCookieTrackingEnabled()) {
            dcsMultiTrack("DCS.dcsuri", pageUrl, "DCS.dcsqry", query, "WT.ti", pageTitle);
        }
    }
    catch (e) { }
}
VELUX.launchSurvey = function ($link, setCookie) {
    var surveyCookieName = $link.attr('href'),
        launchSurveyMessage = ($.cookie(surveyCookieName)) ? false : confirm($link.text());

    if (launchSurveyMessage) {
        if (setCookie) {
            if ($.cookie(surveyCookieName)) {
                return; // If cookie is already set
            }
            else {
                $.cookie(surveyCookieName, true, { expires: 300 }); // Else set cookie
            }
        }
        $link.trigger('click');
    }
    else {
        $.cookie(surveyCookieName, true, { expires: 300 }); // Else set cookie
    }
}


// Some tags in the MOSS content created using RADEditor were encoded in base64.
// This function finds and decodes them.
VELUX.decodeRADEditorEncodedTags = function () {
    function decode_base64(s) {
        var e = {}, i, k, v = [], r = '', w = String.fromCharCode;
        var n = [[65, 91], [97, 123], [48, 58], [47, 48], [43, 44]];

        for (z in n) { for (i = n[z][0]; i < n[z][1]; i++) { v.push(w(i)); } }
        for (i = 0; i < 64; i++) { e[v[i]] = i; }

        for (i = 0; i < s.length; i += 72) {
            var b = 0, c, x, l = 0, o = s.substring(i, i + 72);
            for (x = 0; x < o.length; x++) {
                c = e[o.charAt(x)]; b = (b << 6) + c; l += 6;
                while (l >= 8) { r += w((b >>> (l -= 8)) % 256); }
            }
        }
        return r;
    };
    var $tag = $("#RadEditorEncodedTag");
    var encodedString = $tag.text();
    var html = decode_base64(encodedString);
    $tag.replaceWith(html);
};
$(function () {
    VELUX.decodeRADEditorEncodedTags();
});



VELUX.fixSitemapLayout = function ($sitemap) {

    (function ($) {

        $.fn.tallest = function () { return this._extremities({ 'aspect': 'height', 'max': true })[0] };
        $.fn.tallestSize = function () { return this._extremities({ 'aspect': 'height', 'max': true })[1] };
        $.fn.shortest = function () { return this._extremities({ 'aspect': 'height', 'max': false })[0] };
        $.fn.shortestSize = function () { return this._extremities({ 'aspect': 'height', 'max': false })[1] };
        $.fn.widest = function () { return this._extremities({ 'aspect': 'width', 'max': true })[0] };
        $.fn.widestSize = function () { return this._extremities({ 'aspect': 'width', 'max': true })[1] };
        $.fn.thinnest = function () { return this._extremities({ 'aspect': 'width', 'max': false })[0] };
        $.fn.thinnestSize = function () { return this._extremities({ 'aspect': 'width', 'max': false })[1] };

        /**
        *	Returns an array: the first item is the matched element, and the second item is the dimension
        */
        $.fn._extremities = function (options) {
            var defaults = {
                aspect: 'height', // or 'width'
                max: true	// or false to find the min
            };
            options = $.extend(defaults, options);

            if (this.length < 2) {
                return [this, this[options.aspect]()];
            }

            var bestIndex = 0,
				bestSize = this.eq(0)[options.aspect](),
				thisSize
			;
            for (var i = 1; i < this.length; ++i) {
                thisSize = this.eq(i)[options.aspect]();
                if ((options.max && thisSize > bestSize) || (!options.max && thisSize < bestSize)) {
                    bestSize = thisSize;
                    bestIndex = i;
                }
            }

            return [this.eq(bestIndex), bestSize];
        };
    })(jQuery);

    var $columns, removedColumnsArray = new Array();

    //Top level li's represent columns:
    $columns = $("> ul > li", $sitemap);

    $columns.each(function (i) {
        //Inject CSS handle:
        $(this).wrapInner("<span class='col'></span>");

        //Grab columns to be relocated:
        if (i > 2) {
            var $currentColumn = $(this);
            $currentColumn.remove();
            removedColumnsArray.push($currentColumn);
        }
    });

    //Distribute removed columns, always chosing the shortest column:
    $(removedColumnsArray).each(function () {
        $("> ul > li", $sitemap).shortest().append(this.html());
    });
};

$(function () {
    VELUX.fixSitemapLayout($(".siteMap"));
});

function isCookieTrackingEnabled() {
    return $.cookie("optTracking") != "disabled";
};

//Fix ribbon tabs:
$(function () {
    $(".ms-cui-tts-scale-2").removeClass("ms-cui-tts-scale-2").addClass("ms-cui-tts");
});

//Fix inserted images default margin:
$(function () {
    $("#page img").each(function () {
        var style = $(this).attr("style") || "";
        if ((style.match("margin")) && (style.match("5px"))) {
            $(this).css("margin", "0");
        }
    });
})


