var ua = navigator.userAgent.toLowerCase(); 
var browser,version,data; 
function detect(text) {
	stringposition = ua.indexOf(text) + 1;
	data = text;
	return stringposition;
} 
$(document).ready(function() {
						   
						   
	//menu della pagina menu					   
	$('.toggleContent').hide();
	
	
	$('.toggleOpen').click(function(){
		if(!$(this).next().is('.open')){						
			checkDivToogle();		
			var nextDiv = $(this).next('div');		
			$(nextDiv).addClass('open');		
			$(nextDiv).slideDown('normal');
			$(this).css({'background':"url('grafica/template/piatti/piatti_r19_c1.jpg') no-repeat"});
		}else{
			$(this).css({'background':"url('grafica/template/piatti/piatti_r19_c4.jpg') no-repeat"});
			closeDivToogle($(this).next());
		}
	});
	
	
	function checkDivToogle(){
		$('.toggleContent').each(function(){						  
			if($(this).is('.open')){
				$(this).removeClass('open');
				$(this).slideUp('normal');
			}
		});
	}
	
	function closeDivToogle(ob){	
		$(ob).removeClass('open');
		$(ob).slideUp('normal');
	}
	
	
	//piatti della pagina menu
	$('.toggleContent2').hide();
	
	
	$('.toggleOpen2').click(function(){
		if(!$(this).next().is('.open')){						
			checkDivToogle();		
			var nextDiv = $(this).next('div');		
			$(nextDiv).addClass('open');		
			$(nextDiv).slideDown('normal');
			
			if (detect('msie')) browser = 'Internet Explorer';
			if (!version) version = ua.charAt(stringposition + data.length);
			/*if (browser == 'Internet Explorer' && (version >= 5 && version <=6)) {	
			
				$(this).children('h2').css({backgroundImage:"none"});				
				$(this).children('h2').css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='image', src='grafica/template/piatti/close.png')"});
			
			}else{*/
				$(this).children('h2').css({'background':"url('grafica/template/piatti/close.png') no-repeat right center"});
			//}
			
			
		}else{
			closeDivToogle($(this).next());			
			if (detect('msie')) browser = 'Internet Explorer';
			if (!version) version = ua.charAt(stringposition + data.length);
			/*if (browser == 'Internet Explorer' && (version >= 5 && version <=6)) {	
				$(this).children('h2').css({backgroundImage:"none"});
				$(this).children('h2').css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='image', src='grafica/template/piatti/open.png')"});
			}else{*/
				$(this).children('h2').css({'background':"url('grafica/template/piatti/open.png') no-repeat right center"});
			//}
		}
	});
	
	
	function checkDivToogle(){
		$('.toggleContent2').each(function(){						  
			if($(this).is('.open')){
				$(this).removeClass('open');
				$(this).slideUp('normal');
			}
		});
	}
	


});
