$(document).ready(function(){
	var currentPosition = 0;
	var slideWidth = 500;
	var slides = $('.slide');
	var numberOfSlides = slides.length;
	
	// Remove scrollbar in JS
	$('#slidesContainer').css('overflow', 'hidden');
	
	// Wrap all .slides with #slideInner div
	slides
		.wrapAll('<div id="slideInner"></div>')
		// Float left to display horizontally, readjust .slides width
		.css({
			'float' : 'left',
			'width' : slideWidth,
			'display' : 'block'
		});

	// Set #slideInner width equal to total width of all slides
	$('#slideInner').css('width', slideWidth * numberOfSlides);

	function moveIt(dir) {
		currentPosition = (dir == 'right') ? currentPosition+1 : currentPosition-1;

		$('#slideInner').animate({
			'marginLeft' : slideWidth*(-currentPosition)
		});
	};
	
	slides.children('img')
		.bind('click', function(){
			if(currentPosition<numberOfSlides-1)
				moveIt('right');
			else {
				currentPosition = 1;
				moveIt('left');
			}
		});

	// FOOTER PLACEMENT
//	var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
//	var pageHeight = $("#main").innerHeight();


	var viewportHeight = $(window).height();
	var pageHeight = $(document).height();
//		alert(pageHeight);
	
	
	
	if(($('#main').height() < pageHeight) && !$('#mainImage').length)
		pageHeight = $('#main').height();
		
/*		alert($(document).height());
		alert($('#main').height() );
		alert(pageHeight);
*/
	
//	if($('#productInfo').height() > pageHeight)
//		pageHeight = $('#productInfo').height();
	if(viewportHeight > pageHeight) {
		var padding = viewportHeight - pageHeight;
		$("#footer").css("padding-top", padding + "px");
	}
	
/*	alert(pageHeight);
	alert($(window).height());
	alert(viewportHeight);
	alert($(document).height());
	alert($('#productList').height());
	alert($('#productInfo').height());
	alert($('#productList').innerHeight());
	alert($('#productInfo').innerHeight());
*/
});

