// JavaScript Document

$(document).ready(function() {
				
	var bottomPosition = $(document).height();
			
	$('#footer .bottom').css({});
	
	
	
	$('#home_links li').bind({
		click: function() {	
			//get the url from href attribute and launch the url  
			url =$(this).find("a").attr("href");
			window.open(url); 
			return false; 
		},
		mouseenter: function() {
			$(this).css({cursor: 'pointer'}).find('a').addClass('hover');
			$(this).find('.screenshot').stop().animate({			
				top: '5px'
			}, 250);
		},
		mouseleave: function() {
			$(this).css({cursor: 'default'}).find('a').removeClass('hover');
			$(this).find('.screenshot').stop().animate({			
				top: '50px'
			}, 100);
		}
	});
	
	resizeBanner();
	
	$('#banner_images li').show();
	
	$(window).resize(function() {
		$('#banner_images li').show();
  		resizeBanner();
		
		var listIndex = $('#banner_images li.active').index('#banner_images li');
			if(listIndex<=0)
				listIndex = 0;
			var newLeftValue =  (-listIndex * animateWidth);								   
			$('#banner_images').css({left: newLeftValue + "px"});
	});
	
	
	



});

function activateBannerTimer() {
		$('#banner').oneTime("4s", function() {
			var listIndex = $('#banner_images li.active').next('li').index('#banner_images li');
			if(listIndex<=0)
				listIndex = 0;
			var newLeftValue =  (-listIndex * animateWidth);									   
			$('#banner_images').stop().animate({left: newLeftValue + "px"}, 2500, 
				function() {
		    		// Animation complete.
					activateBannerTimer();
  				}
			);

			$('#banner_images li').removeClass('active');
			$('#banner_images li').removeClass('active');
			$('#banner_images li').eq(listIndex).addClass('active');
						
		});
	}
	
function resizeBanner() {
	bannerImageWidth = $(window).width();
	$("#banner_images li").css({width: bannerImageWidth});
	$("#banner").css({width: bannerImageWidth});
	bannerWidth = ($("#banner_images li").width()) * $("#banner_images li").length;	
	$("#banner_images").css({width: bannerWidth});
		
	animateWidth = $("ul#banner_images li").width();	
}



