$(document).ready(init);
function init() {
	
	// prettyPhoto
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// perform JavaScript after the document is scriptable.
	$(function() {
		// setup ul.tabs to work as tabs for each div directly under div.panes
		$("div.divFlag").tabs("div.panes > div");
	});

	// AD gallery
	//$(document).ready(function(){
	if ($('.ad-gallery').get()!='') {
		$(function() {
			var galleries = $('.ad-gallery').adGallery({enable_keyboard_move: false});
		});
	}
} // end func init


// Ajax con jquery
function aggiornamentoAjax(azione,parametri) {

	$.ajax({ 
		url: urlAjax,
		data: parametri+'&action='+azione,
		type: 'GET',
		cache: false,
		dataType: "json",
		success: function(response) {

			var esito = response.esito;
			var msg = response.msg;

			switch (azione) {

				case "setStato":

					if (esito == 1) {

						$.each(response.dati, function(i,item){
							if (item) {

								var img = $('#stato' + item.id + ' img');

								img.attr('alt', item.imgAlt);
								img.attr('title', item.imgTitle);
								img.removeClass(item.imgNoClass);
								img.addClass(item.imgClass);

								$('#valore_stato_'+item.id).val(item.stato);

							}
						});

					}

					if (msg != '') alert(msg);

				break; // end setStato

				default:

					if (msg != '') alert(msg);

			} // end switch azione

		} 
		});

} // end func aggiornamentoAjax

