/*************************
//* Multi Level CSS Menu
**************************/

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', 'uploads/down.gif', 23], right:['rightarrowclass', 'uploads/right.gif']}

var jqueryslidemenu={

animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '" style="border:0;" />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
			$curobj.click(function(){
				$(this).children("ul:eq(0)").hide()
			})
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="navi" on page:
jqueryslidemenu.buildmenu("navi", arrowimages)


/*************************
//* Slider
**************************/
		var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;

		theInterval = function(cur){
			clearInterval(theInt);

			if( typeof cur != 'undefined' )
				curclicked = cur;

			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');

			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
				curclicked++;
				if( 6 == curclicked )
					curclicked = 0;

			}, 4000);
		};

		$(function(){

			$("#main-photo-slider").codaSlider();

			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");

			$navthumb
			.click(function() {
				var $this = $(this);
				theInterval($this.parent().attr('href').slice(1) - 1);
				return false;
			});

			theInterval();
		});


/*************************
//* SHOW/HIDE
**************************/

function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className=(item.className=='hidden')?'unhidden':'hidden';
}
}


/*************************
//* SScrollbars
**************************/

$(function()
			{
				// set the default options for all scrollpanes on this page
				$.extend($.fn.jScrollPane.defaults, {showArrows:true});
				// The above line could also be expressed like this as we are just setting one default:
				//$.fn.jScrollPane.defaults.showArrows = true;

				// this initialises the demo scollpanes on the page.
				$('#pane').jScrollPane();
				$('#pane2').jScrollPane();
				// overriding showArrows for pane3
				$('#pane3').jScrollPane({scrollbarWidth:20, scrollbarMargin:10, showArrows:true});
				$('#pane4').jScrollPane();

				// this allows you to click a link to add content to #pane4 and shows how to
				// reinitialise the scrollbars when you have done this.
				$('#add-content').bind(
					'click',
					function()
					{
						$('#pane4').append($('<p></p>').html($('#intro').html())).jScrollPane();
					}
				);
				// and this allows you to click the link to reduce the amount of content in
				// #pane4 and reinitialise the scrollbars.
				$('#remove-content').bind(
					'click',
					function()
					{
						$('#pane4').empty().append($('<p></p>').html($('#intro').html())).jScrollPane();
					}
				);
			});
