$(document).ready(function() {
	$("#header .jd_menu .menuImage").appendTo("#hoverMenuImages"); // check append() examples
	
	var index;
	$("#header .jd_menu li.sliderImage").hover(
		function () {
			var index = $("#header .jd_menu li.sliderImage").index(this);
			//alert (index);
			//$("#breadcrumb").html(index);
			$("#hoverMenuImages .menuImage:eq("+index+")").fadeIn(300);
		}, 
		function () {
			var index = $("#header .jd_menu li.sliderImage").index(this);
			$("#hoverMenuImages .menuImage:eq("+index+")").fadeOut(300);
	});
	
	
	$(".promo").hover(
		function () {
			$(this).children(".img1").hide();
			$(this).children("span").addClass("selected");
		}, 
		function () {
			$(this).children(".img1").show();
			$(this).children("span").removeClass("selected");
	});
	$(".promo").click(function () {
		document.location = $(this).children("a").attr("href");
    });

});
$(window).load(function() {
	nivoLoad();
});

function swapImage(source, orderNumber){
	//alert(param);	
	$("img[name=imgOver"+orderNumber+"]").attr("src",source);
}
function nivoLoad(){
	$('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		animSpeed:500, //Slide transition speed
		pauseTime:4000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false //Use image rel for thumbs
	});
}


function submitContact(param){
	
	//validating input
	var allFieldsAreValid = true;
	if( $('.contactForm [name=txtName]').val()=='')
	{
		allFieldsAreValid = false;
		$('.contactForm [name=txtName]').addClass("fieldError");
	}
	else
	{
		$('.contactForm [name=txtName]').removeClass("fieldError");
	}
	
	if( $('.contactForm [name=txtPhone]').val()=='')
	{
		allFieldsAreValid = false;
		$('.contactForm [name=txtPhone]').addClass("fieldError");
	}
	else
	{
		$('.contactForm [name=txtPhone]').removeClass("fieldError");
	}	
	
	if( $('.contactForm [name=txtEmail]').val().search(/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/)==-1)
	{
		allFieldsAreValid = false;
		$('.contactForm [name=txtEmail]').addClass("fieldError");
	}
	else
	{
		$('.contactForm [name=txtEmail]').removeClass("fieldError");
	}
	
	
	
	if (allFieldsAreValid)
	{
		document.contactForm.submit();
	}
	else
	{
		alert(param);
	}
}
