﻿/************************************************************
*** COMMON JAVASCRIPT FUNCTIONS (UNPACKED VERSION)
************************************************************/

/*

All javascript here is original commented un packed, for ease
of editing and updating etc. When new projects are created
ensure that any unused code is removed, especially any large
third party scripts at the bottom of this file.

Store this original in \Scripts\UnPacked\Common.js

Once complete and site is in live state ensure that the script
has been packed and saved as \Scripts\Packed.js to pack the
script visit http://dean.edwards.name/packer/

*/

/************************************************************
*** GENERAL FORM FUNCTIONS
************************************************************/

// cross browser function to find an element by id
function objById(id)
{ 
	if (document.getElementById) return document.getElementById(id); 
	else if (document.all) return document.all[id]; 
	else if (document.layers) return document.layers[id]; 
}

// quick search catch enter
function qsEnt(e)
{
    var keyCode;
    if (window.event) keyCode = window.event.keyCode;
    else if (e) keyCode = e.which;

    if (keyCode == 13) {
        qsGo();
        return false;
    }
    else return true;
}

// run quick search
function qsGo()
{
	var srchTxt = "";
    if (document.forms[0].txtSearch.value != "" && document.forms[0].txtSearch.value != "Enter your search keywords here") srchTxt = document.forms[0].txtSearch.value.replace(/[\<\%\&\@\#\=\+\>\*]*/g, "").replace(/\s+/g, " ").replace(/^\s+/, "").replace(/\s+$/, "");
    //location.href = HTTPHost + "/product-list" + ((srchTxt != "") ? "?Text=" + srchTxt : "");
    location.href = HTTPHost + (document.forms[0].sType2.checked ? "/product-list?CatId=53&Text=" : "/product-list?CatId=52&Text=") + srchTxt;
}
function qsSpareGo() {
    var srchTxt = "";
    if (document.forms[0].txtSpareSearch.value != "" && document.forms[0].txtSpareSearch.value != "Enter your search keywords here") srchTxt = document.forms[0].txtSpareSearch.value.replace(/[\<\%\&\@\#\=\+\>\*]*/g, "").replace(/\s+/g, " ").replace(/^\s+/, "").replace(/\s+$/, "");
    //location.href = HTTPHost + "/product-list" + ((srchTxt != "") ? "?Text=" + srchTxt : "");
    location.href = HTTPHost + "/product-list?CatId=53&Text=" + srchTxt;
}


/************************************************************
*** GENERAL FORM FUNCTIONS
************************************************************/

function focusTxt(a) { a.className = a.className + " hLgt"; }
function blurTxt(a) { a.className = a.className.replace(" hLgt", ""); }


/************************************************************
*** PRODUCT LIST FUNCTIONS
************************************************************/

function ddRpp(a) { location.href=location.href.replace(/&RPP=[0-9]+/, '')+'&RPP='+a.selectedIndex; }
function ddSort(a) { location.href=location.href.replace(/&Sort=[0-9]+/, '')+'&Sort='+a.selectedIndex; }


/************************************************************
*** PRODUCT DETAIL FUNCTIONS
************************************************************/

function chkQty(a) {
    if (isNaN(a.value) || parseInt(a.value) < 1) {
        a.value = '';
        return false;
    }
    return true;
}

// used for calculating total price based on hidden fields populated via ajax,
// updated to include price break calculations
function chkStkPri() {
                    
    // get hidden field data
    var objQuantity = getQtyObj();
    var quantity = objQuantity.value;
    var price = getPrice();
    var priceBreaksArrayString = getPriceBreaks();
    var stock = getStock();

    // check we have a valid quantity
    if (!chkQty(objQuantity)) return;
    
    // see if we are checking stock, if so do so now and correct if required
    if (!isNaN(stock) && stock != '') {
        if (stock == 0) {
            alert('Sorry we do not have enough stock of this product to fulfil your order.');
            objQuantity.value = quantity = 1;
        }
        else if (stock < quantity) {
            alert('Sorry we do not have enough stock of this product to fulfil your order, we have adjusted your qty to the maximum available at the last check.');
            objQuantity.value = quantity = stock;
        }
    }

    // check we have valid price
    if (isNaN(price) || price == '') {
        objById('ttl').value = 'error';
        return;
    }
    else price = parseFloat(price);

    // if we have price break data loop though and get correct price
    if (priceBreaksArrayString != '') {

        var priceBreaksArray = priceBreaksArrayString.split('|');
        
        // loop though price breaks
        for (i = 0; i < priceBreaksArray.length; i++)
        {
            // get qty and price from price break
            var quantityAndPriceArray = priceBreaksArray[i].split(',');
            
            // see if we have enough qty to use this price, quick once we hit a price break qty too high
            if (quantity >= parseInt(quantityAndPriceArray[0])) price = parseFloat(quantityAndPriceArray[1]);
            else break;
        }                  
    }

    // calculate total cost and display
    objById('ttl').innerHTML = '&pound;' + (quantity * price).toFixed(2);
}


/********************************************************************************************
*** MODAL DIALOG FUNCTION - show a page in a modal dialog with overlay (requires modalDialog jQuery library)
********************************************************************************************/

function modalDialog(url, width, height)
{
	// precautionary removal of any existing modal dialog source html (in case it somehow got left behind)
	$("#modal").remove();

	// create new modal
	$("body").append("<div id=\"modal\" style=\"display: none;\"></div>");

	// load the html from the template and show it in a modal dialog
	$.ajax({
		url: FolderRoot + url,
		cache: false,
		dataType: "html",
		success: function (data)
		{
			$("#modal").html(data).modalDialog({ css: { width: width + "px", height: height + "px" } });
		}
	});
}


/********************************************************************************************
*** MODAL FRAME FUNCTION - show an iframe in a modal dialog with overlay (requires modalDialog jQuery library)
********************************************************************************************/

function modalFrame(url, width, height, data)
{
	// precautionary removal of any existing modal dialog source html (in case it somehow got left behind)
	$("#modal").remove();

	// create new modal with an iframe in situ
	$("body").append("<div id=\"modal\" style=\"display: block;\"><a class=\"close\" href=\"javascript:void(0)\" onclick=\"return false;\" style=\"display: block; width: 20px; height: 20px; position: absolute; margin-left: " + (width - 38) + "px; \"><img src=\"" + FolderRoot + "Img/Com/modClose.png\" alt=\"Close\" title=\"Close\" /></a></div>");

	// display the modal window
	$("#modal").modalDialog({ css: { width: width + "px", height: height + "px" }, bgCss: { width: (width + 40) + "px", height: (height + 40) + "px", background: "#2D2D2D", opacity: 0.8} });

	// now add the iframe and hidden field to pass through any data
	$("<input type=\"hidden\" id=\"hfData\" value=\"" + data + "\"><iframe frameborder=\"0\" width=\"100%\" height=\"" + height + "\" scrolling=\"auto\" src=\"" + url + "\"></iframe>").appendTo("#modal");
}

function modalClose()
{
	$((parent) ? $(".modalDialog", parent.document) : $modal = $(".modalDialog")).fadeOut(300, function() { $(this).remove; });
}

/************************************************************
*** EXTERNAL LIBRARIES
************************************************************/

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @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) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { 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; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);


/* Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Version 2.1.2
*/
(function ($) { $.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function (d) { d = $.extend({ top: "auto", left: "auto", width: "auto", height: "auto", opacity: true, src: "javascript:false;" }, d); var c = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + d.src + '"style="display:block;position:absolute;z-index:-1;' + (d.opacity !== false ? "filter:Alpha(Opacity='0');" : "") + "top:" + (d.top == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')" : b(d.top)) + ";left:" + (d.left == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')" : b(d.left)) + ";width:" + (d.width == "auto" ? "expression(this.parentNode.offsetWidth+'px')" : b(d.width)) + ";height:" + (d.height == "auto" ? "expression(this.parentNode.offsetHeight+'px')" : b(d.height)) + ';"/>'; return this.each(function () { if ($(this).children("iframe.bgiframe").length === 0) { this.insertBefore(document.createElement(c), this.firstChild) } }) } : function () { return this }); $.fn.bgIframe = $.fn.bgiframe; function b(c) { return c && c.constructor === Number ? c + "px" : c } })(jQuery);


/*
/* jquery.modalDialog.js - modal dialog plugin for jQuery
/* Colin Jaggs (c) 2011 Pin Digital Ltd
/* adds 4 layers (an iframe (ie6 only) and a 'blackout' mask to cover content behind the modal window, the modal window itself at the size specified, and a modal background ideal for providing borders around the content etc.)
*/
(function($){var b=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);$.fn.modalDialog=function(c){c=$.extend({},$.fn.modalDialog.defaults,c||{});c.overlayCSS=$.extend({},$.fn.modalDialog.defaults.overlayCSS,c.overlayCSS||{});var d=$.extend({},$.fn.modalDialog.defaults.css,c.css||{});var e=$.extend({},$.fn.modalDialog.defaults.bgCss,c.bgCss||{});var f=$(this);var g=c.zIndex;var h=b?$('<iframe class="modalDialog modaliFrm" style="z-index:'+g++ +';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+c.iframeSrc+'"></iframe>'):"";var i=$('<div class="modalDialog modalOvl" style="z-index:'+g++ +';display:none;border:none;margin:0;padding:0;position:fixed;width:100%;height:100%;top:0;left:0"></div>');var j=$('<div class="modalDialog modalBg" style="z-index:'+g++ +';display:none;position:fixed"></div>');var k=$('<div class="modalDialog modalMsg" style="z-index:'+g+';display:none;position:fixed"></div>');if(b)h.css("opacity",0);i.css(c.overlayCSS);j.css(e);k.css(d);$(f).show().appendTo($(k));var l=[h,i,j,k];$.each(l,function(){if(this!="")this.appendTo($("body"))});if(b){$.each([h,i],function(){$(this).css({position:"absolute",width:jQuery.boxModel&&document.documentElement.clientWidth||document.body.clientWidth+"px",height:Math.max(document.body.scrollHeight,document.body.offsetHeight)+"px"})});j.css({position:"absolute"});k.css({position:"absolute"})}j.css({left:"50%",marginLeft:j.outerWidth()/2*-1,top:"50%",marginTop:j.outerHeight()/2*-1});k.css({left:"50%",marginLeft:k.outerWidth()/2*-1,top:"50%",marginTop:k.outerHeight()/2*-1});if(c.fadeIn){i.fadeIn(c.fadeIn);j.fadeIn(c.fadeIn);k.fadeIn(c.fadeIn,function(){if(c.onLoad)c.onLoad()})}else{i.show();j.show();k.show();if(c.onLoad)c.onLoad()}if(c.overlayClickToClose)i.click(function(){$.fn.modalDialogHide(c)});$("#modal "+c.closeSel).click(function(){$.fn.modalDialogHide(c)})};$.fn.modalDialogHide=function(b){b=$.extend({},$.fn.modalDialog.defaults,b||{});var c=$("body").children().filter(".modalDialog").add("body > .modalDialog");if(b.fadeOut)c.fadeOut(b.fadeOut,function(){$(this).remove});else c.remove()};$.fn.modalDialog.defaults={css:{background:"#fff"},bgCss:{},overlayCSS:{backgroundColor:"#000",opacity:.6},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",zIndex:1e3,fadeIn:300,fadeOut:300,closeSel:".close",overlayClickToClose:true,onLoad:null}})(jQuery);


/*
/* jquery.columnise.js - take a list (OL/UL) and split into multiple columns
/* Colin Jaggs (c) 2011 Pin Digital Ltd
*/
(function($){$.fn.columnise=function(b){b=$.extend({cols:3},b);var c=$(this).attr("id");var d=$("> li",this).length/b.cols>parseInt($("> li",this).length/b.cols)?parseInt($("> li",this).length/b.cols)+1:parseInt($("> li",this).length/b.cols);$(this).wrap('<div id="'+c+'"/>');$(this).attr("id","").addClass("col1");for(var e=b.cols;e>1;e--)$('<ul class="col'+e+'" />').insertAfter($(this));var e=0,f=2;$("> li",this).each(function(){e++;if(e>d*(f-1)){$(this).appendTo($("ul.col"+f,this.parent));if(e==d*f)f++}});$("#"+c+" ul").each(function(){$(this).wrap('<div class="'+$(this).attr("class")+'"/>')})}})(jQuery);


/*
 * jQuery Autocomplete plugin 1.1
 *
 * Copyright (c) 2009 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
 * Extended by Colin Jaggs 2010 to include result summary below list
 */
(function(a){a.fn.extend({autocomplete:function(b,c){var d=typeof b=="string";c=a.extend({},a.Autocompleter.defaults,{url:d?b:null,data:d?null:b,delay:d?a.Autocompleter.defaults.delay:10,max:c&&!c.scroll?10:150},c);c.highlight=c.highlight||function(a){return a};c.formatMatch=c.formatMatch||c.formatItem;return this.each(function(){new a.Autocompleter(this,c)})},result:function(a){return this.bind("result",a)},search:function(a){return this.trigger("search",[a])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(a){return this.trigger("setOptions",[a])},unautocomplete:function(){return this.trigger("unautocomplete")}});a.Autocompleter=function(b,c){function x(){e.removeClass(c.loadingClass)}function w(b){var d=[];var e=b.split("\n");for(var f=0;f<e.length;f++){var g=a.trim(e[f]);if(g){g=g.split("|");d[d.length]={data:g,value:g[0],result:c.formatResult&&c.formatResult(g,g[0])||g[0]}}}return d}function v(d,e,f){if(!c.matchCase)d=d.toLowerCase();var g=h.load(d);if(g&&g.length){e(d,g)}else if(typeof c.url=="string"&&c.url.length>0){var i={timestamp:+(new Date)};a.each(c.extraParams,function(a,b){i[a]=typeof b=="function"?b():b});a.ajax({mode:"abort",port:"autocomplete"+b.name,dataType:c.dataType,url:c.url,data:a.extend({q:q(d),limit:c.max},i),success:function(a){var b=c.parse&&c.parse(a)||w(a);h.add(d,b);e(d,b)}})}else{l.emptyList();f(d)}}function u(a,b){if(b&&b.length&&i){x();l.display(b,a);r(a,b[0].value);l.show()}else{t()}}function t(){var a=l.visible();l.hide();clearTimeout(f);x();if(c.mustMatch){e.search(function(a){if(!a){if(c.multiple){var b=p(e.val()).slice(0,-1);e.val(b.join(c.multipleSeparator)+(b.length?c.multipleSeparator:""))}else{e.val("");e.trigger("result",null)}}})}}function s(){clearTimeout(f);f=setTimeout(t,200)}function r(f,h){if(c.autoFill&&q(e.val()).toLowerCase()==f.toLowerCase()&&j!=d.BACKSPACE){e.val(e.val()+h.substring(q(g).length));a(b).selection(g.length,g.length+h.length)}}function q(d){if(!c.multiple)return d;var e=p(d);if(e.length==1)return e[0];var f=a(b).selection().start;if(f==d.length){e=p(d)}else{e=p(d.replace(d.substring(f),""))}return e[e.length-1]}function p(b){if(!b)return[""];if(!c.multiple)return[a.trim(b)];return a.map(b.split(c.multipleSeparator),function(c){return a.trim(b).length?a.trim(c):null})}function o(a,b){if(j==d.DEL){l.hide();return}var f=e.val();if(!b&f==g)return;g=f;f=q(f);if(f.length>=c.minChars){e.addClass(c.loadingClass);if(!c.matchCase)f=f.toLowerCase();v(f,u,t)}else{x();l.hide()}}function n(){var d=l.selected();if(!d)return false;var f=d.result;g=f;if(c.multiple){var h=p(e.val());if(h.length>1){var i=c.multipleSeparator.length;var j=a(b).selection().start;var k,m=0;a.each(h,function(a,b){m+=b.length;if(j<=m){k=a;return false}m+=i});h[k]=f;f=h.join(c.multipleSeparator)}f+=c.multipleSeparator}e.val(f);t();e.trigger("result",[d.data,d.value]);return true}var d={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var e=a(b).attr("autocomplete","off").addClass(c.inputClass);var f;var g="";var h=a.Autocompleter.Cache(c);var i=0;var j;var k={mouseDownOnSelect:false};var l=a.Autocompleter.Select(c,b,n,k);var m;a.browser.opera&&a(b.form).bind("submit.autocomplete",function(){if(m){m=false;return false}});e.bind((a.browser.opera?"keypress":"keydown")+".autocomplete",function(b){i=1;j=b.keyCode;switch(b.keyCode){case d.UP:b.preventDefault();if(l.visible()){l.prev()}else{o(0,true)}break;case d.DOWN:b.preventDefault();if(l.visible()){l.next()}else{o(0,true)}break;case d.PAGEUP:b.preventDefault();if(l.visible()){l.pageUp()}else{o(0,true)}break;case d.PAGEDOWN:b.preventDefault();if(l.visible()){l.pageDown()}else{o(0,true)}break;case c.multiple&&a.trim(c.multipleSeparator)==","&&d.COMMA:case d.TAB:case d.RETURN:if(n()){b.preventDefault();m=true;return false}break;case d.ESC:l.hide();break;default:clearTimeout(f);f=setTimeout(o,c.delay);break}}).focus(function(){i++}).blur(function(){i=0;if(!k.mouseDownOnSelect){s()}}).click(function(){if(i++>1&&!l.visible()){o(0,true)}}).bind("search",function(){function c(a,c){var d;if(c&&c.length){for(var f=0;f<c.length;f++){if(c[f].result.toLowerCase()==a.toLowerCase()){d=c[f];break}}}if(typeof b=="function")b(d);else e.trigger("result",d&&[d.data,d.value])}var b=arguments.length>1?arguments[1]:null;a.each(p(e.val()),function(a,b){v(b,c,c)})}).bind("flushCache",function(){h.flush()}).bind("setOptions",function(){a.extend(c,arguments[1]);if("data"in arguments[1])h.populate()}).bind("unautocomplete",function(){l.unbind();e.unbind();a(b.form).unbind(".autocomplete")});};a.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",summaryClass:"ac_summary",summaryText:["Showing [MaxResults] results of [DataLength]"],showSummary:"always",summarySelectable:false,minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(a){return a[0]},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(a,b){return a.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:true,scrollHeight:180};a.Autocompleter.Cache=function(b){function h(){c={};d=0}function g(){if(!b.data)return false;var c={},d=0;if(!b.url)b.cacheLength=1;c[""]=[];for(var e=0,g=b.data.length;e<g;e++){var h=b.data[e];h=typeof h=="string"?[h]:h;var i=b.formatMatch(h,e+1,b.data.length);if(i===false)continue;var j=i.charAt(0).toLowerCase();if(!c[j])c[j]=[];var k={value:i,data:h,result:b.formatResult&&b.formatResult(h)||i};c[j].push(k);if(d++<b.max){c[""].push(k)}}a.each(c,function(a,c){b.cacheLength++;f(a,c)})}function f(a,e){if(d>b.cacheLength){h()}if(!c[a]){d++}c[a]=e}function e(a,c){if(!b.matchCase)a=a.toLowerCase();var d=a.indexOf(c);if(b.matchContains=="word"){d=a.toLowerCase().search("\\b"+c.toLowerCase())}if(d==-1)return false;return d==0||b.matchContains}var c={};var d=0;setTimeout(g,25);return{flush:h,add:f,populate:g,load:function(f){if(!b.cacheLength||!d)return null;if(!b.url&&b.matchContains){var g=[];for(var h in c){if(h.length>0){var i=c[h];a.each(i,function(a,b){if(e(b.value,f)){g.push(b)}})}}return g}else if(c[f]){return c[f]}else if(b.matchSubset){for(var j=f.length-1;j>=b.minChars;j--){var i=c[f.substr(0,j)];if(i){var g=[];a.each(i,function(a,b){if(e(b.value,f)){g[g.length]=b}});return g}}}return null}}};a.Autocompleter.Select=function(b,c,d,e){function u(){n.empty();var c=t(j.length);for(var d=0;d<c;d++){if(!j[d])continue;var e=b.formatItem(j[d].data,d+1,c,j[d].value,k);if(e===false)continue;var i=a("<li/>").html(b.highlight(e,k)).addClass(d%2==0?"ac_even":"ac_odd").appendTo(n)[0];a.data(i,"ac_data",j[d])}g=n.find("li");if(b.selectFirst){g.slice(0,1).addClass(f.ACTIVE);h=0}else h=NaN;if(a.fn.bgiframe)n.bgiframe()}function t(a){return b.max&&b.max<a?b.max:a}function s(a){h+=a;if(b.summarySelectable&&i){if(h<-1){h=g.size()-1}else if(h>=g.size()){h=-1}}else{if(h<0){h=g.size()-1}else if(h>=g.size()){h=0}}}function r(c){a("li",n).removeClass(f.ACTIVE);o.removeClass(f.ACTIVE);s(c);if(h>-1){var d=g.slice(h,h+1).addClass(f.ACTIVE);if(b.scroll){var e=0;g.slice(0,h).each(function(){e+=this.offsetHeight});if(e+d[0].offsetHeight-n.scrollTop()>n[0].clientHeight){n.scrollTop(e+d[0].offsetHeight-n.innerHeight())}else if(e<n.scrollTop()){n.scrollTop(e)}}}else{o.addClass(f.ACTIVE)}}function q(a){var b=a.target;while(b&&b.tagName!="LI")b=b.parentNode;if(!b)return[];return b}function p(){if(!l)return;m=a("<div/>").hide().addClass(b.resultsClass).css("position","absolute").appendTo(document.body);n=a("<ul/>").appendTo(m).mouseover(function(b){if(q(b).nodeName&&q(b).nodeName.toUpperCase()=="LI"){h=a("li",n).removeClass(f.ACTIVE).index(q(b));o.removeClass(f.ACTIVE);a(q(b)).addClass(f.ACTIVE)}}).click(function(b){a(q(b)).addClass(f.ACTIVE);d();c.focus();return false}).mousedown(function(){e.mouseDownOnSelect=true}).mouseup(function(){e.mouseDownOnSelect=false});if(b.width>0)m.css("width",b.width);o=a("<div/>").hide().addClass(b.summaryClass).appendTo(m).mouseover(function(b){h=-1;a("li",n).removeClass(f.ACTIVE);a(this).addClass(f.ACTIVE)});l=false}var f={ACTIVE:"ac_over"};var g,h=NaN,i=-1,j,k="",l=true,m,n,o;return{display:function(a,b){p();j=a;k=b;u()},next:function(){if(isNaN(h))h=-1;r(1)},prev:function(){if(isNaN(h))h=i&&b.summarySelectable?0:-1;r(-1)},pageUp:function(){if(isNaN(h))h=i&&b.summarySelectable?0:-1;if(h==-1){r(g.size())}else if(h==0&&i&&b.summarySelectable){r(-1)}else if(h!=0&&h-8<0){r(-h)}else{r(-8)}},pageDown:function(){if(isNaN(h))h=-1;if(h==-1){r(1)}else if(h!=g.size()-1&&h+8>g.size()){r(g.size()-1-h)}else{r(8)}},hide:function(){m&&m.hide();g&&g.removeClass(f.ACTIVE);o&&o.hide();h=-1;i=-1},visible:function(){return m&&m.is(":visible")},current:function(){return this.visible()&&(g.filter("."+f.ACTIVE)[0]||b.selectFirst&&g[0])},show:function(){var d=a(c).offset();m.css({width:typeof b.width=="string"||b.width>0?b.width:a(c).width(),top:d.top+c.offsetHeight,left:d.left}).show();if(b.scroll){n.scrollTop(0);n.css({maxHeight:b.scrollHeight,overflow:"auto"});if(a.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var e=0;g.each(function(){e+=this.offsetHeight});var f=e>b.scrollHeight;n.css("height",f?b.scrollHeight:e);if(!f){g.width(n.width()-parseInt(g.css("padding-left"))-parseInt(g.css("padding-right")))}}}if(b.showSummary=="always"||b.showSummary=="tooMany"&&j.length>b.max||b.showSummary=="notEnough"&&j.length<b.max){o.html(b.summaryText.join("<br/>").replace("[MaxResults]",b.max).replace("[DisplayedLength]",b.max>j.length?j.length:b.max).replace("[DataLength]",j.length).replace("[Term]",k)).show();if(a.fn.bgiframe)o.bgiframe();i=1}else{o.hide();i=-1}},selected:function(){var b=g&&g.filter("."+f.ACTIVE).removeClass(f.ACTIVE);return b&&b.length&&a.data(b[0],"ac_data")},emptyList:function(){n&&n.empty()},unbind:function(){m&&m.remove()}}};a.fn.selection=function(a,b){if(a!==undefined){return this.each(function(){if(this.createTextRange){var c=this.createTextRange();if(b===undefined||a==b){c.move("character",a);c.select()}else{c.collapse(true);c.moveStart("character",a);c.moveEnd("character",b);c.select()}}else if(this.setSelectionRange){this.setSelectionRange(a,b)}else if(this.selectionStart){this.selectionStart=a;this.selectionEnd=b}})}var c=this[0];if(c.createTextRange){var d=document.selection.createRange(),e=c.value,f="<->",g=d.text.length;d.text=f;var h=c.value.indexOf(f);c.value=e;this.selection(h,h+g);return{start:h,end:h+g}}else if(c.selectionStart!==undefined){return{start:c.selectionStart,end:c.selectionEnd}}}})(jQuery);


/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 * 
 * Requires: 1.2.2+
 */
(function(a){function c(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=true,g=0,h=0;b=a.event.fix(c);b.type="mousewheel";if(b.wheelDelta){e=b.wheelDelta/120}if(b.detail){e=-b.detail/3}h=e;if(c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS){h=0;g=-1*e}if(c.wheelDeltaY!==undefined){h=c.wheelDeltaY/120}if(c.wheelDeltaX!==undefined){g=-1*c.wheelDeltaX/120}d.unshift(b,e,g,h);return a.event.handle.apply(this,d)}var b=["DOMMouseScroll","mousewheel"];a.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var a=b.length;a;){this.addEventListener(b[--a],c,false)}}else{this.onmousewheel=c}},teardown:function(){if(this.removeEventListener){for(var a=b.length;a;){this.removeEventListener(b[--a],c,false)}}else{this.onmousewheel=null}}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);


/**
 * @author trixta
 * @version 1.2
 */
(function(a){function i(){if(this===b.elem){b.pos=[-260,-260];b.elem=false;c=3}}var b={pos:[-260,-260]},c=3,d=document,e=d.documentElement,f=d.body,g,h;a.event.special.mwheelIntent={setup:function(){var b=a(this).bind("mousewheel",a.event.special.mwheelIntent.handler);if(this!==d&&this!==e&&this!==f){b.bind("mouseleave",i)}b=null;return true},teardown:function(){a(this).unbind("mousewheel",a.event.special.mwheelIntent.handler).unbind("mouseleave",i);return true},handler:function(d,e){var f=[d.clientX,d.clientY];if(this===b.elem||Math.abs(b.pos[0]-f[0])>c||Math.abs(b.pos[1]-f[1])>c){b.elem=this;b.pos=f;c=250;clearTimeout(h);h=setTimeout(function(){c=10},200);clearTimeout(g);g=setTimeout(function(){c=3},1500);d=a.extend({},d,{type:"mwheelIntent"});return a.event.handle.apply(this,arguments)}}};a.fn.extend({mwheelIntent:function(a){return a?this.bind("mwheelIntent",a):this.trigger("mwheelIntent")},unmwheelIntent:function(a){return this.unbind("mwheelIntent",a)}});a(function(){f=d.body;a(d).bind("mwheelIntent.mwheelIntentDefault",a.noop)})})(jQuery);


/*
 * jScrollPane - v2.0.0beta11 - 2011-07-04
 * http://jscrollpane.kelvinluck.com/
 *
 * Copyright (c) 2010 Kelvin Luck
 * Dual licensed under the MIT and GPL licenses.
 */
(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var az,Q=this,Y,ak,v,am,T,Z,y,q,aA,aF,av,i,I,h,j,aa,U,aq,X,t,A,ar,af,an,G,l,au,ay,x,aw,aI,f,L,aj=true,P=true,aH=false,k=false,ap=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aI=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function at(aR){var aM,aO,aN,aK,aJ,aQ,aP=false,aL=false;az=aR;if(Y===c){aJ=D.scrollTop();aQ=D.scrollLeft();D.css({overflow:"hidden",padding:0});ak=D.innerWidth()+f;v=D.innerHeight();D.width(ak);Y=b('<div class="jspPane" />').css("padding",aI).append(D.children());am=b('<div class="jspContainer" />').css({width:ak+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aP=az.stickToBottom&&K();aL=az.stickToRight&&B();aK=D.innerWidth()+f!=ak||D.outerHeight()!=v;if(aK){ak=D.innerWidth()+f;v=D.innerHeight();am.css({width:ak+"px",height:v+"px"})}if(!aK&&L==T&&Y.outerHeight()==Z){D.width(ak);return}L=T;Y.css("width","");D.width(ak);am.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aR.contentWidth){T=aR.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/ak;q=Z/v;aA=q>1;aF=y>1;if(!(aF||aA)){D.removeClass("jspScrollable");Y.css({top:0,width:am.width()-f});n();E();R();w();ai()}else{D.addClass("jspScrollable");aM=az.maintainPosition&&(I||aa);if(aM){aO=aD();aN=aB()}aG();z();F();if(aM){N(aL?(T-ak):aO,false);M(aP?(Z-v):aN,false)}J();ag();ao();if(az.enableKeyboardNavigation){S()}if(az.clickOnTrack){p()}C();if(az.hijackInternalLinks){m()}}if(az.autoReinitialise&&!aw){aw=setInterval(function(){at(az)},az.autoReinitialiseDelay)}else{if(!az.autoReinitialise&&aw){clearInterval(aw)}}aJ&&D.scrollTop(0)&&M(aJ,false);aQ&&D.scrollLeft(0)&&N(aQ,false);D.trigger("jsp-initialised",[aF||aA])}function aG(){if(aA){am.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=am.find(">.jspVerticalBar");aq=U.find(">.jspTrack");av=aq.find(">.jspDrag");if(az.showArrows){ar=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aE(0,-1)).bind("click.jsp",aC);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aE(0,1)).bind("click.jsp",aC);if(az.arrowScrollOnHover){ar.bind("mouseover.jsp",aE(0,-1,ar));af.bind("mouseover.jsp",aE(0,1,af))}al(aq,az.verticalArrowPositions,ar,af)}t=v;am.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});av.hover(function(){av.addClass("jspHover")},function(){av.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);av.addClass("jspActive");var s=aJ.pageY-av.position().top;b("html").bind("mousemove.jsp",function(aK){V(aK.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});o()}}function o(){aq.height(t+"px");I=0;X=az.verticalGutter+aq.outerWidth();Y.width(ak-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aF){am.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));an=am.find(">.jspHorizontalBar");G=an.find(">.jspTrack");h=G.find(">.jspDrag");if(az.showArrows){ay=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aE(-1,0)).bind("click.jsp",aC);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aE(1,0)).bind("click.jsp",aC);if(az.arrowScrollOnHover){ay.bind("mouseover.jsp",aE(-1,0,ay));x.bind("mouseover.jsp",aE(1,0,x))}al(G,az.horizontalArrowPositions,ay,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);h.addClass("jspActive");var s=aJ.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aK){W(aK.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});l=am.innerWidth();ah()}}function ah(){am.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aF&&aA){var aJ=G.outerHeight(),s=aq.outerWidth();t-=aJ;b(an).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;ak-=aJ;G.parent().append(b('<div class="jspCorner" />').css("width",aJ+"px"));o();ah()}if(aF){Y.width((am.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aF){au=Math.ceil(1/y*l);if(au>az.horizontalDragMaxWidth){au=az.horizontalDragMaxWidth}else{if(au<az.horizontalDragMinWidth){au=az.horizontalDragMinWidth}}h.width(au+"px");j=l-au;ae(aa)}if(aA){A=Math.ceil(1/q*t);if(A>az.verticalDragMaxHeight){A=az.verticalDragMaxHeight}else{if(A<az.verticalDragMinHeight){A=az.verticalDragMinHeight}}av.height(A+"px");i=t-A;ad(I)}}function al(aK,aM,aJ,s){var aO="before",aL="after",aN;if(aM=="os"){aM=/Mac/.test(navigator.platform)?"after":"split"}if(aM==aO){aL=aM}else{if(aM==aL){aO=aM;aN=aJ;aJ=s;s=aN}}aK[aO](aJ)[aL](s)}function aE(aJ,s,aK){return function(){H(aJ,s,this,aK);this.blur();return false}}function H(aM,aL,aP,aO){aP=b(aP).addClass("jspActive");var aN,aK,aJ=true,s=function(){if(aM!==0){Q.scrollByX(aM*az.arrowButtonSpeed)}if(aL!==0){Q.scrollByY(aL*az.arrowButtonSpeed)}aK=setTimeout(s,aJ?az.initialDelay:az.arrowRepeatFreq);aJ=false};s();aN=aO?"mouseout.jsp":"mouseup.jsp";aO=aO||b("html");aO.bind(aN,function(){aP.removeClass("jspActive");aK&&clearTimeout(aK);aK=null;aO.unbind(aN)})}function p(){w();if(aA){aq.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageY-aP.top-I,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageY-aS.top-A/2,aQ=v*az.scrollPagePercent,aR=i*aQ/(Z-v);if(aN<0){if(I-aR>aT){Q.scrollByY(-aQ)}else{V(aT)}}else{if(aN>0){if(I+aR<aT){Q.scrollByY(aQ)}else{V(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}if(aF){G.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageX-aP.left-aa,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageX-aS.left-au/2,aQ=ak*az.scrollPagePercent,aR=j*aQ/(T-ak);if(aN<0){if(aa-aR>aT){Q.scrollByX(-aQ)}else{W(aT)}}else{if(aN>0){if(aa+aR<aT){Q.scrollByX(aQ)}else{W(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(aq){aq.unbind("mousedown.jsp")}}function ax(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(av){av.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aJ){if(!aA){return}if(s<0){s=0}else{if(s>i){s=i}}if(aJ===c){aJ=az.animateScroll}if(aJ){Q.animate(av,"top",s,ad)}else{av.css("top",s);ad(s)}}function ad(aJ){if(aJ===c){aJ=av.position().top}am.scrollTop(0);I=aJ;var aM=I===0,aK=I==i,aL=aJ/i,s=-aL*(Z-v);if(aj!=aM||aH!=aK){aj=aM;aH=aK;D.trigger("jsp-arrow-change",[aj,aH,P,k])}u(aM,aK);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aM,aK]).trigger("scroll")}function W(aJ,s){if(!aF){return}if(aJ<0){aJ=0}else{if(aJ>j){aJ=j}}if(s===c){s=az.animateScroll}if(s){Q.animate(h,"left",aJ,ae)}else{h.css("left",aJ);ae(aJ)}}function ae(aJ){if(aJ===c){aJ=h.position().left}am.scrollTop(0);aa=aJ;var aM=aa===0,aL=aa==j,aK=aJ/j,s=-aK*(T-ak);if(P!=aM||k!=aL){P=aM;k=aL;D.trigger("jsp-arrow-change",[aj,aH,P,k])}r(aM,aL);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aM,aL]).trigger("scroll")}function u(aJ,s){if(az.showArrows){ar[aJ?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aJ,s){if(az.showArrows){ay[aJ?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aJ){var aK=s/(Z-v);V(aK*i,aJ)}function N(aJ,s){var aK=aJ/(T-ak);W(aK*j,s)}function ab(aW,aR,aK){var aO,aL,aM,s=0,aV=0,aJ,aQ,aP,aT,aS,aU;try{aO=b(aW)}catch(aN){return}aL=aO.outerHeight();aM=aO.outerWidth();am.scrollTop(0);am.scrollLeft(0);while(!aO.is(".jspPane")){s+=aO.position().top;aV+=aO.position().left;aO=aO.offsetParent();if(/^body|html$/i.test(aO[0].nodeName)){return}}aJ=aB();aP=aJ+v;if(s<aJ||aR){aS=s-az.verticalGutter}else{if(s+aL>aP){aS=s-v+aL+az.verticalGutter}}if(aS){M(aS,aK)}aQ=aD();aT=aQ+ak;if(aV<aQ||aR){aU=aV-az.horizontalGutter}else{if(aV+aM>aT){aU=aV-ak+aM+az.horizontalGutter}}if(aU){N(aU,aK)}}function aD(){return -Y.position().left}function aB(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aB()<10)}function B(){var s=T-ak;return(s>20)&&(s-aD()<10)}function ag(){am.unbind(ac).bind(ac,function(aM,aN,aL,aJ){var aK=aa,s=I;Q.scrollBy(aL*az.mouseWheelSpeed,-aJ*az.mouseWheelSpeed,false);return aK==aa&&s==I})}function n(){am.unbind(ac)}function aC(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aJ,aL=[];aF&&aL.push(an[0]);aA&&aL.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aO){if(aO.target!==this&&!(aL.length&&b(aO.target).closest(aL).length)){return}var aN=aa,aM=I;switch(aO.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aO.keyCode;aK();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aJ=aO.keyCode==s&&aN!=aa||aM!=I;return !aJ}).bind("keypress.jsp",function(aM){if(aM.keyCode==s){aK()}return !aJ});if(az.hideFocus){D.css("outline","none");if("hideFocus" in am[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in am[0]){D.attr("hideFocus",false)}}function aK(){var aN=aa,aM=I;switch(s){case 40:Q.scrollByY(az.keyboardSpeed,false);break;case 38:Q.scrollByY(-az.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*az.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*az.scrollPagePercent,false);break;case 39:Q.scrollByX(az.keyboardSpeed,false);break;case 37:Q.scrollByX(-az.keyboardSpeed,false);break}aJ=aN!=aa||aM!=I;return aJ}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aL,aJ,aK=escape(location.hash);try{aL=b(aK)}catch(s){return}if(aL.length&&Y.find(aK)){if(am.scrollTop()===0){aJ=setInterval(function(){if(am.scrollTop()>0){ab(aK,true);b(document).scrollTop(am.position().top);clearInterval(aJ)}},50)}else{ab(aK,true);b(document).scrollTop(am.position().top)}}}}function ai(){b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function m(){ai();b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aJ;if(s.length>1){aJ=s[1];if(aJ.length>0&&Y.find("#"+aJ).length>0){ab("#"+aJ,true);return false}}})}function ao(){var aK,aJ,aM,aL,aN,s=false;am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aO){var aP=aO.originalEvent.touches[0];aK=aD();aJ=aB();aM=aP.pageX;aL=aP.pageY;aN=false;s=true}).bind("touchmove.jsp",function(aR){if(!s){return}var aQ=aR.originalEvent.touches[0],aP=aa,aO=I;Q.scrollTo(aK+aM-aQ.pageX,aJ+aL-aQ.pageY);aN=aN||Math.abs(aM-aQ.pageX)>5||Math.abs(aL-aQ.pageY)>5;return aP==aa&&aO==I}).bind("touchend.jsp",function(aO){s=false}).bind("click.jsp-touchclick",function(aO){if(aN){aN=false;return false}})}function g(){var s=aB(),aJ=aD();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ap.append(Y.children()));ap.scrollTop(s);ap.scrollLeft(aJ)}b.extend(Q,{reinitialise:function(aJ){aJ=b.extend({},az,aJ);at(aJ)},scrollToElement:function(aK,aJ,s){ab(aK,aJ,s)},scrollTo:function(aK,s,aJ){N(aK,aJ);M(s,aJ)},scrollToX:function(aJ,s){N(aJ,s)},scrollToY:function(s,aJ){M(s,aJ)},scrollToPercentX:function(aJ,s){N(aJ*(T-ak),s)},scrollToPercentY:function(aJ,s){M(aJ*(Z-v),s)},scrollBy:function(aJ,s,aK){Q.scrollByX(aJ,aK);Q.scrollByY(s,aK)},scrollByX:function(s,aK){var aJ=aD()+Math[s<0?"floor":"ceil"](s),aL=aJ/(T-ak);W(aL*j,aK)},scrollByY:function(s,aK){var aJ=aB()+Math[s<0?"floor":"ceil"](s),aL=aJ/(Z-v);V(aL*i,aK)},positionDragX:function(s,aJ){W(s,aJ)},positionDragY:function(aJ,s){V(aJ,s)},animate:function(aJ,aM,s,aL){var aK={};aK[aM]=s;aJ.animate(aK,{duration:az.animateDuration,easing:az.animateEase,queue:false,step:aL})},getContentPositionX:function(){return aD()},getContentPositionY:function(){return aB()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aD()/(T-ak)},getPercentScrolledY:function(){return aB()/(Z-v)},getIsScrollableH:function(){return aF},getIsScrollableV:function(){return aA},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:function(){m()},destroy:function(){g()}});at(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);


/*!
 * jCarousel - Riding carousels with jQuery
 *   http://sorgalla.com/jcarousel/
 *
 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Built on top of the jQuery library
 *   http://jquery.com
 *
 * Inspired by the "Carousel Component" by Bill Scott
 *   http://billwscott.com/carousel/
 *
 * Modified 2011 by Colin Jaggs to support DIV structures as well as UL/OL lists - pass useDivs: true in order to use, otherwise will only work with lists
 *   http://billwscott.com/carousel/
 */
(function(a){var b={vertical:false,rtl:false,start:1,offset:1,size:null,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,useDivs:false,initCallback:null,setupCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,animationStepCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click",buttonNextCallback:null,buttonPrevCallback:null,itemFallbackDimension:null},c=false;a(window).bind("load.jcarousel",function(){c=true});a.jcarousel=function(d,e){this.options=a.extend({},b,e||{});this.locked=false;this.autoStopped=false;this.container=null;this.clip=null;this.list=null;this.buttonNext=null;this.buttonPrev=null;this.buttonNextState=null;this.buttonPrevState=null;if(!e||e.rtl===undefined){this.options.rtl=(a(d).attr("dir")||a("html").attr("dir")||"").toLowerCase()=="rtl"}this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical?this.options.rtl?"right":"left":"top";var f="",g=d.className.split(" ");for(var h=0;h<g.length;h++){if(g[h].indexOf("jcarousel-skin")!=-1){a(d).removeClass(g[h]);f=g[h];break}}if(this.options.useDivs&&d.nodeName.toUpperCase()=="DIV"||!this.options.useDivs&&d.nodeName.toUpperCase()=="UL"||d.nodeName.toUpperCase()=="OL"){this.list=a(d);this.clip=this.list.parents(".jcarousel-clip");this.container=this.list.parents(".jcarousel-container")}else{this.container=a(d);this.list=this.container.find(this.options.useDivs?"div":"ul,ol").eq(0);this.clip=this.container.find(".jcarousel-clip")}if(this.clip.size()===0){this.clip=this.list.wrap("<div></div>").parent()}if(this.container.size()===0){this.container=this.clip.wrap("<div></div>").parent()}if(f!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1){this.container.wrap('<div class=" '+f+'"></div>')}this.buttonPrev=a(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null){this.buttonPrev=a(this.options.buttonPrevHTML).appendTo(this.container)}this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext=a(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null){this.buttonNext=a(this.options.buttonNextHTML).appendTo(this.container)}this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip")).css({position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"});if(!this.options.vertical&&this.options.rtl){this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl")}var i=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;var j=this.list.children(this.options.useDivs?"div":"li");var k=this;if(j.size()>0){var l=0,m=this.options.offset;j.each(function(){k.format(this,m++);l+=k.dimension(this,i)});this.list.css(this.wh,l+100+"px");if(!e||e.size===undefined){this.options.size=j.size()}}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display","block");this.funcNext=function(){k.next()};this.funcPrev=function(){k.prev()};this.funcResize=function(){if(k.resizeTimer){clearTimeout(k.resizeTimer)}k.resizeTimer=setTimeout(function(){k.reload()},100)};if(this.options.initCallback!==null){this.options.initCallback(this,"init")}if(!c&&a.browser.safari){this.buttons(false,false);a(window).bind("load.jcarousel",function(){k.setup()})}else{this.setup()}};var d=a.jcarousel;d.fn=d.prototype={jcarousel:"0.2.8"};d.fn.extend=d.extend=a.extend;d.fn.extend({setup:function(){this.first=null;this.last=null;this.prevFirst=null;this.prevLast=null;this.animating=false;this.timer=null;this.resizeTimer=null;this.tail=null;this.inTail=false;if(this.locked){return}this.list.css(this.lt,this.pos(this.options.offset)+"px");var b=this.pos(this.options.start,true);this.prevFirst=this.prevLast=null;this.animate(b,false);a(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize);if(this.options.setupCallback!==null){this.options.setupCallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt,"0px");this.list.css(this.wh,"10px");if(this.options.initCallback!==null){this.options.initCallback(this,"reset")}this.setup()},reload:function(){if(this.tail!==null&&this.inTail){this.list.css(this.lt,d.intval(this.list.css(this.lt))+this.tail)}this.tail=null;this.inTail=false;if(this.options.reloadCallback!==null){this.options.reloadCallback(this)}if(this.options.visible!==null){var a=this;var b=Math.ceil(this.clipping()/this.options.visible),c=0,e=0;this.list.children("li").each(function(d){c+=a.dimension(this,b);if(d+1<a.first){e=c}});this.list.css(this.wh,c+"px");this.list.css(this.lt,-e+"px")}this.scroll(this.first,false)},lock:function(){this.locked=true;this.buttons()},unlock:function(){this.locked=false;this.buttons()},size:function(a){if(a!==undefined){this.options.size=a;if(!this.locked){this.buttons()}}return this.options.size},has:function(a,b){if(b===undefined||!b){b=a}if(this.options.size!==null&&b>this.options.size){b=this.options.size}for(var c=a;c<=b;c++){var d=this.get(c);if(!d.length||d.hasClass("jcarousel-item-placeholder")){return false}}return true},get:function(b){return a(">.jcarousel-item-"+b,this.list)},add:function(b,c){var e=this.get(b),f=0,g=a(c);if(e.length===0){var h,i=d.intval(b);e=this.create(b);while(true){h=this.get(--i);if(i<=0||h.length){if(i<=0){this.list.prepend(e)}else{h.after(e)}break}}}else{f=this.dimension(e)}if(this.options.useDivs&&g.get(0).nodeName.toUpperCase()=="DIV"||!this.options.useDivs&&g.get(0).nodeName.toUpperCase()=="LI"){e.replaceWith(g);e=g}else{e.empty().append(c)}this.format(e.removeClass(this.className("jcarousel-item-placeholder")),b);var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;var k=this.dimension(e,j)-f;if(b>0&&b<this.first){this.list.css(this.lt,d.intval(this.list.css(this.lt))-k+"px")}this.list.css(this.wh,d.intval(this.list.css(this.wh))+k+"px");return e},remove:function(a){var b=this.get(a);if(!b.length||a>=this.first&&a<=this.last){return}var c=this.dimension(b);if(a<this.first){this.list.css(this.lt,d.intval(this.list.css(this.lt))+c+"px")}b.remove();this.list.css(this.wh,d.intval(this.list.css(this.wh))-c+"px")},next:function(){if(this.tail!==null&&!this.inTail){this.scrollTail(false)}else{this.scroll((this.options.wrap=="both"||this.options.wrap=="last")&&this.options.size!==null&&this.last==this.options.size?1:this.first+this.options.scroll)}},prev:function(){if(this.tail!==null&&this.inTail){this.scrollTail(true)}else{this.scroll((this.options.wrap=="both"||this.options.wrap=="first")&&this.options.size!==null&&this.first==1?this.options.size:this.first-this.options.scroll)}},scrollTail:function(a){if(this.locked||this.animating||!this.tail){return}this.pauseAuto();var b=d.intval(this.list.css(this.lt));b=!a?b-this.tail:b+this.tail;this.inTail=!a;this.prevFirst=this.first;this.prevLast=this.last;this.animate(b)},scroll:function(a,b){if(this.locked||this.animating){return}this.pauseAuto();this.animate(this.pos(a),b)},pos:function(a,b){var c=d.intval(this.list.css(this.lt));if(this.locked||this.animating){return c}if(this.options.wrap!="circular"){a=a<1?1:this.options.size&&a>this.options.size?this.options.size:a}var e=this.first>a;var f=this.options.wrap!="circular"&&this.first<=1?1:this.first;var g=e?this.get(f):this.get(this.last);var h=e?f:f-1;var i=null,j=0,k=false,l=0,m;while(e?--h>=a:++h<a){i=this.get(h);k=!i.length;if(i.length===0){i=this.create(h).addClass(this.className("jcarousel-item-placeholder"));g[e?"before":"after"](i);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(h<=0||h>this.options.size)){m=this.get(this.index(h));if(m.length){i=this.add(h,m.clone(true))}}}g=i;l=this.dimension(i);if(k){j+=l}if(this.first!==null&&(this.options.wrap=="circular"||h>=1&&(this.options.size===null||h<=this.options.size))){c=e?c+l:c-l}}var n=this.clipping(),o=[],p=0,q=0;g=this.get(a-1);h=a;while(++p){i=this.get(h);k=!i.length;if(i.length===0){i=this.create(h).addClass(this.className("jcarousel-item-placeholder"));if(g.length===0){this.list.prepend(i)}else{g[e?"before":"after"](i)}if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(h<=0||h>this.options.size)){m=this.get(this.index(h));if(m.length){i=this.add(h,m.clone(true))}}}g=i;l=this.dimension(i);if(l===0){throw new Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...")}if(this.options.wrap!="circular"&&this.options.size!==null&&h>this.options.size){o.push(i)}else if(k){j+=l}q+=l;if(q>=n){break}h++}for(var r=0;r<o.length;r++){o[r].remove()}if(j>0){this.list.css(this.wh,this.dimension(this.list)+j+"px");if(e){c-=j;this.list.css(this.lt,d.intval(this.list.css(this.lt))-j+"px")}}var s=a+p-1;if(this.options.wrap!="circular"&&this.options.size&&s>this.options.size){s=this.options.size}if(h>s){p=0;h=s;q=0;while(++p){i=this.get(h--);if(!i.length){break}q+=this.dimension(i);if(q>=n){break}}}var t=s-p+1;if(this.options.wrap!="circular"&&t<1){t=1}if(this.inTail&&e){c+=this.tail;this.inTail=false}this.tail=null;if(this.options.wrap!="circular"&&s==this.options.size&&s-p+1>=1){var u=d.intval(this.get(s).css(!this.options.vertical?"marginRight":"marginBottom"));if(q-u>n){this.tail=q-n-u}}if(b&&a===this.options.size&&this.tail){c-=this.tail;this.inTail=true}while(a-->t){c+=this.dimension(this.get(a))}this.prevFirst=this.first;this.prevLast=this.last;this.first=t;this.last=s;return c},animate:function(b,c){if(this.locked||this.animating){return}this.animating=true;var d=this;var e=function(){d.animating=false;if(b===0){d.list.css(d.lt,0)}if(!d.autoStopped&&(d.options.wrap=="circular"||d.options.wrap=="both"||d.options.wrap=="last"||d.options.size===null||d.last<d.options.size||d.last==d.options.size&&d.tail!==null&&!d.inTail)){d.startAuto()}d.buttons();d.notify("onAfterAnimation");if(d.options.wrap=="circular"&&d.options.size!==null){for(var a=d.prevFirst;a<=d.prevLast;a++){if(a!==null&&!(a>=d.first&&a<=d.last)&&(a<1||a>d.options.size)){d.remove(a)}}}};this.notify("onBeforeAnimation");if(!this.options.animation||c===false){this.list.css(this.lt,b+"px");e()}else{var f=!this.options.vertical?this.options.rtl?{right:b}:{left:b}:{top:b};var g={duration:this.options.animation,easing:this.options.easing,complete:e};if(a.isFunction(this.options.animationStepCallback)){g.step=this.options.animationStepCallback}this.list.animate(f,g)}},startAuto:function(a){if(a!==undefined){this.options.auto=a}if(this.options.auto===0){return this.stopAuto()}if(this.timer!==null){return}this.autoStopped=false;var b=this;this.timer=window.setTimeout(function(){b.next()},this.options.auto*1e3)},stopAuto:function(){this.pauseAuto();this.autoStopped=true},pauseAuto:function(){if(this.timer===null){return}window.clearTimeout(this.timer);this.timer=null},buttons:function(a,b){if(a==null){a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last<this.options.size);if(!this.locked&&(!this.options.wrap||this.options.wrap=="first")&&this.options.size!==null&&this.last>=this.options.size){a=this.tail!==null&&!this.inTail}}if(b==null){b=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1);if(!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1){b=this.tail!==null&&this.inTail}}var c=this;if(this.buttonNext.size()>0){this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext);if(a){this.buttonNext.bind(this.options.buttonNextEvent+".jcarousel",this.funcNext)}this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?false:true);if(this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a){this.buttonNext.each(function(){c.options.buttonNextCallback(c,this,a)}).data("jcarouselstate",a)}}else{if(this.options.buttonNextCallback!==null&&this.buttonNextState!=a){this.options.buttonNextCallback(c,null,a)}}if(this.buttonPrev.size()>0){this.buttonPrev.unbind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev);if(b){this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev)}this.buttonPrev[b?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",b?false:true);if(this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=b){this.buttonPrev.each(function(){c.options.buttonPrevCallback(c,this,b)}).data("jcarouselstate",b)}}else{if(this.options.buttonPrevCallback!==null&&this.buttonPrevState!=b){this.options.buttonPrevCallback(c,null,b)}}this.buttonNextState=a;this.buttonPrevState=b},notify:function(a){var b=this.prevFirst===null?"init":this.prevFirst<this.first?"next":"prev";this.callback("itemLoadCallback",a,b);if(this.prevFirst!==this.first){this.callback("itemFirstInCallback",a,b,this.first);this.callback("itemFirstOutCallback",a,b,this.prevFirst)}if(this.prevLast!==this.last){this.callback("itemLastInCallback",a,b,this.last);this.callback("itemLastOutCallback",a,b,this.prevLast)}this.callback("itemVisibleInCallback",a,b,this.first,this.last,this.prevFirst,this.prevLast);this.callback("itemVisibleOutCallback",a,b,this.prevFirst,this.prevLast,this.first,this.last)},callback:function(b,c,d,e,f,g,h){if(this.options[b]==null||typeof this.options[b]!="object"&&c!="onAfterAnimation"){return}var i=typeof this.options[b]=="object"?this.options[b][c]:this.options[b];if(!a.isFunction(i)){return}var j=this;if(e===undefined){i(j,d,c)}else if(f===undefined){this.get(e).each(function(){i(j,this,e,d,c)})}else{var k=function(a){j.get(a).each(function(){i(j,this,a,d,c)})};for(var l=e;l<=f;l++){if(l!==null&&!(l>=g&&l<=h)){k(l)}}}},create:function(a){if(this.options.useDivs)return this.format("<div></div>",a);else return this.format("<li></li>",a)},format:function(b,c){b=a(b);var d=b.get(0).className.split(" ");for(var e=0;e<d.length;e++){if(d[e].indexOf("jcarousel-")!=-1){b.removeClass(d[e])}}b.addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-"+c)).css({"float":this.options.rtl?"right":"left","list-style":"none"}).attr("jcarouselindex",c);return b},className:function(a){return a+" "+a+(!this.options.vertical?"-horizontal":"-vertical")},dimension:function(b,c){var e=a(b);if(c==null){return!this.options.vertical?e.outerWidth(true)||d.intval(this.options.itemFallbackDimension):e.outerHeight(true)||d.intval(this.options.itemFallbackDimension)}else{var f=!this.options.vertical?c-d.intval(e.css("marginLeft"))-d.intval(e.css("marginRight")):c-d.intval(e.css("marginTop"))-d.intval(e.css("marginBottom"));a(e).css(this.wh,f+"px");return this.dimension(e)}},clipping:function(){return!this.options.vertical?this.clip[0].offsetWidth-d.intval(this.clip.css("borderLeftWidth"))-d.intval(this.clip.css("borderRightWidth")):this.clip[0].offsetHeight-d.intval(this.clip.css("borderTopWidth"))-d.intval(this.clip.css("borderBottomWidth"))},index:function(a,b){if(b==null){b=this.options.size}return Math.round(((a-1)/b-Math.floor((a-1)/b))*b)+1}});d.extend({defaults:function(c){return a.extend(b,c||{})},intval:function(a){a=parseInt(a,10);return isNaN(a)?0:a},windowLoaded:function(){c=true}});a.fn.jcarousel=function(b){if(typeof b=="string"){var c=a(this).data("jcarousel"),e=Array.prototype.slice.call(arguments,1);return c[b].apply(c,e)}else{return this.each(function(){var c=a(this).data("jcarousel");if(c){if(b){a.extend(c.options,b)}c.reload()}else{a(this).data("jcarousel",new d(this,b))}})}}})(jQuery);


/*
/* jquery.readMore.js - take a chunk of text and if over a specific number of characters add a 'read more' link and hide the excess
/* Colin Jaggs (c) 2011 Pin Digital Ltd
*/
(function ($){$.fn.readMore=function(b){b=$.extend({},$.fn.readMore.defaults,b||{});$(this).each(function(){if($(this).html().length>b.maxLength){var isIE6or7=($.browser.msie&&/msie [6|7]\.0/i.test(navigator.userAgent))?true:false;if(!isIE6or7)while(b.maxLength>0&&$(this).html()[b.maxLength].match(/[0-9A-Za-z]/))b.maxLength--;var c=$(this).html().substring(0,b.maxLength),d=$(this).html().substring(b.maxLength);$(this).html(c+'<a href="javascript:void(0)" onclick="return false;" class="moreLnk">'+b.linkText+'</a><span class="more" style="display:none;">'+d+"</span>");$("a.moreLnk",this).click(function(){$(this).hide();if(isIE6or7)$(this).siblings(1).show();else $(this).siblings(1).fadeIn("fast");})}})};$.fn.readMore.defaults={maxLength:150,linkText:" … Read more >>>"}})(jQuery);

