$(document).ready(function(){
						   
	$('#nom').focus(function() {
		$(this).val("");
	});
	$('#nom').blur(function() {
		var title = $(this).attr("title")
		if($(this).val()=="") {
			$(this).val(title);
		}
	});
	$('#courriel').focus(function() {
		$(this).val("");
	});
	$('#courriel').blur(function() {
		var title = $(this).attr("title")
		if($(this).val()=="") {
			$(this).val(title);
		}
	});
	$('#telephone').focus(function() {
		$(this).val("");
	});
	$('#telephone').blur(function() {
		var title = $(this).attr("title")
		if($(this).val()=="") {
			$(this).val(title);
		}
	});
	$('#message').focus(function() {
		$(this).val("");
	});
	$('#message').blur(function() {
		var title = $(this).attr("title")
		if($(this).val()=="") {
			$(this).val(title);
		}
	});
						   
	$("ul.thumb li").hover(function() {
		$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-75px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-95px',
				top: '50%',
				left: '50%',
				width: '174px', /* Set new width */
				height: '134px', /* Set new height */
				padding: '0px'
			}, 100); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '150px', /* Set width back to default */
				height: '110px', /* Set height back to default */
				padding: '0px'
			}, 100);
	});
	
	$(".thumbnail").colorbox({opacity:0.90});
	
	$('ul.sub-menu').each(function(index) {
		 $(this).parent().find('a').first().addClass('plus');
	})
	$("ul.menu li a.plus").click(function(){
		if(!$(this).hasClass("active")){
			$("ul li ul li a").removeClass("selected"); //Change the style of the sub-menu
			$("ul li a.active:visible").removeClass("active");
			$("ul li.current_page_item").removeClass("current_page_item");
			$("ul li ul:visible").slideUp("fast");
			$(this).addClass("active");
			$(this).next().slideDown("fast");
			return false;
		} else {
			$(this).removeClass("active");
			$(this).next().slideUp("fast");
			return false;			
		}
	});	
	
	$('.btn-soumettre').click(function() {
		
		var nom = $('#nom').val(); 
		var courriel = $('#courriel').val(); 
		var telephone = $('#telephone').val();
		var message = $('#message').val();
		var check = $('#mycheckbox').is(':checked');
		
		getstr = "nom="+nom+"&courriel="+courriel+"&telephone="+telephone+"&message="+message+"&check="+check;
	
		if(nom == "" || nom == "nom"){$('#errms').text("Nom invalid.");}
		else if(courriel == "" || courriel == "courriel"){$('#errms').text("Courriel invalid.");}
		else if(courriel.indexOf("@") == -1 || courriel.indexOf(".") == -1) {$('#errms').text("Courriel invalid.");}
		else if(message == "" || message == "message"){$('#errms').text("Message invalid.");}
		else {
			getstr = encodeURI(getstr);
			$.ajax({
			method: "get",url: "mail.php",data: getstr,
			beforeSend: function(){$("#errms").hide(); $("#loading").fadeIn('1000');},
			success: function(html){ 
			$("#form-content").html(html);
			}
			}); //close $.ajax(*/
		}
	}); //close click(	
	$("#material").change(function () {
		var content_ready = "";
		var str_material = "";
		$("#material option:selected").each(function () {
		content_ready = $(this).val();
		str_material = $(this).text();
		});
		$.ajax({
		type: "post",url: "http://www.armoiresasuperprix.com/wp-admin/admin-ajax.php",data: "action=sendmaterial&material="+content_ready,
		beforeSend: function(){$("#load-mat").css('visibility', 'visible');},
		success: function(html){
		$("#cor").html('');
		$("#sel-mod").html('');
		$("#sel-cor").html('');
		$("#modelo").html(html);
		}
		}); //close $.ajax(*/
		$.ajax({
		type: "post",url: "http://www.armoiresasuperprix.com/wp-admin/admin-ajax.php",data: "action=sendmaterialimg&material="+content_ready,
		beforeSend: function(){$("#load-mat").css('visibility', 'visible');},
		success: function(html){
		$("#sel-mat").html(html);
		$("#load-mat").css('visibility', 'hidden');
		}
		}); //close $.ajax(*/
	}); //close change
	$("#modelo").change(function () {
		var content_ready = "";
		var str_material = "";
		$("#modelo option:selected").each(function () {
		content_ready = $(this).val();
		str_modelo = $(this).text();
		});
		$.ajax({
		type: "post",url: "http://www.armoiresasuperprix.com/wp-admin/admin-ajax.php",data: "action=sendmodelo&modelo="+content_ready,
		beforeSend: function(){$("#load-mod").css('visibility', 'visible');},
		success: function(html){
		$("#cor").html(html);
		}
		}); //close $.ajax(*/
		$.ajax({
		type: "post",url: "http://www.armoiresasuperprix.com/wp-admin/admin-ajax.php",data: "action=sendmodeloimg&modelo="+content_ready,
		beforeSend: function(){$("#load-mod").css('visibility', 'visible');},
		success: function(html){	
		$("#sel-mod").html(html);
		$("#load-mod").css('visibility', 'hidden');
		}
		}); //close $.ajax(*/		
	}); //close change	
	$("#cor").change(function () {
		var content_ready = "";
		var str_material = "";
		var str_modelo = "";
		$("#cor option:selected").each(function () {
		str_cor = $(this).val();
		});
		$("#material option:selected").each(function () {
		str_material = $(this).val();
		});		
		$("#modelo option:selected").each(function () {
		str_modelo = $(this).val();
		});
		
		$.ajax({
		type: "post",url: "http://www.armoiresasuperprix.com/wp-admin/admin-ajax.php",data: "action=sendcor&mat="+str_material+"&mod="+str_modelo+"&cor="+str_cor,
		beforeSend: function(){$("#load-cor").css('visibility', 'visible');},
		success: function(html){
		$("#sel-cor").html(html);
		$("#load-cor").css('visibility', 'hidden');
		}
		}); //close $.ajax(*/		
	}); //close change	
})
