$(document).ready(function(){
	
	$('ul#faq li p').hide();
	$('ul#faq li table').hide();
	$('ul#faq li h2').each(function() {
		
		$(this).click(function() {
			$(this).siblings().slideToggle();
			return false;
		})
		
	});
	
	
	/* Carousel*/	
	$("#home-carousel").jCarouselLite({
        btnNext: "#home-next",
        btnPrev: "#home-prev",
		visible: 4,
		speed: 500
    });
	
	$("#abductees-carousel").jCarouselLite({
        btnNext: "#abductees-next",
        btnPrev: "#abductees-prev",
		visible: 1,
		easing: 'easeInOutQuint',
		speed: 700
		/* DISUSED EFFECTS
		vertical: true,
		beforeStart: function(a) {
			$('#beam').animate({opacity: 0.4, height: 'toggle'}, 400);			
			$('#beam').slideUp(299);
			$('.abductees-carousel li .prod-photo').stop().fadeTo(1, 1);
		}*/
    });
	
	$("#press-carousel").jCarouselLite({
        btnNext: "#press-next",
        btnPrev: "#press-prev",
		visible: 1,
		easing: 'easeInOutQuint',
		speed: 700
		/* DISUSED EFFECTS
		vertical: true,
		beforeStart: function(a) {
			$('#beam').animate({opacity: 0.4, height: 'toggle'}, 400);			
			$('#beam').slideUp(299);
			$('.abductees-carousel li .prod-photo').stop().fadeTo(1, 1);
		}*/
    });
	
	$('a.lightbox').fancybox({
		hideOnContentClick: false
	});
		
	/* Nav Spotlight Pulsation - IE & Chrome doesn't like the transparent PNG fading*/	
	var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
	$(function () {
        if ($.browser.msie || $.browser.chrome) return;
        $("#nav #spotlight").effect("pulsate", { times:100 }, 5000);		
    });

	/* Toggle 3D effect */
	$("#three-d").click(function(){ 
		var threed = $.cookie('threed');
		if(threed != 'true')
		{
			$('body').addClass("three-d-bg");
			$.cookie('threed', 'true', { expires: 7 });			
			
		}
		else
		{
			$('body').removeClass("three-d-bg");
			$.cookie('threed', 'false', { expires: 7 });
		}		
		
	});
		
	/* Read cooke to check if 3D should be displayed */
	var threed = $.cookie('threed');
	if(threed == 'true')
	{
		$('body').addClass("three-d-bg");
	}
	
	/* Hover effect on buttons */
	$("#btn-send-msg").hover(
      function () {
        $(this).css({'background-position' : '0 -20px'});
      }, 
      function () {
        $(this).css({'background-position' : '0 0'});
      }
    );
	$("#btn-add").hover(
      function () {
        $(this).css({'background-position' : '0 -20px'});
      }, 
      function () {
        $(this).css({'background-position' : '0 0'});
      }
    );	

	/* Pre Load 3D to improve tranistion*/
	$.preloadImages("/images/backgrounds/homepage-bg-3d.jpg", 
					"/images/backgrounds/city-scape-3d.jpg");
	if ($.browser.msie && $.browser.version.substring(0,3) == "6.0"){
		$.preloadImages("/images/backgrounds/homepage-panels-bg-3d.jpg");
	}
});

function load3d() {
	$("#pre-load").append("<img src='/images/backgrounds/homepage-bg-3d.jpg'/>");
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}