﻿//extension to address ASP.NET default long ID naming
jQuery.extend(
{
    clientID: function(id) {
        return jQuery("[id$='" + id + "']");
    }
}
);

//extension to check for dynamically created elements
jQuery.extend(
{
    elementExists: function(id) {
        return !((jQuery.clientID(id).val() == undefined) && (jQuery.clientID('_' + id).val() == undefined));
    }
}
);

/*
* URL Utils - v1.11 - 9/10/2009
* http://benalman.com/
* 
* Copyright (c) 2009 "Cowboy" Ben Alman
* Licensed under the MIT license
* http://benalman.com/about/license/
*/
(function($) { var M, q = {}, z, i = this, u = true, J = false, F = "onhashchange" in i, a = Array.prototype.slice, j = document.location, E, d, b, x, v, e, C, I, p = "urlInternal", L = "urlExternal", y = "queryString", G = "fragment", H = "update", f = "passQueryString", w = "passFragment", c = "fragmentChange", o = "hashchange." + c, h, g; function B(O) { return typeof O === "string" } function l(O) { return typeof O === "object" } function m() { var O = a.call(arguments), P = O.shift(); return function() { return P.apply(this, O.concat(a.call(arguments))) } } function k() { return j.href.replace(/^[^#]*#?/, "") } jQuery.urlTagAttrList = E = function(O) { return jQuery.extend(q, O) }; E({ a: "href", img: "src", form: "action", base: "href", script: "src", iframe: "src", link: "href" }); function r(O) { var P = O.nodeName; return P ? q[P.toLowerCase()] : "" } jQuery.urlInternalHost = d = function(Q) { Q = Q ? "(?:" + Q + "\\.)?" : ""; var P = new RegExp("^" + Q + "(.*)", "i"), O = "^" + j.protocol + "//" + j.hostname.replace(P, Q + "$1") + (j.port ? ":" + j.port : "") + "/"; return b(O) }; jQuery.urlInternalRegExp = b = function(O) { if (O) { M = B(O) ? new RegExp(O, "i") : O } return M }; d("www"); jQuery.isUrlInternal = x = function(O) { if (!O) { return z } if (M.test(O)) { return u } if (/^https?:\/\//i.test(O)) { return J } if (/^(?:#|[a-z\d.-]+:)/i.test(O)) { return z } return u }; jQuery.isUrlExternal = v = function(O) { var P = x(O); return typeof P === "boolean" ? !P : P }; e = function(P, O) { return this.filter(":" + P + (O ? "(" + O + ")" : "")) }; jQuery.fn[p] = m(e, p); jQuery.fn[L] = m(e, L); C = function(S, R, Q, P) { var O = P[3] || r(R); return O ? !!S($(R).attr(O)) : J }; jQuery.expr[":"][p] = m(C, x); jQuery.expr[":"][L] = m(C, v); function K(Q, R, P, O) { var S; if (B(P) || l(P)) { return n(R, P, O, Q) } else { if (l(R)) { return jQuery.param(R) } else { if (B(R)) { return D(R, P, Q) } else { S = Q ? k() : j.search; return D(S, R, Q) } } } } $[y] = m(K, 0); $[G] = m(K, 1); function N() { var O, S, R, Q = a.call(arguments), P = Q.shift(); if (B(Q[1]) || l(Q[1])) { O = Q.shift() } S = Q.shift(); R = Q.shift(); return this.each(function() { var V = $(this), T = O || r(this), U = T && V.attr(T) || ""; U = K(P, U, S, R); V.attr(T, U) }) } jQuery.fn[y] = m(N, 0); jQuery.fn[G] = m(N, 1); function A() { var Q = a.call(arguments), P = Q.shift(), O = Q.shift(), R = K(P); if (jQuery.isFunction(Q[0])) { R = Q.shift()(R) } else { if (jQuery.isArray(Q[0])) { jQuery.each(Q.shift(), function(T, S) { delete R[S] }) } } return K(P, O, R, Q.shift()) } $[f] = m(A, 0); $[w] = m(A, 1); function t() { var O, Q = a.call(arguments), P = Q.shift(); if (B(Q[0])) { O = Q.shift() } return this.each(function() { var T = $(this), R = O || r(this), S = R && T.attr(R) || ""; S = A.apply(this, [P, S].concat(Q)); T.attr(R, S) }) } jQuery.fn[f] = m(t, 0); jQuery.fn[w] = m(t, 1); function D(U, T, Q) { var P, W, S, V = {}, R = { "null": null, "true": u, "false": J }, O = decodeURIComponent, X = Q ? /^.*[#]/ : /^.*[?]|#.*$/g; U = U.replace(X, "").replace(/\+/g, " ").split("&"); while (U.length) { P = U.shift().split("="); W = O(P[0]); if (P.length === 2) { S = O(P[1]); if (T) { if (S && !isNaN(S)) { S = Number(S) } else { if (S === "undefined") { S = z } else { if (R[S] !== z) { S = R[S] } } } } if (jQuery.isArray(V[W])) { V[W].push(S) } else { if (V[W] !== z) { V[W] = [V[W], S] } else { V[W] = S } } } else { if (W) { V[W] = T ? z : "" } } } return V } function n(O, Q, T, P) { var U, W = P ? /^([^#]*)[#]?(.*)$/ : /^([^#?]*)[?]?([^#]*)(#?.*)/, S = O.match(W), V = D(S[2], 0, P), R = S[3] || ""; if (B(Q)) { Q = D(Q, 0, P) } if (T === 2) { U = Q } else { if (T === 1) { U = jQuery.extend({}, Q, V) } else { U = jQuery.extend({}, V, Q) } } U = jQuery.param(U); return S[1] + (P ? "#" : U || !S[1] ? "?" : "") + U + R } jQuery.setFragment = I = function(P, O) { var Q = l(P) ? K(u, P) : (P || "").replace(/^#/, ""); Q = P ? n("#" + k(), "#" + Q, O, 1) : "#"; j.href = j.href.replace(/#.*$/, "") + Q }; $[c] = function(O) { if (O === u) { O = 100 } function P() { var R = jQuery.Event(c); R[G] = k(); $(document).trigger(R) } F && $(i).unbind(o); h && clearTimeout(h); h = null; if (typeof O === "number") { if (F) { $(i).bind(o, P) } else { g = k(); if (jQuery.isFunction(s)) { s = s() } (function Q() { var S = k(), R = s[G](g); if (S !== g) { s[H](S, R); g = S; P() } else { if (R !== g) { I(R, 2) } } h = setTimeout(Q, O < 0 ? 0 : O) })() } } }; function s() { var O, P = jQuery.browser, Q = {}; Q[H] = Q[G] = function(R) { return R }; if (P.msie && P.version < 8) { Q[H] = function(T, R) { var S = O.document; if (T !== R) { S.open(); S.close(); S.location.hash = "#" + T } }; Q[G] = function() { return O.document.location.hash.replace(/^#/, "") }; O = $("<iframe/>").hide().appendTo("body").get(0).contentWindow; Q[H](k()) } return Q } })(jQuery);

/**
* Create a cookie with the given key and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String key The key of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given key.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String key The key of the cookie.
* @return The value of the cookie.
* @type String
*
* @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;
};


// Javascript for Header Marquee Effect

MarqueeScroll = function(name_var) {
    // this.init(name_var);
}

jQuery.extend(MarqueeScroll.prototype, {
    initialize: function() {
        // Four variables
        // ID of the container where the marquee will run.
        this.marqueeContainer = 'headerMarqueeContainer';
        // Height of the marquee container
        this.boxHeight = 26;
        // Duration of the movement in milliseconds
        this.movementDuration = 900;
        // Length of the pause in seconds
        this.pauseLength = 6.0;
        //   ***** IMPORTANT  *****
        // The marquee items inside the container must be position absolute and have a 'Top' value that puts them below the box
        // They should also be the same width and height as the container for best results.
        this.disableInOpera = false;
        this.itemArray = new Array();
        this.itemCount = 0;
        this.newActiveItem = 0;
        this.oldActiveItem = 0;
        this.interval = 0;
        this.activePosition = 0;
        this.startFunction = 'scrollbox.start()';
        this.rotationFunction = 'scrollbox.rotation()';
    },

    init: function() {
        this.initialize();
        // Count the number of items in our marquee container
        this.itemArray = jQuery('div#' + this.marqueeContainer).children();
        this.itemCount = this.itemArray.length;
        if (this.itemCount > 1) {
            if ((BrowserDetect.browser == 'Opera') && (this.disableInOpera)) {
                this.damnOpera();
            }
            else {
                // Do initial move, fire Start
                this.moveInNewItem();
                var time = this.pauseLength * 1000;
                var func = this.startFunction;
                setTimeout(func, time);
            }
        }
        else {
            if (this.itemCount == 1) {
                this.moveInNewItem();
            }
            else {
                // go piss up a rope.
                return false;
            }
        }
    },

    start: function() {
        // Do initial movement, then start rotation interval

        this.changeActiveItem();
        this.moveOutOldItem();
        this.moveInNewItem();
        // alert('in start');
        var pause = this.pauseLength * 1000;
        var func = this.rotationFunction;
        this.interval = setInterval(func, pause);
    },

    moveOutOldItem: function() {
        // Moves the current item out of the box
        // new Effect.Morph(this.itemArray[this.oldActiveItem], {
        // 	style: 'top: -' + this.boxHeight + 'px;', 
        // 	duration: this.movementDuration
        // });
        var val = '-' + this.boxHeight + 'px';
        jQuery(this.itemArray[this.oldActiveItem]).animate({
            top: val
        }, this.movementDuration);
    },

    moveInNewItem: function() {
        // Moves the next item into the box
        // new Effect.Morph(this.itemArray[this.newActiveItem], {
        // 	style: 'top: ' + this.activePosition + 'px;', 
        // 	duration: this.movementDuration
        // });
        // alert(this.movementDuration);
        jQuery(this.itemArray[this.newActiveItem]).animate({
            top: this.activePosition + 'px'
        }, this.movementDuration);

    },

    rotation: function() {
        // The rotation, runs forever
        // Move old item from above box to below box, ready to go next time.
        this.resetOldItem();
        // Identity next and current items
        this.changeActiveItem();
        // Move out old item
        this.moveOutOldItem();
        // Move in old item. 
        this.moveInNewItem();
        // moveOutOldItem() and moveInNewItem() actually run simultaneously
    },

    changeActiveItem: function() {
        // keep track of items
        this.oldActiveItem = this.newActiveItem;
        this.newActiveItem = this.newActiveItem + 1;
        if (this.newActiveItem == this.itemCount) this.newActiveItem = 0;
    },

    resetOldItem: function() {
        // Move old item from above box to below box, ready to go next time.
        // this.itemArray[this.oldActiveItem].setStyle({top: this.boxHeight + 'px' });
        jQuery(this.itemArray[this.oldActiveItem]).css({ top: this.boxHeight + 'px' });
    },

    damnOpera: function() {
        // this.itemArray[0].setStyle({top: '0px' });
        jQuery(this.itemArray[0]).css({ top: '0px' });
    }
});
var scrollbox = new MarqueeScroll();

jQuery(document).ready(function() {
    scrollbox.init();
});


// END Javascript for Header Marquee Effect



// BrowserDetect JS
var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();
// END BrowserDetect JS

