﻿// sostituisce su IE6 gli span del menu con immagini
$(document).ready(function(){
	if (jQuery.browser.msie && parseFloat(jQuery.browser.version) <= 6) {
		$("#wrapper").before('<div id="stopie6">Il programma che state utilizzando per visualizzare i siti internet è <u>obsoleto</u>. Un aggiornamento alla nuova versione migliorerà la sicurezza e le prestazioni. Aggiornate gratuitamente a <a href="http://www.microsoft.com/italy/windows/products/winfamily/ie/default.mspx" target="_blank">Internet Explorer 7</a>, o passate a <a href="http://www.mozilla-europe.org/it/firefox/" target="_blank">Firefox</a> (gratis), o <a href="http://www.opera.com/" target="_blank">Opera</a> (gratis).</div>');
		$('#stopie6').css({'background-color':'#ff9900','color':'#333'});
		$('#stopie6').animate({ 
			padding: "20px",
			fontSize: "1.8em", 
			borderWidth: "1px"
		  }, 800 );
		$('body').css({'background-position':'50% 90px'});
	} 
});
$.fn.menuIE = function(){  
	if (jQuery.browser.msie && parseFloat(jQuery.browser.version) <= 6) {
		
	return this.each(function(){
		var obj = $(this);
		var name = obj.attr('id');
		var elChen = '#'+name+' a';
		$(elChen).css({'backgroundImage':'none'});
		$(elChen+' span').before("<img src='images/"+name+".gif'").remove();
		$(elChen).hover(
		  function () {
			$(elChen+' img').attr({src:'images/'+name+'-hover.gif'});
		  }, 
		  function () {
			$(elChen+' img').attr({src:'images/'+name+'.gif'});
		  }
		);
		});
	}
}
$.fn.styleCheckbox = function () {
	$(":checkbox").each ( function() {
		var nome=$(this).attr('id');
		var etichetta = $("label[for='"+nome+"']");
		var moo = $('<input type="hidden" value="" name="' + this.name + '" id="'+nome+'"/>');
		if (this.checked) {
				$(etichetta).addClass("checked");
				moo.attr('value','on');
		} else {
				$(etichetta).addClass("unchecked");
		}
		$(this).before(moo).remove();
		$(etichetta).click( function() {	
			if(moo.attr('value') == ''){
				val = 'on';
			} else {
				val = '';
			}
			moo.attr('value',val);
			$(this).toggleClass("checked").toggleClass('unchecked');
		})		
	});
}