// numero immagini della galleria
var GalleryImages = 2;

// intervallo tra una foto e la successiva
var GalleryDelay = 6;

// durata transizione tra una foto e la successiva
var GalleryEffectDelay = 5;

// links delle immagini 
var GalleryLink = [
	'http://www.anticabottegadelricamo.it/shop/a1687_Scrigno-Rosa.htm',
	'http://www.anticabottegadelricamo.it/shop/c40_Telai.htm',
	'http://www.anticabottegadelricamo.it/shop/c93_Bambole-con-carillon.htm',
             'http://www.anticabottegadelricamo.it/shop/a1510_Vista-sul-mare-punto-croce.htm',
             'http://www.anticabottegadelricamo.it/shop/a109_Paesaggio-di-montagna-mezzo-punto.htm',
	'http://www.anticabottegadelricamo.it/shop/a826_Ultima-cena-piccolo-punto.htm'		
	// ^^^^^ l'ultimo elemento non richiede la "," finale
]

/* ------------- NON MODIFICARE OLTRE QUESTA LINEA --------------- */

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

function imgClick(e) {
	location.href = GalleryLink[e.idx]
}

function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count;
	$("#scrollup div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
		$(this).css('top', '210px');
	});
	$("#scrollup div.headline:eq(" + current_headline + ")").animate({top: 5},"slow");
	old_headline = current_headline;
}

$(document).ready(function () {

	$("#simpleGallery").flashembed({src: "gallery.swf",bgcolor: "#000000"},{
		path:"gallery/",
		delay: GalleryDelay,
		tdelay: GalleryEffectDelay,
		firstDelay: GalleryDelay,
		onClick:"imgClick",
		n:GalleryImages,
		border:0
	});



	headline_count = $("#scrollup div.headline").size();
	$("#scrollup div.headline:eq("+current_headline+")").css('top', '5px');
	headline_interval = setInterval(headline_rotate,5000);
	$('#scrollup').hover(function() {
		clearInterval(headline_interval);
	}, function() {
		headline_interval = setInterval(headline_rotate,5000);
		headline_rotate();
	});
	

	// aggiungo i wrapper per i box
	$("div.block,div.rbox,div.rbox2").each(function() {
		var title=$(this).find("h1").get(0)
		if (title && title.className != "noscript") {
			$(this).wrapInner('<div class="wrap">').prepend(title)
		}
	});
	
	
	var bC=0
	$("div.boxList .singolo").each(function() {
		bC++;
		if (bC % 3 != 0) $(this).wrapInner("<div class=\"bR\">");
	})
	
	$("#articolo hr").remove();
	
	/*
	$("#articolo img[src*='foto/']:eq(0)").each(function() {
		// var src="thumbnail.aspx?FileName=" + this.src.replace(/http:\/\/www.anticabottegadelricamo.it\/shop(2)?\//,"")+"&w=410&h=300"
		// this.src=src;
	}).prependTo("#articolo").wrap("<div class=\"img\">")
	*/
	
	$("a.lev1").prepend("&nbsp;&nbsp;&raquo; ");
	
	
	// fixo la lunghezza delle colonne (MSIE bug)
	if ($("table.layout td.head").height() > 163) {
		$("table.layout td.left").height(($("table.layout td.right").height()-163)+"px")
	}
	
	$("#dDLRegione option[value='97']").attr('selected', 'selected').text("Italia");
	
	$("form").submit(function() {
		//$(".group1:checked").val();
		if ($("input.consensoP",this).get(0)) {
			if ($("input.consensoP:checked").val() == 1) return true
			alert("Devi prestare il consenso per procedere")
			return false
		}
		return true
    });


		
});