$(document).ready(function()
{
	initValidation();
	initGallery();
	initSlideShow();
	initCarousel();
});

function initValidation()
{		
	$("#directionsForm").validate({
		rules: {
			saddr: "required"
		}
	});
	$("#contactForm").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			phone: "required"
		},
		messages: {
			name: "Please enter your name",
			email: {
				required: "Please enter your email address",
				email: "Please enter a valid email address."
			},
			phone: "Please enter your contact number"
		}
	});
}


function initGallery()
{
	if ($("body").hasClass("product")){
		$("a", "#ImageList").click(function(){
		
			var imgsrc = $("img", this).attr("src");
			var imgtitle = $("img", this).attr("title");
			var imgcurrent = $("#MainViewer").attr("src");
			
			if (imgcurrent != imgsrc) {
				$(".Current", "#ImageList").removeClass("Current");
				$(this).addClass("Current");
				
				$("#MainViewer").fadeOut(function(){
					$(this).attr("src", imgsrc).attr("title", imgtitle).fadeIn();
				});
			}
			
			return false;
		});
	}
}

function initSlideShow()
{
	$('#hs-show').cycle({
		next: '#hs-next',
		prev: '#hs-prev',
		timeout: 7000,
		pause : true,
		random: 1,
		sync: true
	});
}

function initCarousel()
{
    $('#mycarousel').jcarousel({
        vertical: true,
        scroll: 2
    });
}

