$(document).ready(function()
{
    var scrollPosition = getCookie('autoScroll_scrollPosition');
    var rememberScroll = getCookie('autoScroll_rememberScroll');

    if (scrollPosition && rememberScroll)
    {
        $(window).scrollTop(scrollPosition);
        deleteCookie('autoScroll_rememberScroll');
    }

    $('.jqAutoScroll').click(function()
    {
        setCookie('autoScroll_rememberScroll', true);
        return true;
    });
});

$(window).scroll(function()
{
    document.cookie = "autoScroll_scrollPosition=" + $(this).scrollTop();
});

function getCookie(name)
{
    name = escape($.trim(name));

    var cookies = document.cookie.split(';');

    for (var i = 0; i < cookies.length; i++)
    {
        var cookieCrumbs = cookies[i].split('=');
        var cookieName = $.trim(cookieCrumbs[0]);
        var cookieValue = cookieCrumbs[1];

        if (cookieName == name && cookieValue != null)
        {
            return unescape(cookieValue);
        }
    }

    return false;
}

function setCookie(name, value)
{
    document.cookie = escape($.trim(name)) + '=' + escape(value) + ';path=/';
}

function deleteCookie(name)
{
    document.cookie = escape($.trim(name)) + '=;expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
}



/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);

jQuery.autocomplete = function(input, options)
{
    // Create a link to self
    var me = this;

    // Create jQuery object for input element
    var $input = $(input).attr("autocomplete", "off");

    // Apply inputClass if necessary
    if (options.inputClass) $input.addClass(options.inputClass);

    // Create results
    var results = document.createElement("div");
    // Create jQuery object for results
    var $results = $(results);
    $results.hide().addClass(options.resultsClass).css("position", "absolute");
    if (options.width > 0) $results.css("width", options.width);

    // Add to body element
    $("body").append(results);

    input.autocompleter = me;

    var timeout = null;
    var prev = "";
    var active = -1;
    var cache = {};
    var keyb = false;
    var hasFocus = false;
    var lastKeyPressCode = null;

    // flush cache
    function flushCache()
    {
        cache = {};
        cache.data = {};
        cache.length = 0;
    };

    // flush cache
    flushCache();

    // if there is a data array supplied
    if (options.data != null)
    {
        var sFirstChar = "", stMatchSets = {}, row = [];

        // no url was specified, we need to adjust the cache length to make sure it fits the local data store
        if (typeof options.url != "string") options.cacheLength = 1;

        // loop through the array and create a lookup structure
        for (var i = 0; i < options.data.length; i++)
        {
            // if row is a string, make an array otherwise just reference the array
            row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);

            // if the length is zero, don't add to list
            if (row[0].length > 0)
            {
                // get the first character
                sFirstChar = row[0].substring(0, 1).toLowerCase();
                // if no lookup array for this character exists, look it up now
                if (!stMatchSets[sFirstChar]) stMatchSets[sFirstChar] = [];
                // if the match is a string
                stMatchSets[sFirstChar].push(row);
            }
        }

        // add the data items to the cache
        for (var k in stMatchSets)
        {
            // increase the cache size
            options.cacheLength++;
            // add to the cache
            addToCache(k, stMatchSets[k]);
        }
    }

    $input
	.keydown(function(e)
	{
	    // track last key pressed
	    lastKeyPressCode = e.keyCode;
	    switch (e.keyCode)
	    {
	        case 38: // up
	            e.preventDefault();
	            moveSelect(-1);
	            break;
	        case 40: // down
	            e.preventDefault();
	            moveSelect(1);
	            break;
	        case 9:  // tab
	        case 13: // return
	            if (selectCurrent())
	            {
	                // make sure to blur off the current field
	                $input.get(0).blur();
	                e.preventDefault();
	            }
	            break;
	        default:
	            active = -1;
	            if (timeout) clearTimeout(timeout);
	            timeout = setTimeout(function() { onChange(); }, options.delay);
	            break;
	    }
	})
	.focus(function()
	{
	    // track whether the field has focus, we shouldn't process any results if the field no longer has focus
	    hasFocus = true;
	})
	.blur(function()
	{
	    // track whether the field has focus
	    hasFocus = false;
	    hideResults();
	});

    hideResultsNow();

    function onChange()
    {
        // ignore if the following keys are pressed: [del] [shift] [capslock]
        if (lastKeyPressCode == 32 || lastKeyPressCode == 188 || lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32)) return $results.hide();

        //alert(lastKeyPressCode);

        // MODIFICATION to support commas
        var v = $input.val();
        if (v.lastIndexOf(',') > 0)
        {
            v = v.substring(v.lastIndexOf(',') + 1, v.length);
        }

        v = $.trim(v);

        if (v == prev) return;
        prev = v;
        if (v.length >= options.minChars)
        {
            $input.addClass(options.loadingClass);
            requestData(v);
        } else
        {
            $input.removeClass(options.loadingClass);
            $results.hide();
        }
    };

    function moveSelect(step)
    {

        var lis = $("li", results);
        if (!lis) return;

        active += step;

        if (active < 0)
        {
            active = 0;
        } else if (active >= lis.size())
        {
            active = lis.size() - 1;
        }

        lis.removeClass("ac_over");

        $(lis[active]).addClass("ac_over");

        // Weird behaviour in IE
        // if (lis[active] && lis[active].scrollIntoView) {
        // 	lis[active].scrollIntoView(false);
        // }

    };

    function selectCurrent()
    {
        var li = $("li.ac_over", results)[0];
        if (!li)
        {
            var $li = $("li", results);
            if (options.selectOnly)
            {
                if ($li.length == 1) li = $li[0];
            } else if (options.selectFirst)
            {
                li = $li[0];
            }
        }
        if (li)
        {
            selectItem(li);
            return true;
        } else
        {
            return false;
        }
    };

    function selectItem(li)
    {
        if (!li)
        {
            li = document.createElement("li");
            li.extra = [];
            li.selectValue = "";
        }
        var v = $.trim(li.selectValue ? li.selectValue : li.innerHTML);
        input.lastSelected = v;
        prev = v;
        $results.html("");

        // MODIFICATION to support tagging
        if ($input.val().indexOf(',') > 0)
        {
            $input.val($input.val().substring(0, $input.val().lastIndexOf(',')) + ", " + v);
        }
        else
        {
            $input.val(v);
        }
        hideResultsNow();

        $input.focus();

        if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
    };

    // selects a portion of the input string
    function createSelection(start, end)
    {
        // get a reference to the input element
        var field = $input.get(0);
        if (field.createTextRange)
        {
            var selRange = field.createTextRange();
            selRange.collapse(true);
            selRange.moveStart("character", start);
            selRange.moveEnd("character", end);
            selRange.select();
        } else if (field.setSelectionRange)
        {
            field.setSelectionRange(start, end);
        } else
        {
            if (field.selectionStart)
            {
                field.selectionStart = start;
                field.selectionEnd = end;
            }
        }
        field.focus();
    };

    // fills in the input box w/the first match (assumed to be the best match)
    function autoFill(sValue)
    {
        // if the last user key pressed was backspace, don't autofill
        if (lastKeyPressCode != 8)
        {
            // fill in the value (keep the case the user has typed)
            $input.val($input.val() + sValue.substring(prev.length));
            // select the portion of the value not typed by the user (so the next character will erase)
            createSelection(prev.length, sValue.length);
        }
    };

    function showResults()
    {
        // get the position of the input field right now (in case the DOM is shifted)
        var pos = findPos(input);
        // either use the specified width, or autocalculate based on form element
        var iWidth = (options.width > 0) ? options.width : $input.width();
        // reposition
        $results.css({
            width: parseInt(iWidth) + "px",
            top: (pos.y + input.offsetHeight) + "px",
            left: pos.x + "px"
        }).show();
    };

    function hideResults()
    {
        if (timeout) clearTimeout(timeout);
        timeout = setTimeout(hideResultsNow, 200);
    };

    function hideResultsNow()
    {
        if (timeout) clearTimeout(timeout);
        $input.removeClass(options.loadingClass);
        if ($results.is(":visible"))
        {
            $results.hide();
        }
        if (options.mustMatch)
        {
            var v = $input.val();
            if (v != input.lastSelected)
            {
                selectItem(null);
            }
        }
    };

    function receiveData(q, data)
    {
        if (data)
        {
            $input.removeClass(options.loadingClass);
            results.innerHTML = "";

            // if the field no longer has focus or if there are no matches, do not display the drop down
            if (!hasFocus || data.length == 0) return hideResultsNow();

            if ($.browser.msie)
            {
                // we put a styled iframe behind the calendar so HTML SELECT elements don't show through
                $results.append(document.createElement('iframe'));
            }
            results.appendChild(dataToDom(data));
            // autofill in the complete box w/the first match as long as the user hasn't entered in more data
            if (options.autoFill && ($input.val().toLowerCase() == q.toLowerCase())) autoFill(data[0][0]);
            showResults();
        } else
        {
            hideResultsNow();
        }
    };

    function parseData(data)
    {
        if (!data) return null;
        var parsed = [];
        var rows = data.split(options.lineSeparator);
        for (var i = 0; i < rows.length; i++)
        {
            var row = $.trim(rows[i]);
            if (row)
            {
                parsed[parsed.length] = row.split(options.cellSeparator);
            }
        }
        return parsed;
    };

    function escapeHTML(str)
    {
        var div = document.createElement('div');
        var text = document.createTextNode(str);
        div.appendChild(text);
        return div.innerHTML;
    }

    function dataToDom(data)
    {
        var ul = document.createElement("ul");
        var num = data.length;

        // limited results to a max number
        if ((options.maxItemsToShow > 0) && (options.maxItemsToShow < num)) num = options.maxItemsToShow;

        for (var i = 0; i < num; i++)
        {
            var row = data[i];
            if (!row) continue;
            var li = document.createElement("li");
            if (options.formatItem)
            {
                li.innerHTML = escapeHTML(options.formatItem(row, i, num));
                li.selectValue = row[0];
            } else
            {
                li.innerHTML = escapeHTML(row[0]);
                li.selectValue = row[0];
            }
            var extra = null;
            if (row.length > 1)
            {
                extra = [];
                for (var j = 1; j < row.length; j++)
                {
                    extra[extra.length] = row[j];
                }
            }
            li.extra = extra;
            ul.appendChild(li);
            $(li).hover(
				function() { $("li", ul).removeClass("ac_over"); $(this).addClass("ac_over"); active = $("li", ul).indexOf($(this).get(0)); },
				function() { $(this).removeClass("ac_over"); }
			).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
        }
        return ul;
    };

    function requestData(q)
    {
        if (!options.matchCase) q = q.toLowerCase();
        var data = options.cacheLength ? loadFromCache(q) : null;
        // recieve the cached data
        if (data)
        {
            receiveData(q, data);
            // if an AJAX url has been supplied, try loading the data now
        } else if ((typeof options.url == "string") && (options.url.length > 0))
        {
            $.get(makeUrl(q), function(data)
            {
                data = parseData(data);
                addToCache(q, data);
                receiveData(q, data);
            });
            // if there's been no data found, remove the loading class
        } else
        {
            $input.removeClass(options.loadingClass);
        }
    };

    function makeUrl(q)
    {
        var url = '';
        if (options.url.indexOf('?') > 0)
        {
            url = options.url + "&q=" + encodeURI(q);
        }
        else
        {
            url = options.url + "?q=" + encodeURI(q);
        }

        for (var i in options.extraParams)
        {
            url += "&" + i + "=" + encodeURI(options.extraParams[i]);
        }
        return url;
    };

    function loadFromCache(q)
    {
        if (!q) return null;
        if (cache.data[q]) return cache.data[q];
        if (options.matchSubset)
        {
            for (var i = q.length - 1; i >= options.minChars; i--)
            {
                var qs = q.substr(0, i);
                var c = cache.data[qs];
                if (c)
                {
                    var csub = [];
                    for (var j = 0; j < c.length; j++)
                    {
                        var x = c[j];
                        var x0 = x[0];
                        if (matchSubset(x0, q))
                        {
                            csub[csub.length] = x;
                        }
                    }
                    return csub;
                }
            }
        }
        return null;
    };

    function matchSubset(s, sub)
    {
        if (!options.matchCase) s = s.toLowerCase();
        var i = s.indexOf(sub);
        if (i == -1) return false;
        return i == 0 || options.matchContains;
    };

    this.flushCache = function()
    {
        flushCache();
    };

    this.setExtraParams = function(p)
    {
        options.extraParams = p;
    };

    this.findValue = function()
    {
        var q = $input.val();

        if (!options.matchCase) q = q.toLowerCase();
        var data = options.cacheLength ? loadFromCache(q) : null;
        if (data)
        {
            findValueCallback(q, data);
        } else if ((typeof options.url == "string") && (options.url.length > 0))
        {
            $.get(makeUrl(q), function(data)
            {
                data = parseData(data)
                addToCache(q, data);
                findValueCallback(q, data);
            });
        } else
        {
            // no matches
            findValueCallback(q, null);
        }
    }

    function findValueCallback(q, data)
    {
        if (data) $input.removeClass(options.loadingClass);

        var num = (data) ? data.length : 0;
        var li = null;

        for (var i = 0; i < num; i++)
        {
            var row = data[i];

            if (row[0].toLowerCase() == q.toLowerCase())
            {
                li = document.createElement("li");
                if (options.formatItem)
                {
                    li.innerHTML = options.formatItem(row, i, num);
                    li.selectValue = row[0];
                } else
                {
                    li.innerHTML = row[0];
                    li.selectValue = row[0];
                }
                var extra = null;
                if (row.length > 1)
                {
                    extra = [];
                    for (var j = 1; j < row.length; j++)
                    {
                        extra[extra.length] = row[j];
                    }
                }
                li.extra = extra;
            }
        }

        if (options.onFindValue) setTimeout(function() { options.onFindValue(li) }, 1);
    }

    function addToCache(q, data)
    {
        if (!data || !q || !options.cacheLength) return;
        if (!cache.length || cache.length > options.cacheLength)
        {
            flushCache();
            cache.length++;
        } else if (!cache[q])
        {
            cache.length++;
        }
        cache.data[q] = data;
    };

    function findPos(obj)
    {
        var curleft = obj.offsetLeft || 0;
        var curtop = obj.offsetTop || 0;
        while (obj = obj.offsetParent)
        {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
        return { x: curleft, y: curtop };
    }
}

jQuery.fn.autocomplete = function(url, options, data)
{
    // Make sure options exists
    options = options || {};
    // Set url as option
    options.url = url;
    // set some bulk local data
    options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;

    // Set default values for required options
    options.inputClass = options.inputClass || "ac_input";
    options.resultsClass = options.resultsClass || "ac_results";
    options.lineSeparator = options.lineSeparator || "\n";
    options.cellSeparator = options.cellSeparator || "|";
    options.minChars = options.minChars || 1;
    options.delay = options.delay || 400;
    options.matchCase = options.matchCase || 0;
    options.matchSubset = options.matchSubset || 1;
    options.matchContains = options.matchContains || 0;
    options.cacheLength = options.cacheLength || 1;
    options.mustMatch = options.mustMatch || 0;
    options.extraParams = options.extraParams || {};
    options.loadingClass = options.loadingClass || "ac_loading";
    options.selectFirst = options.selectFirst || false;
    options.selectOnly = options.selectOnly || false;
    options.maxItemsToShow = options.maxItemsToShow || -1;
    options.autoFill = options.autoFill || false;
    options.width = parseInt(options.width, 10) || 0;

    this.each(function()
    {
        var input = this;
        new jQuery.autocomplete(input, options);
    });

    // Don't break the chain
    return this;
}

jQuery.fn.autocompleteArray = function(data, options)
{
    return this.autocomplete(null, options, data);
}

jQuery.fn.indexOf = function(e)
{
    for (var i = 0; i < this.length; i++)
    {
        if (this[i] == e) return i;
    }
    return -1;
};

$(function() {
    if ($('.accordionLinks').length) {
        AccordionWidgetInitContent();
    }
})

function AccordionWidgetInitContent() {
    $(".accordionLinks ul.linksGroupList h3").wrapInner("<a href='#'></a>");
    $(".accordionLinks ul.linksGroupList h3").addClass("jsLink");
    $(".accordionLinks ul.linksGroupList div.wrapper").hide();
    showGroupLinks($(".accordionLinks ul.linksGroupList  div.wrapper:first"));
    $(".accordionLinks ul.linksGroupList h3").click(function() {
        var status = $(this).children("img").attr("class");
        if (status == "showArrow") {
            collapseGroupLinks($(this));
            return false;
        } else {
            showGroupLinks($(this));
            return false;
        }
    });
}

function collapseGroupLinks(current) {
    $(".accordionLinks .selected div.wrapper").slideUp();
    current.parent().removeClass("selected");
}

function showGroupLinks(current) {
    $(".accordionLinks .selected div.wrapper").slideUp();
    $(".accordionLinks .selected").removeClass("selected");
    current.parent().addClass("selected");
    current.parent().children("div.wrapper").slideDown();
}

/*  ContentFlow, version 1.0.2 
*  (c) 2007 - 2010 Sebastian Kutsch
*  <http://www.jacksasylum.eu/ContentFlow/>
*
*  ContentFlow is distributed under the terms of the MIT license.
*  (see http://www.jacksasylum.eu/ContentFlow/LICENSE)
*
*--------------------------------------------------------------------------*/
/* 
* ============================================================
* Global configutaion and initilization object
* ============================================================
*/
var ContentFlowGlobal = {
    Flows: new Array,
    AddOns: {},
    scriptName: 'FrontEnd.js', //'contentflow.js'
    scriptElement: null,
    Browser: new (function() {
        this.Opera = window.opera ? true : false;
        this.IE = document.all && !this.Opera ? true : false;
        this.IE6 = this.IE && typeof (window.XMLHttpRequest) == "undefined" ? true : false;
        this.IE8 = this.IE && typeof (document.querySelectorAll) != "undefined" ? true : false;
        this.IE7 = this.IE && !this.IE6 && !this.IE8 ? true : false;
        this.WebKit = /WebKit/i.test(navigator.userAgent) ? true : false,
        this.iPhone = /iPhone|iPod/i.test(navigator.userAgent) ? true : false;
        this.Chrome = /Chrome/i.test(navigator.userAgent) ? true : false;
        this.Safari = /Safari/i.test(navigator.userAgent) && !this.Chrome ? true : false;
        this.Konqueror = navigator.vendor == "KDE" ? true : false;
        this.Konqueror4 = this.Konqueror && /native code/.test(document.getElementsByClassName) ? true : false;
        this.Gecko = !this.WebKit && navigator.product == "Gecko" ? true : false;
        this.Gecko19 = this.Gecko && Array.reduce ? true : false;
    })(),

    getAddOnConf: function(name) {
        if (this.AddOns[name])
            return this.AddOns[name].conf;
        else
            return {};
    },

    setAddOnConf: function(name, conf) {
        this.AddOns[name].setConfig(conf);
    },

    getScriptElement: function(scriptName) {
        var regex = new RegExp(scriptName);
        var scripts = document.getElementsByTagName('script');
        for (var i = 0; i < scripts.length; i++) {
            if (scripts[i].src && regex.test(scripts[i].src))
                return scripts[i];
        }
        return '';
    },

    getScriptPath: function(scriptElement, scriptName) {
        var regex = new RegExp(scriptName + ".*");
        return scriptElement.src.replace(regex, '');
    },

    addScript: function(path) {
        if (this.Browser.IE || this.Browser.WebKit || this.Browser.Konqueror) {
            document.write('<script type="text/javascript" src="' + path + '"><\/script>');
        }
        else {
            var script = document.createElement('script');
            script.src = path;
            script.setAttribute('type', 'text/javascript');
            document.getElementsByTagName('head')[0].appendChild(script);
        }
    },

    addScripts: function(basePath, filenames) {
        for (var i = 0; i < filename.length; i++)
            this.addScript(basepath + filenames[i]);
    },

    addStylesheet: function(path) {
        if (this.Browser.Gecko19) {
            var link = document.createElement('link');
            link.setAttribute('rel', 'stylesheet');
            link.setAttribute('href', path);
            link.setAttribute('type', 'text/css');
            link.setAttribute('media', 'screen');
            document.getElementsByTagName('head')[0].appendChild(link);
        }
        else {
            document.write('<link rel="stylesheet" href="' + path + '" type="text/css" media="screen" />');
        }

    },

    addStylesheets: function(basePath, filenames) {
        for (var i = 0; i < filename.length; i++)
            this.addStylesheet(basepath + filenames[i]);
    },

    initPath: function() {
        /* get / set basic values */
        this.scriptElement = this.getScriptElement(this.scriptName);
        if (!this.scriptElement) {
            this.scriptName = 'contentflow_src.js';
            this.scriptElement = this.getScriptElement(this.scriptName);
        }

        this.BaseDir = this.getScriptPath(this.scriptElement, this.scriptName);
        if (!this.AddOnBaseDir) this.AddOnBaseDir = this.BaseDir;
        if (!this.CSSBaseDir) this.CSSBaseDir = this.BaseDir;
    },

    init: function() {
    /* add default stylesheets */
        // TODO: Removed the next 2 lines... don't appear to be needed: PLEASE CHECK
        //this.addStylesheet(this.CSSBaseDir + 'contentflow.css'); 
        //this.addStylesheet(this.CSSBaseDir + 'mycontentflow.css');    // FF2: without adding a css-file FF2 hangs on a reload.
        
        //      I don't have the slidest idea why
        //      Could be timing problem
        this.loadAddOns = new Array();
        /* add AddOns scripts */
        if (this.scriptElement.getAttribute('load')) {
            var AddOns = this.loadAddOns = this.scriptElement.getAttribute('load').replace(/\ +/g, ' ').split(' ');
            for (var i = 0; i < AddOns.length; i++) {
                if (AddOns[i] == '') continue;
                //if (AddOns[i] == 'myStyle') {
                //this.addStylesheet(this.BaseDir+'mycontentflow.css');
                //continue;
                //}
                this.addScript(this.AddOnBaseDir + 'ContentFlowAddOn_' + AddOns[i] + '.js');
            }
        }

        /* ========== ContentFlow auto initialization on document load ==========
        * thanks to Dean Edwards
        * http://dean.edwards.name/weblog/2005/02/order-of-events/
        */
        var CFG = this;

        /* for Mozilla, Opera 9, Safari */
        if (document.addEventListener) {
            /* for Safari */
            if (this.Browser.WebKit) {
                var _timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState)) {
                        clearInterval(_timer);
                        CFG.onloadInit(); // call the onload handler
                    }
                }, 10);
            }
            else {
                document.addEventListener("DOMContentLoaded", CFG.onloadInit, false);
            }
        }
        else if (this.Browser.IE) {
            document.write("<script id=__ie_cf_onload defer src=javascript:void(0)><\/script>");
            var script = document.getElementById("__ie_cf_onload");
            script.onreadystatechange = function() {
                if (this.readyState == "complete") {
                    CFG.onloadInit(); // call the onload handler
                }
            };
        }

        /* for all other browsers */
        window.addEvent('load', CFG.onloadInit, false);

        /* ================================================================== */

    },

    onloadInit: function() {
        // quit if this function has already been called
        if (arguments.callee.done) return;
        for (var i = 0; i < ContentFlowGlobal.loadAddOns.length; i++) {
            var a = ContentFlowGlobal.loadAddOns[i];
            if (!ContentFlowGlobal.AddOns[a]) {
                var CFG = ContentFlowGlobal;
                window.setTimeout(CFG.onloadInit, 10);
                return;
            }
        }
        // flag this function so we don't do the same thing twice
        arguments.callee.done = true;

        /* fix for mootools */
        if (window.Element && Element.implement && document.all && !window.opera) {
            for (var prop in window.CFElement.prototype) {
                if (!window.Element.prototype[prop]) {
                    var implement = {};
                    implement[prop] = window.CFElement.prototype[prop];
                    Element.implement(implement);
                }
            }
        }

        /* init all manualy created flows */
        for (var i = 0; i < ContentFlowGlobal.Flows.length; i++) {
            ContentFlowGlobal.Flows[i].init();
        }

        /* init the rest */
        var divs = document.getElementsByTagName('div');
        DIVS: for (var i = 0; i < divs.length; i++) {
            if (divs[i].className.match(/\bContentFlow\b/)) {
                for (var j = 0; j < ContentFlowGlobal.Flows.length; j++) {
                    if (divs[i] == ContentFlowGlobal.Flows[j].Container) continue DIVS;
                }
                var CF = new ContentFlow(divs[i], {}, false);
                CF.init();
            }
        }
    }

};

ContentFlowGlobal.initPath();


/*
* ============================================================
* ContentFlowAddOn
* ============================================================
*/
var ContentFlowAddOn = function(name, methods, register) {
    if (typeof register == "undefined" || register != false)
        ContentFlowGlobal.AddOns[name] = this;

    this.name = name;
    if (!methods) methods = {};
    this.methods = methods;
    this.conf = {};
    if (this.methods.conf) {
        this.setConfig(this.methods.conf);
        delete this.methods.conf;
    }


    this.scriptpath = ContentFlowGlobal.AddOnBaseDir;
    if (methods.init) {
        var init = methods.init.bind(this);
        init(this);
    }
};

ContentFlowAddOn.prototype = {
    Browser: ContentFlowGlobal.Browser,

    addScript: ContentFlowGlobal.addScript,
    addScripts: ContentFlowGlobal.addScripts,

    addStylesheet: function(path) {
        if (!path)
            path = this.scriptpath + 'ContentFlowAddOn_' + this.name + '.css';
        ContentFlowGlobal.addStylesheet(path);
    },
    addStylesheets: ContentFlowGlobal.addStylesheets,

    setConfig: function(conf) {
        for (var c in conf) {
            this.conf[c] = conf[c];
        }
    },

    _init: function(flow) {
        if (this.methods.ContentFlowConf) {
            flow.setConfig(this.methods.ContentFlowConf);
        }
    }


};



/* 
* ============================================================
* ContentFlowGUIElement
* ============================================================
*/

var ContentFlowGUIElement = function(CFobj, element) {
    element.setDimensions = function() {
        this.dimensions = this.getDimensions();
        this.center = { x: this.dimensions.width / 2, y: this.dimensions.height / 2 };
        this.position = this.findPos();
    };
    element.addObserver = function(eventName, method) {
        var m = this.eventMethod = method.bind(CFobj);
        this.observedEvent = eventName;
        this.addEvent(eventName, m, false);
    };

    element.makeDraggable = function(onDrag, beforeDrag, afterDrag) {

        this.stopDrag = function(event) {
            if (!event) var event = window.event;
            if (this.Browser.iPhone) {
                window.removeEvent('touchemove', onDrag, false);
                if (!this.ontochmove) {
                    var t = event.target;
                    if (t.firstChild) t = t.firstChild;
                    var e = document.createEvent('MouseEvents');
                    e.initEvent('click', true, true);
                    t.dispatchEvent(e);
                }
            }
            else {
                window.removeEvent('mousemove', onDrag, false);
            }
            afterDrag(event);
        } .bind(this);

        this.initDrag = function(event) {
            if (!event) var event = window.event;
            var e = event;
            if (event.touches) e = event.touches[0];

            this.mouseX = e.clientX;
            this.mouseY = e.clientY;

            beforeDrag(event);

        } .bind(this);

        this.startDrag = function(event) {
            if (!event) var event = window.event;

            var stopDrag = this.stopDrag;

            if (this.Browser.iPhone) {
                var s = this;
                s.ontouchmove = false
                window.addEvent('touchmove', function(e) {
                    s.ontouchmove = true;
                    onDrag(e);
                }, false);
                event.preventDefault();
                window.addEvent('touchend', stopDrag, false);
            }
            else {
                window.addEvent('mousemove', onDrag, false);
                window.addEvent('mouseup', stopDrag, false);
            }
            if (event.preventDefault) { event.preventDefault() }

        } .bind(this);

        var startDrag = this.startDrag;
        if (this.Browser.iPhone) {
            this.addEventListener('touchstart', startDrag, false);
        }
        else {
            this.addEvent('mousedown', startDrag, false);
        }

    };

    element.Browser = ContentFlowGlobal.Browser;
    $CF(element).setDimensions();
    return element;
};


/* 
* ============================================================
* ContentFlowItem
* ============================================================
*/
var ContentFlowItem = function(CFobj, element, index) {
    this.CFobj = CFobj;
    this._activeElement = CFobj.conf.activeElement;
    this.pre = null;
    this.next = null;
    /*
    * ==================== item click events ====================
    * handles the click event on an active and none active item
    */


    this.clickItem = function(event) {
        return false; //---------------------------------------------------------------------------------------------------------------------->DMc: I'VE ADDED THIS!!!!!!!!
        if (!event) var event = window.event;
        var el = event.target ? event.target : event.srcElement;
        var index = el.itemIndex ? el.itemIndex : el.parentNode.itemIndex;
        var item = this.items[index];
        
        if (this._activeItem == item) {
            this.conf.onclickActiveItem(item);
        }
        else {
            if (this.conf.onclickInactiveItem(item) != false) this.moveToIndex(index);
        }
    } .bind(CFobj),

    this.setIndex = function(index) {
        this.index = index;
        this.element.itemIndex = index;
    };
    this.getIndex = function() {
        return this.index;
    };


    /* generate deault HTML structure if item is an image */
    if ($CF(element).nodeName == "IMG") {
        var el = document.createElement('div');
        el.className = "item";

        var cont = element.parentNode.replaceChild(el, element);
        cont.className = "content";
        el.appendChild(cont);

        if (element.title) {
            var cap = document.createElement('div');
            cap.className = "caption";
            cap.innerHTML = element.title;
            el.appendChild(cap);
        }
        element = el;
    }

    /* create item object */
    this.element = $CF(element);
    this.item = element;
    if (typeof index != "undefined") this.setIndex(index);
    this.content = this.element.getChildrenByClassName('content')[0];
    this.caption = this.element.getChildrenByClassName('caption')[0];
    this.label = this.element.getChildrenByClassName('label')[0];

    /* if content is image set properties */
    if (this.content.nodeName == "IMG") {
        CFobj._imagesToLoad++;

        var foobar = function() {
            CFobj._imagesToLoad--;
            this.image = this.content;
            this.setImageFormat(this.image);
            if (CFobj.conf.reflectionHeight > 0) {
                this.addReflection();
            }
            this.initClick();
            CFobj._addItemCueProcess(true);
        } .bind(this);

        if (this.content.complete && this.content.width > 0)
            window.setTimeout(foobar, 100);
        else if (this.Browser.IE && !this.content.onload) {
            var self = this;
            var t = window.setInterval(function() {
                if (self.content.complete && self.content.width > 0) {
                    window.clearInterval(t);
                    foobar();
                }
            }, 10);
        }
        else
            this.content.onload = window.setTimeout(foobar, 100);
    }
    else {
        this.initClick();
        CFobj._addItemCueProcess(true);
    }

};

ContentFlowItem.prototype = {

    Browser: ContentFlowGlobal.Browser,

    makeActive: function() {
        this.element.addClassName('active');
        this.CFobj.conf.onMakeActive(this);
    },

    makeInactive: function() {
        this.element.removeClassName('active');
        this.CFobj.conf.onMakeInactive(this);
    },

    initClick: function() {
        var cItem = this.clickItem;
        this[this._activeElement].addEvent('click', cItem, false);
    },

    setImageFormat: function(img) {
        if (this.Browser.IE6 || this.Browser.IE7) img.style.width = "auto";
        img.origProportion = img.width / img.height;
        img.setAttribute('origProportion', img.width / img.height);
        if (this.Browser.IE6 || this.Browser.IE7) img.style.width = "";
        //img.origWidth = img.width;
        //img.origHeight = img.height;
        if (img.origProportion <= 1)
            img.addClassName('portray');
        else
            img.addClassName('landscape');
    },

    /*
    * add reflection to item
    */
    addReflection: function() {
        var CFobj = this.CFobj;
        var reflection;
        var image = this.content;


        if (this.Browser.IE) {
            var filterString = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)';
            if (CFobj._reflectionColorRGB) {
                // transparent gradient
                if (CFobj.conf.reflectionColor == "transparent") {
                    var RefImg = reflection = this.reflection = document.createElement('img');
                    reflection.src = image.src;
                }
                // color gradient
                else {
                    reflection = this.reflection = document.createElement('div');
                    var RefImg = document.createElement('img');
                    RefImg.src = image.src;
                    reflection.width = RefImg.width;
                    reflection.height = RefImg.height;
                    RefImg.style.width = '100%';
                    RefImg.style.height = '100%';
                    var color = CFobj._reflectionColorRGB;
                    reflection.style.backgroundColor = '#' + color.hR + color.hG + color.hB;
                    reflection.appendChild(RefImg);
                }
                filterString += ' progid:DXImageTransform.Microsoft.Alpha(opacity=0, finishOpacity=50, style=1, finishX=0, startY=' + CFobj.conf.reflectionHeight * 100 + ' finishY=0)';
            } else {
                var RefImg = reflection = this.reflection = document.createElement('img');
                reflection.src = image.src;
            }
            // crop image (streches and crops (clip on default dimensions), original proportions will be restored through CSS)
            filterString += ' progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=' + 1 / CFobj.conf.reflectionHeight + ')';

            if (ContentFlowGlobal.Browser.IE6) {
                if (image.src.match(/\.png$/)) {
                    image.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image.src + "', sizingMethod=scale )";
                    image.filterString = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image.src + "', sizingMethod=scale )";
                    filterString += " progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image.src + "', sizingMethod=scale )";
                    image.origSrc = image.src;
                    image.src = 'img/blank.gif';
                    RefImg.src = "img/blank.gif";
                }
            }

            reflection.filterString = filterString;
            RefImg.style.filter = filterString;

        } else {
            if (CFobj._reflectionWithinImage)
                var canvas = this.canvas = $CF(document.createElement('canvas'));
            else
                var canvas = reflection = this.reflection = document.createElement('canvas');

            if (canvas.getContext) {
                if (CFobj._reflectionWithinImage) {
                    for (var i = 0; i < image.attributes.length; i++) {
                        canvas.setAttributeNode(image.attributes[i].cloneNode(true));
                    }
                }

                var context = canvas.getContext("2d");

                /* calc image size */
                var max = CFobj.maxHeight;
                var size = CFobj._scaleImageSize(this, { width: max, height: max }, max)
                var width = size.width;
                var height = size.height;

                // overwrite default height and width
                if (CFobj._reflectionWithinImage) {
                    canvas.width = width;
                    canvas.height = height;
                    this.setImageFormat(canvas);
                    canvas.height = height * (1 + CFobj.conf.reflectionHeight + CFobj.conf.reflectionGap);

                }
                else {
                    canvas.width = width;
                    canvas.height = height * CFobj.conf.reflectionHeight;
                }

                context.save(); /* save default context */

                /* draw image into canvas */
                if (CFobj._reflectionWithinImage) {
                    context.drawImage(image, 0, 0, width, height);
                }

                /* mirror image by transformation of context and image drawing */
                if (CFobj._reflectionWithinImage) {
                    var contextHeight = height * (1 + CFobj.conf.reflectionGap / 2) * 2;
                }
                else {
                    var contextHeight = image.height;
                }
                // -1 for FF 1.5
                contextHeight -= 1;

                context.translate(0, contextHeight);
                context.scale(1, -1);
                /* draw reflection image into canvas */
                context.drawImage(image, 0, 0, width, height);

                /* restore default context for simpler further canvas manupulation */
                context.restore();

                if (CFobj._reflectionColorRGB) {
                    var gradient = context.createLinearGradient(0, 0, 0, canvas.height);

                    var alpha = [0, 0.5, 1];
                    if (CFobj._reflectionColor == "transparent") {
                        context.globalCompositeOperation = "destination-in";
                        alpha = [1, 0.5, 0];
                    }

                    var red = CFobj._reflectionColorRGB.iR;
                    var green = CFobj._reflectionColorRGB.iG;
                    var blue = CFobj._reflectionColorRGB.iB;
                    if (CFobj._reflectionWithinImage) {
                        gradient.addColorStop(0, 'rgba(' + red + ',' + green + ',' + blue + ',' + alpha[0] + ')');
                        gradient.addColorStop(height / canvas.height, 'rgba(' + red + ',' + green + ',' + blue + ',' + alpha[0] + ')');
                        gradient.addColorStop(height / canvas.height, 'rgba(' + red + ',' + green + ',' + blue + ',' + alpha[1] + ')');
                    }
                    else {
                        gradient.addColorStop(0, 'rgba(' + red + ',' + green + ',' + blue + ',' + alpha[1] + ')');
                    }
                    gradient.addColorStop(1, 'rgba(' + red + ',' + green + ',' + blue + ',' + alpha[2] + ')');

                    context.fillStyle = gradient;
                    context.fillRect(0, 0, canvas.width, canvas.height);

                }

                if (CFobj._reflectionWithinImage) {
                    image.parentNode.replaceChild(canvas, image);
                    this.content = canvas;
                    this.origContent = canvas;
                    delete this.image; // = true;

                }

            } else {
                CFobj._reflectionWithinImage = false;
                delete this.reflection;
            }

        }
        if (reflection) {
            reflection.className = "reflection";
            this.element.appendChild(reflection);

            /* be shure that caption is last child */
            if (this.caption) this.element.appendChild(this.caption);
        }

    }


};

/*
* ============================================================
* ContentFlow
* ============================================================
*/
var ContentFlow = function(container, config) {

    if (container) {
        ContentFlowGlobal.Flows.push(this);
        this.Container = container;
        this._userConf = config ? config : {};
        this.conf = {};
        this._loadedAddOns = new Array();
    } else {
        throw ('ContentFlow ERROR: No flow container node or id given');
    }

};

ContentFlow.prototype = {
    _imagesToLoad: 0,
    _activeItem: 0,
    _currentPosition: 0,
    _targetPosition: 0,
    _stepLock: false,
    _millisecondsPerStep: 40,
    _reflectionWithinImage: true,
    Browser: ContentFlowGlobal.Browser,

    _defaultConf: {
        /* pre conf */
        useAddOns: 'all', // all, none, [AddOn1, ... , AddOnN]

        biggestItemPos: 0,
        loadingTimeout: 30000, //milliseconds
        activeElement: 'content', // item or content

        maxItemHeight: 0,
        scaleFactor: 1,
        scaleFactorLandscape: 1.33,
        scaleFactorPortrait: 1.0,
        fixItemSize: false,
        relativeItemPosition: "top center", // align top/above, bottom/below, left, right, center of position coordinate

        circularFlow: true,
        verticalFlow: false,
        visibleItems: -1,
        endOpacity: 1,
        startItem: "start",
        scrollInFrom: "pre",

        flowSpeedFactor: 0.4,
        flowDragFriction: 0.4,
        scrollWheelSpeed: 0.4,
        keys: {
            13: function() { this.conf.onclickActiveItem(this._activeItem) },
            37: function() { this.moveTo('pre') },
            38: function() { this.moveTo('visibleNext') },
            39: function() { this.moveTo('next') },
            40: function() { this.moveTo('visiblePre') }
        },

        reflectionColor: "transparent", // none, transparent or hex RGB CSS style #RRGGBB
        reflectionHeight: 0.5,          // float (relative to original image height)
        reflectionGap: 0.0,

        /* ==================== actions ==================== */

        onInit: function() { },

        onclickInactiveItem: function(item) { },

        onclickActiveItem: function(item) {
            var url, target;

            if (url = item.content.getAttribute('href')) {
                target = item.content.getAttribute('target');
            }
            else if (url = item.element.getAttribute('href')) {
                target = item.element.getAttribute('target');
            }
            else if (url = item.content.getAttribute('src')) {
                target = item.content.getAttribute('target');
            }

            if (url) {
                if (target)
                    window.open(url, target).focus();
                else
                    window.location.href = url;
            }
        },

        onMakeInactive: function(item) { },

        onMakeActive: function(item) { },

        onReachTarget: function(item) { },

        onMoveTo: function(item) { },

        //onDrawItem: function(item, relativePosition, relativePositionNormed, side, size) {},
        onDrawItem: function(item) { },
        onclickPreButton: function(event) {
            this.moveToIndex('pre');
            return Event.stop(event);
        },

        onclickNextButton: function(event) {
            this.moveToIndex('next');
            return Event.stop(event);
        },

        /* ==================== calculations ==================== */

        calcStepWidth: function(diff) {
            var vI = this.conf.visibleItems;
            var items = this.items.length;
            items = items == 0 ? 1 : items;
            if (Math.abs(diff) > vI) {
                if (diff > 0) {
                    var stepwidth = diff - vI;
                } else {
                    var stepwidth = diff + vI;
                }
            } else if (vI >= this.items.length) {
                var stepwidth = diff / items;
            } else {
                var stepwidth = diff * (vI / items);
                //var stepwidth = diff/absDiff * Math.max(diff * diff,Math.min(absDiff,0.3)) * ( vI / this.items.length);
                //var stepwidth = this.flowSpeedFactor * diff / this.visibleItems;
                //var stepwidth = this.flowSpeedFactor * diff * ( this.visibleItems / this.items.length)
                //var stepwidth = this.flowSpeedFactor * diff / this._millisecondsPerStep * 2; // const. speed
            }
            return stepwidth;
        },

        calcSize: function(item) {
            var rP = item.relativePosition;
            //var rPN = relativePositionNormed;
            //var vI = this.conf.visibleItems; 

            var h = 1 / (Math.abs(rP) + 1);
            var w = h;
            return { width: w, height: h };
        },

        calcCoordinates: function(item) {
            var rP = item.relativePosition;
            //var rPN = item.relativePositionNormed;
            var vI = this.conf.visibleItems;

            var f = 1 - 1 / Math.exp(Math.abs(rP) * 0.75);
            var x = item.side * vI / (vI + 1) * f;
            var y = 1;

            return { x: x, y: y };
        },

        /*
        calcRelativeItemPosition: function (item) {
        var x = 0;
        var y = -1;
        return {x: x, y: y};
        },
        */

        calcZIndex: function(item) {
            return -Math.abs(item.relativePositionNormed);
        },

        calcFontSize: function(item) {
            return item.size.height;
        },

        calcOpacity: function(item) {
            return Math.max(1 - ((1 - this.conf.endOpacity) * Math.sqrt(Math.abs(item.relativePositionNormed))), this.conf.endOpacity);
        }
    },

    /* ---------- end of defaultConf ---------- */


    /*
    * ==================== index helper methods ====================
    */

    /*
    * checks if index is within the index range of the this.items array
    * returns a value that is within this range
    */
    _checkIndex: function(index) {
        index = Math.max(index, 0);
        index = Math.min(index, this.itemsLastIndex);
        return index;
    },

    /*
    * sets the object property itemsLastIndex
    */
    _setLastIndex: function() {
        this.itemsLastIndex = this.items.length - 1;
    },

    /*
    */
    _getItemByIndex: function(index) {
        return this.items[this._checkIndex(index)];
    },

    _getItemByPosition: function(position) {
        return this._getItemByIndex(this._getIndexByPosition(position));
    },

    /* returns the position of an item-index relative to current position */
    _getPositionByIndex: function(index) {
        if (!this.conf.circularFlow) return this._checkIndex(index);
        var cI = this._getIndexByPosition(this._currentPosition);
        var dI = index - cI;
        if (Math.abs(dI) > dI + this.items.length)
            dI += this.items.length;
        else if (Math.abs(dI) > (Math.abs(dI - this.items.length)))
            dI -= this.items.length;

        return this._currentPosition + dI;

    },

    /* returns the index an item at position p would have */
    _getIndexByPosition: function(position) {
        if (position < 0) var mod = 0;
        else var mod = 1;

        var I = (Math.round(position) + mod) % this.items.length;
        if (I > 0) I -= mod;
        else if (I < 0) I += this.items.length - mod;
        else if (position < 0) I = 0;
        else I = this.items.length - 1;

        return I;
    },

    _getIndexByKeyWord: function(keyword, relativeTo, check) {
        if (relativeTo)
            var index = relativeTo;
        else if (this._activeItem)
            var index = this._activeItem.index;
        else
            var index = 0;

        if (isNaN(keyword)) {
            switch (keyword) {
                case "first":
                case "start":
                    index = 0;
                    break;
                case "last":
                case "end":
                    index = this.itemsLastIndex;
                    break;
                case "middle":
                case "center":
                    index = Math.round(this.itemsLastIndex / 2);
                    break;
                case "right":
                case "next":
                    index += 1;
                    break;
                case "left":
                case "pre":
                case "previous":
                    index -= 1;
                    break;
                case 'visible':
                case 'visiblePre':
                case 'visibleLeft':
                    index -= this.conf.visibleItems;
                    break;
                case 'visibleNext':
                case 'visibleRight':
                    index += this.conf.visibleItems;
                    break;
                default:
                    index = index;
            }
        }
        else {
            index = keyword;
        }
        if (check != false)
            index = this._checkIndex(index);

        return index;
    },


    _setCaptionLabel: function(index) {
        if (this.Position && !this.Slider.locked)
            this.Position.setLabel(index);
        this._setGlobalCaption();
    },


    /*
    * ==================== public methods ==================== 
    */
    getAddOnConf: function(name) {
        return ContentFlowGlobal.getAddOnConf(name);
    },

    setAddOnConf: function(name, conf) {
        ContentFlowGlobal.setAddOnConf(name, conf);
    },


    /*
    * calls _init() if ContentFlow has not been initialized before
    * needed if ContentFlow is not automatically initialized on window.load
    */
    init: function() {
        if (this.isInit) return;
        this._init();
    },

    /*
    * parses configuration object and initializes configuration values
    */
    setConfig: function(config) {
        if (!config) return;
        var dC = this._defaultConf;
        for (var option in config) {
            if (dC[option] == "undefined") continue;
            switch (option) {
                case "scrollInFrom":
                case "startItem":
                    if (typeof (config[option]) == "number" || typeof (config[option]) == "string") {
                        //this["_"+option] = config[option];
                        this.conf[option] = config[option];
                    }
                    break;
                default:
                    if (typeof (dC[option] == config[option])) {
                        //this["_"+option] = config[option];
                        if (typeof config[option] == "function") {
                            this.conf[option] = config[option].bind(this);
                        }
                        else {
                            this.conf[option] = config[option];
                        }
                    }
            }
        }
        switch (this.conf.reflectionColor) {
            case this.conf.reflectionColor.search(/#[0-9a-fA-F]{6}/) >= 0 ? this.conf.reflectionColor : this.conf.reflectionColor + "x":
                this._reflectionColorRGB = {
                    hR: this.conf.reflectionColor.slice(1, 3),
                    hG: this.conf.reflectionColor.slice(3, 5),
                    hB: this.conf.reflectionColor.slice(5, 7),
                    iR: parseInt(this.conf.reflectionColor.slice(1, 3), 16),
                    iG: parseInt(this.conf.reflectionColor.slice(3, 5), 16),
                    iB: parseInt(this.conf.reflectionColor.slice(5, 7), 16)
                };
                break;
            case "none":
            case "transparent":
            default:
                this._reflectionColor = "transparent";
                this._reflectionColorRGB = {
                    hR: 0, hG: 0, hB: 0,
                    iR: 0, iG: 0, iB: 0
                };
                break;
        }
        if (this.items) {
            if (this.conf.visibleItems < 0)
                this.conf.visibleItems = Math.round(Math.sqrt(this.items.length));
            this.conf.visibleItems = Math.min(this.conf.visibleItems, this.items.length - 1);
        }

        if (this.conf.relativeItemPosition) {
            var calcRP = {
                x: {
                    left: function(size) { return -1 },
                    center: function(size) { return 0 },
                    right: function(size) { return 1 }
                },
                y: {
                    top: function(size) { return -1 },
                    center: function(size) { return 0 },
                    bottom: function(size) { return 1 }
                }
            };

            var iP = this.conf.relativeItemPosition;
            iP = iP.replace(/above/, "top").replace(/below/, "bottom");
            var x, y = null;
            x = iP.match(/left|right/);
            y = iP.match(/top|bottom/);
            c = iP.match(/center/);
            if (!x) {
                if (c) x = "center";
                else x = "center";
            }
            if (!y) {
                if (c) y = "center";
                else y = "top";
            }
            var calcX = calcRP.x[x];
            var calcY = calcRP.y[y];
            this.conf.calcRelativeItemPosition = function(item) {
                var x = calcX(item.size);
                var y = calcY(item.size);
                return { x: x, y: y };
            };
            this.conf.relativeItemPosition = null;
        }

        if (this._reflectionType && this._reflectionType != "clientside") {
            this.conf.reflectionHeight = 0;
        }

    },

    getItem: function(index) {
        return this.items[this._checkIndex(Math.round(index))];
    },

    /*
    * returns the index number of the active item
    */
    getActiveItem: function() {
        return this._activeItem;
    },

    /*
    * returns the number of items the flow contains
    */
    getNumberOfItems: function() {
        return this.items.length;
    },

    /*
    * reinitializes sizes.
    * called on window.resize
    */
    resize: function() {
        this._initSizes();
        this._initStep();
    },

    /*
    * scrolls flow to item i
    */
    moveToPosition: function(p, holdPos) {
        if (!this.conf.circularFlow) p = this._checkIndex(p);
        this._targetPosition = p;
        this.conf.onMoveTo(this._getItemByPosition(p));
        this._initStep(false, holdPos);
    },
    moveToIndex: function(index) {

        this._targetPosition = Math.round(this._getPositionByIndex(this._getIndexByKeyWord(index, this._activeItem.index, !this.conf.circularFlow)));
        this.conf.onMoveTo(this._getItemByPosition(this._targetPosition));
        this._initStep();
    },
    moveToItem: function(item) {
        var i;
        if (item.itemIndex) i = item.itemIndex;
        else i = item.index;
        this.moveToIndex(i);
    },
    moveTo: function(i) {
        if (typeof i == "object") this.moveToItem(i);
        else if (isNaN(i) || (i == Math.floor(i) && i < this.items.length)) this.moveToIndex(i);
        else this.moveToPosition(i);
    },

    /*
    * initializes item and adds it at index position
    */
    _addItemCue: [],
    _addItemCueProcess: function(deleteFirst) {
        var c = this._addItemCue;
        if (deleteFirst == true)
            c.shift();
        if (c.length > 0 && !c[0].p) {
            c[0].p = true;
            var self = this;
            var t = c.length > 5 ? 1 : 40;
            window.setTimeout(function() { self._addItem(c[0].el, c[0].i) }, t);
        }
    },
    addItem: function(el, index) {
        this._addItemCue.push({ el: el, i: index, p: false });
        if (this._addItemCue.length == 1)
            this._addItemCueProcess();
    },

    _addItem: function(el, index) {
        if (typeof index == "string") {
            switch (index) {
                case "first":
                case "start":
                    index = 0;
                    break;
                case "last":
                case "end":
                    index = isNaN(this.itemsLastIndex) ? 0 : this.itemsLastIndex;
                    index += 1;
                    break;
                default:
                    index = this._getIndexByKeyWord(index);
            }
        }

        index = Math.max(index, 0);
        index = Math.min(index, this.itemsLastIndex + 1);
        index = isNaN(index) ? 0 : index;

        this.Flow.appendChild(el);

        /* init item after insertion. that way it's part of the document and all styles are applied */
        var item = new ContentFlowItem(this, el, index);
        if (this.items.length == 0) {
            this.resize();
            if (this.conf.circularFlow) {
                item.pre = item;
                item.next = item;
            }
        }
        else {
            if (index == this.itemsLastIndex + 1) {
                item.pre = this.items[this.itemsLastIndex];
                item.next = item.pre.next;
            }
            else {
                item.next = this.items[index];
                item.pre = item.next.pre;
            }
            if (item.pre) item.pre.next = item;
            if (item.next) item.next.pre = item;
        }
        this.items.splice(index, 0, item);

        /* adjust item indices */
        for (var i = index; i < this.items.length; i++) {
            this.items[i].setIndex(i);
        }
        this._setLastIndex();

        if (this.conf.origVisibleItems < 0) {
            this.conf.visibleItems = Math.round(Math.sqrt(this.items.length));
        }
        this.conf.visibleItems = Math.min(this.conf.visibleItems, this.items.length - 1);

        /* adjust targetItem, currentPos so that current view does not change*/
        if (Math.round(this._getPositionByIndex(index)) <= Math.round(this._targetPosition)) {
            this._targetPosition++;
            if (!this.conf.circularFlow)
                this._targetPosition = Math.min(this._targetPosition, this.itemsLastIndex);
        }
        if (this._getPositionByIndex(index) <= this._currentPosition) {
            this._currentPosition++;
            if (!this.conf.circularFlow)
                this._currentPosition = Math.min(this._currentPosition, this.itemsLastIndex);
        }

        // avoid display errors (wrong sizing)
        var CF = this;
        window.setTimeout(function() {
            if (CF.items.length == 1) {
                CF._currentPosition = -0.01;
                CF._targetPosition = 0;
                CF.resize();
            }
            else {
                CF._initStep();
            }
        }, 100);

        return index;

    },

    /*
    * removes item at index position, cleans it up and returns it
    */
    rmItem: function(index) {
        if (index == "undefined") index = this._activeItem.index;
        index = this._getIndexByKeyWord(index);
        if (!this.items[index]) return null;

        var item = this.items[index];

        if (item.pre) item.pre.next = item.next;
        if (item.next) item.next.pre = item.pre;
        this.items.splice(index, 1);

        /* adjust item indices */
        for (var i = index; i < this.items.length; i++) {
            this.items[i].setIndex(i);
        }
        this._setLastIndex();

        /* adjust targetItem, currentPos and activeItem so that current view does not change*/
        if (Math.round(this._getPositionByIndex(index)) < Math.round(this._targetPosition)) {
            this._targetPosition--;
            if (!this.conf.circularFlow)
                this._targetPosition = this._checkIndex(this._targetPosition);
        }
        if (this._getPositionByIndex(index) < this._currentPosition) {
            this._currentPosition--;
            if (!this.conf.circularFlow)
                this._currentPosition = this._checkIndex(this._currentPosition);
        }
        this._activeItem = this._getItemByPosition(this._currentPosition);

        /* remove item from DOM tree, take the next step and return removed item  */
        var removedItem = item.element.parentNode.removeChild(item.element);
        // avoid display errors (wrong sizing)
        var CF = this;
        window.setTimeout(function() { CF._initStep() }, 10);
        return removedItem;

    },


    /*
    * ==================== initialization ====================
    */


    /* -------------------- main init -------------------- */
    _init: function() {

        if (typeof (this.Container) == 'string') { // no node
            var container = document.getElementById(this.Container);
            if (container) {
                this.Container = container;
            } else {
                throw ('ContentFlow ERROR: No element with id \'' + this.Container + '\' found!');
                return;
            }
        }

        /* ----------  reserve CSS namespace */

        $CF(this.Container).addClassName('ContentFlow');

        /* ---------- detect GUI elements */
        var flow = $CF(this.Container).getChildrenByClassName('flow')[0];
        if (!flow) {
            throw ('ContentFlow ERROR: No element with class\'flow\' found!');
            return;
        }
        this.Flow = new ContentFlowGUIElement(this, flow);

        var scrollbar = this.Container.getChildrenByClassName('scrollbar')[0];
        if (scrollbar) {
            this.Scrollbar = new ContentFlowGUIElement(this, scrollbar);
            var slider = this.Scrollbar.getChildrenByClassName('slider')[0];
            if (slider) {
                this.Slider = new ContentFlowGUIElement(this, slider);
                var position = this.Slider.getChildrenByClassName('position')[0];
                if (position) {
                    this.Position = new ContentFlowGUIElement(this, position);
                }
            }

        }

        /* ----------  init configuration */
        this.setConfig(this._defaultConf);
        this._initAddOns(); /* init AddOns */
        this.setConfig(this._userConf);

        this._initSizes(); // ......


        /* ---------- init item lists ---------- */
        var items = this.Flow.getChildrenByClassName('item');

        this.items = new Array();
        for (var i = 0; i < items.length; i++) {
            var item = this.items[i] = new ContentFlowItem(this, items[i], i);
            if (i > 0) {
                item.pre = this.items[i - 1];
                item.pre.next = item;
            }
        }
        this._setLastIndex();
        if (this.conf.circularFlow && this.items.length > 0) {
            var s = this.items[0];
            s.pre = this.items[this.items.length - 1];
            s.pre.next = s;
        }

        /* ----------  init GUI */
        this._initGUI();

        /* ---------- init start parameters ---------- */
        if (this._activeElement != "content")
            this._activeElement = "element";

        this.conf.origVisibleItems = this.conf.visibleItems;
        if (this.conf.visibleItems < 0) {
            this.conf.visibleItems = Math.round(Math.sqrt(this.items.length));
        }
        this.conf.visibleItems = Math.min(this.conf.visibleItems, this.items.length - 1);

        this._targetPosition = this._getIndexByKeyWord(this.conf.startItem, 0);

        var index = this._getIndexByKeyWord(this.conf.scrollInFrom, this._targetPosition);
        switch (this.conf.scrollInFrom) {
            case "next":
            case "right":
                index -= 0.5;
                break;
            case "pre":
            case "previous":
            case "left":
                index += 0.5;
                break;
        }
        this._currentPosition = index;


        /* ---------- wait till all images are loaded or 
        * grace time is up to show all and take the first step  
        */
        var now = new Date();
        var cf = this;
        var timer = window.setInterval(
            function() {
                if (cf._imagesToLoad == 0 || new Date() - now > cf._loadingTimeout) {
                    clearInterval(timer);

                    cf._activeItem = cf.getItem(cf._currentPosition);
                    if (cf._activeItem) {
                        cf._activeItem.makeActive();
                        cf._setCaptionLabel(cf._activeItem.index);
                    }

                    cf.Flow.style.visibility = "visible"; // show flow after images are loaded
                    if (cf.loadIndicator) cf.loadIndicator.style.display = "none";
                    if (cf.Scrollbar) cf.Scrollbar.style.visibility = "visible";

                    cf.resize();
                    for (var i = 0; i < cf._loadedAddOns.length; i++) {
                        var a = ContentFlowGlobal.AddOns[cf._loadedAddOns[i]];
                        if (a.methods.afterContentFlowInit)
                            a.methods.afterContentFlowInit(cf);
                    }
                    cf.conf.onInit();
                }
            }, 10
        );

        this.isInit = true;

    },

    /* ---------- init AddOns ---------- */
    _initAddOns: function() {

        // get an array of names of all AddOns that should be used
        var loadAddOns = [];
        if (this._userConf.useAddOns) {
            if (typeof this._userConf.useAddOns == "string") {
                loadAddOns = this._userConf.useAddOns.split(" ");
            }
            else if (typeof this._userConf.useAddOns == "array") {
                loadAddOns = this._userConf.useAddOns;
            }
        }
        else if (this.Container.getAttribute("useAddOns")) {
            loadAddOns = this.Container.getAttribute("useAddOns").split(" ");
        }
        else {
            loadAddOns = this.conf.useAddOns.split(' ');
        }


        // check the names for keywords
        for (var i = 0; i < loadAddOns.length; i++) {
            if (loadAddOns[i] == "none") {
                loadAddOns = new Array();
                break;
            }
            else if (loadAddOns[i] == "all") {
                loadAddOns = new Array();
                for (var AddOn in ContentFlowGlobal.AddOns)
                    loadAddOns.push(AddOn);
                break;
            }
        }

        // init all AddOns that should be used and exist
        for (var i = 0; i < loadAddOns.length; i++) {
            var AddOn = ContentFlowGlobal.AddOns[loadAddOns[i]];
            if (AddOn) {
                this._loadedAddOns.push(loadAddOns[i]);
                AddOn._init(this);
                this.Container.addClassName('ContentFlowAddOn_' + AddOn.name);
                if (AddOn.methods.onloadInit)
                    AddOn.methods.onloadInit(this);
            }
        }

    },


    _initGUI: function() {

        // resize
        //if (!this.Browser.iPhone) {
        var resize = this.resize.bind(this);
        window.addEvent('resize', resize, false);
        //}
        //else {
        //var g = this;
        //window.addEvent('resize', function () {
        //g._initSizes();
        //g._initStep();
        //} , false);
        //}

        // pre and next buttons
        var divs = this.Container.getElementsByTagName('div');
        for (var i = 0; i < divs.length; i++) {
            if ($CF(divs[i]).hasClassName('preButton')) {
                var pre = divs[i];
                var mt = this.conf.onclickPreButton;
                pre.addEvent('click', mt, false);
            }
            else if (divs[i].hasClassName('nextButton')) {
                var next = divs[i];
                var mt = this.conf.onclickNextButton;
                next.addEvent('click', mt, false);
            }
        }

        // Container object
        // mousewheel
        if (this.conf.scrollWheelSpeed != 0) {
            var wheel = this._wheel.bind(this);
            if (window.addEventListener) this.Container.addEventListener('DOMMouseScroll', wheel, false);
            this.Container.onmousewheel = wheel;
        }

        // key strokes
        var key = this._keyStroke.bind(this);
        if (this.conf.keys && !this.Browser.iPhone) {
            if (document.addEventListener) {
                if (!this.Browser.Opera) {
                    var mouseoverCheck = document.createElement('div');
                    mouseoverCheck.addClassName('mouseoverCheckElement');
                    this.Container.appendChild(mouseoverCheck);

                    if (this.Browser.WebKit) {
                        document.body.addEvent('keydown', function(event) {
                            if (mouseoverCheck.offsetLeft > 0) key(event);
                        });
                    } else {
                        window.addEvent('keydown', function(event) {
                            if (mouseoverCheck.offsetLeft > 0) key(event);
                        });
                    }
                }
                else {
                    this.Container.addEvent('keydown', key);
                }
            }
            else {
                this.Container.onkeydown = key;
            }
        }


        // Flow object
        if (this.conf.flowDragFriction > 0) {
            var onDrag = function(event) {
                var e = event;
                if (event.touches) e = event.touches[0];
                var mouseX = e.clientX;
                var mouseY = e.clientY;

                if (this.conf.verticalFlow) {
                    var dist = mouseY - this.Flow.mouseY; // px / or px per sec because _dragFlow wil be called in shorter intervalls if draged fast
                    var dim = this.Flow.dimensions.height;
                }
                else {
                    var dist = mouseX - this.Flow.mouseX; // px / or px per sec because _dragFlow wil be called in shorter intervalls if draged fast
                    var dim = this.Flow.dimensions.width;
                }
                var itemDist = (dist / dim) * (2 * this.conf.visibleItems + 1); // items
                var target = this._currentPosition - itemDist * 2 * this.conf.visibleItems / this.conf.flowDragFriction;

                this.Flow.mouseX = mouseX;
                this.Flow.mouseY = mouseY;

                this.moveToPosition(target, true);
            } .bind(this);

            var beforeDrag = function() { };

            var afterDrag = function(event) {
                var t = Math.round(this._targetPosition);
                if (Math.abs(t - this._currentPosition) > 0.001)
                    this.moveToPosition(t);
            } .bind(this);


            this.Flow.makeDraggable(onDrag, beforeDrag, afterDrag);
        }

        // Scrollbar Object
        if (this.Scrollbar) {
            var click = function(event) {
                if (!event) var event = window.event;

                if (!this.Scrollbar.clickLocked) {
                    var mouseX = event.clientX;
                    var positionOnScrollbar = mouseX - this.Scrollbar.position.left;
                    var targetIndex = Math.round(positionOnScrollbar / this.Scrollbar.dimensions.width * this.itemsLastIndex);
                    this.moveToIndex(targetIndex);
                }
                else
                    this.Scrollbar.clickLocked = false;
            } .bind(this);
            this.Scrollbar.addObserver('click', click);
        }

        // Slider Object
        if (this.Slider) {

            if (this.Browser.IE6) {
                var virtualSlider = document.createElement('div');
                virtualSlider.className = 'virtualSlider';
                this.Slider.appendChild(virtualSlider);
            }

            // position slider on scrollbar
            this.Slider.setPosition = function(relPos) {
                relPos = relPos - Math.floor(relPos) + this._getIndexByPosition(Math.floor(relPos));
                if (Math.round(relPos) < 0)
                    relPos = this.itemsLastIndex;
                else if (relPos <= 0)
                    relPos = 0;
                else if (Math.round(relPos) > this.itemsLastIndex)
                    relPos = 0;
                else if (relPos >= this.itemsLastIndex)
                    relPos = this.itemsLastIndex;


                if (this.items.length > 1) {
                    var sPos = (relPos / this.itemsLastIndex) * this.Scrollbar.dimensions.width;
                } else {
                    var sPos = 0.5 * this.Scrollbar.dimensions.width;
                }
                this.Slider.style.left = sPos - this.Slider.center.x + "px";
                this.Slider.style.top = this.Scrollbar.center.y - this.Slider.center.y + "px";

            } .bind(this);

            // make slider draggable
            var beforeDrag = function(event) {
                this.Scrollbar.clickLocked = true;
            } .bind(this);

            var onDrag = function(event) {
                var e = event;
                if (event.touches) e = event.touches[0];
                var selectedIndex = this._checkIndex((e.clientX - this.Scrollbar.position.left) / this.Scrollbar.dimensions.width * this.itemsLastIndex);
                this._targetPosition = this._getPositionByIndex(selectedIndex);
                this.Slider.setPosition(selectedIndex);
                if (this.Position) this.Position.setLabel(selectedIndex);
                this._initStep(true, true);
            } .bind(this);

            var afterDrag = function(event) {
                this._targetPosition = Math.round(this._targetPosition);
                this.conf.onMoveTo(this._getItemByPosition(this._targetPosition));
                this._initStep(true);
            } .bind(this);

            this.Slider.makeDraggable(onDrag, beforeDrag, afterDrag);
        }


        // Position object
        if (this.Position) {
            this.Position.setLabel = function(index) {
                index = this._checkIndex(Math.round(index));
                if (this.items && this.items[index].label)
                    this.Position.innerHTML = this.items[index].label.innerHTML;
                else
                    this.Position.innerHTML = index + 1;
            } .bind(this);
        }


        this.globalCaption = this.Container.getChildrenByClassName('globalCaption')[0];
        this.loadIndicator = this.Container.getChildrenByClassName('loadIndicator')[0];
    },

    /* ---------- init element sizes ---------- */
    _initSizes: function(x) {
        //if (this.Browser.Konqueror4 && x != true) {
        //var t = this;
        //window.setTimeout( function () { t._initSizes(true) }, 0);
        //return;
        //}

        // sets this.maxHeight
        this._initMaxHeight();

        var scrollbarHeight = this._initScrollbarSize();

        // reduce maxHeit if container has a fixed height
        if (!this.conf.verticalFlow && this.Container.style.height && this.Container.style.height != "auto")
            this.maxHeight -= scrollbarHeight;

        if (!this._activeItem) return;

        var mFS = this._findBiggestItem();

        var pF = this.Flow.findPos();

        /* set height / width of flow */
        if (this.conf.verticalFlow) {
            this.Flow.style.width = mFS.width.width + "px";
            this.Flow.style.height = 3 * mFS.width.width * (1 + this.conf.reflectionHeight + this.conf.reflectionGap) + "px";
        } else {
            this.Flow.style.height = mFS.height.height + (mFS.height.top - pF.top) + "px";
        }

        /* remove gap */
        var s = this.conf.verticalFlow ? mFS.width.width : mFS.height.height;
        var cH = s / (1 + this.conf.reflectionHeight + this.conf.reflectionGap);
        this.Flow.style.marginBottom = -(s - cH) + "px";

        this.Flow.dimensions = this.Flow.getDimensions();

        if (!this.Browser.IE6) {
            if (this.conf.verticalFlow && this.Container.clientWidth < this.Flow.dimensions.width) {
                //this.Container.style.width = this.Flow.dimensions.width+"px";
            }
            else if (this.Container.clientHeight < this.Flow.dimensions.height) {
                this.Container.style.height = this.Flow.dimensions.height + "px";
            }
        }

        if (this.conf.verticalFlow) {
            this.Flow.center = { x: this.Flow.dimensions.height / 2, y: mFS.width.width / 2 };
        } else {
            this.Flow.center = { x: this.Flow.dimensions.width / 2, y: mFS.height.height / 2 };
        }

    },

    /* -------------------------------------------------------------------------------- */

    _initScrollbarSize: function() {
        var SB;
        var SL;
        var PO;
        if (SB = this.Scrollbar) {
            SB.setDimensions();
            var scrollbarHeight = SB.dimensions.height;

            if (SL = this.Slider) {
                SL.setDimensions();
                scrollbarHeight += SL.dimensions.height;

                if (PO = this.Position) {

                    var oldLabel = PO.innerHTML;
                    var maxH = maxW = 0;
                    PO.style.width = "auto";

                    if (this.items) {
                        for (var i = 0; i < this.items.length; i++) {
                            var item = this.items[i];
                            if (item.label) {
                                PO.innerHTML = item.label.innerHTML;
                            }
                            else {
                                PO.innerHTML = item.index;
                            }
                            var h = PO.clientHeight;
                            var w = PO.clientWidth;
                            if (h > maxH) maxH = h;
                            if (w > maxW) maxW = w;
                        }
                    }
                    else {
                        PO.innerHTML = "&nbsp;";
                        maxH = PO.clientHeight;
                        maxW = PO.clientWidth;
                    }

                    PO.innerHTML = oldLabel;

                    PO.setDimensions();

                    PO.style.width = maxW + "px";
                    PO.style.left = (SL.dimensions.width - maxW) / 2 + "px";

                    var extraSpace = PO.position.top - SL.position.top;
                    if (extraSpace > 0) {
                        extraSpace += -SB.dimensions.height + maxH;
                        SB.style.marginBottom = extraSpace + "px";
                    }
                    else {
                        extraSpace *= -1;
                        SB.style.marginTop = extraSpace + "px";
                    }
                    scrollbarHeight += extraSpace;
                }
            }
        }
        else {
            scrollbarHeight = 0;
        }

        return scrollbarHeight;

    },

    /* -------------------------------------------------------------------------------- */

    _initMaxHeight: function() {

        if (this.conf.verticalFlow) {
            var proportion = screen.width / screen.height;
            var Csd = this.Container.style.width;
            var Cdim = this.Container.clientWidth;
            var Fsd = this.Flow.style.width;
            var Fdim = this.Flow.clientWidth;
            var Fdim_o = this.Flow.clientHeight;
        } else {
            var proportion = screen.height / screen.width;
            var Csd = this.Container.style.height;
            var Cdim = this.Container.clientHeight;
            var Fsd = this.Flow.style.height;
            var Fdim = this.Flow.clientHeight;
            var Fdim_o = this.Flow.clientWidth;
        }

        // set height of container and flow
        if (this.ContainerOldDim)
            Csd = this.ContainerOldDim;
        if (this.FlowOldDim)
            Fsd = this.FlowOldDim;

        this.ContainerOldDim = "auto";
        this.FlowOldDim = "auto";


        /* calc maxHeight */
        if (this.conf.maxItemHeight <= 0) {

            this.maxHeight = Fdim_o / 3 * proportion / 1 * this.conf.scaleFactor;  // divided by 3 because of left/center/right, yes it's a magic number

            if (this.conf.verticalFlow && (this.maxHeight == 0 || this.maxHeight > Fdim)) {
                this.maxHeight = Fdim;
            }

            if (Csd && Csd != "auto") {
                var gap = this.conf.verticalFlow ? 0 : this.conf.reflectionGap;
                var rH = this.conf.verticalFlow ? 0 : this.conf.reflectionHeight;
                this.maxHeight = Cdim / (this.conf.scaleFactor * (1 + rH + gap));
                this.ContainerOldDim = Csd;
            }
            else if (Fsd && Fsd != "auto") {
                var gap = this.conf.verticalFlow ? 0 : this.conf.reflectionGap;
                this.maxHeight = Fdim / (this.conf.scaleFactor * (1 + this.conf.reflectionHeight + gap));
                this.FlowOldDim = Fsd;
            }
        }
        else {
            this.maxHeight = this.conf.maxItemHeight;
        }
    },

    /* -------------------------------------------------------------------------------- */

    _findBiggestItem: function() {
        var currentItem = this._activeItem;

        var itemP = currentItem.pre;
        var itemN = currentItem.next;
        var mFS = maxFlowSize = {
            width: { width: 0, left: 0, height: 0, top: 0, item: null, rI: 0 },
            height: { width: 0, left: 0, height: 0, top: 0, item: null, rI: 0 }
        }


        var checkMax = function(item, rI) {
            var el = item.element;
            el.style.display = "block";
            var p = el.findPos();
            var h = el.clientHeight;
            var w = el.clientWidth;
            if (h + p.top >= mFS.height.height + mFS.height.top) {
                mFS.height.height = h;
                mFS.height.top = p.top;
                mFS.height.item = item;
                mFS.height.rI = rI;
            }
            if (w + p.left >= mFS.width.width + mFS.width.left) {
                mFS.width.width = w;
                mFS.width.left = p.left;
                mFS.width.item = item;
                mFS.width.rI = rI;
            }
            el.style.display = "none";
        }

        var ocp = this._currentPosition;
        this._currentPosition = this.conf.visibleItems + 1;

        // find the position with highest y-value
        for (var i = -this.conf.visibleItems; i <= this.conf.visibleItems; i++) {
            currentItem.element.style.display = "none";
            this._positionItem(currentItem, i);
            checkMax(currentItem, i);
        }

        // find the biggest item
        var index = mFS.height.rI;
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            item.element.style.display = "none";
            this._positionItem(item, index);
            checkMax(item, index);
        }

        this._currentPosition = ocp;

        return mFS
    },



    /*
    * ==================== Key strok ====================
    */

    /*
    * handles keystroke events
    */
    _keyStroke: function(event) {
        if (!event) var event = window.event;

        if (event.which) {
            var keyCode = event.which;
        } else if (event.keyCode) {
            var keyCode = event.keyCode;
        }

        if (this.conf.keys[keyCode]) {
            this.conf.keys[keyCode].bind(this)();
            return Event.stop(event);
        }
        else {
            return true;
        }
    },

    /*
    * ==================== mouse wheel ====================
    * Event handler for mouse wheel event
    * http://adomas.org/javascript-mouse-wheel/
    */

    _wheel: function(event) {
        if (!event) var event = window.event; // MS

        var delta = 0;
        if (event.wheelDelta) {
            delta = event.wheelDelta / 120;
        } else if (event.detail) {
            delta = -event.detail / 3;
        }

        if (delta) {
            var target = this._targetPosition;
            if (delta < 0) {
                target += (1 * this.conf.scrollWheelSpeed);
            } else {
                target -= (1 * this.conf.scrollWheelSpeed);
            }
            this.moveToPosition(Math.round(target));
        }

        return Event.stop(event);
    },


    /*
    * ==================== set global Caption ====================
    */
    _setGlobalCaption: function() {
        if (this.globalCaption) {
            this.globalCaption.innerHTML = '';
            if (this._activeItem && this._activeItem.caption)
                this.globalCaption.appendChild(this._activeItem.caption.cloneNode(true));
        }
    },

    /*
    * ==================== move items ====================
    */

    /*
    * intend to make a step 
    */
    _initStep: function(holdSlider, holdPos) {
        if (this.Slider) {
            if (holdSlider) {
                this.Slider.locked = true;
            } else {
                this.Slider.locked = false;
            }
        }
        this._holdPos = holdPos == true ? true : false;
        if (!this._stepLock) {
            this._stepLock = true;
            this._step();
        }
    },

    /*
    * make a step
    */
    _step: function() {

        var diff = this._targetPosition - this._currentPosition;
        var absDiff = Math.abs(diff);
        if (absDiff > 0.001) { // till activeItem is nearly at position 0

            this._currentPosition += this.conf.flowSpeedFactor * this.conf.calcStepWidth(diff, absDiff, this.items.length, this.conf.visibleItems);

            var AI = this.items[(this._getIndexByPosition(this._currentPosition))];

            if (AI && AI != this._activeItem) {
                if (this._activeItem) this._activeItem.makeInactive();
                this._activeItem = AI;
                this._activeItem.makeActive();
                this._setCaptionLabel(this._activeItem.index);
                if (Math.abs(this._targetPosition - this._currentPosition) <= 0.5) this.conf.onReachTarget(this._activeItem);
            }

            this._positionItems();

            var st = this._step.bind(this);
            window.setTimeout(st, this._millisecondsPerStep);

        } else if (!this._holdPos) {
            if (this.Slider) this.Slider.locked = false;
            this._currentPosition = Math.round(this._currentPosition);
            if (this.Position && !this.Slider.locked && this._activeItem) {
                this._setCaptionLabel(this._activeItem.index);
            }
            this._positionItems();
            this._stepLock = false;
        } else {
            this._stepLock = false;
        }

        if (this.Slider && !this.Slider.locked) {
            this.Slider.setPosition(this._currentPosition);
        }
    },



    /* ------------------------------------------------------------------------------------------------------ */

    /*
    * position items
    */
    _positionItems: function() {

        if (this._lastStart) {
            var item = this._lastStart;
            while (item) {
                item.element.style.display = "none";
                item = item.next;
                if (item == this._lastStart) break;
                if (item && item.pre == this._lastEnd) break;
            }
        }
        else {
            this._lastStart = this._activeItem;
        }

        if (!this._activeItem) return;
        var currentItem = this._activeItem;
        var itemP = currentItem.pre;
        var itemN = currentItem.next;

        this._positionItem(currentItem, 0);
        for (var i = 1; i <= this.conf.visibleItems && 2 * i < this.items.length; i++) {
            if (itemP) {
                this._positionItem(itemP, -i);
                this._lastStart = itemP;
                itemP = itemP.pre;
            }
            if (itemN) {
                this._positionItem(itemN, i);
                this._lastEnd = itemN;
                itemN = itemN.next;
            }
        }

    },

    _positionItem: function(item, relativeIndex) {

        var conf = this.conf;
        var vF = conf.verticalFlow;

        var els = item.element.style;
        //els.display =" none";
        //if (els.display != "none") return;

        /* Index and position relative to activeItem */
        var p = item.position = this._currentPosition + relativeIndex;
        var relativePosition = item.relativePosition = Math.round(p) - this._currentPosition;
        var relativePositionNormed = item.relativePositionNormed = conf.visibleItems > 0 ? relativePosition / conf.visibleItems : 0;
        var side = relativePosition < 0 ? -1 : 1;
        side *= relativePosition == 0 ? 0 : 1;
        item.side = side;

        var size = conf.calcSize(item);
        size.height = Math.max(size.height, 0);
        size.width = Math.max(size.width, 0);
        if (item.content.origProportion) size = this._scaleImageSize(item, size);
        item.size = size;

        var coords = item.coordinates = conf.calcCoordinates(item);
        var relItemPos = item.relativeItemPosition = conf.calcRelativeItemPosition(item);
        var zIndex = item.zIndex = conf.calcZIndex(item);
        var fontSize = item.fontSize = conf.calcFontSize(item);
        var opacity = item.opacity = conf.calcOpacity(item);

        size.height *= this.maxHeight;
        size.width *= this.maxHeight;

        /* set position */
        var sA = vF ? size.height : size.width;
        var sB = vF ? size.width : size.height;
        var pX = this.Flow.center.x * (1 + coords.x) + (relItemPos.x - 1) * sA / 2;
        var pY = this.maxHeight / 2 * (1 + coords.y) + (relItemPos.y - 1) * sB / 2;
        els.left = (vF ? pY : pX) + "px";
        els.top = (vF ? pX : pY) + "px";

        this._setItemSize(item, size);

        /* set opacity */
        if (conf.endOpacity != 1) {
            this._setItemOpacity(item);
        }

        /* set font size */
        if (!this.Browser.IE) els.fontSize = (fontSize * 100) + "%";

        /* set z-index */
        els.zIndex = 32768 + Math.round(zIndex * this.items.length); // just for FF

        conf.onDrawItem(item);

        els.visibility = "visible";
        els.display = "block";
    },

    _scaleImageSize: function(item, size, max) {
        var sFL = this.conf.scaleFactorLandscape;
        var sFP = this.conf.scaleFactorPortrait;
        var vF = this.conf.verticalFlow;
        var prop = item.content.origProportion;
        var width = size.width;
        var height = size.height;
        var c = item.content;

        if (vF) {
            if (prop <= 1) {
                if (sFL != "max" && sFL != 1) {
                    height *= sFL;
                    width = Math.min(height * prop, max ? max : 1);
                }
                height = width / prop;
            }
            else if (prop > 1) {
                if (sFP == "max") {
                    height = max ? max : 1;
                }
                else if (sFP != 1) {
                    width *= sFP;
                    height = Math.min(width / prop, max ? max : 1)
                }
                else {
                    height = width / prop;
                }
                width = height * prop;
            }
        }
        else {
            if (prop > 1) {
                if (sFL != "max" && sFL != 1) {
                    width *= sFL;
                    height = Math.min(width / prop, max ? max : 1);
                }
                width = height * prop;
            }
            else if (prop <= 1) {
                if (sFP == "max") {
                    width = max ? max : 1;
                }
                else if (sFP != 1) {
                    height *= sFP;
                    width = Math.min(height * prop, max ? max : 1);
                }
                else {
                    width = height * prop;
                }
                height = width / prop;
            }
        }

        height = isNaN(height) ? 0 : height;
        width = isNaN(width) ? 0 : width;

        if (!max && this.conf.fixItemSize) {

            var propS = size.width / size.height;

            var max = Math.max(size.width, size.height);
            var s = this._scaleImageSize(item, { width: max, height: max }, max);

            if (propS < 1) {
                height = s.height / size.height;
                width = height * prop / propS;
            }
            else {
                width = s.width / size.width;
                height = width / prop * propS;
            }

            var h = height * 100;
            var w = width * 100;
            var mL = (1 - width) / 2 * 100;
            var mT = (1 - height) / propS * 100 * (vF ? 0.5 : 1);
            c.style.height = h + "%";
            if (item.reflection) item.reflection.style.height = h * this.conf.reflectionHeight + "%";
            c.style.width = w + "%";
            if (item.reflection) item.reflection.style.width = w + "%";
            c.style.marginLeft = mL + "%";
            if (item.reflection) item.reflection.style.marginLeft = mL + "%";
            c.style.marginTop = mT + "%";

            item.element.style.overflow = "hidden";

            return size;
        }
        else {
            return { width: width, height: height };
        }

    },

    _setItemSize: (function() {
        if (ContentFlowGlobal.Browser.IE) {
            var _setItemSize = function(item, size) {
                if (!this.conf.fixItemSize) {
                    item.content.style.height = size.height + "px";
                }
                else if (ContentFlowGlobal.Browser.IE6) {
                    var h = parseInt(item.content.style.height) / 100;
                    item.content.style.height = size.height * h + "px";
                    var mT = parseInt(item.content.style.marginTop) / 100;
                    item.content.style.marginTop = size.height * mT + "px";
                }
                if (item.reflection) {
                    var h = parseInt(item.content.style.height);
                    item.reflection.style.height = h * this.conf.reflectionHeight + "px";
                    item.reflection.style.marginTop = h * this.conf.reflectionGap + "px";
                }
                item.element.style.width = size.width + "px";
                item.element.style.height = size.height * (1 + this.conf.reflectionHeight + this.conf.reflectionGap) + "px";
            }
        }
        else {
            var _setItemSize = function(item, size) {
                if (item.reflection) {
                    item.element.style.height = size.height * (1 + this.conf.reflectionHeight + this.conf.reflectionGap) + "px";
                    item.reflection.style.marginTop = size.height * this.conf.reflectionGap + "px";
                }
                else if (this._reflectionWithinImage) {
                    item.element.style.height = size.height * (1 + this.conf.reflectionHeight + this.conf.reflectionGap) + "px";
                }
                else {
                    item.element.style.height = size.height + "px";
                }
                item.element.style.width = size.width + "px";
            }
        }
        return _setItemSize;

    })(),

    _setItemOpacity: (function() {
        if (ContentFlowGlobal.Browser.IE6) {
            var _setItemOpacity = function(item) {
                if (item.content.origSrc && item.content.origSrc.match(/\.png$/)) {
                    var s = item.content.src;
                    item.content.src = item.content.origSrc;
                    item.content.style.filter = item.content.filterString + " progid:DXImageTransform.Microsoft.BasicImage(opacity=" + item.opacity + ")";
                    item.content.src = s;
                }
                else {
                    item.content.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(opacity=" + item.opacity + ")";
                }
                if (item.reflection) item.reflection.style.filter = item.reflection.filterString + "progid:DXImageTransform.Microsoft.BasicImage(opacity=" + item.opacity + ")";
            }
        }
        else if (ContentFlowGlobal.Browser.IE) {
            var _setItemOpacity = function(item) { item.element.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(opacity=" + item.opacity + ")"; }
        }
        else {
            var _setItemOpacity = function(item) { item.element.style.opacity = item.opacity; }
        }
        return _setItemOpacity;
    })()


};


/* ==================== extendig javascript/DOM objects ==================== */

/*
*  adds bind method to Function class
*  http://www.digital-web.com/articles/scope_in_javascript/
*/

if (!Function.bind) {
    Function.prototype.bind = function(obj) {
        var method = this;
        return function() {
            return method.apply(obj, arguments);
        };
    };
}


/*
* extending Math object
*/
if (!Math.erf2) {
    // error function (http://en.wikipedia.org/wiki/Error_function), implemented as erf(x)^2
    Math.erf2 = function(x) {
        var a = -(8 * (Math.PI - 3) / (3 * Math.PI * (Math.PI - 4)));
        var x2 = x * x;
        var f = 1 - Math.pow(Math.E, -x2 * (4 / Math.PI + a * x2) / (1 + a * x2));
        return f;
    };
}

if (!Math._2PI05) {
    Math._2PI05 = Math.sqrt(2 * Math.PI);
}

if (!Math.normDist) {
    // normal distribution
    Math.normDist = function(x, sig, mu) {
        if (!sig) var sig = 1;
        if (!mu) var mu = 0;
        if (!x) var x = -mu;
        return 1 / (sig * Math._2PI05) * Math.pow(Math.E, -(x - mu) * (x - mu) / (2 * sig * sig));
    };
}

if (!Math.normedNormDist) {
    Math.normedNormDist = function(x, sig, mu) {
        return this.normDist(x, sig, mu) / this.normDist(mu, sig, mu);
    };
}

if (!Math.exp) {
    Math.exp = function(x) {
        return Math.pow(Math.E, x);
    };
}

if (!Math.ln) {
    Math.ln = Math.log;
}

if (!Math.log2) {
    Math.log2 = function(x) {
        return Math.log(x) / Math.LN2;
    };
}

if (!Math.log10) {
    Math.log10 = function(x) {
        return Math.log(x) / Math.LN10;
    };
}

if (!Math.logerithm) {
    Math.logerithm = function(x, b) {
        if (!b || b == Math.E)
            return Math.log(x);
        else if (b == 2)
            return Math.log2(x);
        else if (b == 10)
            return Math.log10(x);
        else
            return Math.log(x) / Math.log(b);
    };
}


/*
* extending Event object
*/
if (!Event) var Event = {};

if (!Event.stop) {
    Event.stop = function(event) {
        event.cancelBubble = true;
        if (event.preventDefault) event.preventDefault();
        if (event.stopPropagation) event.stopPropagation();
        return false;
    };
}

/*
* extending Element object
*/
if (document.all && !window.opera) {
    window.$CF = function(el) {
        if (typeof el == "string") {
            return window.$CF(document.getElementById(el));
        }
        else {
            if (CFElement.prototype.extend && el && !el.extend) CFElement.prototype.extend(el);
        }
        return el;
    };
} else {
    window.$CF = function(el) {
        return el;
    };
}

if (!window.HTMLElement) {
    CFElement = {};
    CFElement.prototype = {};
    CFElement.prototype.extend = function(el) {
        for (var method in this) {
            if (!el[method]) el[method] = this[method];
        }
    };
}
else {
    CFElement = window.HTMLElement;
}


/*
* Thanks to Peter-Paul Koch
* http://www.quirksmode.org/js/findpos.html
*/
if (!CFElement.findPos) {
    CFElement.prototype.findPos = function() {
        var obj = this;
        var curleft = curtop = 0;
        try {
            if (obj.offsetParent) {
                curleft = obj.offsetLeft;
                curtop = obj.offsetTop;
                while (obj = obj.offsetParent) {
                    curleft += obj.offsetLeft;
                    curtop += obj.offsetTop;
                }
            }
        }
        catch (ex) { }
        return { left: curleft, top: curtop };
    };
}

if (!CFElement.getDimensions) {
    CFElement.prototype.getDimensions = function() {
        return { width: this.clientWidth, height: this.clientHeight };
    };
}

/*
* checks if an element has the class className
*/
if (!CFElement.hasClassName) {
    CFElement.prototype.hasClassName = function(className) {
        return (new RegExp('\\b' + className + '\\b').test(this.className));
    };
}

/*
* adds the class className to the element
*/
if (!CFElement.addClassName) {
    CFElement.prototype.addClassName = function(className) {
        if (!this.hasClassName(className)) {
            this.className += (this.className ? ' ' : '') + className;
        }
    };
}

/*
* removes the class className from the element el
*/
if (!CFElement.removeClassName) {
    CFElement.prototype.removeClassName = function(className) {
        this.className = this.className.replace(new RegExp('\\b' + className + '\\b'), '').replace(/\s\s/g, ' ');
    };
}

/*
* removes or adds the class className from/to the element el
* depending if the element has the class className or not.
*/
if (!CFElement.toggleClassName) {
    CFElement.prototype.toggleClassName = function(className) {
        if (this.hasClassName(className)) {
            this.removeClassName(className);
        } else {
            this.addClassName(className);
        }
    };
}

/*
* returns all children of element el, which have the class className
*/
if (!CFElement.getChildrenByClassName) {
    CFElement.prototype.getChildrenByClassName = function(className) {
        var children = new Array();
        for (var i = 0; i < this.childNodes.length; i++) {
            var c = this.childNodes[i];
            if (c.nodeType == 1 && $CF(c).hasClassName(className)) {
                children.push(c);
            }
        }
        return children;
    };
}

/*
* Browser independent event handling method.
* adds the eventListener  eventName to element el and attaches the function method to it.
*/
if (!CFElement.addEvent) {
    CFElement.prototype.addEvent = function(eventName, method, capture) {
        if (this.addEventListener) {
            this.addEventListener(eventName, method, capture);
        } else {
            this.attachEvent('on' + eventName, method);
        }
    };
}

/*
* Browser independent event handling method.
* removes the eventListener  eventName with the attached function method from element el.
*/
if (!CFElement.removeEvent) {
    CFElement.prototype.removeEvent = function(eventName, method, capture) {
        if (this.removeEventListener)
            this.removeEventListener(eventName, method, capture);
        else
            this.detachEvent('on' + eventName, method);
    };
}

/*
* Browser independent event handling method.
* adds the eventListener  eventName to element el and attaches the function method to it.
*/
if (!window.addEvent) {
    window.addEvent = function(eventName, method, capture) {
        if (this.addEventListener) {
            this.addEventListener(eventName, method, capture);
        } else {
            if (eventName != 'load' && eventName != 'resize')
                document.attachEvent('on' + eventName, method);
            else
                this.attachEvent('on' + eventName, method);
        }
    };
}

/*
* Browser independent event handling method.
* removes the eventListener  eventName with the attached function method from element el.
*/
if (!window.removeEvent) {
    window.removeEvent = function(eventName, method, capture) {
        if (this.removeEventListener) {
            this.removeEventListener(eventName, method, capture);
        } else {
            if (eventName != 'load' && eventName != 'resize')
                document.detachEvent('on' + eventName, method);
            else
                this.detachEvent('on' + eventName, method);
        }
    };
}

/* ==================== start it all up ==================== */
ContentFlowGlobal.init();




/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


jwplayer = function(a) { return jwplayer.constructor(a) }; jwplayer.constructor = function(a) { }; $jw = jwplayer; jwplayer.utils = function() { }; jwplayer.utils.typeOf = function(b) { var a = typeof b; if (a === "object") { if (b) { if (b instanceof Array) { a = "array" } } else { a = "null" } } return a }; jwplayer.utils.extend = function() { var a = jwplayer.utils.extend["arguments"]; if (a.length > 1) { for (var b = 1; b < a.length; b++) { for (element in a[b]) { a[0][element] = a[b][element] } } return a[0] } return null }; jwplayer.utils.extension = function(a) { return a.substr(a.lastIndexOf(".") + 1, a.length).toLowerCase() }; jwplayer.utils.html = function(a, b) { a.innerHTML = b }; jwplayer.utils.append = function(a, b) { a.appendChild(b) }; jwplayer.utils.wrap = function(a, b) { a.parentNode.replaceChild(b, a); b.appendChild(a) }; jwplayer.utils.ajax = function(d, c, a) { var b; if (window.XMLHttpRequest) { b = new XMLHttpRequest() } else { b = new ActiveXObject("Microsoft.XMLHTTP") } b.onreadystatechange = function() { if (b.readyState === 4) { if (b.status === 200) { if (c) { c(b) } } else { if (a) { a(d) } } } }; b.open("GET", d, true); b.send(null); return b }; jwplayer.utils.load = function(b, c, a) { b.onreadystatechange = function() { if (b.readyState === 4) { if (b.status === 200) { if (c) { c() } } else { if (a) { a() } } } } }; jwplayer.utils.find = function(b, a) { return b.getElementsByTagName(a) }; jwplayer.utils.append = function(a, b) { a.appendChild(b) }; jwplayer.utils.isIE = function() { return (! +"\v1") }; jwplayer.utils.isIOS = function() { var a = navigator.userAgent.toLowerCase(); return (a.match(/iP(hone|ad)/i) !== null) }; jwplayer.utils.hasHTML5 = function(b) { var a = document.createElement("video"); if (!!a.canPlayType) { if (b) { var d = {}; if (b.playlist && b.playlist.length) { d.file = b.playlist[0].file; d.levels = b.playlist[0].levels } else { d.file = b.file; d.levels = b.levels } if (d.file) { return jwplayer.utils.vidCanPlay(a, d.file) } else { if (d.levels && d.levels.length) { for (var c = 0; c < d.levels.length; c++) { if (d.levels[c].file && jwplayer.utils.vidCanPlay(a, d.levels[c].file)) { return true } } } } } else { return true } } return false }; jwplayer.utils.vidCanPlay = function(b, a) { var c = jwplayer.utils.strings.extension(a); if (jwplayer.utils.extensionmap[c] !== undefined) { sourceType = jwplayer.utils.extensionmap[c] } else { sourceType = "video/" + c + ";" } return (b.canPlayType(sourceType) || a.toLowerCase().indexOf("youtube.com") > -1) }; jwplayer.utils.hasFlash = function() { return (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] != "undefined") || (typeof window.ActiveXObject != "undefined") }; (function(e) { e.utils.mediaparser = function() { }; var g = { element: { width: "width", height: "height", id: "id", "class": "className", name: "name" }, media: { src: "file", preload: "preload", autoplay: "autostart", loop: "repeat", controls: "controls" }, source: { src: "file", type: "type", media: "media", "data-jw-width": "width", "data-jw-bitrate": "bitrate" }, video: { poster: "image"} }; var f = {}; e.utils.mediaparser.parseMedia = function(i) { return d(i) }; function c(j, i) { if (i === undefined) { i = g[j] } else { e.utils.extend(i, g[j]) } return i } function d(m, i) { if (f[m.tagName.toLowerCase()] && (i === undefined)) { return f[m.tagName.toLowerCase()](m) } else { i = c("element", i); var n = {}; for (var j in i) { if (j != "length") { var l = m.getAttribute(j); if (!(l === "" || l === undefined || l === null)) { n[i[j]] = m.getAttribute(j) } } } var k = m.style["#background-color"]; if (k && !(k == "transparent" || k == "rgba(0, 0, 0, 0)")) { n.screencolor = k } return n } } function h(o, k) { k = c("media", k); var m = []; if (e.utils.isIE()) { var l = o.nextSibling; if (l !== undefined) { while (l.tagName.toLowerCase() == "source") { m.push(a(l)); l = l.nextSibling } } } else { var j = e.utils.selectors("source", o); for (var n in j) { if (!isNaN(n)) { m.push(a(j[n])) } } } var p = d(o, k); if (p.file !== undefined) { m[0] = { file: p.file} } p.levels = m; return p } function a(k, j) { j = c("source", j); var i = d(k, j); i.width = i.width ? i.width : 0; i.bitrate = i.bitrate ? i.bitrate : 0; return i } function b(k, j) { j = c("video", j); var i = h(k, j); return i } e.utils.mediaparser.replaceMediaElement = function(i, k) { if (e.utils.isIE()) { var l = false; var n = []; var m = i.nextSibling; while (m && !l) { n.push(m); if (m.nodeType == 1 && m.tagName.toLowerCase() == ("/") + i.tagName.toLowerCase()) { l = true } m = m.nextSibling } if (l) { while (n.length > 0) { var j = n.pop(); j.parentNode.removeChild(j) } } i.outerHTML = k } }; f.media = h; f.audio = h; f.source = a; f.video = b })(jwplayer); jwplayer.utils.selectors = function(a, c) { if (c === undefined) { c = document } a = jwplayer.utils.strings.trim(a); var b = a.charAt(0); if (b == "#") { return c.getElementById(a.substr(1)) } else { if (b == ".") { if (c.getElementsByClassName) { return c.getElementsByClassName(a.substr(1)) } else { return jwplayer.utils.selectors.getElementsByTagAndClass("*", a.substr(1)) } } else { if (a.indexOf(".") > 0) { selectors = a.split("."); return jwplayer.utils.selectors.getElementsByTagAndClass(selectors[0], selectors[1]) } else { return c.getElementsByTagName(a) } } } return null }; jwplayer.utils.selectors.getElementsByTagAndClass = function(d, g, f) { elements = []; if (f === undefined) { f = document } var e = f.getElementsByTagName(d); for (var c = 0; c < e.length; c++) { if (e[c].className !== undefined) { var b = e[c].className.split(" "); for (var a = 0; a < b.length; a++) { if (b[a] == g) { elements.push(e[c]) } } } } return elements }; jwplayer.utils.strings = function() { }; jwplayer.utils.strings.trim = function(a) { return a.replace(/^\s*/, "").replace(/\s*$/, "") }; jwplayer.utils.strings.extension = function(a) { return a.substr(a.lastIndexOf(".") + 1, a.length).toLowerCase() }; (function(a) { a.utils.extensionmap = { "3gp": "video/3gpp", "3gpp": "video/3gpp", "3g2": "video/3gpp2", "3gpp2": "video/3gpp2", flv: "video/x-flv", f4a: "audio/mp4", f4b: "audio/mp4", f4p: "video/mp4", f4v: "video/mp4", mov: "video/quicktime", m4a: "audio/mp4", m4b: "audio/mp4", m4p: "audio/mp4", m4v: "video/mp4", mkv: "video/x-matroska", mp4: "video/mp4", sdp: "application/sdp", vp6: "video/x-vp6", aac: "audio/aac", mp3: "audio/mp3", ogg: "audio/ogg", ogv: "video/ogg", webm: "video/webm"} })(jwplayer); (function(b) { var a = []; b.constructor = function(c) { return b.api.selectPlayer(c) }; b.api = function() { }; b.api.events = { API_READY: "jwplayerAPIReady", JWPLAYER_READY: "jwplayerReady", JWPLAYER_FULLSCREEN: "jwplayerFullscreen", JWPLAYER_RESIZE: "jwplayerResize", JWPLAYER_ERROR: "jwplayerError", JWPLAYER_MEDIA_BUFFER: "jwplayerMediaBuffer", JWPLAYER_MEDIA_BUFFER_FULL: "jwplayerMediaBufferFull", JWPLAYER_MEDIA_ERROR: "jwplayerMediaError", JWPLAYER_MEDIA_LOADED: "jwplayerMediaLoaded", JWPLAYER_MEDIA_COMPLETE: "jwplayerMediaComplete", JWPLAYER_MEDIA_TIME: "jwplayerMediaTime", JWPLAYER_MEDIA_VOLUME: "jwplayerMediaVolume", JWPLAYER_MEDIA_META: "jwplayerMediaMeta", JWPLAYER_MEDIA_MUTE: "jwplayerMediaMute", JWPLAYER_PLAYER_STATE: "jwplayerPlayerState", JWPLAYER_PLAYLIST_LOADED: "jwplayerPlaylistLoaded", JWPLAYER_PLAYLIST_ITEM: "jwplayerPlaylistItem" }; b.api.events.state = { BUFFERING: "BUFFERING", IDLE: "IDLE", PAUSED: "PAUSED", PLAYING: "PLAYING" }; b.api.PlayerAPI = function(d) { this.container = d; this.id = d.id; var j = {}; var o = {}; var c = []; var g = undefined; var i = false; var h = []; var m = d.outerHTML; var n = {}; var k = 0; this.setPlayer = function(p) { g = p }; this.stateListener = function(p, q) { if (!o[p]) { o[p] = []; this.eventListener(b.api.events.JWPLAYER_PLAYER_STATE, f(p)) } o[p].push(q); return this }; function f(p) { return function(r) { var q = r.newstate, t = r.oldstate; if (q == p) { var s = o[q]; if (s) { for (var u in s) { if (typeof s[u] == "function") { s[u].call(this, { oldstate: t, newstate: q }) } } } } } } this.addInternalListener = function(p, q) { p.jwAddEventListener(q, 'function(dat) { jwplayer("' + this.id + '").dispatchEvent("' + q + '", dat); }') }; this.eventListener = function(p, q) { if (!j[p]) { j[p] = []; if (g && i) { this.addInternalListener(g, p) } } j[p].push(q); return this }; this.dispatchEvent = function(r) { if (j[r]) { var q = e(r, arguments[1]); for (var p in j[r]) { if (typeof j[r][p] == "function") { j[r][p].call(this, q) } } } }; function e(q, p) { var r = b.utils.extend({}, p); if (q == b.api.events.JWPLAYER_FULLSCREEN) { r.fullscreen = r.message; delete r.message } else { if (q == b.api.events.JWPLAYER_PLAYLIST_ITEM) { if (r.item && r.index === undefined) { r.index = r.item; delete r.item } } else { if (typeof r.data == "object") { r = b.utils.extend(r, r.data); delete r.data } } } return r } this.callInternal = function(q, p) { if (i) { if (typeof g != "undefined" && typeof g[q] == "function") { if (p !== undefined) { return (g[q])(p) } else { return (g[q])() } } return null } else { h.push({ method: q, parameters: p }) } }; this.playerReady = function(r) { i = true; if (!g) { this.setPlayer(document.getElementById(r.id)) } this.container = document.getElementById(this.id); for (var p in j) { this.addInternalListener(g, p) } this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM, function(s) { if (s.index !== undefined) { k = s.index } else { if (s.item !== undefined) { k = s.item } } n = {} }); this.eventListener(b.api.events.JWPLAYER_MEDIA_META, function(s) { b.utils.extend(n, s.metadata) }); this.dispatchEvent(b.api.events.API_READY); while (h.length > 0) { var q = h.shift(); this.callInternal(q.method, q.parameters) } }; this.getItemMeta = function() { return n }; this.getCurrentItem = function() { return k }; this.destroy = function() { j = {}; h = []; if (this.container.outerHTML != m) { b.api.destroyPlayer(this.id, m) } }; function l(r, t, s) { var p = []; if (!t) { t = 0 } if (!s) { s = r.length - 1 } for (var q = t; q <= s; q++) { p.push(r[q]) } return p } }; b.api.PlayerAPI.prototype = { container: undefined, options: undefined, id: undefined, getBuffer: function() { return this.callInternal("jwGetBuffer") }, getDuration: function() { return this.callInternal("jwGetDuration") }, getFullscreen: function() { return this.callInternal("jwGetFullscreen") }, getHeight: function() { return this.callInternal("jwGetHeight") }, getLockState: function() { return this.callInternal("jwGetLockState") }, getMeta: function() { return this.getItemMeta() }, getMute: function() { return this.callInternal("jwGetMute") }, getPlaylist: function() { var d = this.callInternal("jwGetPlaylist"); for (var c = 0; c < d.length; c++) { if (d[c].index === undefined) { d[c].index = c } } return d }, getPlaylistItem: function(c) { if (c == undefined) { c = this.getCurrentItem() } return this.getPlaylist()[c] }, getPosition: function() { return this.callInternal("jwGetPosition") }, getState: function() { return this.callInternal("jwGetState") }, getVolume: function() { return this.callInternal("jwGetVolume") }, getWidth: function() { return this.callInternal("jwGetWidth") }, setFullscreen: function(c) { if (c === undefined) { this.callInternal("jwSetFullscreen", true) } else { this.callInternal("jwSetFullscreen", c) } return this }, setMute: function(c) { if (c === undefined) { this.callInternal("jwSetMute", true) } else { this.callInternal("jwSetMute", c) } return this }, lock: function() { return this }, unlock: function() { return this }, load: function(c) { this.callInternal("jwLoad", c); return this }, playlistItem: function(c) { this.callInternal("jwPlaylistItem", c); return this }, playlistPrev: function() { this.callInternal("jwPlaylistPrev"); return this }, playlistNext: function() { this.callInternal("jwPlaylistNext"); return this }, resize: function(d, c) { this.container.width = d; this.container.height = c; return this }, play: function(c) { if (typeof c === "undefined") { var c = this.getState(); if (c == b.api.events.state.PLAYING || c == b.api.events.state.BUFFERING) { this.callInternal("jwPause") } else { this.callInternal("jwPlay") } } else { this.callInternal("jwPlay", c) } return this }, pause: function() { var c = this.getState(); switch (c) { case b.api.events.state.PLAYING: case b.api.events.state.BUFFERING: this.callInternal("jwPause"); break; case b.api.events.state.PAUSED: this.callInternal("jwPlay"); break } return this }, stop: function() { this.callInternal("jwStop"); return this }, seek: function(c) { this.callInternal("jwSeek", c); return this }, setVolume: function(c) { this.callInternal("jwSetVolume", c); return this }, onBufferChange: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER, c) }, onBufferFull: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_BUFFER_FULL, c) }, onError: function(c) { return this.eventListener(b.api.events.JWPLAYER_ERROR, c) }, onFullscreen: function(c) { return this.eventListener(b.api.events.JWPLAYER_FULLSCREEN, c) }, onMeta: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_META, c) }, onMute: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_MUTE, c) }, onPlaylist: function(c) { return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_LOADED, c) }, onPlaylistItem: function(c) { return this.eventListener(b.api.events.JWPLAYER_PLAYLIST_ITEM, c) }, onReady: function(c) { return this.eventListener(b.api.events.API_READY, c) }, onResize: function(c) { return this.eventListener(b.api.events.JWPLAYER_RESIZE, c) }, onComplete: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_COMPLETE, c) }, onTime: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_TIME, c) }, onVolume: function(c) { return this.eventListener(b.api.events.JWPLAYER_MEDIA_VOLUME, c) }, onBuffer: function(c) { return this.stateListener(b.api.events.state.BUFFERING, c) }, onPause: function(c) { return this.stateListener(b.api.events.state.PAUSED, c) }, onPlay: function(c) { return this.stateListener(b.api.events.state.PLAYING, c) }, onIdle: function(c) { return this.stateListener(b.api.events.state.IDLE, c) }, setup: function(c) { return this }, remove: function() { this.destroy() }, initializePlugin: function(c, d) { return this } }; b.api.selectPlayer = function(d) { var c; if (d == undefined) { d = 0 } if (d.nodeType) { c = d } else { if (typeof d == "string") { c = document.getElementById(d) } } if (c) { var e = b.api.playerById(c.id); if (e) { return e } else { return b.api.addPlayer(new b.api.PlayerAPI(c)) } } else { if (typeof d == "number") { return b.getPlayers()[d] } } return null }; b.api.playerById = function(d) { for (var c in a) { if (a[c].id == d) { return a[c] } } return null }; b.api.addPlayer = function(d) { for (var c in a) { if (a[c] == d) { return d } } a.push(d); return d }; b.api.destroyPlayer = function(f, d) { var e = -1; for (var h in a) { if (a[h].id == f) { e = h; continue } } if (e >= 0) { var c = document.getElementById(a[e].id); if (c) { if (d) { c.outerHTML = d } else { var g = document.createElement("div"); g.setAttribute("id", c.id); c.parentNode.replaceChild(g, c) } } a.splice(e, 1) } return null }; b.getPlayers = function() { return a.slice(0) } })(jwplayer); var _userPlayerReady = (typeof playerReady == "function") ? playerReady : undefined; playerReady = function(b) { var a = jwplayer.api.playerById(b.id); if (a) { a.playerReady(b) } if (_userPlayerReady) { _userPlayerReady.call(this, b) } }; (function(a) { a.embed = function() { }; a.embed.Embedder = function(c) { this.constructor(c) }; a.embed.defaults = { width: 400, height: 300, players: [{ type: "flash", src: "player.swf" }, { type: "html5"}], components: { controlbar: { position: "over"}} }; a.embed.Embedder.prototype = { config: undefined, api: undefined, events: {}, players: undefined, constructor: function(d) { this.api = d; var c = a.utils.mediaparser.parseMedia(this.api.container); this.config = this.parseConfig(a.utils.extend({}, a.embed.defaults, c, this.api.config)) }, embedPlayer: function() { var c = this.players[0]; if (c && c.type) { switch (c.type) { case "flash": if (a.utils.hasFlash()) { if (this.config.file && !this.config.provider) { switch (a.utils.extension(this.config.file).toLowerCase()) { case "webm": case "ogv": case "ogg": this.config.provider = "video"; break } } if (this.config.levels || this.config.playlist) { this.api.onReady(this.loadAfterReady(this.config)) } this.config.id = this.api.id; var e = a.embed.embedFlash(document.getElementById(this.api.id), c, this.config); this.api.container = e; this.api.setPlayer(e) } else { this.players.splice(0, 1); return this.embedPlayer() } break; case "html5": if (a.utils.hasHTML5(this.config)) { var d = a.embed.embedHTML5(document.getElementById(this.api.id), c, this.config); this.api.container = document.getElementById(this.api.id); this.api.setPlayer(d) } else { this.players.splice(0, 1); return this.embedPlayer() } break } } else { this.api.container.innerHTML = "<p>No suitable players found</p>" } this.setupEvents(); return this.api }, setupEvents: function() { for (evt in this.events) { if (typeof this.api[evt] == "function") { (this.api[evt]).call(this.api, this.events[evt]) } } }, loadAfterReady: function(c) { return function(e) { if (c.playlist) { this.load(c.playlist) } else { if (c.levels) { var d = this.getPlaylistItem(0); if (!d) { d = { file: c.levels[0].file, provider: (c.provider ? c.provider : "video")} } if (!d.image) { d.image = c.image } d.levels = c.levels; this.load(d) } } } }, parseConfig: function(c) { var d = a.utils.extend({}, c); if (d.events) { this.events = d.events; delete d.events } if (d.players) { this.players = d.players; delete d.players } if (d.plugins) { if (typeof d.plugins == "object") { d = a.utils.extend(d, a.embed.parsePlugins(d.plugins)) } } if (d.playlist && typeof d.playlist === "string" && !d["playlist.position"]) { d["playlist.position"] = d.playlist; delete d.playlist } if (d.controlbar && typeof d.controlbar === "string" && !d["controlbar.position"]) { d["controlbar.position"] = d.controlbar; delete d.controlbar } return d } }; a.embed.embedFlash = function(e, i, d) { var j = a.utils.extend({}, d); var g = j.width; delete j.width; var c = j.height; delete j.height; delete j.levels; delete j.playlist; a.embed.parseConfigBlock(j, "components"); a.embed.parseConfigBlock(j, "providers"); if (a.utils.isIE()) { var f = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + g + '" height="' + c + '" id="' + e.id + '" name="' + e.id + '">'; f += '<param name="movie" value="' + i.src + '">'; f += '<param name="allowfullscreen" value="true">'; f += '<param name="allowscriptaccess" value="always">'; f += '<param name="wmode" value="opaque">'; f += '<param name="flashvars" value="' + a.embed.jsonToFlashvars(j) + '">'; f += "</object>"; if (e.tagName.toLowerCase() == "video") { a.utils.mediaparser.replaceMediaElement(e, f) } else { e.outerHTML = f } return document.getElementById(e.id) } else { var h = document.createElement("object"); h.setAttribute("type", "application/x-shockwave-flash"); h.setAttribute("data", i.src); h.setAttribute("width", g); h.setAttribute("height", c); h.setAttribute("id", e.id); h.setAttribute("name", e.id); a.embed.appendAttribute(h, "allowfullscreen", "true"); a.embed.appendAttribute(h, "allowscriptaccess", "always"); a.embed.appendAttribute(h, "wmode", "opaque"); a.embed.appendAttribute(h, "flashvars", a.embed.jsonToFlashvars(j)); e.parentNode.replaceChild(h, e); return h } }; a.embed.embedHTML5 = function(d, f, e) { if (a.html5) { d.innerHTML = ""; var c = a.utils.extend({ screencolor: "0x000000" }, e); a.embed.parseConfigBlock(c, "components"); if (c.levels && !c.sources) { c.sources = e.levels } if (c.skin && c.skin.toLowerCase().indexOf(".zip") > 0) { c.skin = c.skin.replace(/\.zip/i, ".xml") } return new (a.html5(d)).setup(c) } else { return null } }; a.embed.appendAttribute = function(d, c, e) { var f = document.createElement("param"); f.setAttribute("name", c); f.setAttribute("value", e); d.appendChild(f) }; a.embed.jsonToFlashvars = function(d) { var c = ""; for (key in d) { c += key + "=" + escape(d[key]) + "&" } return c.substring(0, c.length - 1) }; a.embed.parsePlugins = function(e) { if (!e) { return {} } var g = {}, f = []; for (plugin in e) { var d = plugin.indexOf("-") > 0 ? plugin.substring(0, plugin.indexOf("-")) : plugin; var c = e[plugin]; f.push(plugin); for (param in c) { g[d + "." + param] = c[param] } } g.plugins = f.join(","); return g }; a.embed.parseConfigBlock = function(f, e) { if (f[e]) { var h = f[e]; for (var d in h) { var c = h[d]; if (typeof c == "string") { if (!f[d]) { f[d] = c } } else { for (var g in c) { if (!f[d + "." + g]) { f[d + "." + g] = c[g] } } } } delete f[e] } }; a.api.PlayerAPI.prototype.setup = function(d, e) { if (d && d.flashplayer && !d.players) { d.players = [{ type: "flash", src: d.flashplayer }, { type: "html5"}]; delete d.flashplayer } if (e && !d.players) { if (typeof e == "string") { d.players = [{ type: "flash", src: e}] } else { if (e instanceof Array) { d.players = e } else { if (typeof e == "object" && e.type) { d.players = [e] } } } } var c = this.id; this.remove(); var f = a(c); f.config = d; return (new a.embed.Embedder(f)).embedPlayer() }; function b() { if (!document.body) { return setTimeout(b, 15) } var c = a.utils.selectors.getElementsByTagAndClass("video", "jwplayer"); for (var d = 0; d < c.length; d++) { var e = c[d]; a(e.id).setup({ players: [{ type: "flash", src: "/jwplayer/player.swf" }, { type: "html5"}] }) } } b() })(jwplayer); (function(a) { a.html5 = function(b) { var c = b; this.setup = function(d) { a.utils.extend(this, new a.html5.api(c, d)); return this }; return this }; a.html5.version = "5.3" })(jwplayer); (function(b) { b.html5.utils = function() { }; b.html5.utils.extension = function(d) { return d.substr(d.lastIndexOf(".") + 1, d.length).toLowerCase() }; b.html5.utils.getAbsolutePath = function(j) { if (j === undefined) { return undefined } if (a(j)) { return j } var k = document.location.href.substring(0, document.location.href.indexOf("://") + 3); var h = document.location.href.substring(k.length, document.location.href.indexOf("/", k.length + 1)); var e; if (j.indexOf("/") === 0) { e = j.split("/") } else { var f = document.location.href.split("?")[0]; f = f.substring(k.length + h.length + 1, f.lastIndexOf("/")); e = f.split("/").concat(j.split("/")) } var d = []; for (var g = 0; g < e.length; g++) { if (!e[g] || e[g] === undefined || e[g] == ".") { continue } else { if (e[g] == "..") { d.pop() } else { d.push(e[g]) } } } return k + h + "/" + d.join("/") }; function a(e) { if (e === null) { return } var f = e.indexOf("://"); var d = e.indexOf("?"); return (f > 0 && (d < 0 || (d > f))) } b.html5.utils.mapEmpty = function(d) { for (var e in d) { return false } return true }; b.html5.utils.mapLength = function(e) { var d = 0; for (var f in e) { d++ } return d }; b.html5.utils.log = function(e, d) { if (typeof console != "undefined" && typeof console.log != "undefined") { if (d) { console.log(e, d) } else { console.log(e) } } }; b.html5.utils.css = function(e, h, d) { if (e !== undefined) { for (var f in h) { try { if (typeof h[f] === "undefined") { continue } else { if (typeof h[f] == "number" && !(f == "zIndex" || f == "opacity")) { if (isNaN(h[f])) { continue } if (f.match(/color/i)) { h[f] = "#" + c(h[f].toString(16), 6) } else { h[f] = h[f] + "px" } } } e.style[f] = h[f] } catch (g) { } } } }; function c(d, e) { while (d.length < e) { d = "0" + d } return d } b.html5.utils.isYouTube = function(d) { return d.indexOf("youtube.com") > -1 }; b.html5.utils.getYouTubeId = function(d) { d.indexOf("youtube.com" > 0) } })(jwplayer); (function(b) { var c = b.html5.utils.css; b.html5.view = function(p, n, e) { var s = p; var k = n; var v = e; var u; var f; var z; var q; var A; var m; function x() { u = document.createElement("div"); u.id = k.id; u.className = k.className; k.id = u.id + "_video"; c(u, { position: "relative", height: v.height, width: v.width, padding: 0, backgroundColor: C(), zIndex: 0 }); function C() { if (s.skin.getComponentSettings("display") && s.skin.getComponentSettings("display").backgroundcolor) { return s.skin.getComponentSettings("display").backgroundcolor } return parseInt("000000", 16) } c(k, { position: "absolute", width: v.width, height: v.height, top: 0, left: 0, zIndex: 1, margin: "auto", display: "block" }); b.utils.wrap(k, u); q = document.createElement("div"); q.id = u.id + "_displayarea"; u.appendChild(q) } function i() { for (var C in v.plugins.order) { var D = v.plugins.order[C]; if (v.plugins.object[D].getDisplayElement !== undefined) { v.plugins.object[D].height = B(v.plugins.object[D].getDisplayElement().style.height); v.plugins.object[D].width = B(v.plugins.object[D].getDisplayElement().style.width); v.plugins.config[D].currentPosition = v.plugins.config[D].position } } t() } function t(D) { if (v.getMedia() !== undefined) { for (var C in v.plugins.order) { var E = v.plugins.order[C]; if (v.plugins.object[E].getDisplayElement !== undefined) { if (v.config.chromeless || v.getMedia().hasChrome()) { v.plugins.config[E].currentPosition = b.html5.view.positions.NONE } else { v.plugins.config[E].currentPosition = v.plugins.config[E].position } } } } h(v.width, v.height) } function B(C) { if (typeof C == "number") { return C } if (C === "") { return 0 } return parseInt(C.replace("px", ""), 10) } function o() { m = setInterval(function() { if (u.width && u.height && (v.width !== B(u.width) || v.height !== B(u.height))) { h(B(u.width), B(u.height)) } else { var C = u.getBoundingClientRect(); if (v.width !== C.width || v.height !== C.height) { h(C.width, C.height) } delete C } }, 100) } this.setup = function(C) { k = C; x(); i(); s.jwAddEventListener(b.api.events.JWPLAYER_MEDIA_LOADED, t); o(); var D; if (window.onresize !== null) { D = window.onresize } window.onresize = function(E) { if (D !== undefined) { try { D(E) } catch (F) { } } if (s.jwGetFullscreen()) { v.width = window.innerWidth; v.height = window.innerHeight } h(v.width, v.height) } }; function g(C) { switch (C.keyCode) { case 27: if (s.jwGetFullscreen()) { s.jwSetFullscreen(false) } break; case 32: if (s.jwGetState() != b.api.events.state.IDLE && s.jwGetState() != b.api.events.state.PAUSED) { s.jwPause() } else { s.jwPlay() } break } } function h(F, C) { if (u.style.display == "none") { return } var E = [].concat(v.plugins.order); E.reverse(); A = E.length + 2; if (!v.fullscreen) { v.width = F; v.height = C; f = F; z = C; c(q, { top: 0, bottom: 0, left: 0, right: 0, width: F, height: C }); c(u, { height: z, width: f }); var D = l(r, E); if (D.length > 0) { A += D.length; l(j, D, true) } w() } else { l(y, E, true) } } function l(H, E, F) { var D = []; for (var C in E) { var I = E[C]; if (v.plugins.object[I].getDisplayElement !== undefined) { if (v.plugins.config[I].currentPosition.toUpperCase() !== b.html5.view.positions.NONE) { var G = H(I, A--); if (!G) { D.push(I) } else { v.plugins.object[I].resize(G.width, G.height); if (F) { delete G.width; delete G.height } c(v.plugins.object[I].getDisplayElement(), G) } } else { c(v.plugins.object[I].getDisplayElement(), { display: "none" }) } } } return D } function r(D, E) { if (v.plugins.object[D].getDisplayElement !== undefined) { if (a(v.plugins.config[D].position)) { if (v.plugins.object[D].getDisplayElement().parentNode === null) { u.appendChild(v.plugins.object[D].getDisplayElement()) } var C = d(D); C.zIndex = E; return C } } return false } function j(C, D) { if (v.plugins.object[C].getDisplayElement().parentNode === null) { q.appendChild(v.plugins.object[C].getDisplayElement()) } return { position: "absolute", width: (v.width - B(q.style.left) - B(q.style.right)), height: (v.height - B(q.style.top) - B(q.style.bottom)), zIndex: D} } function y(C, D) { return { position: "fixed", width: v.width, height: v.height, zIndex: D} } function w() { q.style.position = "absolute"; var C = { position: "absolute", width: B(q.style.width), height: B(q.style.height), top: B(q.style.top), left: B(q.style.left) }; c(v.getMedia().getDisplayElement(), C) } function d(D) { var E = { position: "absolute", margin: 0, padding: 0, top: null }; var C = v.plugins.config[D].currentPosition.toLowerCase(); switch (C.toUpperCase()) { case b.html5.view.positions.TOP: E.top = B(q.style.top); E.left = B(q.style.left); E.width = f - B(q.style.left) - B(q.style.right); E.height = v.plugins.object[D].height; q.style[C] = B(q.style[C]) + v.plugins.object[D].height + "px"; q.style.height = B(q.style.height) - E.height + "px"; break; case b.html5.view.positions.RIGHT: E.top = B(q.style.top); E.right = B(q.style.right); E.width = E.width = v.plugins.object[D].width; E.height = z - B(q.style.top) - B(q.style.bottom); q.style[C] = B(q.style[C]) + v.plugins.object[D].width + "px"; q.style.width = B(q.style.width) - E.width + "px"; break; case b.html5.view.positions.BOTTOM: E.bottom = B(q.style.bottom); E.left = B(q.style.left); E.width = f - B(q.style.left) - B(q.style.right); E.height = v.plugins.object[D].height; q.style[C] = B(q.style[C]) + v.plugins.object[D].height + "px"; q.style.height = B(q.style.height) - E.height + "px"; break; case b.html5.view.positions.LEFT: E.top = B(q.style.top); E.left = B(q.style.left); E.width = v.plugins.object[D].width; E.height = z - B(q.style.top) - B(q.style.bottom); q.style[C] = B(q.style[C]) + v.plugins.object[D].width + "px"; q.style.width = B(q.style.width) - E.width + "px"; break; default: break } return E } this.resize = h; this.fullscreen = function(D) { if (navigator.vendor.indexOf("Apple") === 0) { if (v.getMedia().getDisplayElement().webkitSupportsFullscreen) { if (D) { v.fullscreen = false; v.getMedia().getDisplayElement().webkitEnterFullscreen() } else { v.getMedia().getDisplayElement().webkitExitFullscreen() } } else { v.fullscreen = false } } else { if (D) { document.onkeydown = g; clearInterval(m); v.width = window.innerWidth; v.height = window.innerHeight; var C = { position: "fixed", width: "100%", height: "100%", top: 0, left: 0, zIndex: 2147483000 }; c(u, C); C.zIndex = 1; c(v.getMedia().getDisplayElement(), C); C.zIndex = 2; c(q, C) } else { document.onkeydown = ""; o(); v.width = f; v.height = z; c(u, { position: "relative", height: v.height, width: v.width, zIndex: 0 }) } h(v.width, v.height) } } }; function a(d) { return ([b.html5.view.positions.TOP, b.html5.view.positions.RIGHT, b.html5.view.positions.BOTTOM, b.html5.view.positions.LEFT].indexOf(d.toUpperCase()) > -1) } b.html5.view.positions = { TOP: "TOP", RIGHT: "RIGHT", BOTTOM: "BOTTOM", LEFT: "LEFT", OVER: "OVER", NONE: "NONE"} })(jwplayer); (function(a) { var b = { backgroundcolor: "", margin: 10, font: "Arial,sans-serif", fontsize: 10, fontcolor: parseInt("000000", 16), fontstyle: "normal", fontweight: "bold", buttoncolor: parseInt("ffffff", 16), position: a.html5.view.positions.BOTTOM, idlehide: false, layout: { left: { position: "left", elements: [{ name: "play", type: "button" }, { name: "divider", type: "divider" }, { name: "prev", type: "button" }, { name: "divider", type: "divider" }, { name: "next", type: "button" }, { name: "divider", type: "divider" }, { name: "elapsed", type: "text"}] }, center: { position: "center", elements: [{ name: "time", type: "slider"}] }, right: { position: "right", elements: [{ name: "duration", type: "text" }, { name: "blank", type: "button" }, { name: "divider", type: "divider" }, { name: "mute", type: "button" }, { name: "volume", type: "slider" }, { name: "divider", type: "divider" }, { name: "fullscreen", type: "button"}]}} }; _css = a.html5.utils.css; _hide = function(c) { _css(c, { display: "none" }) }; _show = function(c) { _css(c, { display: "block" }) }; a.html5.controlbar = function(j, L) { var i = j; var A = a.utils.extend({}, b, i.skin.getComponentSettings("controlbar"), L); if (a.html5.utils.mapLength(i.skin.getComponentLayout("controlbar")) > 0) { A.layout = i.skin.getComponentLayout("controlbar") } var P; var I; var O; var B; var t = "none"; var f; var h; var Q; var e; var d; var w; var s; var J = {}; var n = false; var c = {}; function H() { O = 0; B = 0; I = 0; if (!n) { var V = { height: i.skin.getSkinElement("controlbar", "background").height, backgroundColor: A.backgroundcolor }; P = document.createElement("div"); P.id = i.id + "_jwplayer_controlbar"; _css(P, V) } v("capLeft", "left", false, P); var W = { position: "absolute", height: i.skin.getSkinElement("controlbar", "background").height, background: " url(" + i.skin.getSkinElement("controlbar", "background").src + ") repeat-x center left", left: i.skin.getSkinElement("controlbar", "capLeft").width }; N("elements", P, W); v("capRight", "right", false, P) } this.getDisplayElement = function() { return P }; this.resize = function(X, V) { a.html5.utils.cancelAnimation(P); document.getElementById(i.id).onmousemove = x; d = X; w = V; x(); var W = u(); D({ id: i.id, duration: Q, position: h }); r({ id: i.id, bufferPercent: e }); return W }; function o() { var W = ["timeSlider", "volumeSlider", "timeSliderRail", "volumeSliderRail"]; for (var X in W) { var V = W[X]; if (typeof J[V] != "undefined") { c[V] = J[V].getBoundingClientRect() } } } function x() { a.html5.utils.cancelAnimation(P); if (g()) { a.html5.utils.fadeTo(P, 1, 0, 1, 0) } else { a.html5.utils.fadeTo(P, 0, 0.1, 1, 2) } } function g() { if (i.jwGetState() == a.api.events.state.IDLE || i.jwGetState() == a.api.events.state.PAUSED) { if (A.idlehide) { return false } return true } if (i.jwGetFullscreen()) { return false } if (A.position.toUpperCase() == a.html5.view.positions.OVER) { return false } return true } function N(Y, X, W) { var V; if (!n) { V = document.createElement("div"); J[Y] = V; V.id = P.id + "_" + Y; X.appendChild(V) } else { V = document.getElementById(P.id + "_" + Y) } if (W !== undefined) { _css(V, W) } return V } function G() { U(A.layout.left); U(A.layout.right, -1); U(A.layout.center) } function U(Y, V) { var Z = Y.position == "right" ? "right" : "left"; var X = a.utils.extend([], Y.elements); if (V !== undefined) { X.reverse() } for (var W = 0; W < X.length; W++) { z(X[W], Z) } } function E() { return I++ } function z(Z, ab) { var Y, W, X, V, ad; switch (Z.name) { case "play": v("playButton", ab, false); v("pauseButton", ab, true); K("playButton", "jwPlay"); K("pauseButton", "jwPause"); break; case "divider": v("divider" + E(), ab, true); break; case "prev": v("prevButton", ab, true); K("prevButton", "jwPlaylistPrev"); break; case "next": v("nextButton", ab, true); K("nextButton", "jwPlaylistNext"); break; case "elapsed": v("elapsedText", ab, true); break; case "time": W = i.skin.getSkinElement("controlbar", "timeSliderCapLeft") === undefined ? 0 : i.skin.getSkinElement("controlbar", "timeSliderCapLeft").width; X = i.skin.getSkinElement("controlbar", "timeSliderCapRight") === undefined ? 0 : i.skin.getSkinElement("controlbar", "timeSliderCapRight").width; Y = ab == "left" ? W : X; V = i.skin.getSkinElement("controlbar", "timeSliderRail").width + W + X; ad = { height: i.skin.getSkinElement("controlbar", "background").height, position: "absolute", top: 0, width: V }; ad[ab] = ab == "left" ? O : B; var aa = N("timeSlider", J.elements, ad); v("timeSliderCapLeft", ab, true, aa, ab == "left" ? 0 : Y); v("timeSliderRail", ab, false, aa, Y); v("timeSliderBuffer", ab, false, aa, Y); v("timeSliderProgress", ab, false, aa, Y); v("timeSliderThumb", ab, false, aa, Y); v("timeSliderCapRight", ab, true, aa, ab == "right" ? 0 : Y); M("time"); break; case "fullscreen": v("fullscreenButton", ab, false); v("normalscreenButton", ab, true); K("fullscreenButton", "jwSetFullscreen", true); K("normalscreenButton", "jwSetFullscreen", false); break; case "volume": W = i.skin.getSkinElement("controlbar", "volumeSliderCapLeft") === undefined ? 0 : i.skin.getSkinElement("controlbar", "volumeSliderCapLeft").width; X = i.skin.getSkinElement("controlbar", "volumeSliderCapRight") === undefined ? 0 : i.skin.getSkinElement("controlbar", "volumeSliderCapRight").width; Y = ab == "left" ? W : X; V = i.skin.getSkinElement("controlbar", "volumeSliderRail").width + W + X; ad = { height: i.skin.getSkinElement("controlbar", "background").height, position: "absolute", top: 0, width: V }; ad[ab] = ab == "left" ? O : B; var ac = N("volumeSlider", J.elements, ad); v("volumeSliderCapLeft", ab, true, ac, ab == "left" ? 0 : Y); v("volumeSliderRail", ab, true, ac, Y); v("volumeSliderProgress", ab, false, ac, Y); v("volumeSliderCapRight", ab, true, ac, ab == "right" ? 0 : Y); M("volume"); break; case "mute": v("muteButton", ab, false); v("unmuteButton", ab, true); K("muteButton", "jwSetMute", true); K("unmuteButton", "jwSetMute", false); break; case "duration": v("durationText", ab, true); break } } function v(Y, ac, ab, Z, V) { if ((i.skin.getSkinElement("controlbar", Y) !== undefined || Y.indexOf("Text") > 0 || Y.indexOf("divider") === 0) && !(Y.indexOf("divider") === 0 && s.indexOf("divider") === 0)) { s = Y; var X = { height: i.skin.getSkinElement("controlbar", "background").height, position: "absolute", display: "block", top: 0 }; if ((Y.indexOf("next") === 0 || Y.indexOf("prev") === 0) && i.jwGetPlaylist().length < 2) { ab = false; X.display = "none" } var aa; if (Y.indexOf("Text") > 0) { Y.innerhtml = "00:00"; X.font = A.fontsize + "px/" + (i.skin.getSkinElement("controlbar", "background").height + 1) + "px " + A.font; X.color = A.fontcolor; X.textAlign = "center"; X.fontWeight = A.fontweight; X.fontStyle = A.fontstyle; X.cursor = "default"; aa = 14 + 3 * A.fontsize } else { if (Y.indexOf("divider") === 0) { X.background = "url(" + i.skin.getSkinElement("controlbar", "divider").src + ") repeat-x center left"; aa = i.skin.getSkinElement("controlbar", "divider").width } else { X.background = "url(" + i.skin.getSkinElement("controlbar", Y).src + ") repeat-x center left"; aa = i.skin.getSkinElement("controlbar", Y).width } } if (ac == "left") { X.left = V === undefined ? O : V; if (ab) { O += aa } } else { if (ac == "right") { X.right = V === undefined ? B : V; if (ab) { B += aa } } } if (Z === undefined) { Z = J.elements } X.width = aa; if (n) { _css(J[Y], X) } else { var W = N(Y, Z, X); if (i.skin.getSkinElement("controlbar", Y + "Over") !== undefined) { W.onmouseover = function(ad) { W.style.backgroundImage = ["url(", i.skin.getSkinElement("controlbar", Y + "Over").src, ")"].join("") }; W.onmouseout = function(ad) { W.style.backgroundImage = ["url(", i.skin.getSkinElement("controlbar", Y).src, ")"].join("") } } } } } function C() { i.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_LOADED, y); i.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_BUFFER, r); i.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE, p); i.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_TIME, D); i.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_MUTE, T); i.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_VOLUME, k); i.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_COMPLETE, F) } function y() { H(); G(); u(); R() } function R() { D({ id: i.id, duration: i.jwGetDuration(), position: 0 }); r({ id: i.id, bufferProgress: 0 }); T({ id: i.id, mute: i.jwGetMute() }); p({ id: i.id, newstate: a.api.events.state.IDLE }); k({ id: i.id, volume: i.jwGetVolume() }) } function K(X, Y, W) { if (n) { return } if (i.skin.getSkinElement("controlbar", X) !== undefined) { var V = J[X]; if (V !== null) { _css(V, { cursor: "pointer" }); if (Y == "fullscreen") { V.onmouseup = function(Z) { Z.stopPropagation(); i.jwSetFullscreen(!i.jwGetFullscreen()) } } else { V.onmouseup = function(Z) { Z.stopPropagation(); if (W !== null) { i[Y](W) } else { i[Y]() } } } } } } function M(V) { if (n) { return } var W = J[V + "Slider"]; _css(J.elements, { cursor: "pointer" }); _css(W, { cursor: "pointer" }); W.onmousedown = function(X) { t = V }; W.onmouseup = function(X) { X.stopPropagation(); S(X.pageX) }; W.onmousemove = function(X) { if (t == "time") { f = true; var Y = X.pageX - c[V + "Slider"].left - window.pageXOffset; _css(J.timeSliderThumb, { left: Y }) } } } function S(W) { f = false; var V; if (t == "time") { V = W - c.timeSliderRail.left + window.pageXOffset; var Y = V / c.timeSliderRail.width * Q; if (Y < 0) { Y = 0 } else { if (Y > Q) { Y = Q - 3 } } i.jwSeek(Y); if (i.jwGetState() != a.api.events.state.PLAYING) { i.jwPlay() } } else { if (t == "volume") { V = W - c.volumeSliderRail.left - window.pageXOffset; var X = Math.round(V / c.volumeSliderRail.width * 100); if (X < 0) { X = 0 } else { if (X > 100) { X = 100 } } if (i.jwGetMute()) { i.jwSetMute(false) } i.jwSetVolume(X) } } t = "none" } function r(W) { if (W.bufferPercent !== null) { e = W.bufferPercent } var X = c.timeSliderRail.width; var V = isNaN(Math.round(X * e / 100)) ? 0 : Math.round(X * e / 100); _css(J.timeSliderBuffer, { width: V }) } function T(V) { if (V.mute) { _hide(J.muteButton); _show(J.unmuteButton); _hide(J.volumeSliderProgress) } else { _show(J.muteButton); _hide(J.unmuteButton); _show(J.volumeSliderProgress) } } function p(V) { if (V.newstate == a.api.events.state.BUFFERING || V.newstate == a.api.events.state.PLAYING) { _show(J.pauseButton); _hide(J.playButton) } else { _hide(J.pauseButton); _show(J.playButton) } x(); if (V.newstate == a.api.events.state.IDLE) { _hide(J.timeSliderBuffer); _hide(J.timeSliderProgress); _hide(J.timeSliderThumb); D({ id: i.id, duration: i.jwGetDuration(), position: 0 }) } else { _show(J.timeSliderBuffer); if (V.newstate != a.api.events.state.BUFFERING) { _show(J.timeSliderProgress); _show(J.timeSliderThumb) } } } function F(V) { D(a.utils.extend(V, { position: 0, duration: Q })) } function D(Y) { if (Y.position !== null) { h = Y.position } if (Y.duration !== null) { Q = Y.duration } var W = (h === Q === 0) ? 0 : h / Q; var V = isNaN(Math.round(c.timeSliderRail.width * W)) ? 0 : Math.round(c.timeSliderRail.width * W); var X = V; J.timeSliderProgress.style.width = V + "px"; if (!f) { if (J.timeSliderThumb) { J.timeSliderThumb.style.left = X + "px" } } if (J.durationText) { J.durationText.innerHTML = m(Q) } if (J.elapsedText) { J.elapsedText.innerHTML = m(h) } } function m(V) { str = "00:00"; if (V > 0) { str = Math.floor(V / 60) < 10 ? "0" + Math.floor(V / 60) + ":" : Math.floor(V / 60) + ":"; str += Math.floor(V % 60) < 10 ? "0" + Math.floor(V % 60) : Math.floor(V % 60) } return str } function l() { var Y, W; var X = document.getElementById(P.id + "_elements").childNodes; for (var V in document.getElementById(P.id + "_elements").childNodes) { if (isNaN(parseInt(V, 10))) { continue } if (X[V].id.indexOf(P.id + "_divider") === 0 && W.id.indexOf(P.id + "_divider") === 0) { X[V].style.display = "none" } else { if (X[V].id.indexOf(P.id + "_divider") === 0 && Y.style.display != "none") { X[V].style.display = "block" } } if (X[V].style.display != "none") { W = X[V] } Y = X[V] } } function u() { l(); if (i.jwGetFullscreen()) { _show(J.normalscreenButton); _hide(J.fullscreenButton) } else { _hide(J.normalscreenButton); _show(J.fullscreenButton) } var W = { width: d }; var V = {}; if (A.position.toUpperCase() == a.html5.view.positions.OVER || i.jwGetFullscreen()) { W.left = A.margin; W.width -= 2 * A.margin; W.top = w - i.skin.getSkinElement("controlbar", "background").height - A.margin; W.height = i.skin.getSkinElement("controlbar", "background").height } else { W.left = 0 } V.left = i.skin.getSkinElement("controlbar", "capLeft").width; V.width = W.width - i.skin.getSkinElement("controlbar", "capLeft").width - i.skin.getSkinElement("controlbar", "capRight").width; var X = i.skin.getSkinElement("controlbar", "timeSliderCapLeft") === undefined ? 0 : i.skin.getSkinElement("controlbar", "timeSliderCapLeft").width; _css(J.timeSliderRail, { width: (V.width - O - B), left: X }); if (J.timeSliderCapRight !== undefined) { _css(J.timeSliderCapRight, { left: X + (V.width - O - B) }) } _css(P, W); _css(J.elements, V); o(); return W } function k(Z) { if (J.volumeSliderRail !== undefined) { var X = isNaN(Z.volume / 100) ? 1 : Z.volume / 100; var Y = parseInt(J.volumeSliderRail.style.width.replace("px", ""), 10); var V = isNaN(Math.round(Y * X)) ? 0 : Math.round(Y * X); var aa = parseInt(J.volumeSliderRail.style.right.replace("px", ""), 10); var W = i.skin.getSkinElement("controlbar", "volumeSliderCapLeft") === undefined ? 0 : i.skin.getSkinElement("controlbar", "volumeSliderCapLeft").width; _css(J.volumeSliderProgress, { width: V, left: W }); if (J.volumeSliderCapLeft !== undefined) { _css(J.volumeSliderCapLeft, { left: 0 }) } } } function q() { H(); G(); o(); n = true; C(); R(); P.style.opacity = A.idlehide ? 0 : 1 } q(); return this } })(jwplayer); (function(b) { var a = ["width", "height", "state", "playlist", "item", "position", "buffer", "duration", "volume", "mute", "fullscreen"]; b.html5.controller = function(s, q, d, p) { var v = s; var x = d; var c = p; var j = q; var z = true; var t = (x.config.debug !== undefined) && (x.config.debug.toString().toLowerCase() == "console"); var h = new b.html5.eventdispatcher(j.id, t); b.utils.extend(this, h); function l(C) { h.sendEvent(C.type, C) } x.addGlobalListener(l); function o() { try { if (x.playlist[0].levels[0].file.length > 0) { if (z || x.state == b.api.events.state.IDLE) { x.setActiveMediaProvider(x.playlist[x.item]); x.addEventListener(b.api.events.JWPLAYER_MEDIA_BUFFER_FULL, function() { x.getMedia().play() }); if (x.config.repeat) { x.addEventListener(b.api.events.JWPLAYER_MEDIA_COMPLETE, function(D) { setTimeout(m, 25) }) } x.getMedia().load(x.playlist[x.item]); z = false } else { if (x.state == b.api.events.state.PAUSED) { x.getMedia().play() } } } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function A() { try { if (x.playlist[0].levels[0].file.length > 0) { switch (x.state) { case b.api.events.state.PLAYING: case b.api.events.state.BUFFERING: x.getMedia().pause(); break } } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function w(C) { try { if (x.playlist[0].levels[0].file.length > 0) { switch (x.state) { case b.api.events.state.PLAYING: case b.api.events.state.PAUSED: case b.api.events.state.BUFFERING: x.getMedia().seek(C); break } } return true } catch (D) { h.sendEvent(b.api.events.JWPLAYER_ERROR, D) } return false } function i() { try { if (x.playlist[0].levels[0].file.length > 0 && x.state != b.api.events.state.IDLE) { x.getMedia().stop() } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function f() { try { if (x.playlist[0].levels[0].file.length > 0) { if (x.config.shuffle) { n(r()) } else { if (x.item + 1 == x.playlist.length) { n(0) } else { n(x.item + 1) } } } if (x.state != b.api.events.state.PLAYING && x.state != b.api.events.state.BUFFERING) { o() } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function e() { try { if (x.playlist[0].levels[0].file.length > 0) { if (x.config.shuffle) { n(r()) } else { if (x.item === 0) { n(x.playlist.length - 1) } else { n(x.item - 1) } } } if (x.state != b.api.events.state.PLAYING && x.state != b.api.events.state.BUFFERING) { o() } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function r() { var C = null; if (x.playlist.length > 1) { while (C === null) { C = Math.floor(Math.random() * x.playlist.length); if (C == x.item) { C = null } } } else { C = 0 } return C } function n(D) { x.resetEventListeners(); x.addGlobalListener(l); try { if (x.playlist[0].levels[0].file.length > 0) { var E = x.state; if (E !== b.api.events.state.IDLE) { i() } x.item = D; z = true; h.sendEvent(b.api.events.JWPLAYER_PLAYLIST_ITEM, { item: D }); if (E == b.api.events.state.PLAYING || E == b.api.events.state.BUFFERING) { o() } } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function y(D) { try { switch (typeof (D)) { case "number": x.getMedia().volume(D); break; case "string": x.getMedia().volume(parseInt(D, 10)); break } return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function k(D) { try { x.getMedia().mute(D); return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function g(D, C) { try { x.width = D; x.height = C; c.resize(D, C); return true } catch (E) { h.sendEvent(b.api.events.JWPLAYER_ERROR, E) } return false } function u(D) { try { x.fullscreen = D; c.fullscreen(D); return true } catch (C) { h.sendEvent(b.api.events.JWPLAYER_ERROR, C) } return false } function B(C) { try { i(); x.loadPlaylist(C); z = true; return true } catch (D) { h.sendEvent(b.api.events.JWPLAYER_ERROR, D) } return false } b.html5.controller.repeatoptions = { LIST: "LIST", ALWAYS: "ALWAYS", SINGLE: "SINGLE", NONE: "NONE" }; function m() { x.resetEventListeners(); x.addGlobalListener(l); switch (x.config.repeat.toUpperCase()) { case b.html5.controller.repeatoptions.SINGLE: o(); break; case b.html5.controller.repeatoptions.ALWAYS: if (x.item == x.playlist.length - 1 && !x.config.shuffle) { n(0); o() } else { f() } break; case b.html5.controller.repeatoptions.LIST: if (x.item == x.playlist.length - 1 && !x.config.shuffle) { n(0) } else { f() } break } } this.play = o; this.pause = A; this.seek = w; this.stop = i; this.next = f; this.prev = e; this.item = n; this.setVolume = y; this.setMute = k; this.resize = g; this.setFullscreen = u; this.load = B } })(jwplayer); (function(a) { a.html5.defaultSkin = function() { this.text = '<?xml version="1.0" ?><skin author="LongTail Video" name="Five" version="1.0"><settings><setting name="backcolor" value="0xFFFFFF"/><setting name="frontcolor" value="0x000000"/><setting name="lightcolor" value="0x000000"/><setting name="screencolor" value="0x000000"/></settings><components><component name="controlbar"><settings><setting name="margin" value="20"/><setting name="fontsize" value="11"/></settings><elements><element name="background" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFJJREFUeNrslLENwAAIwxLU/09j5AiOgD5hVQzNAVY8JK4qEfHMIKBnd2+BQlBINaiRtL/aV2rdzYBsM6CIONbI1NZENTr3RwdB2PlnJgJ6BRgA4hwu5Qg5iswAAAAASUVORK5CYII="/><element name="capLeft" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAYCAIAAAC0rgCNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD5JREFUeNosi8ENACAMAgnuv14H0Z8asI19XEjhOiKCMmibVgJTUt7V6fe9KXOtSQCfctJHu2q3/ot79hNgANc2OTz9uTCCAAAAAElFTkSuQmCC"/><element name="capRight" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAYCAIAAAC0rgCNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD5JREFUeNosi8ENACAMAgnuv14H0Z8asI19XEjhOiKCMmibVgJTUt7V6fe9KXOtSQCfctJHu2q3/ot79hNgANc2OTz9uTCCAAAAAElFTkSuQmCC"/><element name="divider" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAYCAIAAAC0rgCNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD5JREFUeNosi8ENACAMAgnuv14H0Z8asI19XEjhOiKCMmibVgJTUt7V6fe9KXOtSQCfctJHu2q3/ot79hNgANc2OTz9uTCCAAAAAElFTkSuQmCC"/><element name="playButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAYCAYAAAAVibZIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEhJREFUeNpiYqABYBo1dNRQ+hr6H4jvA3E8NS39j4SpZvh/LJig4YxEGEqy3kET+w+AOGFQRhTJhrEQkGcczfujhg4CQwECDADpTRWU/B3wHQAAAABJRU5ErkJggg=="/><element name="pauseButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAYCAYAAAAVibZIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAChJREFUeNpiYBgFo2DwA0YC8v/R1P4nRu+ooaOGUtnQUTAKhgIACDAAFCwQCfAJ4gwAAAAASUVORK5CYII="/><element name="prevButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAYCAYAAAAVibZIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEtJREFUeNpiYBgFo2Dog/9QDAPyQHweTYwiQ/2B+D0Wi8g2tB+JTdBQRiIMJVkvEy0iglhDF9Aq9uOpHVEwoE+NJDUKRsFgAAABBgDe2hqZcNNL0AAAAABJRU5ErkJggg=="/><element name="nextButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAYCAYAAAAVibZIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAElJREFUeNpiYBgFo2Dog/9AfB6I5dHE/lNqKAi/B2J/ahsKw/3EGMpIhKEk66WJoaR6fz61IyqemhEFSlL61ExSo2AUDAYAEGAAiG4hj+5t7M8AAAAASUVORK5CYII="/><element name="timeSliderRail" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADxJREFUeNpiYBgFo2AU0Bwwzluw+D8tLWARFhKiqQ9YuLg4aWsBGxs7bS1gZ6e5BWyjSX0UjIKhDgACDABlYQOGh5pYywAAAABJRU5ErkJggg=="/><element name="timeSliderBuffer" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpiYBgFo2AU0Bww1jc0/aelBSz8/Pw09QELOzs7bS1gY2OjrQWsrKy09gHraFIfBaNgqAOAAAMAvy0DChXHsZMAAAAASUVORK5CYII="/><element name="timeSliderProgress" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAClJREFUeNpiYBgFo2AU0BwwAvF/WlrARGsfjFow8BaMglEwCugAAAIMAOHfAQunR+XzAAAAAElFTkSuQmCC"/><element name="timeSliderThumb" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAICAYAAAA870V8AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABZJREFUeNpiZICA/yCCiQEJUJcDEGAAY0gBD1/m7Q0AAAAASUVORK5CYII="/><element name="muteButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAYCAYAAADKx8xXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiYBgFIw3MB+L/5Gj8j6yRiRTFyICJXHfTXyMLAXlGati4YDRFDj8AEGAABk8GSqqS4CoAAAAASUVORK5CYII="/><element name="unmuteButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAYCAYAAADKx8xXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpiYBgFgxz8p7bm+cQa+h8LHy7GhEcjIz4bmAjYykiun/8j0fakGPIfTfPgiSr6aB4FVAcAAQYAWdwR1G1Wd2gAAAAASUVORK5CYII="/><element name="volumeSliderRail" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAYCAYAAADkgu3FAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGpJREFUeNpi/P//PwM9ABMDncCoRYPfIqqDZcuW1UPp/6AUDcNM1DQYKtRAlaAj1mCSLSLXYIIWUctgDItoZfDA5aOoqKhGEANIM9LVR7SymGDQUctikuOIXkFNdhHEOFrDjlpEd4sAAgwAriRMub95fu8AAAAASUVORK5CYII="/><element name="volumeSliderProgress" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAYCAYAAADkgu3FAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFtJREFUeNpi/P//PwM9ABMDncCoRYPfIlqAeij9H5SiYZiqBqPTlFqE02BKLSLaYFItIttgQhZRzWB8FjENiuRJ7aAbsMQwYMl7wDIsWUUQ42gNO2oR3S0CCDAAKhKq6MLLn8oAAAAASUVORK5CYII="/><element name="fullscreenButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAE5JREFUeNpiYBgFo2DQA0YC8v/xqP1PjDlMRDrEgUgxkgHIlfZoriVGjmzLsLFHAW2D6D8eA/9Tw7L/BAwgJE90PvhPpNgoGAVDEQAEGAAMdhTyXcPKcAAAAABJRU5ErkJggg=="/><element name="normalscreenButton" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEZJREFUeNpiYBgFo2DIg/9UUkOUAf8JiFFsyX88fJyAkcQgYMQjNkzBoAgiezyRbE+tFGSPxQJ7auYBmma0UTAKBhgABBgAJAEY6zON61sAAAAASUVORK5CYII="/></elements></component><component name="display"><elements><element name="background" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEpJREFUeNrszwENADAIA7DhX8ENoBMZ5KR10EryckCJiIiIiIiIiIiIiIiIiIiIiIh8GmkRERERERERERERERERERERERGRHSPAAPlXH1phYpYaAAAAAElFTkSuQmCC"/><element name="playIcon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALdJREFUeNrs18ENgjAYhmFouDOCcQJGcARHgE10BDcgTOIosAGwQOuPwaQeuFRi2p/3Sb6EC5L3QCxZBgAAAOCorLW1zMn65TrlkH4NcV7QNcUQt7Gn7KIhxA+qNIR81spOGkL8oFJDyLJRdosqKDDkK+iX5+d7huzwM40xptMQMkjIOeRGo+VkEVvIPfTGIpKASfYIfT9iCHkHrBEzf4gcUQ56aEzuGK/mw0rHpy4AAACAf3kJMACBxjAQNRckhwAAAABJRU5ErkJggg=="/><element name="muteIcon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNrs1jEOgCAMBVAg7t5/8qaoIy4uoobyXsLCxA+0NCUAAADGUWvdQoQ41x4ixNBB2hBvBskdD3w5ZCkl3+33VqI0kjBBlh9rp+uTcyOP33TnolfsU85XX3yIRpQph8ZQY3wTZtU5AACASA4BBgDHoVuY1/fvOQAAAABJRU5ErkJggg=="/><element name="errorIcon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWlJREFUeNrsl+1twjAQhsHq/7BBYQLYIBmBDcoGMAIjtBPQTcII2SDtBDBBwrU6pGsUO7YbO470PtKJkz9iH++d4ywWAAAAAABgljRNsyWr2bZzDuJG1rLdZhcMbTjrBCGDyUKsqQLFciJb9bSvuG/WagRVRUVUI6gqy5HVeKWfSgRyJruKIU//TrZTSn2nmlaXThrloi/v9F2STC1W4+Aw5cBzkquRc09bofFNc6YLxEON0VUZS5FPTftO49vMjRsIF3RhOGr7/D/pJw+FKU+q0vDyq8W42jCunDqI3LC5XxNj2wHLU1XjaRnb0Lhykhqhhd8MtSF5J9tbjCv4mXGvKJz/65FF/qJryyaaIvzP2QRxZTX2nTuXjvV/VPFSwyLnW7mpH99yTh1FEVro6JBSd40/pMrRdV8vPtcKl28T2pT8TnFZ4yNosct3Q0io6JfBiz1FlGdqVQH3VHnepAEAAAAAADDzEGAAcTwB10jWgxcAAAAASUVORK5CYII="/><element name="bufferIcon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuhJREFUeNrsWr9rU1EUznuNGqvFQh1ULOhiBx0KDtIuioO4pJuik3FxFfUPaAV1FTdx0Q5d2g4FFxehTnEpZHFoBy20tCIWtGq0TZP4HfkeHB5N8m6Sl/sa74XDybvv3vvOd8/Pe4lXrVZT3dD8VJc0B8QBcUAcEAfESktHGeR5XtMfqFQq/f92zPe/NbtGlKTdCY30kuxrpMGO94BlQCXs+rbh3ONgA6BlzP1p20d80gEI5hmA2A92Qua1Q2PtAFISM+bvjMG8U+Q7oA3rQGASwrYCU6WpNdLGYbA+Pq5jjXIiwi8EEa2UDbQSaKOIuV+SlkcCrfjY8XTI9EpKGwP0C2kru2hLtHqa4zoXtZRWyvi4CLwv9Opr6Hkn6A9HKgEANsQ1iqC3Ub/vRUk2JgmRkatK36kVrnt0qObunwUdUUMXMWYpakJsO5Am8tAw2GBIgwWA+G2S2dMpiw0gDioQRQJoKhRb1QiDwlHZUABYbaXWsm5ae6loTE4ZDxN4CZar8foVzOJ2iyZ2kWF3t7YIevffaMT5yJ70kQb2fQ1sE5SHr2wazs2wgMxgbsEKEAgxAvZUJbQLBGTSBMgNrncJbA6AljtS/eKDJ0Ez+DmrQEzXS2h1Ck25kAg0IZcUOaydCy4sYnN2fOA+2AP16gNoHALlQ+fwH7XO4CxLenUpgj4xr6ugY2roPMbMx+Xs18m/E8CVEIhxsNeg83XWOAN6grG3lGbk8uE5fr4B/WH3cJw+co/l9nTYsSGYCJ/lY5/qv0thn6nrIWmjeJcPSnWOeY++AkF8tpJHIMAUs/MaBBpj3znZfQo5psY+ZrG4gv5HickjEOymKjEeRpgyST6IuZcTcWbnjcgdPi5ghxciRKsl1lDSsgwA1i8fssonJgzmTSqfGUkCENndNdAL7PS6QQ7ZYISTo+1qq0LEWjTWcvY4isa4z+yfQB+7ooyHVg5RI7/i1Ijn/vnggDggDogD4oC00P4KMACd/juEHOrS4AAAAABJRU5ErkJggg=="/></elements></component><component name="dock"><elements><element name="button" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFBJREFUeNrs0cEJACAQA8Eofu0fu/W6EM5ZSAFDRpKTBs00CQQEBAQEBAQEBAQEBAQEBATkK8iqbY+AgICAgICAgICAgICAgICAgIC86QowAG5PAQzEJ0lKAAAAAElFTkSuQmCC"/></elements></component><component name="playlist"><elements><element name="item" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAIAAAC1nk4lAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHhJREFUeNrs2NEJwCAMBcBYuv/CFuIE9VN47WWCR7iocXR3pdWdGPqqwIoMjYfQeAiNh9B4JHc6MHQVHnjggQceeOCBBx77TifyeOY0iHi8DqIdEY8dD5cL094eePzINB5CO/LwcOTptNB4CP25L4TIbZzpU7UEGAA5wz1uF5rF9AAAAABJRU5ErkJggg=="/><element name="sliderRail" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA8CAIAAADpFA0BAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADhJREFUeNrsy6ENACAMAMHClp2wYxZLAg5Fcu9e3OjuOKqqfTMzbs14CIZhGIZhGIZhGP4VLwEGAK/BBnVFpB0oAAAAAElFTkSuQmCC"/><element name="sliderThumb" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA8CAIAAADpFA0BAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNrsy7ENACAMBLE8++8caFFKKiRffU53112SGs3ttOohGIZhGIZhGIZh+Fe8BRgAiaUGde6NOSEAAAAASUVORK5CYII="/></elements></component></components></skin>'; this.xml = null; if (window.DOMParser) { parser = new DOMParser(); this.xml = parser.parseFromString(this.text, "text/xml") } else { this.xml = new ActiveXObject("Microsoft.XMLDOM"); this.xml.async = "false"; this.xml.loadXML(this.text) } return this } })(jwplayer); (function(a) { _css = a.html5.utils.css; _hide = function(b) { _css(b, { display: "none" }) }; _show = function(b) { _css(b, { display: "block" }) }; a.html5.display = function(k, s) { var q = k; var d = {}; var f; var t; var r; var l; var g; var j = q.skin.getComponentSettings("display").bufferrotation === undefined ? 15 : parseInt(q.skin.getComponentSettings("display").bufferrotation, 10); var e = q.skin.getComponentSettings("display").bufferinterval === undefined ? 100 : parseInt(q.skin.getComponentSettings("display").bufferinterval, 10); var c = { display: { style: { cursor: "pointer", top: 0, left: 0 }, click: p }, display_icon: { style: { cursor: "pointer", position: "absolute", top: ((q.skin.getSkinElement("display", "background").height - q.skin.getSkinElement("display", "playIcon").height) / 2), left: ((q.skin.getSkinElement("display", "background").width - q.skin.getSkinElement("display", "playIcon").width) / 2), border: 0, margin: 0, padding: 0, zIndex: 3} }, display_iconBackground: { style: { cursor: "pointer", position: "absolute", top: ((t - q.skin.getSkinElement("display", "background").height) / 2), left: ((f - q.skin.getSkinElement("display", "background").width) / 2), border: 0, backgroundImage: (["url(", q.skin.getSkinElement("display", "background").src, ")"]).join(""), width: q.skin.getSkinElement("display", "background").width, height: q.skin.getSkinElement("display", "background").height, margin: 0, padding: 0, zIndex: 2} }, display_image: { style: { display: "none", width: f, height: t, position: "absolute", cursor: "pointer", left: 0, top: 0, margin: 0, padding: 0, textDecoration: "none", zIndex: 1} }, display_text: { style: { zIndex: 4, position: "relative", opacity: 0.8, backgroundColor: parseInt("000000", 16), color: parseInt("ffffff", 16), textAlign: "center", fontFamily: "Arial,sans-serif", padding: "0 5px", fontSize: 14}} }; q.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE, i); q.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_MUTE, i); q.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_ITEM, i); q.jwAddEventListener(a.api.events.JWPLAYER_ERROR, o); u(); function u() { d.display = n("div", "display"); d.display_text = n("div", "display_text"); d.display.appendChild(d.display_text); d.display_image = n("img", "display_image"); d.display_image.onerror = function(v) { _hide(d.display_image) }; d.display_icon = n("div", "display_icon"); d.display_iconBackground = n("div", "display_iconBackground"); d.display.appendChild(d.display_image); d.display_iconBackground.appendChild(d.display_icon); d.display.appendChild(d.display_iconBackground); b() } this.getDisplayElement = function() { return d.display }; this.resize = function(w, v) { f = w; t = v; _css(d.display, { width: w, height: v }); _css(d.display_text, { width: (w - 10), top: ((t - d.display_text.getBoundingClientRect().height) / 2) }); _css(d.display_image, { width: w, height: v }); _css(d.display_iconBackground, { top: ((t - q.skin.getSkinElement("display", "background").height) / 2), left: ((f - q.skin.getSkinElement("display", "background").width) / 2) }); i({}) }; function n(v, x) { var w = document.createElement(v); w.id = q.id + "_jwplayer_" + x; _css(w, c[x].style); return w } function b() { for (var v in d) { if (c[v].click !== undefined) { d[v].onclick = c[v].click } } } function p(v) { if (typeof v.preventDefault != "undefined") { v.preventDefault() } else { v.returnValue = false } if (q.jwGetState() != a.api.events.state.PLAYING) { q.jwPlay() } else { q.jwPause() } } function h(v) { if (g) { return } _show(d.display_iconBackground); d.display_icon.style.backgroundImage = (["url(", q.skin.getSkinElement("display", v).src, ")"]).join(""); _css(d.display_icon, { display: "block", width: q.skin.getSkinElement("display", v).width, height: q.skin.getSkinElement("display", v).height, top: (q.skin.getSkinElement("display", "background").height - q.skin.getSkinElement("display", v).height) / 2, left: (q.skin.getSkinElement("display", "background").width - q.skin.getSkinElement("display", v).width) / 2 }); if (q.skin.getSkinElement("display", v + "Over") !== undefined) { d.display_icon.onmouseover = function(w) { d.display_icon.style.backgroundImage = ["url(", q.skin.getSkinElement("display", v + "Over").src, ")"].join("") }; d.display_icon.onmouseout = function(w) { d.display_icon.style.backgroundImage = ["url(", q.skin.getSkinElement("display", v).src, ")"].join("") } } else { d.display_icon.onmouseover = null; d.display_icon.onmouseout = null } } function m() { _hide(d.display_icon); _hide(d.display_iconBackground) } function o(v) { g = true; m(); d.display_text.innerHTML = v.error; _show(d.display_text); d.display_text.style.top = ((t - d.display_text.getBoundingClientRect().height) / 2) + "px" } function i(v) { if ((v.type == a.api.events.JWPLAYER_PLAYER_STATE || v.type == a.api.events.JWPLAYER_PLAYLIST_ITEM) && g) { g = false; _hide(d.display_text) } if (l !== undefined) { clearInterval(l); l = null; a.html5.utils.animations.rotate(d.display_icon, 0) } switch (q.jwGetState()) { case a.api.events.state.BUFFERING: h("bufferIcon"); r = 0; l = setInterval(function() { r += j; a.html5.utils.animations.rotate(d.display_icon, r % 360) }, e); h("bufferIcon"); break; case a.api.events.state.PAUSED: _css(d.display_image, { background: "transparent no-repeat center center" }); h("playIcon"); break; case a.api.events.state.IDLE: if (q.jwGetPlaylist()[q.jwGetItem()].image) { _css(d.display_image, { display: "block" }); d.display_image.src = a.html5.utils.getAbsolutePath(q.jwGetPlaylist()[q.jwGetItem()].image) } else { _css(d.display_image, { display: "none" }); delete d.display_image.src } h("playIcon"); break; default: if (q.jwGetMute()) { _css(d.display_image, { display: "none" }); delete d.display_image.src; h("muteIcon") } else { _css(d.display_image, { display: "none" }); delete d.display_image.src; _hide(d.display_iconBackground); _hide(d.display_icon) } break } } return this } })(jwplayer); (function(jwplayer) { jwplayer.html5.eventdispatcher = function(id, debug) { var _id = id; var _debug = debug; var _listeners; var _globallisteners; this.resetEventListeners = function() { _listeners = {}; _globallisteners = [] }; this.resetEventListeners(); this.addEventListener = function(type, listener, count) { try { if (_listeners[type] === undefined) { _listeners[type] = [] } if (typeof (listener) == "string") { eval("listener = " + listener) } _listeners[type].push({ listener: listener, count: count }) } catch (err) { jwplayer.html5.utils.log("error", err) } return false }; this.removeEventListener = function(type, listener) { try { for (var lisenterIndex in _listeners[type]) { if (_listeners[type][lisenterIndex].toString() == listener.toString()) { _listeners[type].slice(lisenterIndex, lisenterIndex + 1); break } } } catch (err) { jwplayer.html5.utils.log("error", err) } return false }; this.addGlobalListener = function(listener, count) { try { if (typeof (listener) == "string") { eval("listener = " + listener) } _globallisteners.push({ listener: listener, count: count }) } catch (err) { jwplayer.html5.utils.log("error", err) } return false }; this.removeGlobalListener = function(listener) { try { for (var lisenterIndex in _globallisteners) { if (_globallisteners[lisenterIndex].toString() == listener.toString()) { _globallisteners.slice(lisenterIndex, lisenterIndex + 1); break } } } catch (err) { jwplayer.html5.utils.log("error", err) } return false }; this.sendEvent = function(type, data) { if (data === undefined) { data = {} } jwplayer.utils.extend(data, { id: _id, version: jwplayer.html5.version, type: type }); if (_debug) { jwplayer.html5.utils.log(type, data) } for (var listenerIndex in _listeners[type]) { try { _listeners[type][listenerIndex].listener(data) } catch (err) { jwplayer.html5.utils.log("There was an error while handling a listener", _listeners[type][listenerIndex].listener, err) } if (_listeners[type][listenerIndex].count === 1) { delete _listeners[type][listenerIndex] } else { if (_listeners[type][listenerIndex].count > 0) { _listeners[type][listenerIndex].count = _listeners[type][listenerIndex].count - 1 } } } for (var globalListenerIndex in _globallisteners) { try { _globallisteners[globalListenerIndex].listener(data) } catch (err) { jwplayer.html5.utils.log("There was an error while handling a listener", _globallisteners[globalListenerIndex].listener, err) } if (_globallisteners[globalListenerIndex].count === 1) { delete _globallisteners[globalListenerIndex] } else { if (_globallisteners[globalListenerIndex].count > 0) { _globallisteners[globalListenerIndex].count = _globallisteners[globalListenerIndex].count - 1 } } } } } })(jwplayer); (function(a) { a.html5.extensionmap = { "3gp": "video/3gpp", "3gpp": "video/3gpp", "3g2": "video/3gpp2", "3gpp2": "video/3gpp2", flv: "video/x-flv", f4a: "audio/mp4", f4b: "audio/mp4", f4p: "video/mp4", f4v: "video/mp4", mov: "video/quicktime", m4a: "audio/mp4", m4b: "audio/mp4", m4p: "audio/mp4", m4v: "video/mp4", mkv: "video/x-matroska", mp4: "video/mp4", sdp: "application/sdp", vp6: "video/x-vp6", aac: "audio/aac", mp3: "audio/mp3", ogg: "audio/ogg", ogv: "video/ogg", webm: "video/webm"} })(jwplayer); (function(a) { var b = { prefix: "http://l.longtailvideo.com/html5/", file: "logo.png", link: "http://www.longtailvideo.com/players/jw-flv-player/", margin: 8, out: 0.5, over: 1, timeout: 3, hide: true, position: "bottom-left" }; _css = a.html5.utils.css; a.html5.logo = function(g, h) { var l = g; var j; if (b.prefix) { var i = g.version.split(/\W/).splice(0, 2).join("/"); if (b.prefix.indexOf(i) < 0) { b.prefix += i + "/" } } if (h.position == a.html5.view.positions.OVER) { h.position = b.position } var f = a.utils.extend({}, b); if (!f.file) { return } var c = document.createElement("img"); c.id = l.id + "_jwplayer_logo"; c.style.display = "none"; c.onload = function(n) { _css(c, k()); l.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE, m) }; if (f.file.indexOf("http://") === 0) { c.src = f.file } else { c.src = f.prefix + f.file } c.onmouseover = function(n) { c.style.opacity = f.over; d() }; c.onmouseout = function(n) { c.style.opacity = f.out; d() }; c.onclick = e; function k() { var p = { textDecoration: "none", position: "absolute" }; p.display = f.hide ? "none" : "block"; var o = f.position.toLowerCase().split("-"); for (var n in o) { p[o[n]] = f.margin } return p } this.resize = function(o, n) { }; this.getDisplayElement = function() { return c }; function e(n) { n.stopPropagation(); window.open(f.link, "_blank"); return } function d() { if (j) { clearTimeout(j) } j = setTimeout(function() { a.html5.utils.fadeTo(c, 0, 0.1, parseFloat(c.style.opacity)) }, f.timeout * 1000) } function m(n) { switch (l.jwGetState()) { case a.api.events.state.BUFFERING: c.style.display = "block"; c.style.opacity = f.out; if (f.hide) { d() } break; case a.api.events.state.PAUSED: break; case a.api.events.state.IDLE: break; case a.api.events.state.PLAYING: break; default: if (f.hide) { d() } break } } return this } })(jwplayer); (function(a) { var c = { ended: a.api.events.state.IDLE, playing: a.api.events.state.PLAYING, pause: a.api.events.state.PAUSED, buffering: a.api.events.state.BUFFERING }; var b = a.html5.utils.css; a.html5.mediavideo = function(f, C) { var G = { abort: t, canplay: m, canplaythrough: m, durationchange: q, emptied: t, ended: m, error: l, loadeddata: q, loadedmetadata: q, loadstart: m, pause: m, play: J, playing: m, progress: z, ratechange: t, seeked: m, seeking: m, stalled: m, suspend: m, timeupdate: J, volumechange: t, waiting: m, canshowcurrentframe: t, dataunavailable: t, empty: t, load: e, loadedfirstframe: t }; var H = new a.html5.eventdispatcher(); a.utils.extend(this, H); var h = f; var x = C; var D; var F; var d = a.api.events.state.IDLE; var A = null; var n; var g = 0; var y = false; var r = false; var L; var K; var i = []; var M; var B = false; function v() { return d } function e(N) { } function t(N) { } function m(N) { if (c[N.type]) { s(c[N.type]) } } function s(N) { if (B) { return } if (n) { N = a.api.events.state.IDLE } if (N == a.api.events.state.PAUSED && d == a.api.events.state.IDLE) { return } if (d != N) { var O = d; h.state = N; d = N; var P = false; if (N == a.api.events.state.IDLE) { p(); if (h.position >= h.duration && (h.position || h.duration)) { P = true } if (x.style.display != "none" && !h.config.chromeless) { x.style.display = "none" } } H.sendEvent(a.api.events.JWPLAYER_PLAYER_STATE, { oldstate: O, newstate: N }); if (P) { H.sendEvent(a.api.events.JWPLAYER_MEDIA_COMPLETE) } } n = false } function q(N) { var O = { height: N.target.videoHeight, width: N.target.videoWidth, duration: Math.round(N.target.duration * 10) / 10 }; if (h.duration === 0 || isNaN(h.duration)) { h.duration = Math.round(N.target.duration * 10) / 10 } h.playlist[h.item] = a.utils.extend(h.playlist[h.item], O); H.sendEvent(a.api.events.JWPLAYER_MEDIA_META, { metadata: O }) } function J(O) { if (n) { return } if (O !== undefined && O.target !== undefined) { if (h.duration === 0 || isNaN(h.duration)) { h.duration = Math.round(O.target.duration * 10) / 10 } if (!y && x.readyState > 0) { s(a.api.events.state.PLAYING) } if (d == a.api.events.state.PLAYING) { if (!y && x.readyState > 0) { y = true; try { x.currentTime = h.playlist[h.item].start } catch (N) { } x.volume = h.volume / 100; x.muted = h.mute } h.position = Math.round(O.target.currentTime * 10) / 10; H.sendEvent(a.api.events.JWPLAYER_MEDIA_TIME, { position: Math.round(O.target.currentTime * 10) / 10, duration: Math.round(O.target.duration * 10) / 10 }) } } z(O) } function E() { var N = (i[i.length - 1] - i[0]) / i.length; M = setTimeout(function() { if (!F) { z({ lengthComputable: true, loaded: 1, total: 1 }) } }, N * 10) } function z(P) { var O, N; if (P !== undefined && P.lengthComputable && P.total) { o(); O = P.loaded / P.total * 100; N = O / 100 * (h.duration - x.currentTime); if (50 < O && !F) { clearTimeout(M); E() } } else { if ((x.buffered !== undefined) && (x.buffered.length > 0)) { maxBufferIndex = 0; if (maxBufferIndex >= 0) { O = x.buffered.end(maxBufferIndex) / x.duration * 100; N = x.buffered.end(maxBufferIndex) - x.currentTime } } } if (D === false && d == a.api.events.state.BUFFERING) { D = true; H.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER_FULL) } if (!F) { if (O == 100 && F === false) { F = true } if (O !== null && (O > h.buffer)) { h.buffer = Math.round(O); H.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER, { bufferPercent: Math.round(O) }) } } } function w() { if (A === null) { A = setInterval(function() { J() }, 100) } } function p() { clearInterval(A); A = null } function l(P) { var O = "There was an error: "; if ((P.target.error && P.target.tagName.toLowerCase() == "video") || P.target.parentNode.error && P.target.parentNode.tagName.toLowerCase() == "video") { var N = P.target.error === undefined ? P.target.parentNode.error : P.target.error; switch (N.code) { case N.MEDIA_ERR_ABORTED: O = "You aborted the video playback: "; break; case N.MEDIA_ERR_NETWORK: O = "A network error caused the video download to fail part-way: "; break; case N.MEDIA_ERR_DECODE: O = "The video playback was aborted due to a corruption problem or because the video used features your browser did not support: "; break; case N.MEDIA_ERR_SRC_NOT_SUPPORTED: O = "The video could not be loaded, either because the server or network failed or because the format is not supported: "; break; default: O = "An unknown error occurred: "; break } } else { if (P.target.tagName.toLowerCase() == "source") { K--; if (K > 0) { return } O = "The video could not be loaded, either because the server or network failed or because the format is not supported: " } else { a.html5.utils.log("Erroneous error received. Continuing..."); return } } u(); O += j(); B = true; H.sendEvent(a.api.events.JWPLAYER_ERROR, { error: O }); return } function j() { var P = ""; for (var O in L.levels) { var N = L.levels[O]; var Q = x.ownerDocument.createElement("source"); P += a.html5.utils.getAbsolutePath(N.file); if (O < (L.levels.length - 1)) { P += ", " } } return P } this.getDisplayElement = function() { return x }; this.play = function() { if (d != a.api.events.state.PLAYING) { if (x.style.display != "block") { x.style.display = "block" } x.play(); w() } }; this.pause = function() { x.pause(); s(a.api.events.state.PAUSED) }; this.seek = function(N) { if (!(h.duration === 0 || isNaN(h.duration)) && !(h.position === 0 || isNaN(h.position))) { x.currentTime = N; x.play() } }; function u() { x.pause(); p(); h.position = 0; n = true; s(a.api.events.state.IDLE) } this.stop = u; this.volume = function(N) { x.volume = N / 100; h.volume = N; H.sendEvent(a.api.events.JWPLAYER_MEDIA_VOLUME, { volume: Math.round(N) }) }; this.mute = function(N) { x.muted = N; h.mute = N; H.sendEvent(a.api.events.JWPLAYER_MEDIA_MUTE, { mute: N }) }; this.resize = function(O, N) { if (false) { b(x, { width: O, height: N }) } H.sendEvent(a.api.events.JWPLAYER_MEDIA_RESIZE, { fullscreen: h.fullscreen, width: O, hieght: N }) }; this.fullscreen = function(N) { if (N === true) { this.resize("100%", "100%") } else { this.resize(h.config.width, h.config.height) } }; this.load = function(N) { I(N); H.sendEvent(a.api.events.JWPLAYER_MEDIA_LOADED); D = false; F = false; y = false; if (!h.config.chromeless) { i = []; o(); s(a.api.events.state.BUFFERING); setTimeout(function() { J() }, 25) } }; function o() { var N = new Date().getTime(); i.push(N) } this.hasChrome = function() { return r }; function I(U) { h.duration = U.duration; r = false; L = U; var P = document.createElement("video"); P.preload = "none"; B = false; K = 0; for (var O in U.levels) { var N = U.levels[O]; if (a.html5.utils.isYouTube(N.file)) { delete P; k(N.file); return } var Q; if (N.type === undefined) { var T = a.html5.utils.extension(N.file); if (a.html5.extensionmap[T] !== undefined) { Q = a.html5.extensionmap[T] } else { Q = "video/" + T + ";" } } else { Q = N.type } if (P.canPlayType(Q) === "") { continue } var S = x.ownerDocument.createElement("source"); S.src = a.html5.utils.getAbsolutePath(N.file); S.type = Q; K++; P.appendChild(S) } if (K === 0) { B = true; H.sendEvent(a.api.events.JWPLAYER_ERROR, { error: "The video could not be loaded because the format is not supported by your browser: " + j() }) } if (h.config.chromeless) { P.poster = a.html5.utils.getAbsolutePath(U.image); P.controls = "controls" } P.style.position = x.style.position; P.style.top = x.style.top; P.style.left = x.style.left; P.style.width = x.style.width; P.style.height = x.style.height; P.style.zIndex = x.style.zIndex; P.onload = e; P.volume = 0; x.parentNode.replaceChild(P, x); P.id = x.id; x = P; for (var R in G) { x.addEventListener(R, function(V) { if (V.target.parentNode !== null) { G[V.type](V) } }, true) } } function k(R) { var O = document.createElement("object"); R = ["http://www.youtube.com/v/", R.replace(/^[^v]+v.(.{11}).*/, "$1"), "&amp;hl=en_US&amp;fs=1&autoplay=1"].join(""); var U = { movie: R, allowFullScreen: "true", allowscriptaccess: "always" }; for (var N in U) { var S = document.createElement("param"); S.name = N; S.value = U[N]; O.appendChild(S) } var T = document.createElement("embed"); var P = { src: R, type: "application/x-shockwave-flash", allowscriptaccess: "always", allowfullscreen: "true", width: document.getElementById(f.id).style.width, height: document.getElementById(f.id).style.height }; for (var Q in P) { T[Q] = P[Q] } O.appendChild(T); O.style.position = x.style.position; O.style.top = x.style.top; O.style.left = x.style.left; O.style.width = document.getElementById(f.id).style.width; O.style.height = document.getElementById(f.id).style.height; O.style.zIndex = 2147483000; x.parentNode.replaceChild(O, x); O.id = x.id; x = O; r = true } this.embed = I; return this } })(jwplayer); (function(jwplayer) { var _configurableStateVariables = ["width", "height", "start", "duration", "volume", "mute", "fullscreen", "item", "plugins"]; jwplayer.html5.model = function(api, container, options) { var _api = api; var _container = container; var _model = { id: _container.id, playlist: [], state: jwplayer.api.events.state.IDLE, position: 0, buffer: 0, config: { width: 480, height: 320, item: 0, skin: undefined, file: undefined, image: undefined, start: 0, duration: 0, bufferlength: 5, volume: 90, mute: false, fullscreen: false, repeat: "none", autostart: false, debug: undefined, screencolor: undefined} }; var _media; var _eventDispatcher = new jwplayer.html5.eventdispatcher(); var _components = ["display", "logo", "controlbar"]; jwplayer.utils.extend(_model, _eventDispatcher); for (var option in options) { if (typeof options[option] == "string") { var type = /color$/.test(option) ? "color" : null; options[option] = jwplayer.html5.utils.typechecker(options[option], type) } var config = _model.config; var path = option.split("."); for (var edge in path) { if (edge == path.length - 1) { config[path[edge]] = options[option] } else { if (config[path[edge]] === undefined) { config[path[edge]] = {} } config = config[path[edge]] } } } for (var index in _configurableStateVariables) { var configurableStateVariable = _configurableStateVariables[index]; _model[configurableStateVariable] = _model.config[configurableStateVariable] } var pluginorder = _components.concat([]); if (_model.plugins !== undefined) { if (typeof _model.plugins == "string") { var userplugins = _model.plugins.split(","); for (var userplugin in userplugins) { pluginorder.push(userplugin.replace(/^\s+|\s+$/g, "")) } } else { for (var plugin in _model.plugins) { pluginorder.push(plugin.replace(/^\s+|\s+$/g, "")) } } } if (jwplayer.utils.isIOS()) { _model.config.chromeless = true } if (_model.config.chromeless) { pluginorder = [] } _model.plugins = { order: pluginorder, config: { controlbar: { position: jwplayer.html5.view.positions.BOTTOM} }, object: {} }; if (typeof _model.config.components != "undefined") { for (var component in _model.config.components) { _model.plugins.config[component] = _model.config.components[component] } } for (var pluginIndex in _model.plugins.order) { var pluginName = _model.plugins.order[pluginIndex]; var pluginConfig = _model.config[pluginName] === undefined ? {} : _model.config[pluginName]; _model.plugins.config[pluginName] = _model.plugins.config[pluginName] === undefined ? pluginConfig : jwplayer.utils.extend(_model.plugins.config[pluginName], pluginConfig); if (_model.plugins.config[pluginName].position === undefined) { _model.plugins.config[pluginName].position = jwplayer.html5.view.positions.OVER } } _model.loadPlaylist = function(arg, ready) { var input; if (typeof arg == "string") { try { input = eval(arg) } catch (err) { input = arg } } else { input = arg } var config; switch (jwplayer.utils.typeOf(input)) { case "object": config = input; break; case "array": config = { playlist: input }; break; default: config = { file: input }; break } _model.playlist = new jwplayer.html5.playlist(config); if (_model.config.shuffle) { _model.item = _getShuffleItem() } else { if (_model.config.item >= _model.playlist.length) { _model.config.item = _model.playlist.length - 1 } _model.item = _model.config.item } if (!ready) { _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYLIST_LOADED); _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYLIST_ITEM, { item: _model.item }) } _model.setActiveMediaProvider(_model.playlist[_model.item]) }; function _getShuffleItem() { var result = null; if (_model.playlist.length > 1) { while (result === null) { result = Math.floor(Math.random() * _model.playlist.length); if (result == _model.item) { result = null } } } else { result = 0 } return result } function forward(evt) { if (evt.type == jwplayer.api.events.JWPLAYER_MEDIA_LOADED) { _container = _media.getDisplayElement() } _eventDispatcher.sendEvent(evt.type, evt) } _model.setActiveMediaProvider = function(playlistItem) { if (_media !== undefined) { _media.resetEventListeners() } _media = new jwplayer.html5.mediavideo(_model, _container); _media.addGlobalListener(forward); if (_model.config.chromeless) { _media.load(playlistItem) } return true }; _model.getMedia = function() { return _media }; _model.setupPlugins = function() { for (var plugin in _model.plugins.order) { try { if (jwplayer.html5[_model.plugins.order[plugin]] !== undefined) { _model.plugins.object[_model.plugins.order[plugin]] = new jwplayer.html5[_model.plugins.order[plugin]](_api, _model.plugins.config[_model.plugins.order[plugin]]) } else { if (window[_model.plugins.order[plugin]] !== undefined) { _model.plugins.object[_model.plugins.order[plugin]] = new window[_model.plugins.order[plugin]](_api, _model.plugins.config[_model.plugins.order[plugin]]) } else { _model.plugins.order.splice(plugin, plugin + 1) } } } catch (err) { jwplayer.html5.utils.log("Could not setup " + _model.plugins.order[plugin]) } } }; return _model } })(jwplayer); (function(a) { a.html5.playlist = function(b) { var d = []; if (b.playlist && b.playlist.length > 0) { for (var c in b.playlist) { d.push(new a.html5.playlistitem(b.playlist[c])) } } else { d.push(new a.html5.playlistitem(b)) } return d } })(jwplayer); (function(a) { a.html5.playlistitem = function(c) { var b = { author: "", date: "", description: "", image: "", link: "", mediaid: "", tags: "", title: "", provider: "", file: "", streamer: "", duration: -1, start: 0, currentLevel: -1, levels: [] }; for (var d in b) { if (c[d] !== undefined) { b[d] = c[d] } } if (b.levels.length === 0) { b.levels[0] = new a.html5.playlistitemlevel(b) } return b } })(jwplayer); (function(a) { a.html5.playlistitemlevel = function(b) { var d = { file: "", streamer: "", bitrate: 0, width: 0 }; for (var c in d) { if (b[c] !== undefined) { d[c] = b[c] } } return d } })(jwplayer); (function(a) { a.html5.skin = function() { var b = {}; var c = false; this.load = function(d, e) { new a.html5.skinloader(d, function(f) { c = true; b = f; e() }, function() { new a.html5.skinloader("", function(f) { c = true; b = f; e() }) }) }; this.getSkinElement = function(d, e) { if (c) { try { return b[d].elements[e] } catch (f) { a.html5.utils.log("No such skin component / element: ", [d, e]) } } return null }; this.getComponentSettings = function(d) { if (c) { return b[d].settings } return null }; this.getComponentLayout = function(d) { if (c) { return b[d].layout } return null } } })(jwplayer); (function(a) { a.html5.skinloader = function(f, n, i) { var m = {}; var c = n; var j = i; var e = true; var h; var l = f; var q = false; function k() { if (l === undefined || l === "") { d(a.html5.defaultSkin().xml) } else { a.utils.ajax(a.html5.utils.getAbsolutePath(l), function(r) { d(r.responseXML) }, function(r) { d(a.html5.defaultSkin().xml) }) } } function d(w) { var C = w.getElementsByTagName("component"); if (C.length === 0) { return } for (var F = 0; F < C.length; F++) { var A = C[F].getAttribute("name"); var z = { settings: {}, elements: {}, layout: {} }; m[A] = z; var E = C[F].getElementsByTagName("elements")[0].getElementsByTagName("element"); for (var D = 0; D < E.length; D++) { b(E[D], A) } var x = C[F].getElementsByTagName("settings")[0]; if (x !== undefined && x.childNodes.length > 0) { var I = x.getElementsByTagName("setting"); for (var N = 0; N < I.length; N++) { var O = I[N].getAttribute("name"); var G = I[N].getAttribute("value"); var v = /color$/.test(O) ? "color" : null; m[A].settings[O] = a.html5.utils.typechecker(G, v) } } var J = C[F].getElementsByTagName("layout")[0]; if (J !== undefined && J.childNodes.length > 0) { var K = J.getElementsByTagName("group"); for (var u = 0; u < K.length; u++) { var y = K[u]; m[A].layout[y.getAttribute("position")] = { elements: [] }; for (var M = 0; M < y.attributes.length; M++) { var B = y.attributes[M]; m[A].layout[y.getAttribute("position")][B.name] = B.value } var L = y.getElementsByTagName("*"); for (var t = 0; t < L.length; t++) { var r = L[t]; m[A].layout[y.getAttribute("position")].elements.push({ type: r.tagName }); for (var s = 0; s < r.attributes.length; s++) { var H = r.attributes[s]; m[A].layout[y.getAttribute("position")].elements[t][H.name] = H.value } if (m[A].layout[y.getAttribute("position")].elements[t].name === undefined) { m[A].layout[y.getAttribute("position")].elements[t].name = r.tagName } } } } e = false; p() } } function p() { clearInterval(h); if (!q) { h = setInterval(function() { o() }, 100) } } function b(w, v) { var u = new Image(); var r = w.getAttribute("name"); var t = w.getAttribute("src"); var y; if (t.indexOf("data:image/png;base64,") === 0) { y = t } else { var s = a.html5.utils.getAbsolutePath(l); var x = s.substr(0, s.lastIndexOf("/")); y = [x, v, t].join("/") } m[v].elements[r] = { height: 0, width: 0, src: "", ready: false }; u.onload = function(z) { g(u, r, v) }; u.onerror = function(z) { q = true; p(); j() }; u.src = y } function o() { for (var r in m) { if (r != "properties") { for (var s in m[r].elements) { if (!m[r].elements[s].ready) { return } } } } if (e === false) { clearInterval(h); c(m) } } function g(r, t, s) { m[s].elements[t].height = r.height; m[s].elements[t].width = r.width; m[s].elements[t].src = r.src; m[s].elements[t].ready = true; p() } k() } })(jwplayer); (function(a) { var b = {}; a.html5.utils.animations = function() { }; a.html5.utils.animations.transform = function(c, d) { c.style.webkitTransform = d; c.style.MozTransform = d; c.style.OTransform = d }; a.html5.utils.animations.transformOrigin = function(c, d) { c.style.webkitTransformOrigin = d; c.style.MozTransformOrigin = d; c.style.OTransformOrigin = d }; a.html5.utils.animations.rotate = function(c, d) { a.html5.utils.animations.transform(c, ["rotate(", d, "deg)"].join("")) }; a.html5.utils.cancelAnimation = function(c) { delete b[c.id] }; a.html5.utils.fadeTo = function(l, f, e, i, h, d) { if (b[l.id] != d && d !== undefined) { return } var c = new Date().getTime(); if (d > c) { setTimeout(function() { a.html5.utils.fadeTo(l, f, e, i, 0, d) }, d - c) } l.style.display = "block"; if (i === undefined) { i = l.style.opacity === "" ? 1 : l.style.opacity } if (l.style.opacity == f && l.style.opacity !== "" && d !== undefined) { if (f === 0) { l.style.display = "none" } return } if (d === undefined) { d = c; b[l.id] = d } if (h === undefined) { h = 0 } var j = (c - d) / (e * 1000); j = j > 1 ? 1 : j; var k = f - i; var g = i + (j * k); if (g > 1) { g = 1 } else { if (g < 0) { g = 0 } } l.style.opacity = g; if (h > 0) { b[l.id] = d + h * 1000; a.html5.utils.fadeTo(l, f, e, i, 0, b[l.id]); return } setTimeout(function() { a.html5.utils.fadeTo(l, f, e, i, 0, d) }, 10) } })(jwplayer); (function(c) { var d = new RegExp(/^(#|0x)[0-9a-fA-F]{3,6}/); c.html5.utils.typechecker = function(g, f) { f = f === null ? b(g) : f; return e(g, f) }; function b(f) { var g = ["true", "false", "t", "f"]; if (g.indexOf(f.toLowerCase().replace(" ", "")) >= 0) { return "boolean" } else { if (d.test(f)) { return "color" } else { if (!isNaN(parseInt(f, 10)) && parseInt(f, 10).toString().length == f.length) { return "integer" } else { if (!isNaN(parseFloat(f)) && parseFloat(f).toString().length == f.length) { return "float" } } } } return "string" } function e(g, f) { if (f === null) { return g } switch (f) { case "color": if (g.length > 0) { return a(g) } return null; case "integer": return parseInt(g, 10); case "float": return parseFloat(g); case "boolean": if (g.toLowerCase() == "true") { return true } else { if (g == "1") { return true } } return false } return g } function a(f) { switch (f.toLowerCase()) { case "blue": return parseInt("0000FF", 16); case "green": return parseInt("00FF00", 16); case "red": return parseInt("FF0000", 16); case "cyan": return parseInt("00FFFF", 16); case "magenta": return parseInt("FF00FF", 16); case "yellow": return parseInt("FFFF00", 16); case "black": return parseInt("000000", 16); case "white": return parseInt("FFFFFF", 16); default: f = f.replace(/(#|0x)?([0-9A-F]{3,6})$/gi, "$2"); if (f.length == 3) { f = f.charAt(0) + f.charAt(0) + f.charAt(1) + f.charAt(1) + f.charAt(2) + f.charAt(2) } return parseInt(f, 16) } return parseInt("000000", 16) } })(jwplayer); (function(a) { a.html5.api = function(b, j) { var i = {}; if (!a.utils.hasHTML5()) { return i } var d = document.createElement("div"); b.parentNode.replaceChild(d, b); d.id = b.id; i.version = a.html5.version; i.id = d.id; var h = new a.html5.model(i, d, j); var e = new a.html5.view(i, d, h); var g = new a.html5.controller(i, d, h, e); i.skin = new a.html5.skin(); i.jwPlay = g.play; i.jwPause = g.pause; i.jwStop = g.stop; i.jwSeek = g.seek; i.jwPlaylistItem = g.item; i.jwPlaylistNext = g.next; i.jwPlaylistPrev = g.prev; i.jwResize = g.resize; i.jwLoad = g.load; function f(k) { return function() { return h[k] } } i.jwGetItem = f("item"); i.jwGetPosition = f("position"); i.jwGetDuration = f("duration"); i.jwGetBuffer = f("buffer"); i.jwGetWidth = f("width"); i.jwGetHeight = f("height"); i.jwGetFullscreen = f("fullscreen"); i.jwSetFullscreen = g.setFullscreen; i.jwGetVolume = f("volume"); i.jwSetVolume = g.setVolume; i.jwGetMute = f("mute"); i.jwSetMute = g.setMute; i.jwGetState = f("state"); i.jwGetVersion = function() { return i.version }; i.jwGetPlaylist = function() { return h.playlist }; i.jwAddEventListener = g.addEventListener; i.jwRemoveEventListener = g.removeEventListener; i.jwSendEvent = g.sendEvent; i.jwGetLevel = function() { }; i.jwGetBandwidth = function() { }; i.jwGetLockState = function() { }; i.jwLock = function() { }; i.jwUnlock = function() { }; function c(m, l, k) { return function() { m.loadPlaylist(m.config, true); m.setupPlugins(); l.setup(m.getMedia().getDisplayElement()); var n = { id: i.id, version: i.version }; k.sendEvent(a.api.events.JWPLAYER_READY, n); if (playerReady !== undefined) { playerReady(n) } if (window[m.config.playerReady] !== undefined) { window[m.config.playerReady](n) } m.sendEvent(a.api.events.JWPLAYER_PLAYLIST_LOADED); m.sendEvent(a.api.events.JWPLAYER_PLAYLIST_ITEM, { item: m.config.item }); if (m.config.autostart === true && !m.config.chromeless) { k.play() } } } if (h.config.chromeless) { setTimeout(c(h, e, g), 25) } else { i.skin.load(h.config.skin, c(h, e, g)) } return i } })(jwplayer);

////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////


var PODCAST = PODCAST || {
    foo: false, //don't ask - foo is audioIsCurrentlyPlaying
    bar: false // bar is videoIsCurrentlyPlaying
};

$(document).ready(function() {
    PODCAST.GENERAL.init();
    PODCAST.FLASH.VIDEO.init();
    PODCAST.UTIL.paginationInit();
});

PODCAST.GENERAL = {
    init: function() {
        $("li.podcast_widget").each(function() {
            PODCAST.GENERAL.setup($(this));
        });
    },

    setup: function(pcw) {

        //PODCAST.FLASH.VIDEO.previewPictureChange(pcw);

        //change the list of categories based on the coverflow arrows being clicked within context.
        PODCAST.UTIL.externalCategoryControls(pcw);
        var podcastSection = pcw.find('div.podcastContainer');
        var tabLink = pcw.find('ul.podcastTabControls a');
        var playLink = pcw.find('a.playMedia');
        var nextAndPrevButtons = pcw.find('div.ContentFlow div.scrollbar div');

        //Transcript variables
        var transcripts = pcw.find('div.transcript');
        var transcriptContainer = pcw.find('div.transcriptContainer');
        var currentTranscriptContent = transcriptContainer.find('.transcriptContent');
        var viewCurrentTranscript = transcriptContainer.find('.transcriptContainer span.transcriptHeader');

        //Category variables
        var contentFlow = pcw.find('div.ContentFlow');
        var flowItem = contentFlow.find('a.item');
        var categoryItem = pcw.find('li.audioCategories');

        currentTranscriptContent.hide();
        transcriptContainer.find('span.transcriptHeader').remove();
        transcripts.hide();

        //if there's only 1 category. Hide the coverflow arrows
        if (categoryItem.length < 2) {
            podcastSection.find('div.ContentFlow .preButton').hide();
            podcastSection.find('div.ContentFlow .nextButton').hide();
        }

        playLink.click(function(e) {
            e.preventDefault();
            var shell = this;

            PODCAST.TRANSCRIPT.reset(currentTranscriptContent); //resetToDefaults(currentTranscriptContent);
            PODCAST.TRANSCRIPT.show(shell); //transcriptFunc(shell);
            PODCAST.UTIL.whichSectionReact(shell, playLink); //playStopFunc(shell);
            return false;
        });

        nextAndPrevButtons.click(function(e) {
            PODCAST.TRANSCRIPT.reset(currentTranscriptContent);
        });

        //Tab Controls
        PODCAST.UTIL.tabControls(tabLink, podcastSection, currentTranscriptContent, playLink); //tabShowHide(tabLink, podcastSection);

        //Category Controls
        tabFader(flowItem, categoryItem);
        flowItem.click(function(e) {
            e.preventDefault();
            currentTranscriptContent.slideUp();
            $('.audioTranscript span').slideUp();
        });
        PODCAST.TRANSCRIPT.init(pcw);
    }
};




/////////////////////////////////////////////////////////////////////////////////////////////////////////
///                     TRANSCRIPT: init, reset, show
/////////////////////////////////////////////////////////////////////////////////////////////////////////
PODCAST.TRANSCRIPT = {
    init: function(context) {
        var thisContainer = context.find('.audioTranscript');
        var thisContent = context.find('.transcriptContent');
        var firstTranscript = context.find('ul.audioLinks li#audioCategory1 ul.pages li div.transcript:first').text();
        var firstTranscriptHead = context.find('ul.audioLinks li#audioCategory1 h5 span.fl:first').text();
        var tempTrigger;

        if (!firstTranscriptHead) {
            thisContainer = context.find('.videoTranscript');
            firstTranscriptHead = context.find('ul.videoLinks span.titleHeader:first').text();
            firstTranscript = context.find('ul.videoLinks div.transcript:first').text();
        }

        tempTrigger = '<span class="transcriptHeader">View <strong>' + firstTranscriptHead + '</strong> transcript</span>';

        thisContainer.prepend(tempTrigger);
        thisContent.empty().append(firstTranscript);

        thisContainer.find('.transcriptHeader').click(function() {
            var that = $(this);
            that.toggleClass('active');
            that.next('div').slideToggle();
        });
    },

    reset: function(content) {
        content.filter(':visible').slideUp().empty();
        $('.transcriptContainer span.transcriptHeader').remove();
    },

    show: function(context) {
        var thisContainer = $(context).closest('.podcastContainer').find('.transcriptContainer');
        var thisContent = thisContainer.find('.transcriptContent');

        var transcriptHeader = $(context).html();
        //the line below throws an error in all IE's when using .trim()

        var tempTranscript = $(context).closest('li').find('.transcript').html();

        if (tempTranscript !== "") {
            var tempTrigger = '<span class="transcriptHeader">View <strong>' + transcriptHeader + '</strong> transcript</span>';

            thisContainer.prepend(tempTrigger);
            thisContent.empty().append(tempTranscript);
        }

        $('.transcriptContainer span.transcriptHeader').click(function() {
            var that = $(this);
            that.toggleClass('active');
            that.next('div').slideToggle();
        });
    }
};



/////////////////////////////////////////////////////////////////////////////////////////////////////////
///                     FLASH: AUDIO (INIT, PLAY, STOP), VIDEO (INIT, PLAY, STOP, PREVIEWPICURE)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
PODCAST.FLASH = {

    AUDIO: {
        play: function(file) {
            document.getElementById("myFlash").SetVariable("player:jsUrl", file);
            document.getElementById("myFlash").SetVariable("player:jsPlay", "");
            PODCAST.foo = true;
        },
        stop: function(context) {
            var flashMovie = $('.audioPlayer object');
            var myFlash = document.getElementById("myFlash");
            //if (myFlash && typeof myFlash.SetVariable == 'function') {
            myFlash.SetVariable("player:jsStop", "");
            //}
            PODCAST.foo = false;
        }
    },

    VIDEO: {
        init: function(videoFile, newPreviewImage, play) {
            var previewImage, mediaspace, mediaHeight, mediaWidth, firstFile;

            PODCAST.bar = true;

            mediaspace = $('.podcastTabControls');
            mediaWidth = mediaspace.width();
            mediaHeight = parseInt(mediaWidth) / 2


            if ($('div#videoPlayer').length) {

                if (!videoFile) { firstFile = $('.videoLinks a.playMedia').attr('href'); } else { firstFile = videoFile; }
                if (!newPreviewImage) { previewImage = $('.videoLinks span.hide:first').text(); } else { previewImage = newPreviewImage; }
                jwplayer('mediaspace').setup({
                    flashplayer: "/WidgetResources/portal/video/player.swf",
                    file: firstFile,
                    height: mediaHeight,
                    width: mediaWidth,
                    image: previewImage,
                    autostart: play,
                    controlbar: "bottom"
                });

            }
        },
        stop: function() {
            jwplayer().stop();
            PODCAST.bar = false;
        },
        getPreviewPicturePath: function(that) {
            var imagePath, paramArr, image;
            return imagePath = $(that).parent().find('.hide').text();
        }
    }
};


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///                     UTILITIES: Pagination && External Category Controls && Number Conversions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PODCAST.UTIL = {
    //Workout which section we are in (audio or video) and react accordingly
    whichSectionReact: function(context, playLink) {
        if ($(context).parent().hasClass('cross')) {
            playLink.parent().removeClass('cross');
            var whichSection = $(context).parent().parent().parent().parent().parent().parent().attr('id');
            if (whichSection == 'audio') {
                PODCAST.FLASH.AUDIO.stop($(context));
            } else {
                //jwplayer().stop();
                PODCAST.FLASH.VIDEO.stop();
            }
        } else {
            playLink.parent().removeClass('cross');
            $(context).parent().toggleClass('cross');
            var whichCrossSection = $(context).parent().parent().parent().parent().parent().parent().attr('id');
            if (whichCrossSection == 'audio') {
                PODCAST.FLASH.AUDIO.play($(context).attr('href'));
            } else {
                PODCAST.FLASH.VIDEO.init($(context).attr('href'), PODCAST.FLASH.VIDEO.getPreviewPicturePath(context), true);
                PODCAST.bar = true;
            }
        }
    },

    tabControls: function(tabTrigger, tabSections, content, playLink) {
        var v = false, a = true;
        tabSections.hide().filter(':first').show();
        tabTrigger.filter(':first').parent().addClass('active');

        tabTrigger.click(function(e) {
            e.preventDefault();
            var section = $(this).text();
            var shell = $(this.hash);

            if (section == "Video") {
                if (PODCAST.foo == true) {
                    PODCAST.FLASH.AUDIO.stop();
                    a = PODCAST.foo = false;
                }
                PODCAST.FLASH.VIDEO.init(false, false, false);
                PODCAST.TRANSCRIPT.reset(content);
                playLink.parent().removeClass('cross');
                v = PODCAST.bar = true;

            } else if (section == "Audio") {
                if (PODCAST.bar == true) {
                    jwplayer().stop();
                    v = PODCAST.bar = false;
                }
                a = PODCAST.foo = true;
            } else if (section == "External Media") {
                PODCAST.FLASH.VIDEO.init(false, false, false);
                if (PODCAST.foo == true) {
                    PODCAST.FLASH.AUDIO.stop();
                }
                else if (PODCAST.bar == true) {
                    jwplayer().stop();
                    PODCAST.bar == false;
                }
            }

            tabTrigger.parent().removeClass('active');
            $(this).parent().addClass('active');

            tabSections.hide();
            shell.show();

            return false;
        });
    },

    //Artificially create pagination
    paginationInit: function() {
        var paginateContainers = $('.paginateThis');
        $.each(paginateContainers, function(index, value) {
            PODCAST.UTIL.paginate(value, 10);
        });
    },

    //pass in container and how many items per page you wish to show at anyone time
    paginate: function(container, itemsPerPage) {
        var shell = $(container);
        var rowsPerPage = itemsPerPage;
        var rowsPerPageIndex = itemsPerPage - 1;
        var rows = shell.find('ul.pages li');
        var totalNumRows = rows.length;
        var totalPages = Math.ceil(totalNumRows / rowsPerPage); //always round up

        //if there's more than 1 page
        if (totalNumRows > rowsPerPage) {
            //hide all apart from the first set.
            rows.filter(':gt(' + rowsPerPageIndex + ')').hide();

            //add a list of pagination controls "1, 2, 3"
            var pagControls = "<ul class='podcastPagination fc pagControls'></ul>";
            shell.append(pagControls);

            //store the controls container in memory
            var pagControlsShell = shell.find('ul.pagControls');

            //for each number of pages, add an li and the number
            for (var i = 1; i <= totalPages; i++) {
                if (i == 1)
                    var thisListItem = "<li class='active'>" + i + "</li>";
                else
                    var thisListItem = "<li>" + i + "</li>";
                pagControlsShell.append(thisListItem);
            }

            var controlItem = pagControlsShell.find('li');

            controlItem.click(function() {
                var thus = $(this);
                var thisIndex = thus.text(); //1
                var end = thisIndex * rowsPerPage; //1 * 2 = 2
                var start = end - rowsPerPage; //2 - 2 = 0

                thus.parent().children().removeClass("active");
                thus.addClass("active");

                rows.hide();
                rows.slice(start, end).show();
            });
        }
    },

    //make an array based on category length, keep track of current position and hide and show when clicked
    externalCategoryControls: function(context) {
        var cfItems = context.find('div.ContentFlow a.item');
        var items = jQuery.makeArray(cfItems);
        var currentPosition = 1;

        var previous = context.find('div.scrollbar div.preButton');
        var next = context.find('div.scrollbar div.nextButton');

        previous.click(function() {
            if (currentPosition <= 1) {
                currentPosition = items.length;
            } else {
                currentPosition = --currentPosition;
            }
            PODCAST.UTIL.showCurrentPodcastCat(currentPosition)
        });

        next.click(function() {
            if (currentPosition >= items.length) {
                currentPosition = 1;
            } else {
                currentPosition = ++currentPosition;
            }
            PODCAST.UTIL.showCurrentPodcastCat(currentPosition)
        });
    },

    //hide and show category based on what int is fed in
    showCurrentPodcastCat: function(catIndex) {
        var thisCat = '#audioCategory' + catIndex;
        var podcastCats = $('ul.audioLinks li.audioCategories').hide();
        $(thisCat).show()
    },

    intNegToPos: function(n) {
        if (n < 0) {
            return n * -1;
        } else {
            return n;
        }
    },

    intPosToNeg: function(n) {
        if (n > 0) {
            return n * -1;
        } else {
            return n;
        }
    }
};


$(function() {
    //contentPathwaysWidget();
    initContentPathwaysWidget();
    showHideAtoZ();
    showAll();
});

function initContentPathwaysWidget() {
    $("li.pathways_widget").each(function() {
        contentPathwaysWidget($(this));
    });
}

function contentPathwaysWidget(bpw) {
    var pathwaysTriggers = bpw.find('.pathwaysTriggers a');
    var pathwaysContent = bpw.find('.pathwaysContent');
    pathwaysSwitcher(pathwaysTriggers, pathwaysContent);
}

//Global Tab functionality - using fading
function pathwaysSwitcher(tabTrigger, tabSetions) {
    tabSetions.hide().filter(':first').show();
    tabTrigger.filter(':first').parent().addClass('active');

    tabTrigger.click(function() {
        var them = $(this.hash);

        tabTrigger.parent().removeClass('active');
        $(this).parent().addClass('active');

        tabSetions.filter(':visible').hide();
        them.show();

        return false
    });
}

function showHideAtoZ() {

    $('ul .atozList a').click(function() {
        $('#atozTitles div').each(function(index) {
            $(this).hide();
        });

        var letter = $(this).attr('href');
        $(letter).show();
    });
}

function showAll() {

    $('ul .atozList a').click(function() {

        var letter = $(this).attr('href');

        if (letter == "#all") {
            $('#atozTitles div').each(function(index) {
                $(this).show();
            });
        }
    });
}

$(document).ready(function() {
    //
    $('.CBTwidget').each(function() {
        var widget = $(this);
        var options = {
            pageSize: widget.find('.genericeCBTPagesize').val(),
            currentPage: 1,
            holder: null,
            pagerLocation: 'after'
        };
        widget.find('ul.topicLinkList').cbtPager(options);

        widget.find('div.pager ul li a').live('click', function() {
            widget.find('div.wlLoading').show();
            var url = $(this).attr('href');
            $.post(url, function(data) {
                widget.find('.boxInner').remove();
                widget.find('.OuterContent').append($(data).find('.boxInner'));

                //This function is written in the portal itself and not in widget library.
                if (typeof appendNewWindowSpan == 'function') {
                    appendNewWindowSpan(widget.find('a:not(div.pager a)'));
                }
            });
            widget.find('div.wlLoading').hide();
            return false;
        });
    });



});

(function($) {

    $.fn.cbtPager = function(options) {

        var defaults = {
            pageSize: 10,
            currentPage: 1,
            holder: null,
            pagerLocation: "after"
        };

        var options = $.extend(defaults, options);

        //options.pageSize = $(".cbtPagerContainer + input.genericeCBTPagesize").val();
        
        return this.each(function() {


            var selector = $(this);
            var pageCounter = 1;

            selector.wrap("<div class='cbtPagerContainer'></div>");

            selector.parents(".cbtPagerContainer").find("ul.cbtPagerNav").remove();
           
            
            selector.children().each(function(i) {

                if (i < pageCounter * options.pageSize && i >= (pageCounter - 1) * options.pageSize) {
                    $(this).addClass("cbtPagerPage" + pageCounter);
                }
                else {
                    $(this).addClass("cbtPagerPage" + (pageCounter + 1));
                    pageCounter++;
                }

            });

            // show/hide the appropriate regions 
            selector.children().hide();
            selector.children(".cbtPagerPage" + options.currentPage).show();

            if (pageCounter <= 1) {
                return;
            }

            //Build pager navigation
            var pageNav = "<ul class='cbtPagerNav'>";
            for (i = 1; i <= pageCounter; i++) {
                if (i == options.currentPage) {
                    pageNav += "<li class='currentPage cbtPageNav" + i + "'><a rel='" + i + "' href='#'>" + i + "</a></li>";
                }
                else {
                    pageNav += "<li class='cbtPageNav" + i + "'><a rel='" + i + "' href='#'>" + i + "</a></li>";
                }
            }
            pageNav += "</ul>";

            if (!options.holder) {
                switch (options.pagerLocation) {
                    case "before":
                        selector.before(pageNav);
                        break;
                    case "both":
                        selector.before(pageNav);
                        selector.after(pageNav);
                        break;
                    default:
                        selector.after(pageNav);
                }
            }
            else {
                $(options.holder).append(pageNav);
            }

            //pager navigation behaviour
            selector.parent().find(".cbtPagerNav a").click(function() {

                //grab the REL attribute 
                var clickedLink = $(this).attr("rel");
                options.currentPage = clickedLink;

                if (options.holder) {
                    $(this).parent("li").parent("ul").parent(options.holder).find("li.currentPage").removeClass("currentPage");
                    $(this).parent("li").parent("ul").parent(options.holder).find("a[rel='" + clickedLink + "']").parent("li").addClass("currentPage");
                }
                else {
                    //remove current current (!) page
                    $(this).parent("li").parent("ul").parent(".cbtPagerContainer").find("li.currentPage").removeClass("currentPage");
                    //Add current page highlighting
                    $(this).parent("li").parent("ul").parent(".cbtPagerContainer").find("a[rel='" + clickedLink + "']").parent("li").addClass("currentPage");
                }

                //hide and show relevant links
                selector.children().hide();
                selector.find(".cbtPagerPage" + clickedLink).show();

                return false;
            });

            $(".cbtPagerContainer + div.pager").hide();
        });
    }

})(jQuery);


$(document).ready(function() {

    $('.ow').each(function() {
        $(this).find('ul.owitems').quickPager({ pageSize: 1 });
        owMoreInfo(this);
    });
});



function owMoreInfo(obj) {
    $(obj).find('.owMoreinfo').hide();

    $('<a class="owMoreinfolink" href="#">More</a>').insertAfter($(obj).find('.owMoreinfo'));
    $(obj).find('.owMoreinfolink').live('click', function() {
        var ml = $(this).prev();
        var ow = $(this).parent()
        //$(ml).css("background-color", "red");
        if ($(ml).is(':visible')) {
            $(ow).find('.owMoreinfolink').html('More');
            $(ow).find('.owMoreinfolink').removeClass('owMoreinfolinkUp');
        }
        else {
            $(ow).find('.owMoreinfolink').html('Less');
            $(ow).find('.owMoreinfolink').addClass('owMoreinfolinkUp');
        }
        $(ow).find('.owMoreinfo').toggle();
        return false;
    });
}


(function($) {

    $.fn.quickPager = function(options) {

        var defaults = {
            pageSize: 10,
            currentPage: 1,
            holder: null,
            pagerLocation: "after"
        };

        var options = $.extend(defaults, options);


        return this.each(function() {


            var selector = $(this);
            var pageCounter = 1;

            selector.wrap("<div class='simplePagerContainer'></div>");

            selector.children().each(function(i) {

                if (i < pageCounter * options.pageSize && i >= (pageCounter - 1) * options.pageSize) {
                    $(this).addClass("simplePagerPage" + pageCounter);
                }
                else {
                    $(this).addClass("simplePagerPage" + (pageCounter + 1));
                    pageCounter++;
                }

            });

            // show/hide the appropriate regions 
            selector.children().hide();
            selector.children(".simplePagerPage" + options.currentPage).show();

            if (pageCounter <= 1) {
                return;
            }

            //Build pager navigation
            var pageNav = "<ul class='simplePagerNav'>";
            for (i = 1; i <= pageCounter; i++) {
                if (i == options.currentPage) {
                    pageNav += "<li class='currentPage simplePageNav" + i + "'><a rel='" + i + "' href='#'><span class='text'>" + i + "</span><span class='image'></span></a></li>";
                }
                else {
                    pageNav += "<li class='simplePageNav" + i + "'><a rel='" + i + "' href='#'><span class='text'>" + i + "</span><span class='image'></span></a></li>";
                }
            }
            pageNav += "</ul>";
            pageNav += "<ul class='NextNav'>";
            pageNav += "<li class='simplePageNavPrev'><a rel='prev' href='#'><span class='text'>&lt;&lt;&nbsp;Previous</span><span class='image'></span></a></li>";
            pageNav += "<li class='simplePageNavNext'><a rel='next' href='#'><span class='text'>Next&nbsp;&gt;&gt;</span><span class='image'></span></a></li>";
            pageNav += "</ul>";

            if (!options.holder) {
                switch (options.pagerLocation) {
                    case "before":
                        selector.before(pageNav);
                        break;
                    case "both":
                        selector.before(pageNav);
                        selector.after(pageNav);
                        break;
                    default:
                        selector.after(pageNav);
                }
            }
            else {
                $(options.holder).append(pageNav);
            }

            //pager navigation behaviour
            selector.parent().find(".simplePagerNav a").click(function() {

                //grab the REL attribute
                var clickedLink = $(this).attr("rel");

                if (clickedLink == 1) {
                    selector.parent().find('.simplePageNavPrev').hide();
                }
                else {
                    selector.parent().find('.simplePageNavPrev').show();
                }
                if (clickedLink == pageCounter) {
                    selector.parent().find('.simplePageNavNext').hide();
                }
                else {
                    selector.parent().find('.simplePageNavNext').show();
                }
                options.currentPage = clickedLink;

                if (options.holder) {
                    $(this).parent("li").parent("ul").parent(options.holder).find("li.currentPage").removeClass("currentPage");
                    $(this).parent("li").parent("ul").parent(options.holder).find("a[rel='" + clickedLink + "']").parent("li").addClass("currentPage");
                }
                else {
                    //remove current current (!) page
                    $(this).parent("li").parent("ul").parent(".simplePagerContainer").find("li.currentPage").removeClass("currentPage");
                    //Add current page highlighting
                    $(this).parent("li").parent("ul").parent(".simplePagerContainer").find("a[rel='" + clickedLink + "']").parent("li").addClass("currentPage");
                }

                //hide and show relevant links
                selector.children().hide();
                selector.find(".simplePagerPage" + clickedLink).show();

                return false;
            });

            selector.parent().find(".simplePageNavPrev a").click(function() {
                var clickedLink = parseFloat(selector.parent().find('.currentPage a').attr("rel"));
                if (clickedLink > 1) {
                    clickedLink = clickedLink - 1;
                }
                selector.parent().find('.simplePageNav' + clickedLink + ' a').trigger('click');
                return false;
            });


            selector.parent().find(".simplePageNavNext a").click(function() {
                var clickedLink = parseFloat(selector.parent().find('.currentPage a').attr("rel"));
                clickedLink = clickedLink + 1;
                selector.parent().find('.simplePageNav' + clickedLink + ' a').trigger('click');
                return false;
            });

        });
    }


})(jQuery);


jQuery.hookUpRecentActivityWidgetOverview = function(maxItems) {
    $(document).ready(function() {

        $('.owitem .RecentActivity  div.boxContent div.boxInner').each(function() {
            var RecentActivityWidget = $(this);
            if ($(RecentActivityWidget).find('.ActivityList').size() > 1) {
                $(RecentActivityWidget).find('.ActivityList:first').remove();
            }

            var html = '<ul class="ActivityMenu fc">' +
                    '<li class="first selected"><a href="#AllList">All</a></li>';

            $(RecentActivityWidget).find('div.ActivityList h3').each(function() {
                var list = $(this).next('ul');
                html += '<li><a href="#' + list.attr('class') + '">' + $(this).text() + '</a></li>';
            });

            html += '</ul>';

            $(RecentActivityWidget).find('ul, h3').css('display', 'none');

            $(RecentActivityWidget).prepend(html);

            $(RecentActivityWidget).find('ul.ActivityMenu li a').click(function() {
                $(this).parents('ul.ActivityMenu').find('li').removeClass('selected');
                $(this).parents('li').addClass('selected');

                $(RecentActivityWidget).find('ul:not(.ActivityMenu), h3').css('display', 'none');

                var indexOfHash = $(this).attr('href').indexOf('#');
                var className = $(this).attr('href').substring(indexOfHash + 1);
                $(RecentActivityWidget).find('ul.' + className).css('display', 'block');

                return false;
            });

            var allItemClasses = new Array();

            $(RecentActivityWidget).find('.ActivityList > ul > li').each(function() {
                allItemClasses.push($(this).attr('class').replace(' alt', ''));
            });

            allItemClasses.sort();
            allItemClasses.reverse();

            if ($(RecentActivityWidget).find('.ActivityList ul.AllList').length == 0) {
                var allItemsHtml = '<ul class="AllList">';

                var itemLength = allItemClasses.length < maxItems ? allItemClasses.length : maxItems;

                var altRow = false;
                for (var i = 0; i < itemLength; i++) {
                    var element = RecentActivityWidget.find('.ActivityList ul li.' + allItemClasses[i]);
                    allItemsHtml += '<li' + (altRow ? ' class="alt"' : '') + '>' + element.html() + '</li>';

                    altRow = !altRow;
                }

                allItemsHtml += '</ul>';

                $(RecentActivityWidget).find('.ActivityList').append(allItemsHtml);
            }
            else {
                $(RecentActivityWidget).find('.ActivityList ul.AllList').show();
            }

        });

    });
};

$(document).ready(function() {
    moduleLinksInit();
});

function moduleLinksInit() {
    var container = $('.learningmodule_widget');
    $.each(container, function(index, value) {

        var currentContainer = $(value);

        var defaultValue = currentContainer.find('p.defaultSize').html();
        currentContainer.find('p.defaultSize').hide();
        moduleSetup(value, defaultValue);
    });
}

function moduleSetup(container, noOfRows) {
    if ($('.learningmodule_widget').length) {
        if (noOfRows > 0) {
            var noOfRowsVisible = noOfRows - 1;
            var newContainer = $(container); //$('.learningmodule_widget');
            var listItems = newContainer.find('ul.modules > li');
            var moreLink = newContainer.find('.more');
            var moreLinkSpan = moreLink.find('span');

            listItems.filter(':gt(' + noOfRowsVisible + ')').hide();

            moreLink.click(function(e) {
                var shell = $(this);
                if (shell.parent().find('ul li:hidden').length) {
                    shell.parent().find('ul li:hidden').slideDown();
                    moreLinkSpan.text('Hide');
                    $(this).addClass('expanded');
                    return false;
                } else {
                    listItems.filter(':gt(' + noOfRowsVisible + ')').slideUp();
                    moreLinkSpan.text('More');
                    $(this).removeClass('expanded');
                    return false;
                }
                e.preventDefault();
            });
        }
    }
}


$(function () {
    if($('.faq_widget').length) {
        WILIB.FAQ.init();
    }
});

var WILIB = WILIB || {};

WILIB.FAQ = {

    init: function() {
        $('li.faq_widget').each(function() {
            WILIB.FAQ.setup($(this));
        });
    },

    setup: function(wfaq) {
        var faqSections = wfaq.find('.faqList li:not(.alwaysExpanded)');

        var sectionTitle = faqSections.children("h3");
        var faqQuestions = wfaq.find('.faqQuestions li');
        var faqQuestion = faqQuestions.children("h4");

        faqSections.find('.wrapper').hide(); //.filter(':first').show();
        //wrapper.parent().addClass('selected');
        //var innerWrapper = wrapper.find('.wrapper').hide().filter(':first').show();
        //innerWrapper.parent().addClass('selected');

        //faqSections.filter(':first').addClass('selected');

        sectionTitle.click(function(event) {
            event.stopPropagation();
            var status = $(this).parent().attr("class");

            if (status == "selected") {
                WILIB.FAQ.hide($(this), faqSections);
            } else {
                WILIB.FAQ.show($(this), faqSections);
            }
        });

        faqQuestion.click(function(event) {
            event.stopPropagation();
            var status = $(this).parent().attr("class");

            if (status == "selected") {
                WILIB.FAQ.hide($(this));
            } else {
                WILIB.FAQ.show($(this));
            }
        });
    },

    show: function(current) {
        current.parent().parent().children('.selected:not(.alwaysExpanded)').children('div.wrapper').slideUp();
        current.parent().parent().children('.selected:not(.alwaysExpanded)').removeClass('selected');
        current.parent().addClass("selected");
        current.parent().children('div.wrapper').slideDown();
    },

    hide: function(current) {
        current.parent().parent().children('.selected:not(.alwaysExpanded)').children('div.wrapper').slideUp();
        current.parent().parent().children('.selected:not(.alwaysExpanded)').removeClass('selected');
    }
};


function FeatureWidget(fwt) {
    var featureWidget = this;

    // Start Timer
    function StartTimer() {
        fwt.everyTime(8000, "featureTimer", function(i) {
            featureWidget.show();
        }, 0);
    }

    StartTimer();
    
    // Private var holding the widget tab links, chained to add the click events
    var widgetTabs = fwt.find(".featureTabs li:not(.last) a")
                        .click(function(e) {
                            e.preventDefault();
                            fwt.stopTime("featureTimer");
                            var index = $.inArray($(this).context, widgetTabs);
                            featureWidget.show(index);
                            StartTimer();
                        });/*.mouseout(function() {
                            featureWidget.show();
                            StartTimer();
                        });*/

    widgetTabs.filter(':first').parent().addClass('active').show();
    
    // Private var holding the widget tab content areas
    var tabContents = fwt.find('.featureContainer');
    tabContents.hide().filter(':first').show()
    
    this.index = 0;
    this.animating = false;
    this.show = function(index) {
        if (!this.animating) {
            var previousIndex = this.index; // Save off current index

            // Increment index unless one has been provided
            if (index > -1) {
                this.index = index;
            }
            else {
                this.index = this.index + 1;
            }

            if ((this.index) === widgetTabs.length) {
                // Ensure it returns to 0 on the last item
                this.index = 0;
            }

            widgetTabs.eq(previousIndex).parent().removeClass("active");
            widgetTabs.eq(this.index).parent().attr("class", "active");
            //this.animating = true;
            tabContents.eq(previousIndex).fadeOut(1000, function() {
                tabContents.eq(featureWidget.index).fadeIn(1500);
                featureWidget.animating = false;
            });
        }
    }
    
}

$(document).ready(function() {
    initFeaturesWidgets();
});

function initFeaturesWidgets() {

    $("li.featuresWidget").each(function() {
        FeatureWidget($(this));
    });

}



/**
* jQuery.timers - Timer abstractions for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/10/16
*
* @author Blair Mitchelmore
* @version 1.2
*
**/

jQuery.fn.extend({
    everyTime: function(interval, label, fn, times) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, times);
        });
    },
    oneTime: function(interval, label, fn) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, 1);
        });
    },
    stopTime: function(label, fn) {
        return this.each(function() {
            jQuery.timer.remove(this, label, fn);
        });
    }
});

jQuery.extend({
    timer: {
        global: [],
        guid: 1,
        dataKey: "jQuery.timer",
        regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
        powers: {
            // Yeah this is major overkill...
            'ms': 1,
            'cs': 10,
            'ds': 100,
            's': 1000,
            'das': 10000,
            'hs': 100000,
            'ks': 1000000
        },
        timeParse: function(value) {
            if (value == undefined || value == null)
                return null;
            var result = this.regex.exec(jQuery.trim(value.toString()));
            if (result[2]) {
                var num = parseFloat(result[1]);
                var mult = this.powers[result[2]] || 1;
                return num * mult;
            } else {
                return value;
            }
        },
        add: function(element, interval, label, fn, times) {
            var counter = 0;

            if (jQuery.isFunction(label)) {
                if (!times)
                    times = fn;
                fn = label;
                label = interval;
            }

            interval = jQuery.timer.timeParse(interval);

            if (typeof interval != 'number' || isNaN(interval) || interval < 0)
                return;

            if (typeof times != 'number' || isNaN(times) || times < 0)
                times = 0;

            times = times || 0;

            var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});

            if (!timers[label])
                timers[label] = {};

            fn.timerID = fn.timerID || this.guid++;

            var handler = function() {
                if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
                    jQuery.timer.remove(element, label, fn);
            };

            handler.timerID = fn.timerID;

            if (!timers[label][fn.timerID])
                timers[label][fn.timerID] = window.setInterval(handler, interval);

            this.global.push(element);

        },
        remove: function(element, label, fn) {
            var timers = jQuery.data(element, this.dataKey), ret;

            if (timers) {

                if (!label) {
                    for (label in timers)
                        this.remove(element, label, fn);
                } else if (timers[label]) {
                    if (fn) {
                        if (fn.timerID) {
                            window.clearInterval(timers[label][fn.timerID]);
                            delete timers[label][fn.timerID];
                        }
                    } else {
                        for (var fn in timers[label]) {
                            window.clearInterval(timers[label][fn]);
                            delete timers[label][fn];
                        }
                    }

                    for (ret in timers[label]) break;
                    if (!ret) {
                        ret = null;
                        delete timers[label];
                    }
                }

                for (ret in timers) break;
                if (!ret)
                    jQuery.removeData(element, this.dataKey);
            }
        }
    }
});

jQuery(window).bind("unload", function() {
    jQuery.each(jQuery.timer.global, function(index, item) {
        jQuery.timer.remove(item);
    });
});

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$(document).ready(function() {
	initInformationLiteracyWidgets();
});

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function initInformationLiteracyWidgets() {

	$("li.cycle_widget").each(function() {
		initInformationLiteracyWidget($(this));
	});

}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function initInformationLiteracyWidget(ilw) {

	var steps = ilw.find("div.steps");
	var hotspots = ilw.find(".ilCycle a");

	steps.hide().filter(":first").fadeIn("slow");
	hotspots.filter(":first").parent().addClass("active");

	var ilwConfig = {
		sensitivity: 3,
		interval: 200,
		over: informationLiteracyWidgetHoverIntentOver,
		timeout: 500,
		out: informationLiteracyWidgetHoverIntentOut
	};

	hotspots.hoverIntent(ilwConfig);

}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function informationLiteracyWidgetHoverIntentOver() {

	var shell = $(this.hash);

	$(this).parent().parent().children().removeClass('active');
	$(this).parent().addClass('active');

	var cs = $('.steps', '.cycle_widget');

	cs.filter(':visible').fadeOut("slow", function() {
		shell.fadeIn("slow");
	});
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function informationLiteracyWidgetHoverIntentOut() {
	// we want to do nothing
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$(document).ready(function()
{
    $('.multiColumnTab').each(function()
    {
        var widget = $(this);

        var tabTriggers = widget.find('.tabTriggers > li');
        var tabs = widget.find('.tabContent');

        tabs.hide().eq(0).show();
        tabTriggers.eq(0).addClass('active');

        tabTriggers.click(function(e)
        {
            e.preventDefault();

            var index = $(this).index();

            tabTriggers.removeClass('active').eq(index).addClass('active');
            tabs.hide().eq(index).show();
        });
    });
});

$(function() {
    if($('.nhsmap_widget').length) {
        WILIB.NHSMAP.init();
    }
});

var WILIB = WILIB || {};

WILIB.NHSMAP = {
    init : function () {
        $('li.nhsmap_widget').each(function() {
            WILIB.NHSMAP.setup($(this));
        });
    },

    setup : function (nhsmap) {
        var area = nhsmap.find('ul.nhsmap li a');
        area.mouseover(function(e) {
            e.preventDefault();
            var el = $(this);
            var elText = el.text();
            
            WILIB.NHSMAP.showTooltip(el, elText);
        });

        area.mouseout(function(e) {
            e.preventDefault();
            var el = $(this);
            var elText = el.text();
            WILIB.NHSMAP.removeTooltip(el, elText);
        });
    },

    showTooltip : function (element, elementText) {
        var tempHTML = '<span class="mapTooltip">' + elementText +'<span class="mapTooltipTail"></span></span>';
        element.empty().append(tempHTML);
        element.addClass('tooltipContainer');
        var xPos = (element.width() / 2 - 10);
        $('.mapTooltip').css('left', xPos);
    },

    removeTooltip : function (element, elementText) {
        element.empty().append(elementText);
        element.removeClass('tooltipContainer');
    }
};

$(document).ready(function() {
    initEmptyBoardSelect();
});

function initEmptyBoardSelect() {
    $('input.submit').click(function() {
        var parent = $(this).parents('div.formRow');
        if (parent.find('select').val() == '') {
            parent.append('<span class="error">Please select a Board</span>');
            return false;
        }
    });
}


$(document).ready(function() {
    qualityStrategyWidget();
});

function qualityStrategyWidget() {
    var cycleSections = $('.qualitystrategy_widget .steps', '.cycle-widget');
    var cycleTrigger = $('.qualitystrategy_widget .ilCycle a', '.cycle_widget');

    cycleSections.hide().filter(':first').show();
    cycleTrigger.filter(':first').parent().addClass('active');

    cycleTrigger.mouseover(function() {
        var shell = $(this.hash);

        cycleTrigger.parent().removeClass('active');
        $(this).parent().addClass('active');

        cycleSections.filter(':visible').fadeOut("slow", function() {
            shell.fadeIn("slow");
        });

        return false
    });
}

$(document).ready(function() {
    quickLinksInit();
});

function quickLinksInit() {
    var container = $('.quicklinks_widget');
    $.each(container, function(index, value) {
        var showCount = $(value).find('.defaultSize').html(); //$(container).find('.defaultSize').html();
        quickLinksSetup(value, showCount);
    });
}

function quickLinksSetup(container, noOfRows) {
    if ($('.quicklinks_widget').length && noOfRows) {
        var noOfRowsVisible = noOfRows - 1;
        var newContainer = $(container); //$('.quicklinks_widget');
        var listItems = newContainer.find('ul.quickLinksItems li');
        var moreLink = newContainer.find('.more');
        var moreLinkSpan = moreLink.find('span');

        if (noOfRows > 0) {
            listItems.filter(':gt(' + noOfRowsVisible + ')').hide();
        }

        moreLink.click(function() {
            var shell = $(this);
            if (shell.parent().find('ul.quickLinksItems li:hidden').length) {
                shell.parent().find('ul.quickLinksItems li:hidden').slideDown();
                moreLinkSpan.text('Hide');
                moreLink.addClass('fullList');
                return false;
            } else {
                listItems.filter(':gt(' + noOfRowsVisible + ')').slideUp();
                moreLinkSpan.text('More');
                moreLink.removeClass('fullList');
                return false;
            }
        });
    }
}

$(document).ready(function() {

var defaultValue = $("p.defaultFeedsDisplay").html();
    $("p.defaultFeedsDisplay").hide();
    newsFeedsInit(defaultValue);

});

function newsFeedsInit(noOfFeeds) {
    var container = $('.newsfeeds_widget');
    $.each(container, function(index, value) {
        newsFeedsSetup(value, noOfFeeds);
    });
}

function newsFeedsSetup(c, num) {
    // assumption, the number of h4's = the number of ul's

    var numVisible = num - 1;

    var lists = $(c).find('ul.news');
    var headings = $(c).find('h4.listHeader');

    var moreLink = $(c).find('.more');
    var moreLinkSpan = moreLink.find('span');

    if (numVisible > 0) {
        lists.filter(':gt(' + numVisible + ')').hide();
        headings.filter(':gt(' + numVisible + ')').hide();
    }

    moreLink.click(function() {
        if (lists.filter('ul:hidden').length > 0) {
            lists.filter('ul:hidden').slideDown();
            headings.filter('h4:hidden').slideDown();
            moreLinkSpan.text('Hide');
        } else {
            headings.filter(':gt(' + numVisible + ')').slideUp();
            lists.filter(':gt(' + numVisible + ')').slideUp();
            moreLinkSpan.text('More RSS newsfeeds');
        }
        return false;
    });
}


$(document).ready(function() {
    $('.saveAndShare').each(function() {
        var saveShareWidget = $(this);

        saveShareWidget.find('.tagging .addTags input[type=text]').autocomplete('/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType&action=searchTags',
        {
            delay: 400,
            minChars: 1,
            matchSubset: 1,
            matchContains: 1,
            cacheLength: 10,
            formatItem: function(row) { return row[0]; },
            autoFill: false,
            max: 10
        });

        saveShareWidget.find('.ssEmail fieldset, .ssEmail p.emailAllLogin').hide();

        var emailButton = saveShareWidget.find('.ssEmail > strong');

        emailButton.css('cursor', 'pointer');

        emailButton.click(function() {
            var form = $(this).parent().find('fieldset, p.emailAllLogin');

            if (form.css('display') == 'none') {
                form.show(400);
            }
            else {
                form.hide(400);
            }
        });

        saveShareWidget.find('.ssEmail .formButtons input[type=submit]').click(function() {
            var form = $(this).parent().parent();

            form.find('p.error').remove();

            var recipients = $.trim(form.find('.email input[type=text]').val());
            var subject = $.trim(form.find('.subject input[type=text]').val());
            var message = $.trim(form.find('.message textarea').val());

            var formErrorFound = false;

            if (recipients.length === 0) {
                form.find('.email input[type=text]').after('<p class="error">Required</p>');
                formErrorFound = true;
            }

            var emails = recipients.split(';');

            var emailRegex = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

            for (var i in emails) {
                var email = $.trim(emails[i]);

                if (email.length > 0 && !emailRegex.test(email)) {
                    form.find('.email input[type=text]').after('<p class="error">Invalid email address(es)</p>');
                    formErrorFound = true;
                    break;
                }
            }

            if (subject.length === 0) {
                form.find('.subject input[type=text]').after('<p class="error">Required</p>');
                formErrorFound = true;
            }

            if (message.length === 0) {
                form.find('.message textarea').after('<p class="error">Required</p>');
                formErrorFound = true;
            }

            return !formErrorFound;
        });

        var clearingAllProgress = false;
        saveShareWidget.find('li.ssClear input[type=submit]').click(function() {
            if (!clearingAllProgress) {
                clearingAllProgress = true;
                
                var button = saveShareWidget.find('.jqTopRecords input.button');
                var uiControls = saveShareWidget.find('.uiControls');

                $.post('/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType&action=clearAll', function(data) {
                    if (button.hasClass('unmark')) { button.removeClass('unmark'); }
                    if (!button.hasClass('mark')) { button.addClass('mark'); }

                    button.val(button.val().replace('Unmark', 'Mark'));

                    saveShareWidget.find('.recordList ul.selectedRecords li').remove();

                    if (uiControls.css('display') != 'none') {
                        uiControls.hide(1000);
                    }

                    if (typeof saveShare_unmarkAllRecords == 'function') {
                        saveShare_unmarkAllRecords();
                    }
                });
                
                clearingAllProgress = false;
                return false;
            }
        });

        var printButton = saveShareWidget.find('.ssPrint a');

        printButton.attr('href', '');

        printButton.click(function() {
            var frame = $(this).parent().find('iframe');

            if (frame.length === 0) {
                var style = 'width: 0; height: 0; border: none;';
                $(this).parent().append('<iframe border="0" width="0" height="0" style="' + style + '" src=""></iframe>');

                frame = $(this).parent().find('iframe');
            }

            frame.attr('src', '/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType&action=iframe');

            return false;
        });

        var markingProgress = false;

        saveShareWidget.find('.jqTopRecords input.button').click(function() {
            if (!markingProgress) {
                markingProgress = true;

                var button = $(this);

                $.post('/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType&action=markRecords', function(data) {
                    var uiControls = saveShareWidget.find('.uiControls');

                    if (button.hasClass('mark')) {
                        button.removeClass('mark');
                        button.addClass('unmark');

                        button.val(button.val().replace('Mark', 'Unmark'));

                        var recordsList = saveShareWidget.find('.recordList ul.selectedRecords');
                        recordsList.find('li').remove();

                        for (var i = 0; i < data.length; i++) {
                            recordsList.append('<li' + (i % 2 != 0 ? ' class="even" ' : '') + '>' +
                            data[i].Name + '<input type="hidden" value="" /></li>');

                            recordsList.find('li').last().find('input[type=hidden]').val(data[i].Id);
                        }

                        if (uiControls.css('display') == 'none') {
                            uiControls.show(1000);
                        }

                        if (typeof saveShare_markAllRecords == 'function') {
                            saveShare_markAllRecords();
                        }
                    }
                    else {
                        button.removeClass('unmark');
                        button.addClass('mark');

                        button.val(button.val().replace('Unmark', 'Mark'));

                        saveShareWidget.find('.recordList ul.selectedRecords li').remove();

                        if (uiControls.css('display') != 'none') {
                            uiControls.hide(1000);
                        }

                        if (typeof saveShare_unmarkAllRecords == 'function') {
                            saveShare_unmarkAllRecords();
                        }
                    }

                    markingProgress = false;
                });
            }

            return false;
        });
    });
});

function saveShare_AddResource(id, name, url, type, source, pubDate, mkn)
{
    var found = $('.saveAndShare .recordList ul.selectedRecords li input[type=hidden][value=\'' + id.replace('\'', '\\\'') + '\']').length > 0;
    if(!found)
    {
        $.post('/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType',
        {
            action: 'addResource',
            id: id,
            name: name,
            url: url,
            type: type,
            source: source,
            pubDate: pubDate,
            mkn: mkn
        },
        function(data)
        {
            if (data == 'success')
            {
                var selectedRecords = $('.saveAndShare .recordList ul.selectedRecords');
                var recordCount = selectedRecords.find('li').length;

                selectedRecords.append('<li' + (recordCount % 2 != 0 ? ' class="even" ' : '') + '>' +
                    name + '<input type="hidden" value="" /></li>');

                var insertedItem = selectedRecords.find('li').last();
                insertedItem.find('input[type=hidden]').val(id);

                if ($('.saveAndShare .uiControls').css('display') == 'none')
                {
                    $('.saveAndShare .uiControls').show(1000);
                }
            }
        });
    }
}

function saveShare_RemoveResource(id)
{
    var record = $('.saveAndShare .recordList ul.selectedRecords li input[type=hidden][value=\'' + id.replace('\'', '\\\'') + '\']').parent();
    if (record.length > 0)
    {
        $.post('/umbraco/WidgetLibrary/WidgetAjaxHandler.aspx?t=NES.WidgetLibrary.WidgetTypes.TKN.SaveShare.SaveShareWidgetType', { action: 'removeResource', id: id }, function(data)
        {
            if (data == 'success')
            {
                var selectedRecords = record.parent();

                record.remove();

                var increment = 1;
                selectedRecords.find('li').each(function()
                {
                    if (increment % 2 == 0)
                    {
                        $(this).addClass('even');
                    }
                    else
                    {
                        $(this).removeClass('even');
                    }

                    increment++;
                });

                var recordCount = $('.saveAndShare .recordList ul.selectedRecords li').length;

                if (recordCount == 0)
                {
                    $('.saveAndShare .uiControls').hide(1000);
                }
            }
        });
    }
}

$(document).ready(function()
{
    $('.bookAndJournals ul.menu li a').click(function ()
    {
        var name = $(this).attr('class');

        var item = $(this).parent();
        var menu = item.parent();
        menu.find('li').removeClass('selected');
        item.addClass('selected');

        $('.bookAndJournals div.panel').hide();
        $('.bookAndJournals div.' + name).show();

        return false;
    });
});

/*
 * jQuery Tools 1.2.3 - The missing UI library for the Web
 * 
 * [tabs]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Sat Jul 03 19:35:31 GMT 2010
 */
(function(c){function p(e,b,a){var d=this,l=e.add(this),h=e.find(a.tabs),i=b.jquery?b:e.children(b),j;h.length||(h=e.children());i.length||(i=e.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return d.click(n,g);if(f>n)return d.click(0,g)}if(!k.length){if(j>=0)return d;f=a.initialIndex;k=h.eq(f)}if(f===j)return d;
g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(d,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return d}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return d.click(j+1)},prev:function(){return d.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
i.find("a[href^=#]").unbind("click.T");return d}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(d).bind(g,a[g]);d[g]=function(k){c(d).bind(g,k);return d}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){d.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){d.click(c(this).attr("href"),f)});if(location.hash)d.click(location.hash);else if(a.initialIndex===
0||a.initialIndex>0)d.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.3"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(e,b){o[e]=b}};var o={"default":function(e,b){this.getPanes().hide().eq(e).show();b.call()},fade:function(e,b){var a=this.getConf(),d=a.fadeOutSpeed,l=this.getPanes();d?l.fadeOut(d):l.hide();l.eq(e).fadeIn(a.fadeInSpeed,b)},slide:function(e,b){this.getPanes().slideUp(200);
this.getPanes().eq(e).slideDown(400,b)},ajax:function(e,b){this.getPanes().eq(0).load(this.getTabs().eq(e).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(e,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(e).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(e,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b={onBeforeClick:b};b=c.extend({},
c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),e,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);

$(function () {
    $(".accordion").tabs(".accordion div.pane", { tabs: 'h2', effect: 'slide', initialIndex: 20 });
});

$(function () {
    $("div.slidetabs").tabs(".images > div", {
        effect: 'fade',
        fadeInSpeed: 1500,
        fadeOutSpeed: 1500,
        rotate: true
    }).slideshow({ autoplay: true });
});

/*
 * jQuery Tools 1.2.3 - The missing UI library for the Web
 * 
 * [tabs, tabs.slideshow]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Sun Jul 04 13:04:45 GMT 2010
 */
(function(c){function p(e,b,a){var d=this,l=e.add(this),h=e.find(a.tabs),i=b.jquery?b:e.children(b),j;h.length||(h=e.children());i.length||(i=e.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return d.click(n,g);if(f>n)return d.click(0,g)}if(!k.length){if(j>=0)return d;f=a.initialIndex;k=h.eq(f)}if(f===j)return d;
g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(d,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return d}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return d.click(j+1)},prev:function(){return d.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
i.find("a[href^=#]").unbind("click.T");return d}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(d).bind(g,a[g]);d[g]=function(k){c(d).bind(g,k);return d}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){d.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){d.click(c(this).attr("href"),f)});if(location.hash)d.click(location.hash);else if(a.initialIndex===
0||a.initialIndex>0)d.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.3"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(e,b){o[e]=b}};var o={"default":function(e,b){this.getPanes().hide().eq(e).show();b.call()},fade:function(e,b){var a=this.getConf(),d=a.fadeOutSpeed,l=this.getPanes();d?l.fadeOut(d):l.hide();l.eq(e).fadeIn(a.fadeInSpeed,b)},slide:function(e,b){this.getPanes().slideUp(200);
this.getPanes().eq(e).slideDown(400,b)},ajax:function(e,b){this.getPanes().eq(0).load(this.getTabs().eq(e).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(e,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(e).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(e,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b={onBeforeClick:b};b=c.extend({},
c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),e,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);
(function(d){function r(g,a){function p(f){var e=d(f);return e.length<2?e:g.parent().find(f)}var c=this,j=g.add(this),b=g.data("tabs"),h,l,m,n=false,o=p(a.next).click(function(){b.next()}),k=p(a.prev).click(function(){b.prev()});d.extend(c,{getTabs:function(){return b},getConf:function(){return a},play:function(){if(!h){var f=d.Event("onBeforePlay");j.trigger(f);if(f.isDefaultPrevented())return c;n=false;h=setInterval(b.next,a.interval);j.trigger("onPlay");b.next()}},pause:function(){if(!h)return c;
var f=d.Event("onBeforePause");j.trigger(f);if(f.isDefaultPrevented())return c;h=clearInterval(h);m=clearInterval(m);j.trigger("onPause")},stop:function(){c.pause();n=true}});d.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","),function(f,e){d.isFunction(a[e])&&c.bind(e,a[e]);c[e]=function(s){return c.bind(e,s)}});if(a.autopause){var t=b.getTabs().add(o).add(k).add(b.getPanes());t.hover(function(){c.pause();l=clearInterval(l)},function(){n||(l=setTimeout(c.play,a.interval))})}if(a.autoplay)m=
setTimeout(c.play,a.interval);else c.stop();a.clickable&&b.getPanes().click(function(){b.next()});if(!b.getConf().rotate){var i=a.disabledClass;b.getIndex()||k.addClass(i);b.onBeforeClick(function(f,e){if(e){k.removeClass(i);e==b.getTabs().length-1?o.addClass(i):o.removeClass(i)}else k.addClass(i)})}}var q;q=d.tools.tabs.slideshow={conf:{next:".forward",prev:".backward",disabledClass:"disabled",autoplay:false,autopause:true,interval:3E3,clickable:true,api:false}};d.fn.slideshow=function(g){var a=
this.data("slideshow");if(a)return a;g=d.extend({},q.conf,g);this.each(function(){a=new r(d(this),g);d(this).data("slideshow",a)});return g.api?a:this}})(jQuery);


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// frontEndScript.js - BEGIN
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$(function() {

    initContentTabbedWidgets();
    overiderDefaultTab();

});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function overiderDefaultTab() {

    if (location.href.indexOf("#") != -1)
    {
        var substr = location.href.split('#');
        var tab = substr[1];

        if (tab.length > 0) {
            switchTab(tab);
        }
    }
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function switchTab(tab) {
    var targetTabTriggers = $('.tabTriggers').find('a[href*=' + tab + ']').parent().parent();

    targetTabTriggers.children('.active').removeClass('active');
    targetTabTriggers.find('a[href*=' + tab + ']').parent().addClass('active');

    var shell = $('#' + tab);

    //$('.tabContent').hide();
    targetTabTriggers.parent().find('.tabContent').hide();
    shell.show();

    return false
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function initContentTabbedWidgets() {

    $("li.qit_widget").each(function() {
        initContentTabbedWidget($(this));
    });

}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function initContentTabbedWidget(ctw) {

    var tTriggers = ctw.find('.tabTriggers a');
    var tContent = ctw.find('.tabContent');
    tabFader(tTriggers, tContent);

}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function tabFader(tabTrigger, tabSections) {

    tabSections.hide().filter(':first').show();
    tabTrigger.filter(':first').parent().addClass('active');

    tabTrigger.click(function() {

        tabTrigger.parent().removeClass('active');
        $(this).parent().addClass('active');
        tabSections.hide().filter(this.hash).show();
        return false

    });

}


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// frontEndScript.js - END
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$(document).ready(function()
{
    $('.elibrary ul.menu li a').click(function()
    {
        var name = $(this).attr('class');

        var item = $(this).parent();
        var menu = item.parent();
        menu.find('li').removeClass('selected');
        item.addClass('selected');

        $('.elibrary div.panel').hide();
        $('.elibrary div.' + name).show();

        return false;
    });

    $('.elibrary .journals form').submit(function()
    {
        var text = $.trim($(this).find('input[type=text]').val());

        if (text.length < 3)
        {
            if ($(this).find('.error').length == 0)
            {
                $(this).find('input[type=text]').after('<p class="error">Please enter a search term (minimum 3 characters)</p>');
            }
            return false;
        }
    });

    $('.elibrary .articles form').submit(function()
    {
        var title = $.trim($(this).find('input[name=Title]').val());
        var author = $.trim($(this).find('input[name=Author]').val());
        var journalTitle = $.trim($(this).find('input[name=JournalTitle]').val());
        var keyword = $.trim($(this).find('input[name=Keyword]').val());
        var issn = $.trim($(this).find('input[name=ISSN]').val());
        var volume = $.trim($(this).find('input[name=Volume]').val());
        var issue = $.trim($(this).find('input[name=Issue]').val());
        var startPage = $.trim($(this).find('input[name=StartPage]').val());
        var publishedYear = $.trim($(this).find('input[name=PublishedYear]').val());

        if (title == '' && author == '' && journalTitle == '' && keyword == '' && issn == '' &&
            volume == '' && issue == '' && startPage == '' && publishedYear == '')
        {
            if ($(this).find('.error').length == 0)
            {
                $(this).find('.right').after('<p class="error">Please enter at least one search term.</p>');
            }

            return false;
        }
    });

    $('.elibrary .books form').submit(function()
    {
        var title = $.trim($(this).find('input[name=Title]').val());
        var author = $.trim($(this).find('input[name=Author]').val());
        var keyword = $.trim($(this).find('input[name=Keyword]').val());

        if (title == '' && author == '' && keyword == '')
        {
            if ($(this).find('.error').length == 0)
            {
                $(this).find('.fullTextOptions').after('<p class="error">Please enter at least one search term.</p>');
            }

            return false;
        }
    });

    $('.elibrary .libraries form').submit(function()
    {
        var location = $.trim($(this).find('input[name=Keyword]').val());

        if (location == '')
        {
            if ($(this).find('.error').length == 0)
            {
                $(this).find('.buttonBox').after('<p class="error">Please enter a search term (minimum 3 characters).</p>');
            }

            return false;
        }
    });
});

$(document).ready(function()
{
    TKN_ResourcesWidget_ProgressiveEnhancement();
});

function TKN_ResourcesWidget_ProgressiveEnhancement()
{
    $('.tknResources').each(function()
    {
        var headings = $(this).find('.resourceGroupList > li > h3');

        headings.css('cursor', 'pointer');

        headings.click(function()
        {
            var index = $(this).parent().parent().children('li').index($(this).parent());

            var container = $(this).siblings('div.resourcesList');
            var height = container.attr('data-height');
            if (height)
            {
                container.css('height', height + 'px');
            }

            if (container.css('display') == 'none')
            {
                $('ul.resourceGroupList li.selected div.resourcesList').slideUp(500, function()
                {
                    $(this).parent().removeClass('selected');
                });

                $(this).parent().addClass('selected');
                container.slideDown(500);
            }
            else
            {
                container.slideUp(500, function()
                {
                    $(this).parent().removeClass('selected');
                });
            }
        });

        var firstContainer = $(this).find('.resourceGroupList > li > div.resourcesList:first');
        if (firstContainer.length > 0)
        {
            var height = firstContainer.attr('data-height');
            if (height)
            {
                firstContainer.css('height', height + 'px');
            }
            firstContainer.parent().addClass('selected');
            firstContainer.show();
        }
    });
}

$(document).ready(function() {
    searchProvidersInit();
});

function searchProvidersInit() {
    $('.searchProviders').show();
}



