/********
javascript for piazza della sole
********/

//everything happens after the page loads
$(function(){
		
	$('#store-slideshow').innerfade({ 
		animationtype: 'fade', 
		speed: 2500, 
		timeout: 4500
	}); 

	$('#newsletter-submit').ajaxForm(function() { 
	    alert("Thank you for joining!"); 
	});
	
	
	//Designers sliders
	if( $('body').hasClass('designers') ) {
		var liWidth = $('.slideshow-box li').css('width').replace("px", "");
		var navWidth = 4 * liWidth;
		var ulWidth = Array();
		ulWidth['shoes'] = ($('#shoes ul li').size() * liWidth * -1) + navWidth;
		ulWidth['handbags'] = ($('#handbags ul li').size() * liWidth * -1) + navWidth;
		ulWidth['jewels'] = ($('#jewels ul li').size() * liWidth * -1) + navWidth;
		
		$('a.slide-previous').click(function() {
			var id = $(this).attr('rel');
			var currentPos = $('#' + id + ' ul').css("left").replace("px", "");
			if(currentPos < 0) {
				$('#' + id + ' ul').animate({"left": (parseInt(currentPos)+parseInt(navWidth))+"px"}, 800);
			} else if(currentPos == 0) {
				//$(this).css({'color' : '#333'});
			}
			return false;
		});
		
		$('a.slide-next').click(function() {
			var id = $(this).attr('rel');
			var currentPos = $('#' + id + ' ul').css("left").replace("px", "");
			if((currentPos/navWidth) > (ulWidth[id]/(navWidth)) ) {
				$('#' + id + ' ul').animate({"left": (parseInt(currentPos)-parseInt(navWidth))+"px"}, 800);
			} else {
				//$(this).css({'color' : '#333'});
			}
			return false;
		});
		
		//lightbox
		$('.images a').lightBox();
	}
		
});
