/**
 * @author jasonjohnston *  created on 8-12-2009
 */


/*
	
	$(function(){
		$('#img_0').onImagesLoad({
			selectorCallback: function(){
				$('#img_0').toggleClass('comp');
				var src = $('#img_0').attr("src");
				$('#slideShow').addClass('img_0');
			}
		});
	});
*/

		
	
 $(document).ready(function(){
	
	// category hover
	$('.category').hover(
		function(){
			$('.category').removeClass('hover')
			$(this).addClass('hover');
							
			// hide all subs
			$('.sub_hide').removeClass('sub_show');
			var sub = $(this).attr('id');
			// show the target sub menu
			sub = '#'+sub+'_sub';
			$(sub).addClass('sub_show');
		},
		function(){
			//$(this).toggleClass('hover');

		}
	);
	// anchor hover
	$("a").hover(
		function(){
			$(this).toggleClass('hover');
			
		},
		function(){
			$(this).toggleClass('hover');
		}
	);
	
	// slide show hover
	$('#slideShow').hover(
		function(){
			//$('.sub_hide').removeClass('sub_show');
		},
		function(){}
		
	);

	

	
/*
	function waitForSlide(){
		if($('img:first').hasClass('comp')){
			

			
		}
		else{
			setTimeout(function(){
				waitForSlide();
			},250);
		}
	}
	waitForSlide();
*/
	
	var numImg  = $('img').length;
	var index = 0;
	var slideShow = $('#slideShow');
	
	// show  the next slidecurrent slide for 5 sec
	function showNextSlide(){
		
		
		$('#slideShow').toggleClass('img_'+index);
		
		if((++index) == numImg){
			index = 0;
		}
		
		// pause for a sec
		setTimeout(function(){
			// show the current slide
			$('#slideShow').toggleClass('img_'+index);
		},450);
		
	};
	
	slideShow = setInterval(function(){
		showNextSlide();
	}, 5500);
	
	



	

	
	

 });
