/* DOCUMENT READY */
$(function(){
	/* FIX PNG */
	if(document.compatMode && document.all) {
		$(document).pngFix({ blankgif: img_dir + '/pixel.gif' });
	}
	
	/* SCROLLING NEWS PRIMO PRIANO */
	$('.primo-piano-container').sliderNews();
	
	/* INPUT LOGIN */
	$('#login-form #username, #login-form #password').click(function(){
		$(this).val('');
	}).focus(function(){
		$(this).val('');
	});
	
	/* SLIDER LISTA PRODOTTI */
	$('.product-list').slideGallery({
		items: '.product-items',
		n_slide: 4
	});
	
	/* INPUT RICERCA */
	var default_val = 'cerca azienda o prodotto';
	$('#search-simple').find('#keyword').bind('click focus', function(){
		$(this).removeClass('input-is-empty');
		if($(this).val() == default_val) $(this).val('');
	}).bind('blur', function(){
		if($(this).val() == '') {
			$(this).addClass('input-is-empty');
			$(this).val(default_val);
		}
	});
	
	/* TEXTAREA */
	$('textarea').bind('focus click', function(){
		this.value = $.trim(this.value);
	});
	
	/* DETTAGLIO FAQ */
	$('.faq-open-detail').click(function(){
		var link = $(this);
		link.nextAll('.faq-txt').slideToggle('normal', function(){
			if($(this).is(':visible')) {
				link.attr('title', 'Chiudi dettaglio');
				link.html('Chiudi dettaglio');
			} else {
				link.attr('title', 'Dettaglio');
				link.html('Dettaglio');
			}
		});
	});
});

/* VIDEO YOUTUBE */
function youtube(id,container,W,H) {
	params = {
		allowfullscreen: 'true',
		allowscriptaccess: 'samedomain',
		wmode: 'transparent'
	};
	attributes = {
		id: container,
		name: container
	};
	
	swfobject.embedSWF('http://www.youtube.com/v/'+id+'&showinfo=0&fs=1', container, W, H, '9.0.0', false, false, params, attributes);
}
