function switchPanel(jElement){
    var classToToggle = jElement.attr('rel');
    $('div.'+classToToggle).toggle();
}
function askConfirmation(anElement){
	if(anElement.attr('title')) return confirm(anElement.attr('title')+'?');
	return confirm('Eseguo la azione?');
}


$(document).ready(function(){
	var imgLoader = new Image();// preload image
	imgLoader.src = '/scuole.parmalat.it/css/ui/menu/left-hover.png';
	imgLoader.src = '/scuole.parmalat.it/css/ui/menu/left.png';
	imgLoader.src = '/scuole.parmalat.it/css/ui/menu/right.png';
	imgLoader.src = '/scuole.parmalat.it/css/ui/menu/left-hover.png';
	imgLoader.src = '/empty.gif';
	
	$('.view-photo-gallery').cycle({
		pager:  '#nav',
		pagerAnchorBuilder: function(idx, slide) {
			//alert(idx);
			if((idx+1)%5==0){
        		return '<div style="display:block; float:left; padding-right:0; padding-bottom:15px;" class="thumbnail"><a href="#" style="display:block;height:79px; overflow:hidden;"><img src="' + slide.src + '" width="120" /></a></div><div style="clear:both">&nbsp;</div>';
			}
			else{
				return '<div style="display:block; float:left; padding-right:8px; padding-bottom:15px;" class="thumbnail"><a href="#" style="display:block;height:79px; overflow:hidden;"><img src="' + slide.src + '" width="120" /></a></div>';
			}
    	}
	});
	
	
	$('a.ajax-load').click(function(){
		$.ajax({
    		url:this.href, 
    		success: function(html){
    			$('#ajax-placeholder').html(html);
    		}
    	});
    	return false;
	});
	
	
	
	/*$('td.left').each(function(){
		$(this).html('<img src="/scuole.parmalat.it/css/ui/backgrounds/table-product-left.png" width="5" height="33" style="float:left;"  />');
	});
	$('td.right').each(function(){
		$(this).html('<img src="/scuole.parmalat.it/css/ui/backgrounds/table-product-right.png" style="float:right;" width="5" height="33" />');
	});*/
	
		$('ul.candy-menu li a span').each(function(i){
			$(this).before('<span class="left">&nbsp;</span>');
			$(this).after('<span class="right">&nbsp;</span>');
		});
		$('h3.rounded-corner-title, h3.green-rounded-corner-title, h3.arancio-rounded-corner-title').each(function(i){
			$(this).wrapInner('<span class="center"></span>');
			$(this).prepend('<span class="left">&nbsp;</span>');
			$(this).append('<span class="right">&nbsp;</span>');
		});
		
		$.validator.addMethod("woselect", function(value, element) { return this.optional(element) || !/^WONoSelectionString/.test(value); }, "Questo campo è obbligatorio.");
	$('.confirmation').click(function(){ return askConfirmation($(this)); });
	
	
	
	$.validator.addClassRules({ woselect: { woselect:true } });
	
	$.extend($.validator.messages, {
		required: "Questo campo è obbligatorio.",
		remote: "Riempire questo campo per continuare.",
		email: "Inserire un indirizzo email valido.",
		url: "Inserire un indirizzo URL valido.",
		date: "Inserire una data in formato mm.gg.aaaa.",
		dateDE: "Inserire una data in formato gg.mm.aaaa.",
		dateISO: "Inserire una data in formato aaaa.mm.gg.",
		number: "Inserire un numero.",
		numberDE: "Inserire un numero.",
		digits: "Inserire (solo) un numero.",
		creditcard: "Inserire un numero di carta di credito valido.",
		equalTo: "Inserire lo stesso valore usato sopra.",
		accept: "Usare un'estensione valida.",
		maxlength: $.format("Inserire al massimo {0} caratteri."),
		minlength: $.format("Inserire almeno {0} caratteri."),
		rangelength: $.format("Inserire da {0} a {1} caratteri."),
		range: $.format("Inserire un numero compreso tra {0} e {1}."),
		max: $.format("Inserire un numero minore o uguale a {0}."),
		min: $.format("Inserire un numero maggiore o uguale a {0}."),
		woselect: $.format("seleziona la voce dal menù")
	});
	
	$('form.to-validate').validate();
});
    	
    	