/*
Vision Racer core JS V1.1 July 2011
© Matt Sherwen / Sherwen Studios Ltd.
*/
$(document).ready(function(){
	
	

}); //end doc ready

						   
function showHeader(){
 $('h1.vision-racer').show().animate({left:'35px'},2000, 'easeOutCubic');
 //$('div#navi').show().animate({right:'0'},2000, 'easeOutCubic');
}

function hideHeader(){
 $('h1.vision-racer').animate({left:'-=500px'});
 //$('div#navi').animate({right:'-=500px'});	
}

function hideAll(){
$('h1.vision-racer').hide().animate({left:'-=500px'});
}

function loadHome(){
showHeader();
}

//scrolling content pane
$('#content').mouseover(function (event) {
    // attach 3 pieces of data to the #content element
    $(this)
      .data('down', true) // a flag indicating the mouse is down
      .data('x', event.clientX) // the current mouse down X coord
      .data('scrollLeft', this.scrollLeft); // the current scroll position
        
    // return false to avoid selecting text and dragging links within the scroll window
    return false;
  }).mouseup(function (event) {
    // on mouse up, cancel the 'down' flag
    $(this).data('down', false);
  }).mousemove(function (event) {
    // if the mouse is down - start the drag effect
    if ($(this).data('down') == true) {
      // this.scrollLeft is the scrollbar caused by the overflowing content
      // the new position is: original scroll position + original mouse down X - new X
      this.scrollLeft = $(this).data('scrollLeft') - $(this).data('x') + event.clientX;
	 //right and left opacity fade
	  if(event.clientX < 250) {
		//highlight left column
		$('.col.left').stop().animate({opacity: 1}, 2000)
		$('.col.right').stop().animate({opacity: 0.25}, 2000);
		
		} else if(event.clientX > 800) {
		//highlight left column
		$('.col.right').stop().animate({opacity: 1}, 2000)
		$('.col.left').stop().animate({opacity: 0.25}, 2000);
		
		}
	 
	 }
	 
	 
  }).css({
    'overflow' : 'hidden', // change to hidden for JS users
    'cursor' : '-moz-grab' // add the grab cursor
  });

// finally, we want to handle the mouse going out of the browser window and
// it not triggering the mouse up event (because the mouse is still down)
// but it messes up the tracking of the mouse down
$(window).mouseout(function (event) {
  if ($('#content').data('down')) {
    try {
      // *try* to get the element the mouse left the window by and if
      // we really did leave the window, then cancel the down flag
      if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML') {
        $('#content').data('down', false);
      }                
    } catch (e) {}
  }
});
