$(document).ready(function(){
	
	$('#vetrine .margin').last().removeClass('margin');
	
	//$('#product-search-box select').selectmenu({ width: 209 }); 
	$('#store-search-box select').selectmenu({ width: 147 }); 
	
	$('#store-search-box select:first').change(function() {
		region = $(this).val();
		options = '<option value="">'+provText+'</option>';
		$.each(arrayProvinces, function(i, val) {
	    	if(this[2] == region)
	    		options += '<option value="'+this[1]+'">'+this[1]+'</option>';
		});
		$('#store-search-box select:last').html(options).selectmenu({ width: 147 }); 
	});
	
	$('.search-box .submit img').click(function() {
		$(this).parent().parent().submit();
	}); 
	
	$('input').each(function() { 
	
		$(this).focus(function() {
			$(this).prev().addClass('no-display'); 
		});
	
		$(this).blur(function() {
			if($(this).val() == '')
				$(this).prev().removeClass('no-display'); 
		});
	});
	
	$('.search-box li.label').each(function() {
		label = $(this).children().first();
		input = $(this).children().last();
		
		position = input.position();
		//label.css({	'left': position.left+6, 'top' : position.top+5 });
		label.addClass('absolute');
		
		$(this).mouseover(function() {
			$(this).children().first().animate({ 'opacity': 0.5 }, 200);
		});
		
		$(this).mouseleave(function() {
			$(this).children().first().animate({ 'opacity': 1 }, 200);
		});
	});
	
	validator = $('#store-search-box form').validate({
  	 	rules: {
  	 		name: "required",
  	 		email: {
  	 			required: true,
  	 			email: true
  	 		},
  	 		province: "required"
  	 	},
  	 	messages: {
  	 		name: "",
  	 		email: "",
  	 		province: "asasas"
  	 	},
  	 	invalidHandler: function() {
		    $('div.response').text(errore_noncompilati).removeClass('no-display');
		}

  	});
  	
}); 

