$('document').ready(function (){
	//nav img tabs
	$('#nav li').hover(
		//over
		function(){
			$(this).children().css("background-position","center left");
			$(this).prev().children().css("background-position","bottom left");
		},
		//out
		function(){
			$(this).children().css("background-position","top left");
			$(this).prev().children().css("background-position","top left");
		}
	);
			
	
	//testimonials slideshow
	$('.slideholder').innerfade({
		animationtype: 'fade',
		speed: 'slow',
		timeout: 15000,
		type: 'random_start'
	});


	//faq
	$('#faq_holder').find('dd').hide().end().find('dt').click(function() {
         var answer = $(this).next();
         if (answer.is(':visible')) {
             answer.slideUp("fast");
         } else {
             answer.slideDown("fast");
         }
     });

	 $('#faq_expand').click(function(){
		$('#faq_holder dd').slideDown();
	 });
	 $('#faq_collapse').click(function(){
		 $('#faq_holder dd').slideUp();
	 });


	 //VIDEOS
	 //create the embed player
	 $('#video_player a.direct_video').flash(
        { height: 370, width: 450 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.src = $this.attr('href');
            $('#embed').html($.fn.flash.transform(htmlOptions));						
        }
    );
	
	//thumbnail click
	$('.video_thumb').click(function(){
		//set some variables
		var player = $(this).find('span.player').html();
		var title = $(this).find('span.title').html();
		var desc = $(this).find('span.desc').html();
		
		
		//flassh the embed div with the new player
		$('#embed').html('<img src="layout_imgs/ajax-loader.gif" alt="loading" />');
		$('#embed').flash(
			{ height: 370, width: 450 },
			{ version: 8 },
			function(htmlOptions) {
				$this = $(this);
				htmlOptions.src = player;
				$('#embed').html($.fn.flash.transform(htmlOptions));						
			}
		);

		//update the video_info div
		$('#video_info h3').html(title);
		$('#video_info .desc').html(desc);
		
	});

	//filter onchange
	$('#video_filters select').change(function(){
		var selected_class = '';
				
		//get the selected class
		$(this).each(function () {
			selected_class = $(this).attr('value');
		});
		//alert(selected_class);

		if(selected_class==undefined){
			$('.video_thumb').fadeIn();
		} else {
			$('.video_thumb').not("."+selected_class).fadeOut();
			$('.video_thumb.'+selected_class).fadeIn();
		}

	});
	

});