// JavaScript Document

$(document).ready(function(){
						   
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

	$.preLoadImages('/common/images/biography.gif','/common/images/book.gif','/common/images/contact.gif','/common/images/media.gif','/common/images/screen.gif','/common/images/voice.gif','/loader.gif','/common/images/media_bill.jpg');
						   
			
	$('#overlay').css({opacity:0.9});
			
	$('#picture').fadeIn();
	$('#navigation').fadeIn();
	
	$(document).pngfix();
	
	var status = 0;
	var ajaxStatus = 0;
	var section = "";
		
	$('.navigation').click(function(){	
		
		section = $(this).attr('section');
		
		offset = $(this).attr('offset');
		
		//alert(status +"/"+ $(this).attr('section'));
		
		if(status == 0 && ajaxStatus == 0){
			
			status = 1;
			ajaxStatus = 1;
			
		$.ajax({
		   url: "/includes/" + $(this).attr('section') + ".cfm",
		   cache: true,
		   success: function(html){
			   
			   
			   
			   $('#content').css({opacity:0});
			   $('.pointer').fadeIn();
			   
			   
			$('#pointer_spacer').animate({height:offset+'px'});
			$('#content').html(html);
			$('#content').show();
			
			$('#content').animate({width:'360px',opacity:1},1000,'easeOutSine',function(){
			
			$('#loader').fadeIn();						
			$('.title_image').show().css({opacity:0}).animate({opacity:1},function(){
									
										$('#content_copy').jScrollPane();
										$('#content_copy').fadeIn();
										$('#loader').fadeOut();
										ajaxStatus = 0;	
										
										if(section == "media"){
			$('#picture').attr('src','/common/images/media_bill.jpg');
			
		}
		else{
			$('#picture').attr('src','/common/images/picture.jpg');
			
		}
									
																			   
				});														
			});
			
		   }
		 });

			
		
		}
		if(status == 1 && ajaxStatus == 0){
		
		ajaxStatus = 1;
										
		
		$('#loader').fadeIn();
		$('#content_copy').hide();
		$('.title_image').css({opacity:0}).hide();
		
		
		$.ajax({
		   url: "/includes/" + $(this).attr('section') + ".cfm",
		   cache: true,
		   success: function(html){
			   
			$('#loader').fadeOut();
			$('#pointer_spacer').animate({height:offset+'px'});
			$('#content').html(html);
			$('.title_image').show().css({opacity:0}).animate({opacity:1},function(){
										
										$('#content_copy').jScrollPane();
										$('#content_copy').fadeIn();
										ajaxStatus = 0;
							
									
		if(section == "media"){
			$('#picture').attr('src','/common/images/media_bill.jpg');
			
		}
		else{
			$('#picture').attr('src','/common/images/picture.jpg');
			
		}
			
										
										
																			   
				});
			
		   }
		   });
		
		}
						 
	});
	
	$('#overlay, #mp3-close, #video-close').click(function(){
					   
					   $('#mp3-close, #video-close').hide();
					   $('#mp3, #video').hide();
					   $('#mp3-player, #video-player').html('&nbsp;').hide();
					   $('#overlay').fadeOut();
					   
					   });
	
})

