window.addEvent('domready',function(){


	$$('.prodotto').each(function(el, index){
		
		el.addEvent('mouseover', function(e){
		
			el.setStyle('border-left', '6px solid #8d8d8d');
			
		});
		
		el.addEvent('mouseout', function(e){
			
			el.setStyle('border-left', '6px solid white');
			
		})
		
	});



	/*
		Attivo i place holder all'interno dei campi input
	*/
	$$('*[rel=placeholder]').each(function(el, index) {

		el.set('value', el.get('alt'));

		el.addEvent('focus', function(e){
			e.stop();
			if(el.get('value')==el.get('alt')){ el.set('value', ''); }
		});

		el.addEvent('blur', function(e){
			e.stop();
			if(el.get('value') == '') { el.set('value', el.get('alt')); }
		});

	});

});

// aggiungo un link non intrusivo
function ajax_click(linkable, targetId)
{
	ajax_callback(linkable.href, targetId);
}

// eseguo il callback e faccio l'update di un target
function ajax_callback(requestUrl, targetId)
{
	var fadeIn = new Fx.Morph(targetId, {duration:250});

	var fadeOut = new Fx.Morph(targetId,{
	        duration: 250,
			onStart: function() {
				// $('ajax_loader').addClass('ajax_loader');
			},
	        onComplete: function () {
			    var req = new Request.HTML({
			        url: requestUrl,
					evalResponse: true,
					evalScripts: true,
			        onSuccess: function(html) {
			            // Clear the text currently inside the results div.
			            $(targetId).set('text', '');
			            // Inject the new DOM elements into the results div.
			            $(targetId).adopt(html);
			        },
			        // Our request will most likely succeed, but just in case, we'll add an
			        // onFailure method which will let the user know what happened.
			        onFailure: function() {
			            $(targetId).set('text', 'The request failed.');
			        },
					onComplete: function() {
						// $('ajax_loader').removeClass('ajax_loader');
						fadeIn.start({opacity:1});
					}
			    }).send();

			}
	}).start({opacity:0});
}

// esegue il submit di un form in post e la callback ajax
function ajax_submit(formId, targetId)
{	
	var fadeIn = new Fx.Morph(targetId, {duration:250});

	var fadeOut = new Fx.Morph(targetId,{
	        duration: 250,
			onStart: function() {
				// $('ajax_loader').addClass('ajax_loader');
			},
	        onComplete: function () {
			    var req = new Request.HTML({
			        url: $(formId).action,
					evalResponse: true,
					evalScripts: true,
			        onSuccess: function(html) {
			            // Clear the text currently inside the results div.
			            $(targetId).set('text', '');
			            // Inject the new DOM elements into the results div.
			            $(targetId).adopt(html);
			        },
			        // Our request will most likely succeed, but just in case, we'll add an
			        // onFailure method which will let the user know what happened.
			        onFailure: function(){
			            $(targetId).set('text', 'The request failed.');
			        },
					onComplete: function() {
						// $('ajax_loader').removeClass('ajax_loader');
						fadeIn.start({opacity:1});
					}
			    }).post($(formId));

			}
	}).start({opacity:0});
}