
$(document).ready( function() {

	//functions for IE6 to trigger quicklinks from main menu
	$('div#nav-wrapper div#nav ul li').mouseover(function() {														  	
															$(this).children('ul').addClass('visibleSubNav'); 
															$(this).children('ul').css('display','block');
															}); 
	$('div#nav-wrapper div#nav ul li').mouseout(function() {
															$(this).children('ul').removeClass('visibleSubNav');
															$(this).children('ul').css('display','none');
															}); 
	



	//GENERAL DOCUMENT ENHANCEMENT
	$("a.email").each( //Email address obfuscation
		function () {
			e = this.rel.replace("/","@");
			this.href = "mailto:"+e;
			$(this).text(e);
		}
	);

	$("a.external").click( //Open link in new window
		function() {
			window.open(this.href);
			return false;
		}
	);

	$(".rollover").hover( //Rollover images
		function() {
			if($(this).attr("src").indexOf("-over")==-1) {
				var newSrc = $(this).attr("src").replace(".gif","-over.gif");
				$(this).attr("src",newSrc);
			}
		},
		function() {
			if($(this).attr("src").indexOf("-over") != -1) {
				var oldSrc = $(this).attr("src").replace("-over.gif",".gif");
				$(this).attr("src",oldSrc);
			}
		}
	);

	$("input.input-text").each ( //Input field default text toggle
		function() {
			this.rel=this.value;
		}
	);

	$("input.input-text").focus(function() {
		if (this.value==this.rel) {
			this.value='';
		}
	});

	$("input.input-text").blur(function() {
		if (this.value=='') {
			this.value=this.rel;
		}
	});
	
	//Styling last Child Element in List
	$("div#main-wrapper div#main div.white-lists div.column ul li:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div#main-wrapper div#left-col div#useful ul li:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div#main-wrapper div#main div#home-left-col div#news-carousel-middle ul li:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div#footer-wrapper div#footer ul li:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div.box-right table tr td:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div#whitebox table tr:last-child").each(
		function(){																	
              $(this).addClass("last");
            });
	$("div.double:last-child").each(
		function(){																	
              $(this).addClass("last");
            });

	
	//ACCORDION
	//$("#accordion").each (
		//function() {
			//$(this).accordion({ header: 'p.heading' }); //Initialise accordion
			
			/*var currentIndex=$("#accordion h2").eq(0); //Set current active heading

			$("#accordion h2").click ( //Active heading click event
				function() {
					currentIndex.removeClass();
					$(this).addClass("active");
					currentIndex=$(this);
				}
			);*/
		//}
	//);
	
	
	//NEWS SCROLLING CAROUSEL
	$("#news-carousel").each (
		function() {

			var scrollValue=$("#news-carousel").css("width"); //Get incremental scroll value
			scrollValue=scrollValue.replace("px","");
			
			var numberOfItems=Math.ceil($("#news-carousel #scroller .news-item").length/2); //Get number of scroll increments

			var currentThumbnail=$("#news-carousel-top ol li").eq(0); //Set current active thumbnail

			for ($i=0; $i<=$("#news-carousel-top ol li").length; $i++) { //Set thumbnail indices
				$("#news-carousel-top ol li").eq($i).attr("rel",$i);
			}

			$("#news-carousel-top ol li").hover( //Thumbnail rollovers event
				function() {
					if($("img",this).attr("src").indexOf("-active")==-1) {
						var newSrc = $("img",this).attr("src").replace(".gif","-active.gif");
						$("img",this).attr("src",newSrc);
					}
				},
				function() {
					if($("img",this).attr("src").indexOf("-active")!=-1 && $(this).attr("className")!="active") {
						var oldSrc = $("img",this).attr("src").replace("-active.gif",".gif");
						$("img",this).attr("src",oldSrc);
					}
				}
			);

			$("#news-carousel-top ol li").click ( //Thumbnail click event
				function () {
					var $index=$(this).attr("rel"); //Set new index

					$("img",currentThumbnail).attr("src","/images/buttons/news-carousel.gif"); //Deactivate current thumbnail
					currentThumbnail.removeClass();

					$("#scroller").animate({left: (scrollValue*($index)*-1)}, {duration: 500, easeMethod: "easeInOut"}); //Scroll carousel
					
					currentThumbnail=$("#news-carousel-top ol li").eq($index); //Set current active thumbnail
					currentThumbnail.addClass("active");
					
					return false;
				}
			);

		}
	);
	
	//TABBED CONTENT (Contact forms)
	$("#tabbed-content").each (
		function() {
			var numberOfTabs=$("#tabbed-content ul#tab-list li").length; //Get number of tabs

			for ($i=0; $i<numberOfTabs; $i++) { //Set tab indices and hide tabs
				$("#tabbed-content ul#tab-list li").eq($i).attr("rel",$i);
				$("#tabbed-content .tab").eq($i).css("display","none");
			}
			$("#tabbed-content .tab").eq(0).css("display","block");

			$("#tabbed-content ul#tab-list li").click ( //Tab click event
				function() {
					showTab($(this).attr("rel"));
					return false;
				}
			);

			function showTab($index) { //Show tab
				for ($i=0; $i<numberOfTabs; $i++) {
					$("#tabbed-content .tab").eq($i).hide();
					$("#tabbed-content .tab").eq($index).show();
					
					$("#tabbed-content ul#tab-list li").removeClass();
					$("#tabbed-content ul#tab-list li").eq($index).addClass("active");
				}
			}
		}
	);

	//SOCIAL MEDIA TABS (Facebook, Twitter, DCU)
	$("#tabbed-content").each (
		function() {
			var numberOfTabs=$("#social-tabs ul#social-tab-list li").length;

			for ($i=0; $i<=numberOfTabs; $i++) { //Set tab indices and hide tabs
				$("#social-tabs ul#social-tab-list li").eq($i).attr("rel",$i);
				$("#social-tabs div.tab").eq($i).css("display","none");
			}
			$("#social-tabs div.tab").eq(0).css("display","block");
			
			$("#social-tabs ul#social-tab-list li").click ( //Tab click event
				function() {
					showTab($(this).attr("rel"));
					return false;
				}
			);
			
			function showTab($index) {
				for ($i=0; $i<numberOfTabs; $i++) {
					$("#social-tabs .tab").eq($i).hide();
					$("#social-tabs .tab").eq($index).show();
				}
			}
		}
	);
	
	//SMALL TABBED CONTENT (Generic content, small tabs)
	$("#small-tabbed-content").each (
		function() {
			var numberOfTabs=$("#small-tabbed-content ul#small-tabs li").length; //Get number of tabs

			for ($i=0; $i<numberOfTabs; $i++) { //Set tab indices and hide tabs
				$("#small-tabbed-content ul#small-tabs li").eq($i).attr("rel",$i);
				$("#small-tabbed-content .tab").eq($i).css("display","none");
			}
			$("#small-tabbed-content .tab").eq(0).css("display","block");

			$("#small-tabbed-content ul#small-tabs li").click ( //Tab click event
				function() {
					showTab($(this).attr("rel"));
					return false;
				}
			);

			function showTab($index) { //Show tab
				for ($i=0; $i<numberOfTabs; $i++) {
					$("#small-tabbed-content .tab").eq($i).hide();
					$("#small-tabbed-content .tab").eq($index).show();
					
					$("#small-tabbed-content ul#small-tabs li").removeClass();
					$("#small-tabbed-content ul#small-tabs li").eq($index).addClass("active");
				}
			}
		}
	);
	
	
	
	//SIMPLE TABBED CONTENT (Generic content, small tabs)
	$(".simple-tabbed-content").each (
		function() {
			var numberOfTabs=$(".simple-tabbed-content ul#tab-list li").length; //Get number of tabs

			for ($i=0; $i<numberOfTabs; $i++) { //Set tab indices and hide tabs
				$(".simple-tabbed-content ul#tab-list li").eq($i).attr("rel",$i);
				$(".simple-tabbed-content .tab").eq($i).css("display","none");
			}
			$(".simple-tabbed-content .tab").eq(0).css("display","block");

			$(".simple-tabbed-content ul#tab-list li").click ( //Tab click event
				function() {
					showTab($(this).attr("rel"));
					return false;
				}
			);

			function showTab($index) { //Show tab
				for ($i=0; $i<numberOfTabs; $i++) {
					$(".simple-tabbed-content .tab").eq($i).hide();
					$(".simple-tabbed-content .tab").eq($index).show();
					
					$(".simple-tabbed-content ul#tab-list li a").removeClass("active");
					$(".simple-tabbed-content ul#tab-list li a").eq($index).addClass("active");
				}
			}
		}
	);
	
	
	
	$("#social-media ul li img").each ( //Social media icon rollover fade effect
		function() {
			$(this).css("opacity",0.8);
		}
	);
	
	$("#social-media ul li img").hover (
		function() {
			$(this).fadeTo("fast",1.0);
		},
		function() {
			$(this).fadeTo("fast",0.8);
		}
	);
	
	//BREADCRUMBS
	String.noLC = new Object ({the:1, a:1, an:1, and:1, or:1, but:1, aboard:1, about:1, above:1, across:1, after:1, against:1, along:1, amid:1, among:1, around:1, as:1, at:1, before:1, behind:1, below:1, beneath:1, beside:1, besides:1, between:1, beyond:1, but:1, by:1, 'for':1, from:1, 'in':1, inside:1, into:1, like:1, minus:1, near:1, of:1, off:1, on:1, onto:1, opposite:1, outside:1, over:1, past:1, per:1, plus:1, regarding:1, since:1, than:1, through:1, to:1, toward:1, towards:1, under:1, underneath:1, unlike:1, until:1, up:1, upon:1, versus:1, via:1, 'with':1, within:1, without:1});
	String.prototype.titleCase = function () {var parts = this.split(' '); if ( parts.length == 0 ) return ''; var fixed = new Array(); for ( var i in parts ) {var fix = ''; if ( String.noLC[parts[i]] ) {fix = parts[i].toLowerCase();} else if ( parts[i].match(/^([A-Z]\.)+$/i) ) {fix = parts[i].toUpperCase();} else if ( parts[i].match(/^[^aeiouy]+$/i) ) {fix = parts[i].toUpperCase();} else {fix = parts[i].substr(0,1).toUpperCase() + parts[i].substr(1,parts[i].length);} fixed.push(fix); } fixed[0] = fixed[0].substr(0,1).toUpperCase() + fixed[0].substr(1,fixed[0].length); return fixed.join(' ');}

	if($('#breadcrumbs ol')) {
		var crumbs =window.location.pathname.split('/'), i, u ='/', p, currLink;
		for(i=0;i<crumbs.length -1;i++) if(crumbs[i].length) {
			u += crumbs[i] + '/';
			$('#breadcrumbs ol').append('<li><a href="' +u+ '">' + crumbs[i].replace(/\-/g, ' ').titleCase() + '</a></li>');
		}
		p =crumbs.pop();
		$('#breadcrumbs ol').append('<li>' + $('title').text() + '</li>');
		//$('#breadcrumbs ol').append('<li>' + p.replace(/\.[^.]+$/, '').replace(/\-/g, ' ').titleCase() + '</li>');
	
	}


	if($('#accordion'))  {
		var lUrl, lAbs, lRel, foundLink;
		if($('#subnav').length>0) {
			lUrl =document.location.href;
			lAbs =window.location.pathname;
			lRel =window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1);
			for(i=0;i<$('#subnav p').length; i++) if($('#subnav p:eq(' + i + ') a').attr('href')!='#') $('#subnav p:eq(' + i + ')').addClass('link'); 
			var mainlinks =$('#subnav p.link');
			for(i =0; i<mainlinks.length; i++) {
				currLink =$('#subnav p.link:eq(' + i + ') a').attr('href');
				if(currLink===lRel || currLink===lAbs || currLink===lUrl) {
					$('.ui-state-active').removeClass('ui-state-active');
					$('#subnav p.link:eq(' + i + ')').addClass('link-active');
					foundLink =true;
					$('#subnav').accordion({header: 'p:not(.link)', collapsible: true, active: false, changestart: function(event, ui) {$('#subnav p.link-active').removeClass('link-active');}});				
					break;
				}
				
			}
			
			var parents =$('#subnav p:not(.link)'), j, children, child, gchildren, path =window.location.pathname;
			if(!foundLink) for(i =0; i<parents.length; i++) {
				children =$('#subnav ul:eq('+i+') li');
				//if($(children).length=='0' && $('#subnav p:eq(' + i + ') a').attr('href')!='#') $('#subnav p:eq(' + i + ')').addClass('link'); 
				for(j =0; j<$(children).length; j++) {
					currLink =$(children[j]).children('a').attr('href');
					if(currLink===lRel || currLink===lAbs || currLink===lUrl) {
						$('#subnav').accordion({header: 'p:not(.link)', active: i });
						
						$(children[j]).html($(children[j]).children('a').html());
						$(children[j]).addClass('active');
						foundLink =true;
						break;
					}
				}
			}
		}
		if(!foundLink) {
			if ($('#subnav').length) $('#subnav').accordion({header: 'p:not(.link)', active: 100}); 
			//changed from 0(the first list menu) to 100 for sub navigation menu jquery.accordion effect 240810 by Yang
			
			else {
				$('#accordion').accordion({header: 'p.heading:not(.link)', active: 0});
			}
		}
	}
	jQuery.fn.captioned =function() {
		var alt, src, w, h;
		this.each(function() {
			src =$(this).attr('src');
			w =$(this).width();
			h =$(this).height();
			alt =$(this).attr('alt');
			$(this).replaceWith('<table style="width: '+w+'px; height: '+h+'px;" class="captionedImage" cellpadding="0" cellspacing="0" border="0"><tr><td valign="bottom" style="background: url('+src+'); width: '+w+'px; height: '+h+'px;"><div class="caption">'+alt+'</div></div>');
		});
		return(this);
		
	}
	$('.captioned').captioned();
	
	
	
	if($('.smallbox-columns .smallbox').length>1) {
		for(var i=0; i<$('.smallbox-columns .smallbox').length; i=i+2) if(i<$('.smallbox-columns .smallbox').length) {
			var lB =$('.smallbox-columns .smallbox:eq(' + i + ') a .rollover').offset().top;
			var rB =$('.smallbox-columns .smallbox:eq(' + (i+1) + ') a .rollover').offset().top;
			if(lB>rB) {
				var t = $('.smallbox-columns .smallbox:eq(' + i + ') a .rollover').css('marginTop').replace(/.*[\w]/, '') + (lB -rB) + 'px';
				$('.smallbox-columns .smallbox:eq(' + (i+1) + ') a .rollover').css({marginTop: t});
			}else if(rB>lB) {
				var t = $('.smallbox-columns .smallbox:eq(' + (i+1) + ') a .rollover').css('marginTop').replace(/.*[\w]/, '') + (rB -lB) + 'px';
				$('.smallbox-columns .smallbox:eq(' + i + ') a .rollover').css({marginTop: t});
			}
		}
	}
	

//style search results
if($('.search-result ul').length>0) {
	var i, j, gc =$('.search-result ul'), rc =0;
	for(i =0; i<gc.length; i++) {
		rc =$('.search-result ul:eq(' + i + ') li');
		for(j =0; j<rc.length; j++) {
			if(j/2!=Math.round(j/2)) $('.search-result ul:eq(' + i + ') li:eq(' + j + ')').addClass('alt');
		}
	}
	
		
}


	//For HR Training Categories Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$(".trigger").click(function(){
		$(this).next().slideToggle('normal');	
		return false;
	});

		// For pop up window 
		var windowSizeArray = [ "width=956,height=712", "width=300,height=400,scrollbars=yes" ];
		
		
		$('.newWindow').click(function (event){

			var url = $(this).attr("href");

			var windowName = "popUp";//$(this).attr("name");

			var windowSize = windowSizeArray[$(this).attr("rel")];

			window.open(url, windowName, windowSize);

			event.preventDefault();

		});
		
		
		
		
		/* ISS inner nav toggle */
		function initMenu() {
		  $('#menu ul').hide();
		  $('#menu li a').click(
			function() {
				$(this).next().slideToggle('normal');	
				
			  }
			);
			
		/* ISS inner nav to highlight current page link */
			var url = window.location.toString();
			
				$('#menu li a').each(function(){
					  var myHref= $(this).attr('href');
					  if( url.match(myHref)) {
						   $(this).addClass('active')
							$(this).closest('ul').show();
					  }
				});

			
		  }
	
	
		initMenu();		




	$("#showHide #accordion div").hide();

	$("#showHide #accordion h4").click(function(){
		$(this).next("div").slideToggle("slow").siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h4").removeClass("active");
		return false;
	});
	
	$("#showHide #accordion .close").click(function(){
		$(this).parent().slideUp("slow");
		$(this).fadeOut('fast');	
		
		$(window).scrollTop( $("#accordion").offset().top, 1500);		
		
		return false;
	});
	
		
	




(function($) {
	$.fn.listnav = function(options) {
		var opts = $.extend({}, $.fn.listnav.defaults, options);
		var letters = ['_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-'];
		var firstClick = false;
		opts.prefixes = $.map(opts.prefixes, function(n) { return n.toLowerCase(); });

		return this.each(function() {
			var $wrapper, list, $list, $letters, $letterCount, id;
			id = this.id;
			$wrapper = $('#' + id + '-nav'); // user must abide by the convention: <ul id="myList"> for list and <div id="myList-nav"> for nav wrapper
			$list = $(this);

			var counts = {}, allCount = 0, isAll = true, numCount = 0, prevLetter = '';

			function init() {
				$wrapper.append(createLettersHtml());

				$letters = $('.ln-letters', $wrapper).slice(0, 1); // will always be a single item
				if (opts.showCounts) $letterCount = $('.ln-letter-count', $wrapper).slice(0, 1); // will always be a single item

				addClasses();
				addNoMatchLI();
				if (opts.flagDisabled) addDisabledClass();
				bindHandlers();

				if (!opts.includeAll) $list.show(); // show the list in case the recommendation for includeAll=false was taken

				// remove nav items we don't need
				//
				if (!opts.includeAll) $('.all', $letters).remove();
				if (!opts.includeNums) $('._', $letters).remove();
				if (!opts.includeOther) $('.-', $letters).remove();

				$(':last', $letters).addClass('ln-last'); // allows for styling a case where last item needs right border set (because items before that only have top, left and bottom so that border between items isn't doubled)
				
				if ($.cookie && (opts.cookieName != null)) {
					var cookieLetter = $.cookie(opts.cookieName);
					if (cookieLetter != null) opts.initLetter = cookieLetter;
				}

				// decide what to show first
				//
				if (opts.initLetter != '') {
					firstClick = true;
					$('.' + opts.initLetter.toLowerCase(), $letters).slice(0, 1).click(); // click the initLetter if there was one
				}
				else {
					if (opts.includeAll) $('.all', $letters).addClass('ln-selected'); // showing all: we don't need to click this: the whole list is already loaded
					else { // ALL link is hidden, click the first letter that will display LI's
						for (var i = ((opts.includeNums) ? 0 : 1); i < letters.length; i++) {
							if (counts[letters[i]] > 0) {
								firstClick = true;
								$('.' + letters[i], $letters).slice(0, 1).click();
								break;
							}
						}
					}
				}
			}

			// positions the letter count div above the letter links (so we only have to do it once: after this we just change it's left position via mouseover)
			//
			function setLetterCountTop() {
				$letterCount.css({ top: $('.a', $letters).slice(0, 1).offset({ margin: false, border: true }).top - $letterCount.outerHeight({ margin: true }) }); // note: don't set top based on '.all': it might not be visible
			}

			// adds a class to each LI that has text content inside of it (ie, inside an <a>, a <div>, nested DOM nodes, etc)
			//
			function addClasses() {
				var str, firstChar, firstWord, spl, $this, hasPrefixes = (opts.prefixes.length > 0);
				$($list).children().each(function() {
					$this = $(this), firstChar = '', str = $.trim($this.text()).toLowerCase();
					if (str != '') {
						if (hasPrefixes) {
							spl = str.split(' ');
							if ((spl.length > 1) && ($.inArray(spl[0], opts.prefixes) > -1)) {
								firstChar = spl[1].charAt(0);
								addLetterClass(firstChar, $this, true);
							}
						}


						firstChar = str.charAt(0);
						addLetterClass(firstChar, $this);
					}
				});
			}

			function addLetterClass(firstChar, $el, isPrefix) {
				if (/\W/.test(firstChar)) firstChar = '-'; // not A-Z, a-z or 0-9, so considered "other"
				if (!isNaN(firstChar)) firstChar = '_'; // use '_' if the first char is a number
				$el.addClass('ln-' + firstChar);

				if (counts[firstChar] == undefined) counts[firstChar] = 0;
				counts[firstChar]++;
				if (!isPrefix) allCount++;
			}

			function addDisabledClass() {
				for (var i = 0; i < letters.length; i++) {
					if (counts[letters[i]] == undefined) $('.' + letters[i], $letters).addClass('ln-disabled');
				}
			}

			function addNoMatchLI() {
				$list.append('<li class="ln-no-match" style="display:none">' + opts.noMatchText + '</li>');
			}

			function getLetterCount(el) {
				if ($(el).hasClass('all')) return allCount;
				else {
					var count = counts[$(el).attr('class').split(' ')[0]];
					return (count != undefined) ? count : 0; // some letters may not have a count in the hash
				}
			}

			function bindHandlers() {

				// sets the top position of the count div in case something above it on the page has resized
				//
				if (opts.showCounts) {
					$wrapper.mouseover(function() {
						setLetterCountTop();
					});
				}

				// mouseover for each letter: shows the count above the letter
				//
				if (opts.showCounts) {
					$('a', $letters).mouseover(function() {
						var left = $(this).position().left;
						var width = ($(this).outerWidth({ margin: true }) - 1) + 'px'; // the -1 is to tweak the width a bit due to a seeming inaccuracy in jquery ui/dimensions outerWidth (same result in FF2 and IE6/7)
						var count = getLetterCount(this);
						$letterCount.css({ left: left, width: width }).text(count).show(); // set left position and width of letter count, set count text and show it
					});

					// mouseout for each letter: hide the count
					//
					$('a', $letters).mouseout(function() {
						$letterCount.hide();
					});
				}

				// click handler for letters: shows/hides relevant LI's
				//
				$('a', $letters).click(function() {
					$('a.ln-selected', $letters).removeClass('ln-selected');

					var letter = $(this).attr('class').split(' ')[0];

					if (letter == 'all') {
						$list.children().show();
						$list.children('.ln-no-match').hide();
						isAll = true;
					} else {
						if (isAll) {
							$list.children().hide();
							isAll = false;
						} else if (prevLetter != '') $list.children('.ln-' + prevLetter).hide();

						var count = getLetterCount(this);
						if (count > 0) {
							$list.children('.ln-no-match').hide(); // in case it's showing
							$list.children('.ln-' + letter).show();
						}
						else $list.children('.ln-no-match').show();

						prevLetter = letter;
					}

					if ($.cookie && (opts.cookieName != null)) $.cookie(opts.cookieName, letter);


					$(this).addClass('ln-selected');
					$(this).blur();
					if (!firstClick && (opts.onClick != null)) opts.onClick(letter);
					else firstClick = false;
					return false;
				});
			}

			// creates the HTML for the letter links
			//	
			function createLettersHtml() {
				var html = [];
				for (var i = 1; i < letters.length; i++) {
					if (html.length == 0) html.push('<a class="all" href="#">ALL</a>');
					html.push('<a class="' + letters[i] + '" href="#">' + ((letters[i] == '-') ? '...' : letters[i].toUpperCase()) + '</a>');
				}
				return '<div class="ln-letters">' + html.join('') + '</div>' + ((opts.showCounts) ? '<div class="ln-letter-count" style="display:none; position:absolute; top:0; left:0; width:20px;">0</div>' : ''); // the styling for ln-letter-count is to give us a starting point for the element, which will be repositioned when made visible (ie, should not need to be styled by the user)
			}

			init();
		});
	};

	$.fn.listnav.defaults = {
		initLetter: '',
		includeAll: true,
		incudeOther: false,
		includeNums: true,
		flagDisabled: true,
		noMatchText: 'No matching entries',
		showCounts: true,
		cookieName: null,
		onClick: null,
		prefixes: []
	};
})(jQuery);

$('#myList').listnav({
 	initLetter: 'a', 
    includeAll: true, 
    includeOther: false, 
    flagDisabled: true, 
	showCounts: true,
    noMatchText: 'No matching entries, please click another letter.', 
    cookieName: 'my-main-list'}
);

});




function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.rotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};



$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	$('div.rotator').fadeIn(1000);
    $('div.rotator ul li').fadeIn(1000); // tweek for IE
});


	


