﻿//Swf Object
(function (A) { A.flashPlayerVersion = function () { var D, B = null, I = false, H = "ShockwaveFlash.ShockwaveFlash"; if (!(D = navigator.plugins["Shockwave Flash"])) { try { B = new ActiveXObject(H + ".7") } catch (G) { try { B = new ActiveXObject(H + ".6"); D = [6, 0, 21]; B.AllowScriptAccess = "always" } catch (F) { if (D && D[0] === 6) { I = true } } if (!I) { try { B = new ActiveXObject(H) } catch (E) { D = "X 0,0,0" } } } if (!I && B) { try { D = B.GetVariable("$version") } catch (C) { } } } else { D = D.description } D = D.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|,)(\d+)/); return [D[1] * 1, D[3] * 1, D[5] * 1] } (); A.flashExpressInstaller = "expressInstall.swf"; A.hasFlashPlayer = (A.flashPlayerVersion[0] !== 0); A.hasFlashPlayerVersion = function (C) { var B = A.flashPlayerVersion; C = (/string|integer/.test(typeof C)) ? C.toString().split(".") : C; return (C) ? (B[0] >= (C.major || C[0] || B[0]) && B[1] >= (C.minor || C[1] || B[1]) && B[2] >= (C.release || C[2] || B[2])) : (B[0] !== 0) }; A.flash = function (M) { if (!A.hasFlashPlayer) { return false } var C = M.swf || "", K = M.params || {}, E = document.createElement("body"), B, L, H, D, J, I, G, F; M.height = M.height || 180; M.width = M.width || 320; if (M.hasVersion && !A.hasFlashPlayerVersion(M.hasVersion)) { A.extend(M, { id: "SWFObjectExprInst", height: Math.max(M.height, 137), width: Math.max(M.width, 214) }); C = M.expressInstaller || A.flashExpressInstaller; K = { flashvars: { MMredirectURL: window.location.href, MMplayerType: (A.browser.msie && A.browser.win) ? "ActiveX" : "PlugIn", MMdoctitle: document.title.slice(0, 47) + " - Flash Player Installation"}} } if (M.flashvars && typeof K === "object") { A.extend(K, { flashvars: M.flashvars }) } for (J in (I = ["swf", "expressInstall", "hasVersion", "params", "flashvars"])) { delete M[I[J]] } B = []; for (J in M) { if (typeof M[J] === "object") { L = []; for (I in M[J]) { L.push(I.replace(/([A-Z])/, "-$1").toLowerCase() + ":" + M[J][I] + ";") } M[J] = L.join("") } B.push(J + '="' + M[J] + '"') } M = B.join(" "); if (typeof K === "object") { B = []; for (J in K) { if (typeof K[J] === "object") { L = []; for (I in K[J]) { if (typeof K[J][I] === "object") { H = []; for (G in K[J][I]) { if (typeof K[J][I][G] === "object") { D = []; for (F in K[J][I][G]) { D.push(F.replace(/([A-Z])/, "-$1").toLowerCase() + ":" + K[J][I][G][F] + ";") } K[J][I][G] = D.join("") } H.push(G + "{" + K[J][I][G] + "}") } K[J][I] = H.join("") } L.push(window.escape(I) + "=" + window.escape(K[J][I])) } K[J] = L.join("&amp;") } B.push('<PARAM NAME="' + J + '" VALUE="' + K[J] + '">') } K = B.join("") } if (!(/style=/.test(M))) { M += ' style="vertical-align:text-top;"' } if (!(/style=(.*?)vertical-align/.test(M))) { M = M.replace(/style="/, 'style="vertical-align:text-top;') } if (A.browser.msie) { M += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; K = '<PARAM NAME="movie" VALUE="' + C + '">' + K } else { M += ' type="application/x-shockwave-flash" data="' + C + '"' } E.innerHTML = "<OBJECT " + M + ">" + K + "</OBJECT>"; return A(E.firstChild) }; A.fn.flash = function (C) { if (!A.hasFlashPlayer) { return this } var B = 0, D; while ((D = this.eq(B++))[0]) { D.html(A.flash(A.extend({}, C))); if (D[0].firstChild.getAttribute("id") === "SWFObjectExprInst") { B = this.length } } return this } } (jQuery));
//End SwfObject

$(document).ready(function () {

    browser();
    fontResizer();
    //checks flash player version and player itself for SIFR
    if (parseInt($.flashPlayerVersion) < 9 || $.hasFlashPlayer == false) { $('body').addClass('noSIFR'); }


    $("#nav li").hover(function () {
        $(this).addClass('active').children('a').addClass('active');
    }, function () {
        $(this).removeClass('active').children('a').removeClass('active');
    });

    $(".topics li").each(function () {
        if ($(this).height() > 54) { $(this).children().css('padding', '6px 0px'); }
    });

    var toolSize = ($(".topics li").size() / 2) * 65;
    if (toolSize) { $(".topics ul").css('height', toolSize); }

    $('ul.toggleList li.has-children > a').click(function () {
        $(this).toggleClass('open');
        $(this).parent().children('ul').animate({
            height: "toggle",
            opacity: "toggle"
        }, 500);
        return false;
    });
    /*
    $("#memberControlBtn").click(function(){
    $("#memberMenu").toggleClass("active");
    $(this).toggleClass("active");
    return false;
    });*/

    $("#memberControl .hello").click(function () {
        $(this).parent().children('#memberMenu').slideToggle();
        $(this).toggleClass('active');
        return false;
    });

    $("#intranetMenu .button").click(function () {
        $(this).parent().children('ul').slideToggle();
        return false;
    });

    var lWidth = $('#memberControl .hello').css('width');
    var loginWidth = parseInt(lWidth);
    if (loginWidth < 173) {
        $('#memberControl .hello').css('width', '173px');
    }

    //var mWidth = $('.hello').innerWidth();
    //$('#memberControl').css('width', mWidth + 'px');

    var mWidth = $('.hello').innerWidth();
    /*if ($('div.hello').parent().hasClass('logged-in')) {
        var aWidth = $('#dashboard').innerWidth();
        mWidth += aWidth;
        $('#memberControl').css('width', mWidth + 'px');
    }
    else {
        $('#memberControl').css('width', '162px');
    }*/
    
    /* Apply template class higher up */
    var classes = $("#contentWrapper div.section").attr('class');
    classes = classes.replace('section ', '');
    if (classes) $("#contentWrapper").addClass(classes);

    /* this function moved from home.js to utils.js */
    $carousel = $('#carousel');
    if ($carousel.length) {
        $('#carousel').show();
        $('#mycarousel').jcarousel();
    }

    /* end move */
    $('#carousel li a img').each(function () {
        var $this = $(this);
        if ($this.innerWidth() >= $this.innerHeight()) {
            $this.addClass('marginTop');
        }
    });


    swapValues = [];
    $(".swap").each(function (i) {
        swapValues[i] = $(this).val();
        $(this).focus(function () {
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function () {
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });



    //back to top	
    $(function () {
        var divHeight = $("div#top").height();
        if (divHeight > 1000) {
            $("div.footer .backToTop").css("display", "block");
        } else {
            $("div.footer .backToTop").css("display", "none");
        }

    });

    $("#alert a.close").click(function () {
        $(this).parent().slideUp("slow", function () { if ($("#alert").height() == 0) { $("#alert").hide(); } });

        return false;
    });

    if ($('.sponsorGroup').length) {
        $('.sponsorGroup .left').each(function () {
            $(this).next('div').andSelf().wrapAll('<div class="sponsorWrap" />');
        });
    }

    //DatePicker

    $(function () {
        $('.date-pick').datePicker(
				{
				    startDate: '01/01/1970',
				    endDate: ((new Date()).asString())
				}
			);
    });

    // TOOLBOX FAQ
    $('.qa .question a').click(function () { $(this).parent().parent().children('.answer').toggle(); return false; });
    $('.qa .answer a.close').click(function () { $(this).parent().slideUp(); return false; });
    $('.toolbox .pager a.expand').click(function () { $('.qa .answer').each(function () { $(this).slideDown(); }); return false; });
    $('.toolbox .pager a.close').click(function () { $('.qa .answer').each(function () { $(this).slideUp(); }); return false; });
});


jQuery.timer = function (time, func, callback) {
    var a = { timer: setTimeout(func, time), callback: null }
    if (typeof (callback) == 'function') { a.callback = callback; }
    return a;
};

jQuery.clearTimer = function (a) {
    clearTimeout(a.timer);
    if (typeof (a.callback) == 'function') { a.callback(); };
    return this;
};
//adds classes to html and body for browser/version & os
(function ($) { $.browserTest = function (a, z) { var u = 'unknown', x = 'X', m = function (r, h) { for (var i = 0; i < h.length; i = i + 1) { r = r.replace(h[i][0], h[i][1]); } return r; }, c = function (i, a, b, c) { var r = { name: m((a.exec(i) || [u, u])[1], b) }; r[r.name] = true; r.version = (c.exec(i) || [x, x, x, x])[3]; if (r.name.match(/safari/) && r.version > 400) { r.version = '2.0'; } if (r.name === 'presto') { r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b'; } r.versionNumber = parseFloat(r.version, 10) || 0; r.versionX = (r.version !== x) ? (r.version + '').substr(0, 1) : x; r.className = r.name + r.versionX; return r; }; a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) ? m(a, [[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], ['Chrome Safari', 'Chrome'], ['KHTML', 'Konqueror'], ['Minefield', 'Firefox'], ['Navigator', 'Netscape']]) : a).toLowerCase(); $.browser = $.extend((!z) ? $.browser : {}, c(a, /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, [], /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/)); $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [['konqueror', 'khtml'], ['msie', 'trident'], ['opera', 'presto']], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/); $.os = { name: (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris') }; if (!z) { $('html').addClass([$.os.name, $.browser.name, $.browser.className, $.layout.name, $.layout.className].join(' ')); } }; $.browserTest(navigator.userAgent); })(jQuery);
browser = function () {

    var OSName = "Unknown OS";
    var browser = "";
    if (navigator.appVersion.indexOf("Mac") != -1) OSName = "Mac";
    if (navigator.appVersion.indexOf("Win") != -1) OSName = "PC";
    bodyClass = $.browser.className + OSName
    $("body").addClass(bodyClass);
    //
}

function fontResizer() {
    function clearSelected() { $("a#smallFont").removeClass("currFont"); $("a#medFont").removeClass("currFont"); $("a#largeFont").removeClass("currFont"); $("body").removeClass("smallFont").removeClass("medFont").removeClass("largeFont") }
    function saveState(curSize) { var date = new Date(); date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); document.cookie = "fontSizer" + "=" + curSize + expires + "; path=/"; }
    $("a#smallFont").click(function () { clearSelected(); $('body').addClass('smallFont'); $("a#smallFont").addClass("currFont"); saveState("smallFont"); return false });
    $("a#medFont").click(function () { clearSelected(); $('body').addClass('medFont'); $("a#medFont").addClass("currFont"); saveState("medFont"); return false });
    $("a#largeFont").click(function () { clearSelected(); $('body').addClass('largeFont'); $("a#largeFont").addClass("currFont"); saveState("largeFont"); return false });
    function getCookie(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; }
    var savedSize = getCookie('fontSizer');
    if (savedSize != "") { $('body').addClass(savedSize); if (savedSize == "smallFont") { $("a#smallFont").addClass("currFont"); } else if (savedSize == "largeFont") { $("a#largeFont").addClass("currFont"); } else { $("a#medFont").addClass("currFont"); } } else { $('body').addClass("smallFont"); $("a#smallFont").addClass("currFont"); }
}


$(function () {
    $('a.toggle').click(function () {
        var activeClass = $(this).parent().attr('class');
        $(this).parent().children('ul').toggle();
        if (activeClass.indexOf('active') > 0) {
            $(this).parent().removeClass('active');
        } else {
            $(this).parent().addClass('active');
        }
        return false;
    });

    $('a.balloon').mouseover(function (e) {

        var info = $(this).attr('href');
        var beingShown = false;
        var shown = false;
        if ($(info).css('display') == "block") { beingShown = true; }
        if (beingShown || shown) {
            // don't trigger the animation again
            return;
        } else {
            // reset position of info box
            beingShown = true;
            var pos = $(this).position();
            var height = $(this).children('img').css('height');
            height = height.replace('px', '');
            if ($.browser.className == "msie7") { pos.top = pos.top + 150; }
            if ($.browser.className == "msie6") { pos.top = pos.top + 150; }
            $(info).css({
                top: pos.top - height - 163,
                left: pos.left - 200,
                display: 'block'
            });

        }

        return false;
    });

    $('div.tooltip').mouseover(function () {
        var beingShown = true;
        $(this).css('display', 'block');
    }).mouseout(function () {
        $(this).css('display', 'none');
        var beingShown = false;
    });

    $('a.balloon').mouseout(function () {
        var info = $(this).attr('href');
        $(info).css('display', 'none');
        var beingShown = false;
        var shown = false;
        return false;
    });


    $('a.trigger').each(function () {

        var trigger = $(this);
        var info = $(trigger.attr('href'));
        var xy = $(this).position();
        var top = xy.top - info.innerHeight();
        var width = $(this).width();
        //var left = (xy.left + width) - info.width();
        info.css('top', top);
        info.css('left', 138);
        var hideDelayTimer = null;
        var beingShown = false;
        var hideDelay = 500;
        var shown = false;
        var time = 250;

        var hoverChildren;
        function checkHoverChildren() {
            $('.meta').children().hover(function () {
                hoverChildren = true;
            }, function () {
                hoverChildren = false;
                beingShown = false;
            });
            return hoverChildren;
        }

        $(trigger).mouseover(function (e) {

            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    display: 'block'
                }).animate({
                    opacity: 1
                }, time, 'swing', function () {
                    beingShown = true;
                    //shown = true;
                });

            }

            return false;
        }).mouseout(function () {
            checkHoverChildren()
            if (hoverChildren = true) {
                //keep checking
                beingShown = true;
                checkHoverChildren();

            } else {

                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        opacity: 0
                    }, time, 'swing', function () {
                        beingShown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);
                beingShown = false;
                return false;
            }

        });
    });


    /*

    $('.media-viewer .images img').eq(0).css('display', 'block');

    $(window).load(function () {
    if (jQuery('.media-viewer').attr('class')) {
    var stopcycle = $('.media-viewer .images img').size();

    jQuery('.media-viewer .images').cycle({
    fx: 'fade',
    autostop: 1,
    autostopCount: stopcycle,
    after: onAfter,
    timeout: 2500
    });
    }
    });

    jQuery(".media-viewer .nav a").click(function () {

    jQuery('.media-viewer .images').cycle('stop');
    $(".media-viewer .images img").each(function () { jQuery(this).removeAttr("style"); jQuery(this).css('display', 'none'); });

    var newthumb = jQuery(this).html();
    newthumb = parseInt(newthumb) - 1;
    jQuery(".media-viewer .images img").each(function () { });
    jQuery(".media-viewer .images img").eq(newthumb).css('display', 'block');

    jQuery(this).parent().children('a').each(function () { jQuery(this).removeClass('active'); });
    jQuery(this).addClass('active');


    return false;
    });
    */

    var mv = $('.media-viewer')
    mvi = $('.images', mv),
  	  mvii = $('div', mvi),
  	  mvna = $('.nav a', mv);


    mvii.eq(0).show();

    $(window).load(function () {
        if (mv.attr('class')) {
            var stopcycle = mvii.length;

            mvi.cycle({
                fx: 'fade',
                autostop: 1,
                autostopCount: stopcycle,
                after: onAfter,
                timeout: 2500
            });
        }
    });

    mvna.click(function () {
        var $this = $(this),
			newthumb = $this.html();

        mvi.cycle('stop');
        mvii.removeAttr('style').hide();
        newthumb = parseInt(newthumb) - 1;
        mvii.eq(newthumb).show();
        $this.addClass('active').siblings().removeClass('active');
        return false;
    });

});

if ($('p.calloutQuote')) {
    $('p.calloutQuote').wrap('<span class="calloutQuote" />');
}


function getOffset(el) {
    var _x = 0;
    var _y = 0;
    while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.offsetParent;
    }
    return { top: _y, left: _x };
}

function clearForm(formid) {

    var oForm = document.getElementById(formid);

    var elements = oForm.elements;

    oForm.reset();

    for (i = 0; i < elements.length; i++) {

        field_type = elements[i].type.toLowerCase();

        switch (field_type) {

            case "text":
            case "password":
            case "textarea":
            case "hidden":

                elements[i].value = "";
                break;

            case "radio":
            case "checkbox":
                if (elements[i].checked) {
                    elements[i].checked = false;
                }
                break;

            case "select-one":
            case "select-multi":
                elements[i].selectedIndex = -1;
                break;

            default:
                break;
        }
    }

    return false;
}

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    index = index + 1;

    index = index - $('.media-viewer .images img').size();
    index = Math.abs(index);

    jQuery('.media-viewer .nav').children('a').each(function () { jQuery(this).removeClass('active'); });
    jQuery('.media-viewer .nav a').eq(index).addClass('active');
} // JavaScript Document
