// JavaScript Document
$(document).ready(function() {
	
		  $(".accordion").hrzAccordion(
						  {eventTrigger:"mouseover",
						  openOnLoad:"1",
						  //cycle: true,
						  cycleInterval: 5000,
						  openEaseAction: "swing",
						  closeEaseAction: "swing",
						  handlePosition: "left"
		  });
		
		$.superbox.settings = {
			overlayOpacity: .6 // Background opaqueness
		};
		$.superbox();

		$('.button-expand').click(function() {
						var content = $(this).parent().find('.expand-content');
						var display = $(content).css('display');
						var buttonText = $(this).html();
						
						$(content).toggle('slow');
						
						switch (display) {
							case 'none':
								$(this).html('<img src="/_images/button-collapse.jpg" border="0" alt="/\" /> collapse');
								break;
							default :
								$(this).html('<img src="/_images/button-expand.jpg" border="0" alt="\/" /> expand');
								break;
						} 
        });
	
	
		// dropdown menu basic actions
		//
		$('.dropdown-content').each(function(){
											$(this).hide();
											});
		function menuShow() { var thisMenuItem = $(this).find('.dropdown-content');
								$(thisMenuItem).slideDown();
		}
		function menuHide() { var thisMenuItem = $(this).find('.dropdown-content');
								$(thisMenuItem).hide();
		}
	
		$('.rootLink').hoverIntent({
						 sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
						 interval: 100,   // number = milliseconds for onMouseOver polling interval
						 over: menuShow,     // function = onMouseOver callback (required)
						 timeout: 50,   // number = milliseconds delay before onMouseOut
						 out: menuHide      // function = onMouseOut callback (required)
						});
		
		// dropdown menu's hover states
		//
		$(".drop-bot li").hoverIntent({
		 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
		 interval: 50,   // number = milliseconds for onMouseOver polling interval
		 over: addBack,     // function = onMouseOver callback (required)
		 timeout: 0,   // number = milliseconds delay before onMouseOut
		 out: removeBack      // function = onMouseOut callback (required)
	   	});
		
		function addBack() { 	var width = $(this).width(); 
								if (width < 105) {
										$(this).parent().addClass('hoverOn90');
								}
								else if (width > 105 && width <= 110) {
										$(this).parent().addClass('hoverOn110');	
								}
								else if (width > 110 && width <= 125) {
										$(this).parent().addClass('hoverOn125');
								}
								else if (width > 125 && width < 170) {
										$(this).parent().addClass('hoverOn155');
								}
								else if (width >= 170 && width < 185) {
										$(this).parent().addClass('hoverOn175');
								}
								}
		function removeBack() { $(this).parent().removeClass(); }
		
		
		// menu link redirection
		//
		$('.dropdown-content li span').click(function(){
							var	href = $(this).attr('title');
							
							window.location = href;
							
							});
		$('.drop-bot li').click(function(){
							 var href = $(this).attr('title');
							 
							 window.location = href;
							 
							 });
		
		
		
		// various page functions
		//
		
		$('.hidden').each(function(){
							   $(this).hide();
							   });
		$('.expander').click(function() {
							  var target = $(this).next();
							  $(target).toggle();
							  });
			
	
			
		// Slider functions
		//
		
		function mycarousel_initCallback(carousel) {

		for (i=2;i<=4;i++) { 
				$('#control'+i).bind('click', function() {
					strID = this.id;
					intCNum = parseInt(strID.substring(strID.length-1,strID.length), 10) + 1;
					carousel.scroll(intCNum);
					return false;
				});
			}
		};
		
			if (document.getElementById('carousel-management'))		
				$('#carousel-management').jcarousel({
					scroll: 1,
					initCallback: mycarousel_initCallback
				});
		
		// slider query to content
		//
		
		
		function trigger(data) {
		  var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
		  selectNav.call(el);
		}
		
		if (window.location.hash) {
		  trigger({ id : window.location.hash.substr(1) });
		} else {
		  $('ul.navigation a:first').click();
		}

		//$('iframe').each(function() { $(this).attr('scrolling') = 'no'; });
});
