//////////////////////////////////////////////////////
//
//	The purpose of this file is to
//	apply a hover class on mouseover
//	on the <li> elements in the nav.
//	This is because IE doesn't put
//	the pseudo class :hover on <li> elements
//
//	This is code that uses the
//	jquery javascript library (http://jquery.com/)
//
//////////////////////////////////////////////////////

var current = 0;
	function loadSlide(start)
	{
		if(start != undefined)
			current = start;
		
		//member functions
		function prev()
		{
			var next;
			if(current == 0)
					next = 2;
				else
					next = (current - 1) % 3;
			
			$('.color_box_holder .screen').fadeIn('slow', function(){
				$($('.color_box_holder .color_box')[current]).hide();
				$($('.color_box_holder .color_box')[next]).show();
				$('.color_box_holder .screen').fadeOut('slow');
				
			});
				
			$('.image_box .screen').fadeIn('slow', function(){
				$($('.image_box img')[current]).hide();	
				$($('.image_box img')[next]).show();
				$('.image_box .screen').fadeOut('slow');
				current = next;
			});
			
			
		}
		
		function next()
		{
			
			var next;
			next = (current + 1) % 3;
			
			
			$('.color_box_holder .screen').fadeIn('slow', function(){
				$($('.color_box_holder .color_box')[current]).hide();
				$($('.color_box_holder .color_box')[next]).show();
				$('.color_box_holder .screen').fadeOut('slow');
				
			});
				
			$('.image_box .screen').fadeIn('slow', function(){
				$($('.image_box img')[current]).hide();	
				$($('.image_box img')[next]).show();
				$('.image_box .screen').fadeOut('slow');
				current = next;
			});
		}
		//initialize slides
		//current = 0;
		$($('.image_box img')[current]).show();
		$($('.color_box_holder .color_box')[current]).show();
		
		$('.screen').fadeOut('slow');
		
		//action callbacks
		$('.left_arrow a').click(function(){
			prev();
			return false;
		});
		
		$('.right_arrow a').click(function(){
			next();
			return false;
		});
		
		$('.color_box_next').click(function(){
			next();
			return false;
		});
		
		
	}




$(window).load(function() {

	
	$('.arrow_box img').hover(function(){
		this.src = 'cmsimages/arrow_hover.png';
		
	},function(){
		this.src = 'cmsimages/arrow.png';
	});
	
	$('.left_arrow img').hover(function(){
		this.src = 'cmsimages/btn-left_hover.gif';
	},
	function(){
		this.src = 'cmsimages/btn-left.gif';
	});
	
	$('.right_arrow img').hover(function(){
		this.src = 'cmsimages/btn-right_hover.gif';
	},
	function(){
		this.src = 'cmsimages/btn-right.gif';
	});
	
	$('#pane1').jScrollPane({scrollbarOnLeft: true, showArrows:true, scrollbarWidth: 9, dragMinHeight: 45});
	
	/*$('.image_box').each(function(){
		loadSlide();
	});*/
	
	$('#navigate').hide('10', function(){
		$('#navigate').animate({height: '33px', opacity: 'show'},1200, function(){
			$('#headernav').show(1000);
			
			});
	});
	


	if (document.all&&document.getElementById) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navtop > li").hover(function() {
			$(this).addClass("hover");
			
		},
		function () {
			$(this).removeClass("hover");
		});
		
		$(".navtop > li li ").hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
			
		});
		
		
	} else {
		// this is need for safari when nav covers flash
		$(".navtop li ul").mouseover(function () {
			$(this).addClass("redraw");
		});
		$(".navtop li ul").mouseout(function () {
			$(this).removeClass("redraw");
		});
	}
});
