function NoAutorization(stringa) {
	alert(stringa);
}

function vimecStyled(el) {
	el.html(el.html().replace('Vimec', '<span class="vimec">Vimec</span>'));
	//$('.inner').wrap('<span class="vimec" />');
}

function mOver(el) {
	var url = el.css('background-image')
	  , extension = url.substring(url.lastIndexOf('.'), url.length)
	    ;

	el.mouseover(function() {
		el.css('background-image', url.replace(extension,'b' + extension));
	}).mouseout(function() {
		el.css('background-image', url);
	});
}

$(document).ready(function(){

	// gestione IMG HOVER
	$('.mHover').each(function() { mOver($(this)); });
	$('.linksBt').each(function() { mOver($(this)); });
	$('.linksBtV').each(function() { mOver($(this)); });
	$('.accessoRiservato').each(function() { mOver($(this)); });

	if ($('.opener').length > 0 || $('.opened').length > 0) {
		$('.opened').hide();
		$('.opener').each(function() {
			$(this).click(function() {
				//$('.opened').hide();
				var idToOpen = $(this).attr('href')
				  //, idToOpen = idToOpen.replace('#', '')
				;
				$(idToOpen).slideToggle();
				return false;
			});
		});
	}

	/* Stili e sfondi
	 *
	 */
	
	//ho aggiunto una clausola speciale per firefox 3 per risolvere il problema del round border sulle immagini
	var ua = $.browser;
	  if ( ua.mozilla && ua.version.slice(0,3) == "1.9" ) {
		  $('img[name=fotodettaglio]').load(function(){
				var src = $(this).attr('src');
				var width = parseInt($(this).width());
				$('img[name=fotodettaglio]').parent().attr({'style':'-moz-border-radius: 11px;height:216px;width:'+width+'px;background-repeat:no-repeat;-moz-background-size:100% 100%;background-image:url('+src+')'});
				$(this).css('visibility','hidden');
			})
	  }
	
	
	if ($('.foto').length > 0) {
		$('.foto').each(function() {
			var src = $('img', this).attr('src');
			
			//$('img', this).hide();
			//$(this).css('background', 'url(' + src + ') no-repeat top left');
			
		});
	}
	if ($('.thumb').length > 0) {
		if (jQuery.support.opacity) {
			$('.thumb').each(function() {
				var src = $('img', this).attr('src');
				$('img', this).hide();
				$(this).css({
					'background': 'url(' + src + ') no-repeat top left'
				  , '-moz-background-size': '43px 42px'
				  , 'background-size': '43px 42px'
				  , '-webkit-background-size': '43px 42px'
				}).data('src', src);
			});
		} else {
			$('.thumb').each(function() {
				var src = $('img', this).attr('src');
				//$('img', this).hide();
				$(this).data('src', src);
			});}
		$('.thumb').hover(
			function() { $(this).addClass('hover'); }
		  , function() { $(this).removeClass('hover'); }
		).click(function() {
			var id  = $(this).attr('id')
			  , num = id.split('_')
			  , src = $(this).data('src')
				;
			$('.foto').find('[name=fotodettaglio]').attr('src',src);
			src = src.replace("/r/", "/o/");
			$('.foto').attr('href', src);
			
					
		});
	}

	if ($('#gammaProdotti li').length > 0) {
		$('#gammaProdotti li').live('mouseover mouseout', function(event) {
			  if ( event.type == "mouseover" ) {
				  $(this).addClass('hover');
				  $('img', this).stop().fadeTo('fast', 0.1);
				  $('.GPText', this).stop().fadeTo('fast', 1);
			  } else {
				  $(this).removeClass('hover');
				  $('img', this).stop().fadeTo('fast', 1);
				  $('.GPText', this).stop().fadeTo('fast', 0);
			  }
			return false;
		});
	}

	if ($('#home').length > 0) {
		vimecStyled($('#home'));
	}
	if ($('#homeTxt').length > 0) {
		vimecStyled($('#homeTxt'));
	}
	if ($('#container2').length > 0) {
		$('#container2').prepend('<div id="bgRound">&nbsp;</div>');
	}

	$('body').prepend('<div id="lineDx">&nbsp;</div>');
	if ($('#linkColSx').length > 0) {
		var offset = $('#linkColSx').offset();
		$('body').prepend('<div id="lineSx">&nbsp;</div>');
		$('#lineSx').css('top', offset.top + 'px');
	}

	if ($('input[type="text"], input[type="password"]').length > 0) {
		$('input[type="text"], input[type="password"]').css({
			'background': 'url(/skin/website/widgets/sf-input.png) no-repeat right top'
		  , 'border': 'solid 1px #cecece'
		  , 'border-top': 'solid 1px #8f8f8f'
		  , 'border-bottom': 'solid 1px #e4e4e4'
		});
	}

	if ($('.fotoGallery').length > 0) {
		//$('.fotoGallery').lightBox();
		$('.fotoGallery').lightbox({show_linkback: false})
	}

});

