// Javascript library for Scalibor sites
// This js uses jQuery functions. Include jQuery FIRST!

// Loads up the various functions we are going to use
$(document).ready(function(){
	jsEnabled();
	if($(".homeBanner").length > 0 && $("body").css("min-width") != "1px") {
		quoteSelector();
		roundedHomeBanner();
	};
	if($("#newsTicker").length > 0 && $("body").css("min-width") != "1px") {
		headlineSelector();
	};
	ga_track();
	corners();
	boxLink();
	boxMoreButton();
	blockQuote();
	serviceLinks();
	textLogo();
	addSelectors();
	navHoverCorners();
	expandFAQs();
	listLinkHover();
	leftmenu();
});


//  click tracker - needs Google Analytics JS
function ga_track() {
 if (typeof(_gat) == 'object') {
  $('a').each(function() {
   var uri = $(this).attr('href');
	if (uri) {
	   if (uri.match(/^mailto/i)) {
	    $(this).click(function() { ahTracker._trackEvent('mailto', 'click', uri.substr(7));siteTracker._trackEvent('mailto', 'click', uri.substr(7));});
	   } else if (uri.match(/^https?:/i)) {
	    $(this).click(function() { ahTracker._trackEvent('external', 'click', uri);siteTracker._trackEvent('external', 'click', uri);});
	   } else if (uri.match(/\.[a-z]{3}$/i) && ! uri.match(/\.(aspx?|html?)([\?#].*)?$/i)) {
	  	var filetype = uri.substr(-3)
	    $(this).click(function() { ahTracker._trackEvent('downloads', filetype.toUpperCase(), uri);siteTracker._trackEvent('downloads', filetype.toUpperCase(), uri);});
	   }
	}
  });
 }
}



// Adds a class to the body so I can style differently depending on whether Javascript is enabled.
function jsEnabled() {
	$("body").addClass("jsenabled");
}

// adds lots of divs used to create the rounded corners
function corners() {
  $("#header").append('<div class="corner24BL corner"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="shape04 dot"></div><div class="shape05 dot"></div><div class="shape06 dot"></div><div class="shape07 dot"></div><div class="shape08 dot"></div><div class="shape09 dot"></div><div class="shape10 dot"></div><div class="shape11 dot"></div><div class="shape12 dot"></div><div class="shape13 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div><div class="dot16 dot"></div><div class="dot17 dot"></div><div class="dot18 dot"></div><div class="dot19 dot"></div><div class="dot20 dot"></div><div class="dot21 dot"></div><div class="dot22 dot"></div><div class="dot23 dot"></div><div class="dot24 dot"></div><div class="dot25 dot"></div><div class="dot26 dot"></div><div class="dot27 dot"></div><div class="dot28 dot"></div><div class="dot29 dot"></div><div class="dot30 dot"></div><div class="dot31 dot"></div><div class="dot32 dot"></div><div class="dot33 dot"></div><div class="dot34 dot"></div><div class="dot35 dot"></div><div class="dot36 dot"></div><div class="dot37 dot"></div><div class="dot38 dot"></div><div class="dot39 dot"></div><div class="dot40 dot"></div><div class="dot41 dot"></div><div class="dot42 dot"></div><div class="dot43 dot"></div><div class="dot44 dot"></div><div class="dot45 dot"></div></div>');
	$(".rounded .box h3, #subNav").append('<div class="corner corner10TL"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div><div class="corner corner10TR"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div><div class="corner corner10BL"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div>');
	$(".rounded .box h3").after('<div class="extraBorder"></div>');
	$(".rounded  p a em, .homeBanner").append('<div class="corner corner10TL"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div><div class="corner corner10TR"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div><div class="corner corner10BR"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div><div class="corner corner10BL"><div class="shape01 dot"></div><div class="shape02 dot"></div><div class="shape03 dot"></div><div class="dot01 dot"></div><div class="dot02 dot"></div><div class="dot03 dot"></div><div class="dot04 dot"></div><div class="dot05 dot"></div><div class="dot06 dot"></div><div class="dot07 dot"></div><div class="dot08 dot"></div><div class="dot09 dot"></div><div class="dot10 dot"></div><div class="dot11 dot"></div><div class="dot12 dot"></div><div class="dot13 dot"></div><div class="dot14 dot"></div><div class="dot15 dot"></div></div>');
}

// adds divs used to create the main navigation hover state
function navHoverCorners() {
	$("#navigation a").wrapInner('<span class="text"></span>');
	$("#navigation a").append('<span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span>');
}

// wraps a link around a whole box
function boxLink() {	
	var thisBox = $('.single');
	for (var i = 0, j = thisBox.length; i < j; i++){
		var linkTitle = $(thisBox[i]).children('h3').children('a').text();
		var linkHref = $(thisBox[i]).children('h3').children('a').attr('href');
		$(thisBox[i]).children('h3').children('a').remove;
		$(thisBox[i]).children('h3').text(linkTitle);
		$(thisBox[i]).addClass("boxLink");
	};
	$(".single").click(function(){
		window.location = linkHref; return false;
	});
	$(".single").hover(
	function(){
		$(this).addClass('singleHover');
	},
	function(){
		$(this).removeClass('singleHover');
	});
}

// adds a 'more' button to box heading links
function boxMoreButton() {	
  $(".box h3 a").prepend('<span class="readMore"></span>');
}

// wraps quotes around blockquotes
function blockQuote() {	
  $("blockquote").prepend('<p class="quote"><span>&ldquo;</span></p>');
	$("blockquote").append('<p class="quote"><span>&rdquo;</span></p>');
	if ($("blockquote cite").length > 0) {
	  $("blockquote cite").before('<p class="quote"><span>&rdquo;</span></p>');
	  $("blockquote cite + p").remove();
	}	
}

// wraps quotes around blockquotes
function serviceLinks() {	
  $("#serviceLink").click(function(){
	  $("#serviceLinksBox").slideToggle("slow");
	  $(this).toggleClass("active");
	});
  $(".slClose").click(function(){
	  $("#serviceLinksBox").slideToggle("slow");
	  $(this).toggleClass("active");
	});
}

// print alt text instead of logo for text only print version
function textLogo() {	
  var altText = $("#header img").attr("alt");
	$("#header img").parent().parent().prepend('<div class="col fakeTitle" id="pageTitle">' + altText + '</div>');
}

// adds a class to the first and last <li> of every list
function addSelectors() {
	$("ul li:first-child").addClass("firstLi");
	$("ul li:last-child").addClass("lastLi");
	$("ol li:first-child").addClass("firstLi");
	$("ol li:last-child").addClass("lastLi");
}

// Smoothly transition between ticker headlines
function headlineSelector() {
	$("#newsTicker ul li:not(:has[id='tickerIntro'])").hide();
	$("#newsTicker ul li:not(:has[id='tickerIntro']):first").show();
	$("#newsTicker").everyTime("8s",function(){
		$("#newsTicker ul li:not(:has[id='tickerIntro']):visible").fadeOut("slow", function() {
			nextHeadline = $(this).next();
			if(nextHeadline.length==0)
				nextHeadline = $("#newsTicker ul li:not(:has[id='tickerIntro']):first");
			nextHeadline.fadeIn("slow");
		});
	});
}

// Smoothly transition between banner quotes
function quoteSelector() {
	$(".homeBanner ul.boxInner li").hide();
	$(".homeBanner ul.boxInner li:first").show();	
	$(".homeBanner").prepend('<div class="selectorContainer"><div class="selector"><ul></ul></div></div>');
	var listItems = "";
	$(".homeBanner ul li").each(function(intIndex) {
		listItems += '<li><a href="#" id="quoteSel'+intIndex+'">&#8226;</a></li>';
	});
	$(".homeBanner .selector ul").append(listItems);
	$(".homeBanner .selector ul").prepend('<li class="leftBorder"></li>').append('<li class="rightBorder"></li>');	
	$(".homeBanner .selectorContainer .selector ul li:has('a'):first a").addClass("current");
	$(".homeBanner .selectorContainer .selector ul li a").click(fadeQuote);
	$(".homeBanner").everyTime("16s",fadeQuote);
}

function fadeQuote() {
		$(".homeBanner").stopTime().everyTime("16s",fadeQuote);
		var numQuote;
		if($(this).is('a')) {
			numQuote = $(this).attr("id").substring(8);
		}
		else {
			numQuote = $(".homeBanner .selectorContainer .selector ul li:has(a.current)").next().children('a');
			if(numQuote.length==0)
				numQuote = $(".homeBanner .selectorContainer .selector ul li:has('a'):first a");
			numQuote = numQuote.attr("id").substring(8);
		}
		$(".homeBanner ul.boxInner li").stop(true,true);
		$(".homeBanner ul.boxInner li:visible").fadeOut("slow", function() {
			$(".homeBanner ul.boxInner li#quote"+numQuote).fadeIn("slow");
		});
		$(".homeBanner .selectorContainer .selector ul li a.current").removeClass("current");
		$(".homeBanner .selectorContainer .selector ul li a#quoteSel"+numQuote).addClass("current");
		if($(this).is('a')) {
			return false;
		}
}

// adds rounded corners to the home banner using curvycorners plugin
function roundedHomeBanner() {
	$(".boxInner").corner({
	  tl: { radius: 13 },
	  tr: { radius: 13 },
	  bl: { radius: 13 },
	  br: { radius: 13 },
	  antiAlias: true,
	  autoPad: true });
	$(".homeBanner .box").corner({
	  tl: { radius: 15 },
	  tr: { radius: 15 },
	  bl: { radius: 15 },
	  br: { radius: 15 },
	  antiAlias: true,
	  autoPad: false });
}

// Smoothly expands FAQ answers, only showing one at a time
function expandFAQs() {
	$('.lAnswer').hide();
	$('.lAnswer:first').show(); $('.faqs li:first').addClass("current");
	$('.lQuestion').click(function(){
		$(".faqs li.current").removeClass("current");
		$(this).parent().addClass("current");
		$(this).parent().siblings().find('.lAnswer').slideUp("fast");
		$(this).siblings('.lAnswer').slideDown("fast");
		if($(this).attr('href') =='#') {
			return false;
		} else {
			return true;
		};
	});
}

// Add hover state to list items
function listLinkHover() {
	$(".faqs li").hover(
		function() {
			$(this).addClass("hover");
		},
		function() {
			$(this).removeClass("hover");
		}
	);
	$(".faqs li").click(function() {
		if ($(this).find("a").attr("href")) {
			window.location = ($(this).find("a").attr("href"));
		}
	});
}

// resize font size, cookie based
function setCurrFsize(id){
	var cookie = readCookie("fontSize");
	var currentSize = cookie ? cookie : 100;
	fsize(currentSize,id);
}
function fsize(newSize,id){
	var vfontsize = document.getElementById(id);
	if(vfontsize){	vfontsize.style.fontSize = newSize + "%";}
	createCookie("fontSize", newSize, 0);
}
var cookie = readCookie("fontSize");
var textsize = cookie ? cookie : 100;
function changetextsize(up){
  if(up){
   textsize = parseFloat(textsize)+15;
  }else{
   textsize =parseFloat(textsize)-15;
  }
}

// cookie handling
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

// bookmark
function bookmark(title, url) {
if (window.sidebar) // FF
    window.sidebar.addPanel(title, url, '');
else if(window.opera && window.print) { // Opera
	alert('Please press <Ctrl+D> to bookmark this page (<Ctrl+T> in older Opera versions).');
}
else if(document.all) {// MSIE
    window.external.AddFavorite(url ,title);
}
else if(navigator.appName=='Netscape') { //NS and Chrome
	alert('Please press <Ctrl+D> to bookmark this page.');
}
else
	alert('Bookmarks cannot be set in your browser automatically. Please use the browser menu to manually bookmark this page.');
}

function leftmenu(){

	$('#subNav').treeview({

		collapsed: true,	

		persist: "location",

		unique: true

	});

}
// show hide content with link
function showHideLink (id) {
	var vis = (document.getElementById(id).style.display) == "none" ? "block" : "none";
	document.getElementById(id).style.display = vis;
}
// show hide content with checkbox

function showHideBox (it, box) {

	var vis = (box.checked) ? "block" : "none";

	document.getElementById(it).style.display = vis;

}

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip2.htm for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/images/layout/tooltiparrow.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


/*
 * Treeview 1.4 - jQuery plugin to hide and show branches of a tree
 * 
 * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
 * http://docs.jquery.com/Plugins/Treeview
 *
 * Copyright (c) 2007 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.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
 *
 */;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("<div class=\""+CLASSES.hitarea+"\"/>").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){settings=$.extend({cookieId:"treeview"},settings);if(settings.add){return this.trigger("add",[settings.add]);}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}function serialize(){function binary(arg){return arg?1:0;}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}break;}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery);
 
 
 //this function adds a key-value pair to the querystring. If the key exists in the querystring, it will be 
//removed and replaced by the new key-value pair. If the key is empty, the value will always be added to the
//querystring.
function jump(key, value)
{
    var searchString = location.search;
    
    if (key.length > 0)
    {
        myRegExp = new RegExp("&*" + key + "=\\w+","gi");
        searchString = searchString.replace(myRegExp, "");
        
        if (searchString.length > 0)
        {
            if (searchString == '?')
            {
                searchString += key + '=' + value;
            }
            else
            {
                searchString += '&' + key + '=' + value;
            }
        }
        else
        {
            searchString += '?' + key + '=' + value;
        }
    }
    else
    {
        searchString += value;
    }
    
    window.location.href = location.protocol + '//' + location.hostname + location.pathname + searchString;	
    
    return false;
}
 
