﻿/**
* 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);

/// <summary>
/// Check the current request to see if it has the needed requirements to run GallupPaging
/// </summary>
function hasPagingSupport() {
    if (typeof (hasPagingSupport.support) != "undefined") {
        return hasPagingSupport.support;
    }

    var ie55 = /msie 5\.[56789]/i.test(navigator.userAgent);

    hasPagingSupport.support = (typeof (document.implementation) != "undefined" &&
			document.implementation.hasFeature("html", "1.0") &&
			typeof (document.body.innerHTML) == "string" || ie55)

    return hasPagingSupport.support;

};

function loadPagingPages(el) {
    if ((!hasPagingSupport()) ||
	(el.pages.length != 0)) return;

    var pageHash = document.location.hash;
    if ((pageHash == null) || (pageHash == '')) {
        pageHash = "#1";
    }

    var _pages = $('div.page').get();

    if (_pages.length > 0) {
        for (i = 0; i < _pages.length; i++) {
            _pages[i].className = "pagehide";

            el.pages[i] = _pages[i];

            if (pageHash == _pages[i].id.replace('page', '#')) {
                el.selectedIndex = i;
            }
        }

        if (el.selectedIndex == null || el.pages[el.selectedIndex] == null) {
            el.selectedIndex = 0;
        }

        el.pages[el.selectedIndex].className = "pageshow";
    }
};

function setSelectedIndex(el, n) {
    if (el.selectedIndex != n) {
        if (el.selectedIndex != null && el.pages[el.selectedIndex] != null) {
            el.pages[el.selectedIndex].className = "pagehide";
        }

        var _activeLinks = getElementsByClass("pagingnavigationoption" + el.selectedIndex, el.element.parentNode, "a");

        if (_activeLinks.length > 0) {
            for (i = 0; i < _activeLinks.length; i++) {
                _activeLinks[i].className = "pagingnavigationoption" + el.selectedIndex;
            }
        }

        el.pages[n].className = "pageshow";
        el.selectedIndex = n;

        highlightLinks(el);
    }
};

function highlightLinks(el) {
    var _activeLinks = getElementsByClass("pagingnavigationoption" + el.selectedIndex, el.element.parentNode, "a");

    if (_activeLinks.length > 0) {
        for (i = 0; i < _activeLinks.length; i++) {
            _activeLinks[i].className += " pagingnavigationoptionon";
        }
    }
}

function createNavigation(el, localPageName) {
    // Add Paging, if there are more then 1 page
    if (el.pages.length > 1) {

        var text1 = localPageName + ": ";
        var div1 = createNavigationBlock("pagingnavigationtop", text1);
        var div2 = createNavigationBlock("pagingnavigationbottom", text1);

        for (i = 0; i < el.pages.length; i++) {
            div1.appendChild(createNavigationLink(el, i));
            div2.appendChild(createNavigationLink(el, i));
        }

        var wrapper = document.getElementById("pagingwrapper");
        var clearingDiv = document.createElement("div");
        // don't use clearfix, it inherits a line-height and is too common a definition to remove that height
        clearingDiv.className = "clearer";
        clearingDiv.innerHTML = " ";
        wrapper.insertBefore(clearingDiv, wrapper.firstChild);
        wrapper.insertBefore(div1, clearingDiv);
        el.element.appendChild(div2);

        highlightLinks(el);
    }
};

function createNavigationBlock(cssClass, text1) {
    var text = document.createTextNode(text1);
    var span = document.createElement("SPAN");
    span.appendChild(text);

    var div = document.createElement("DIV");
    div.className = "pagingnavigation " + cssClass;
    div.id = cssClass;
    div.appendChild(span);

    return div;
};

function createNavigationLink(el, position) {
    var _num = (position + 1);

    var a = document.createElement("A");
    a.href = "#" + _num;
    a.className = "pagingnavigationoption" + position;
    a.innerHTML = _num;

    a.onclick = function() {
        $.scrollTo('div.headings h1', 0);
        setSelectedIndex(el, position);
    };
    return a;
}

function startPaging(el, localPageName) {
    if (!hasPagingSupport() || el == null) return;

    this.element = el;
    this.selectedIndex = null;
    this.pages = [];

    var PageName = localPageName;

    // Load the Pages
    loadPagingPages(this);
    createNavigation(this, localPageName);
};

function getElementsByClass(searchClass, node, tag) {
    var classElements = new Array();
    if (node == null)
        node = document;
    if (tag == null)
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if (pattern.test(els[i].className)) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
};

/// <summary>
/// Article pagination. Initialize and pass in the local language var
/// </summary>
jQuery(function initializationPaging() {
    // Grab the main node
    var _pages;
    var _continue = false;
    var _localPageName = "Page";

    try {
        _pages = $('div#pages')[0];
        if (_pages) {
            _continue = true;
        }
    }
    catch (e)
    { }

    if (_continue == true) {
        // get the local language key for the word "Page"
        _localPageName = $('a#pageName').attr("rel");
        startPaging(_pages, _localPageName);
    }
});
/// <summary>
/// * wrapList 2009.05.12
/// @author Elizabeth Davies
/// </summary>
jQuery(function () {
jQuery.fn.wrapList = function(options) {
    var defaults = { maxListLength: 10, numColumns: 2, subListClass: 'subList' };
    var opts = $.extend(defaults, options);
    return this.each(function() {
        var ul = this;
        var li = $(ul).children('li');
        var ItemsPerColumn = $(li).length;  // determine #items in list
        // if there are more than maxListLength, split it by numColumns. Round up if Modulus
        // only rebuild the list if length > maxListLength
        if (ItemsPerColumn > opts.maxListLength) {
            ItemsPerColumn = Math.ceil(ItemsPerColumn / opts.numColumns);
            $(ul).empty();
            var curUl = ul;

            for (var i = 0; i < ItemsPerColumn; i++) {
                $(ul).append(li[i]);
            }
            for (var i = 1; i < li.length / ItemsPerColumn; i++) {
                $(curUl).parent().find('ul').wrapAll('<div></div>');
                var newUl = document.createElement('ul');
                for (var j = ItemsPerColumn * i; j < (ItemsPerColumn * i) + ItemsPerColumn; j++)
                    $(newUl).append(li[j]);
                $(newUl).addClass(opts.subListClass);
                $(curUl).after(newUl);
                curUl = newUl;
            }
        };

    });
};
});

/// <summary>
/// jquery replacement for www sitemap
/// </summary>
jQuery(function activemenuhover() {
    $('#sitemap div.menu').hover(
        function() {
            $(this).addClass('activemenu').find('div.title').addClass('activeTitle');
        },
        function() {
            $(this).removeClass('activemenu').find('div.title').removeClass('activeTitle');
        }
    );
});

/// <summary>
/// jquery menu action call for hover/flyout for top menu
/// </summary>
jQuery(function toptiermenuhover() {
    // find and remove the hasSubNav place holder class that prevents the arrowDown from flickering onLoad.
    $('div.row2 ul.listlevel1').find('li.hasSubNav').removeClass('hasSubNav');
    // Tier1 menu. Add class for arrow indicator if submenu exists
    $('div.row2 ul.listlevel1 li').find('ul.listlevel2').prev('a').addClass('arrowDown').addClass('clearfix').removeClass('hasSubNav');
    // add a delay for IE8 to realize there's a function called wrapList out there otherwise IE8 pukes
    setTimeout("$('div.row2 ul.listlevel1 li').find('ul.listlevel2').wrapList({ maxListLength: 7, numColumns: 2, subListClass: 'listlevel2'})", 200);

    // set required values for hover behaviors
    $('div.row2 ul.listlevel1 li').hover(
        function() {
            $(this).find('ul').addClass('showList').prev('a').addClass('arrowDownHover');
            $(this).find('ul').parent('div').addClass('wrapList').addClass('clearfix');
            $(this).find('div.wrapList').prev('a').addClass('arrowDownHover');
            var totalWidth = ($('ul.showList').outerWidth(true)) * 2;
            $(this).find('ul').parent('div').css('width', totalWidth);
        },
        function() {
            $(this).find('ul').removeClass('showList').prev('a').removeClass('arrowDownHover');
            $(this).find('div.wrapList').prev('a').removeClass('arrowDownHover');
            $(this).find('ul').parent('div').removeClass('wrapList').removeClass('clearfix').css('width', '0px');
        }
    );
    });

/// <summary>
/// jquery menu action call for hover/flyout for secondary menu
/// </summary>
jQuery(function secondarymenuhover() {
    // find and remove the hasSubNav place holder class that prevents the arrowDown from flickering onLoad.
    $('div.secondarynavigation ul.listlevel1').find('li.hasSubNav').removeClass('hasSubNav');
    // Add class for arrow indicator if submenu exists
    $('div.secondarynavigation ul.listlevel1 li').find('ul.listlevel2').prev('a').addClass('arrowDown').addClass('clearfix').removeClass('hasSubNav');

    // set required values for hover behaviors
    $('div.secondarynavigation ul.listlevel1 li').hover(
    function() {
        $(this).find('ul').addClass('showList').prev('a').addClass('arrowDownHover');
        var totalWidth = ($('ul.showList a').outerWidth(true));
        $(this).find('ul.showList').css('left','8px').css('width', totalWidth);
        var moreWidth = ($('li.moredropdownmenu a').outerWidth(true));
        var position = moreWidth - totalWidth - 8;
        $('li.moredropdownmenu ul.showList').css('left', position);
    },
    function() {
        $(this).find('ul.showList').css('width', '0').css('left','-9999em');
        $('li.moredropdownmenu ul.showList').css('left', '-9999em');
        $(this).find('ul').removeClass('showList').prev('a').removeClass('arrowDownHover');
    }
    ); // end hover
});

jQuery(function searchBoxClick() {
    _value = $('#searchform input.searchinput').val();
    if (_value == '') {
        $('#searchform').find('input.searchinput').addClass('bgWords');
    }
    $('#searchform input.searchinput').click(function() {
        $(this).removeClass('bgWords')
    });
    $('#searchform input.searchinput').blur(function() {
        _value = $('input.searchinput').val();
        if (_value == '') {
            $(this).addClass('bgWords');
        }
    });
});

function popfplayer(identKey) {
    testwindow = window.open("/popup/" + identKey + "/fvideo.aspx", "mywindow", "location=0,status=0,scrollbars=0,resizable=0,width=800,height=490");
}
