//if js is enable add this class to html in order for nav function
$('html').addClass('js');
		
//bg scroller
	var scrollSpeed = 48; 		// Speed in milliseconds
	var step = 1; 				// How many pixels to move per step
	var current = 0;			// The current pixel row
	var imageWidth = 1058;		// Background image width
	//var headerWidth = 1280;		// How wide the header is.
	
	//The pixel row where to start a new loop
	//var restartPosition = -(imageWidth - headerWidth);
	var restartPosition = -(imageWidth);
	
	function scrollBg(){
		//Go to next pixel row.
		current -= step;
		
		//If at the end of the image, then go to the top.
		if (current == restartPosition){
			current = 0;
		}
		
		//Set the CSS of the header.
		$('#anawrap').css("background-position",current+"px 70px");
	}
	
	//Calls the scrolling function repeatedly
	var init = setInterval("scrollBg()", scrollSpeed);
	//end bg scroller

			
$(document).ready(function(){
	//show initial state
	$('#intro').show();		

//spaceguy aninmation

$('#guy').toggle(function(){
	
	//not very elegant but sometimes pointer can get in the way of animation
	$('#blip01').hide();
	$('#guypic-left').die('mouseenter mouseleave');
	
	$('#guy').animate({left:0, top:240}, 900, function (){
	  $('#guypic-left').replaceWith('<img id="guypic-right" src="images/guy-right.png" alt="" width="219" height="152" border="0">');
	  });

   	},
   function(){
   
      $('#guy').animate({left: ($(window).width()-280), top:140}, 900, function (){
	  	$('#guypic-right').replaceWith('<img id="guypic-left" src="images/guy-left.png" alt="" width="219" height="152" border="0">');
	  	});
		
		//not very elegant but rebind toggle blip02
		$('#guypic-left').live('mouseenter mouseleave', function() {
 			 $('#blip01').toggle();
		});
});

//endGUY


//dog aninmation
$('#dog').toggle( function(){
		
	//not very elegant but sometimes pointer can get in the way of animation
	$('#blip02').hide();
	$('#dogpic-right').die('mouseenter mouseleave');

      $('#dog').animate({left: ($(window).width()-280), top:40}, 900, function (){
	  	$('#dogpic-right').replaceWith('<img id="dogpic-left" src="images/dog-left.png" alt="" width="230" height="115" border="0">');
	  	});
   },
   function(){
   
      $('#dog').animate({left: 20, top:90}, 900, function (){
	  	$('#dogpic-left').replaceWith('<img id="dogpic-right" src="images/dog-right.png" alt="" width="230" height="115" border="0">');
	  	});
		
		//not very elegant but rebind toggle blip02
		$('#dogpic-right').live('mouseenter mouseleave', function() {
 			 $('#blip02').toggle();
		});
		
});

//enddog

		
//ACCORDION BUTTON ACTION	
$('.showMore').click(function() {

//hide just opened div if reclick on 'button'
	if($(this).next().is(":visible")){
		$(this).next().slideUp();
	}
	else {
		$('div.linksContent').slideUp('normal');	
	$(this).next().slideDown('normal');
	}

}); //endAccordian


//hide all show div with href
$('#nav li a').click(function(e) {
	e.preventDefault();
	$('.act').hide();
	//$('#newbook').hide();
	$('#nav li a').removeClass('selected');
	$(this).addClass('selected');
       $($(this).attr('href')).slideDown(500);
	
   });		
   
 
 //covers nav
$('.cvrlnk').click(function(e) {
	e.preventDefault();
	
	 var xx = $(this).attr('href');
	//alert (xx);
	
	$('.act').hide();
	$('#nav li a').removeClass('selected');
	
	$('[href=' + xx + ']').addClass('selected');
    $($(this).attr('href')).slideDown(500);
	 
	
   });  
   
	
	
//show hide on hover 


$('#guypic-left').live('mouseenter mouseleave', function() {
  $('#blip01').toggle();
});

$('#dogpic-right').live('mouseenter mouseleave', function() {
  $('#blip02').toggle();
});

   
});//endReady
