﻿





/**
* 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);



/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name 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 name The name 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 name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name 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(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/* jfeed */

eval(function(p, a, c, k, e, d) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('3.X=a(h){h=3.J({v:D,C:D,u:D},h);k(h.v){$.W({t:\'V\',v:h.v,C:h.C,U:\'4\',u:a(4){d f=j B(4);k(3.T(h.u))h.u(f)}})}};a B(4){k(4)2.K(4)};B.r={t:\'\',l:\'\',c:\'\',b:\'\',g:\'\',K:a(4){k(3(\'8\',4).y==1){2.t=\'x\';d s=j z(4)}H k(3(\'f\',4).y==1){2.t=\'S\';d s=j A(4)}k(s)3.J(2,s)}};a o(){};o.r={c:\'\',b:\'\',g:\'\',i:\'\',n:\'\'};a A(4){2.q(4)};A.r={q:a(4){d 8=3(\'f\',4).9(0);2.l=\'1.0\';2.c=3(8).5(\'c:e\').6();2.b=3(8).5(\'b:e\').p(\'I\');2.g=3(8).5(\'R:e\').6();2.w=3(8).p(\'4:Q\');2.i=3(8).5(\'i:e\').6();2.m=j G();d f=2;3(\'P\',4).F(a(){d 7=j o();7.c=3(2).5(\'c\').9(0).6();7.b=3(2).5(\'b\').9(0).p(\'I\');7.g=3(2).5(\'O\').9(0).6();7.i=3(2).5(\'i\').9(0).6();7.n=3(2).5(\'n\').9(0).6();f.m.E(7)})}};a z(4){2.q(4)};z.r={q:a(4){k(3(\'x\',4).y==0)2.l=\'1.0\';H 2.l=3(\'x\',4).9(0).p(\'l\');d 8=3(\'8\',4).9(0);2.c=3(8).5(\'c:e\').6();2.b=3(8).5(\'b:e\').6();2.g=3(8).5(\'g:e\').6();2.w=3(8).5(\'w:e\').6();2.i=3(8).5(\'N:e\').6();2.m=j G();d f=2;3(\'7\',4).F(a(){d 7=j o();7.c=3(2).5(\'c\').9(0).6();7.b=3(2).5(\'b\').9(0).6();7.g=3(2).5(\'g\').9(0).6();7.i=3(2).5(\'M\').9(0).6();7.n=3(2).5(\'L\').9(0).6();f.m.E(7)})}};', 60, 60, '||this|jQuery|xml|find|text|item|channel|eq|function|link|title|var|first|feed|description|options|updated|new|if|version|items|id|JFeedItem|attr|_parse|prototype|feedClass|type|success|url|language|rss|length|JRss|JAtom|JFeed|data|null|push|each|Array|else|href|extend|parse|guid|pubDate|lastBuildDate|content|entry|lang|subtitle|atom|isFunction|dataType|GET|ajax|getFeed'.split('|')))

;
/*
* Print Element Plugin 0.9
*
* Copyright (c) 2009 Erik Zaadi
*
* Inspired by PrintArea (http://plugins.jquery.com/project/PrintArea) and
* http://stackoverflow.com/questions/472951/how-do-i-print-an-iframe-from-javascript-in-safari-chrome
*
* $Id: jquery.printElement.js PENDING ID ErikZ $
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/
(function($) {
    $.fn.printElement = function(options) { var mainOptions = $.extend({}, $.fn.printElement.defaults, options); $("[id^='printElement_']").remove(); return this.each(function() { var opts = $.meta ? $.extend({}, mainOptions, $this.data()) : mainOptions; _printElement($(this), opts); }); }; $.fn.printElement.defaults = { printMode: 'iframe', pageTitle: '', overrideElementCSS: [], printBodyOptions: { styleToAdd: 'padding:10px;margin:10px;', classNameToAdd: '' }, leaveOpen: false, iframeElementOptions: { styleToAdd: 'position:absolute;width:0px;height:0px;', classNameToAdd: ''} }; function _printElement(element, opts) {
        var $elementToPrint = $(element); var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popup.document; }
        else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }); document.body.appendChild(iframe); documentToWriteTo = iframe.contentWindow.document; var iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; }
        documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus();
    }; function _getMarkup(element, opts) {
        var $elementToPrint = $(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS && opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { html.push('<link type="text/css" rel="stylesheet" href="' + opts.overrideElementCSS[x] + '" >'); } }
        else { $(document).find("link ").filter(function() { return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function() { html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >'); }); }
        html.push('</head><body onload="printPage();" style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $elementToPrint.attr("class") + '">' + $elementToPrint.html() + '</div>'); html.push('<script type="text/javascript">function printPage() { focus();print();' + (opts.leaveOpen ? '' : 'close();') + '}</script></body></html>'); return html.join('');
    };
})(jQuery);



/* protect-data http://code.google.com/p/protect-data/
*/


var x = function($) {
    $.extend($, { protectData: { forms: [], unsavedChanges: false, protectAjax: false, ajaxUnportectNTimes: 0, stateChangeCallback: function(isProtected) { }, initialize: function() {
        if (this.running) return; this.running = true; var self = this; if ($.fn.ajaxSubmit) { var oldAjaxSubmit = $.fn.ajaxSubmit; $.fn.ajaxSubmit = function(e) { self.unprotect(); oldAjaxSubmit.call($.fn, e); } }
        $().ajaxSend(function(e, r, s) { self.ajaxCallback.call(self, e, r, s) });
    }, reset: function() {
    this.ajaxUnportectNTimes = 0; this.unsavedChanges = false; this.ajaxProtect = false; this.stateChangeCallback = function(isProtected) { }; window.onbeforeunload = null; for (var key in this.forms) {
        
            if ($.browser.msie) { $(':input', this.forms[key].form).unbind('.protectData'); }
            this.forms[key].form.unbind('.protectData');
        }
        this.forms = [];
    }, forms: [], message: "You have made changes to this page and leaving means losing all unsaved changes... \n\nAre you sure you want to leave without saving?\n\n" + "OK -> Leave and lose changes                            Cancel -> Stay\n", protect: function() { if (this.unsavedChanges) return; this.stateChangeCallback(true); this.unsavedChanges = true; window.onbeforeunload = function() { return $.protectData.message; } }, unprotect: function() { if (!this.unsavedChanges) return; this.stateChangeCallback(false); this.unsavedChanges = false; window.onbeforeunload = null; }, unprotectAjax: function(times) { if (times === 0 || times === '0') return; if (times === undefined) times = 1; times = parseInt(times, 10); this.ajaxUnportectNTimes += times; }, ajaxCallback: function(event, request, settings) {
        if (!this.protectAjax) return; if (!this.unsavedChanges) return; if (this.ajaxUnportectNTimes) { this.ajaxUnportectNTimes--; return; }
        if (confirm(this.message)) this.unprotect(); else request.abort();
    }, ProtectedForm: function(form) {
        this.form = $(form); $.protectData.forms.push(this); if ($.browser.msie) { $(':input', form).bind('change.protectData', function() { $.protectData.protect(); }); } else { this.form.bind('change.protectData', function() { $.protectData.protect(); }); }
        this.form.bind('submit.protectData', function() { $.protectData.unprotect(); });
    } }
    }); $.extend($.fn, { protectData: function(options) { options = options || {}; $.extend($.protectData, options); $.protectData.initialize(); $(this).each(function() { if ($(this).is('form')) { new $.protectData.ProtectedForm(this); } }); } });
} (jQuery);


/* jquery checkbox */
/**
* jQuery custom checkboxes
* 
* Copyright (c) 2008 Khavilo Dmitry (http://widowmaker.kiev.ua/checkbox/)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* @version 1.3.0 Beta 1
* @author Khavilo Dmitry
* @mailto wm.morgun@gmail.com
**/

(function($) {
    /* Little trick to remove event bubbling that causes events recursion */
    var CB = function(e) {
        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
    };

    $.fn.checkbox = function(options) {
        /* IE6 background flicker fix */
        try { document.execCommand('BackgroundImageCache', false, true); } catch (e) { }

        /* Default settings */
        var settings = {
            cls: 'jquery-checkbox',  /* checkbox  */
            empty: '/content/images/1x1.gif'  /* checkbox  */
        };

        /* Processing settings */
        settings = $.extend(settings, options || {});

        /* Adds check/uncheck & disable/enable events */
        var addEvents = function(object) {
            var checked = object.checked;
            var disabled = object.disabled;
            var $object = $(object);

            if (object.stateInterval)
                clearInterval(object.stateInterval);

            object.stateInterval = setInterval(
				function() {
				    if (object.disabled != disabled)
				        $object.trigger((disabled = !!object.disabled) ? 'disable' : 'enable');
				    if (object.checked != checked)
				        $object.trigger((checked = !!object.checked) ? 'check' : 'uncheck');
				},
				10 /* in miliseconds. Low numbers this can decrease performance on slow computers, high will increase responce time */
			);
            return $object;
        };
        //try { console.log(this); } catch(e) {}

        /* Wrapping all passed elements */
        return this.each(function() {
            var ch = this; /* Reference to DOM Element*/
            var $ch = addEvents(ch); /* Adds custom events and returns, jQuery enclosed object */

            /* Removing wrapper if already applied  */
            if (ch.wrapper) ch.wrapper.remove();

            /* Creating wrapper for checkbox and assigning "hover" event */
            ch.wrapper = $('<span class="' + settings.cls + '"><span class="mark"><img src="' + settings.empty + '" /></span></span>');
            ch.wrapperInner = ch.wrapper.children('span:eq(0)');
            ch.wrapper.hover(
				function(e) { ch.wrapperInner.addClass(settings.cls + '-hover'); CB(e); },
				function(e) { ch.wrapperInner.removeClass(settings.cls + '-hover'); CB(e); }
			);

            /* Wrapping checkbox */
            $ch.css({ position: 'absolute', zIndex: -1, visibility: 'hidden' }).after(ch.wrapper);

            /* Ttying to find "our" label */
            var label = false;
            if ($ch.attr('id')) {
                label = $('label[for=' + $ch.attr('id') + ']');
                if (!label.length) label = false;
            }
            if (!label) {
                /* Trying to utilize "closest()" from jQuery 1.3+ */
                label = $ch.closest ? $ch.closest('label') : $ch.parents('label:eq(0)');
                if (!label.length) label = false;
            }
            /* Labe found, applying event hanlers */
            if (label) {
                label.hover(
					function(e) { ch.wrapper.trigger('mouseover', [e]); },
					function(e) { ch.wrapper.trigger('mouseout', [e]); }
				);
                label.click(function(e) { $ch.trigger('click', [e]); CB(e); return false; });
            }
            ch.wrapper.click(function(e) { $ch.trigger('click', [e]); CB(e); return false; });
            $ch.click(function(e) { CB(e); });
            $ch.bind('disable', function() { ch.wrapperInner.addClass(settings.cls + '-disabled'); }).bind('enable', function() { ch.wrapperInner.removeClass(settings.cls + '-disabled'); });
            $ch.bind('check', function() { ch.wrapper.addClass(settings.cls + '-checked'); }).bind('uncheck', function() { ch.wrapper.removeClass(settings.cls + '-checked'); });

            /* Disable image drag-n-drop for IE */
            $('img', ch.wrapper).bind('dragstart', function() { return false; }).bind('mousedown', function() { return false; });

            /* Firefox antiselection hack */
            if (window.getSelection)
                ch.wrapper.css('MozUserSelect', 'none');

            /* Applying checkbox state */
            if (ch.checked)
                ch.wrapper.addClass(settings.cls + '-checked');
            if (ch.disabled)
                ch.wrapperInner.addClass(settings.cls + '-disabled');
        });
    }
})(jQuery);

/* 

WBCF

*/
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}

// general UI initialisation
$(function () {

    // preload nav images
    var preload1 = document.createElement('img');
    preload1.src = "/Content/Images/top_nav_rollover.png";
    var preload2 = document.createElement('img');
    preload2.src = "/Content/Images/ulr-reports-hover.png";

    // small dropdowns (more)
    $(".smalldropdownmore").click(function () {
        $(this).parent().find(".smalldropdown").show();
        $(this).addClass("highlighted");
    });

    $(".smalldropdown").hide().mouseleave(function () { $(this).hide().parent().find(".smalldropdownmore").removeClass("highlighted"); }).click(function () { $(this).hide().parent().find(".smalldropdownmore").removeClass("highlighted"); });

    // context help
    $(".contexthelp").find("a.link").click(function () {
        $(this).parent().find("div.contextpopup").show();
        $(this).addClass("highlighted");
    });
    $(".contextpopup").hide().click(function () { $(this).hide().parent().find(".link").removeClass("highlighted"); });

    // skinnable selects
    $(".skin").each(
      function (i) {
          selectContainer = $(this);
          // Remove the class for non JS browsers
          selectContainer.removeClass('skin');
          // Add the class for JS Browers
          selectContainer.addClass('skinned-select');
          // Find the select box
          selectContainer.children().before('<div class="select-text">a</div>').each(
          function () {
              $(this).prev().text(this.options[this.selectedIndex].innerHTML)
          }
        );
          // Store the parent object
          var parentTextObj = selectContainer.children().prev();
          // As we click on the options
          selectContainer.children().change(function () {
              // Set the value of the html
              parentTextObj.text(this.options[this.selectedIndex].innerHTML);
          })
      }
    );


    $(".navtoggle").click(function () {
        if ($(this).find("span").text() == "-") {
            $(this).parent().find(".items:first").slideUp('slow');
            $(this).find("span").text("+");
        }
        else {
            $(this).parent().find(".items:first").slideDown('slow');
            $(this).find("span").text("-");
        }

    });


    /*  reassign tab orders */
    var tabindex = 1;
    $('input,select,textarea').each(function () {
        if (this.type != "hidden") {
            var $input = $(this);
            $input.attr("tabindex", tabindex);
            tabindex++;
        }
    });

    //basic and ajax protection
    $('form').not("#loginform").not("#search").protectData();
    $.protectData.protectAjax = false;

    $('.yesno').wrap('<div class="yesnocontainer"/>');
    $('.yesno').checkbox();
    var scs = getParameterByName("scs");

    if (scs == "1") {
        setTimeout(function () { alert("Your changes have been saved."); }, 500);
    }
    if (scs == "2") {
        setTimeout(function () { alert("Your changes have been saved, and the learner has been sent a confirmation email for their records"); }, 500);
    }

    if (scs == "3") {
        setTimeout(function () { alert("The user has been emailed a request to accept you as their ULR."); }, 500);
    }

    if (scs == "4") {
        setTimeout(function () { alert("The user has been emailed a request to accept you as their learner."); }, 500);
    }

    if (scs == "5") {
        setTimeout(function () { alert("That email address is not registered in the system."); }, 500);
    }
    $('input').attr("autocomplete", "off");



    // videos box
    loadVideo(0);

    $('#videoPrev').click(function () { currentVideoIndex--; if (currentVideoIndex == -1) currentVideoIndex = videoList.length - 1; loadVideo(currentVideoIndex); });
    $('#videoNext').click(function () { currentVideoIndex++; if (currentVideoIndex == videoList.length) currentVideoIndex = 0; loadVideo(currentVideoIndex); });
    $('.videoClick').click(function () { window.open(videoList[currentVideoIndex].url,"wbcfvideo",""); });

    $('input.narrow').wrap($("<div class='narrowWrap'>"));

});


var currentVideoIndex = 0;

function loadVideo(index) {
    if (typeof videoList == "undefined")
        return;
    $('#videoText').text(videoList[index].title);
    
}


