// global vars

var misura = 6;

// starter ------------------------------

$( function(){
	footer_animation();
	menu_images();
	internal_background();
});

// funzioni globali ----------------------

function footer_animation () {
	bot="-60px";

	arrow_up=theme_url+"css/images/up_arrow.gif";
	arrow_down=theme_url+"css/images/down_arrow.gif";

	$("#main_footer")
	.css("bottom",bot)
	.prepend("<div id='arrow'><img id='arrow_gif' src='"+arrow_up+"'></div>");

	$("#arrow_gif").click( function () {
		if ( $("#arrow_gif").attr("src") == arrow_up ) {
			$("#main_footer").animate({
				bottom: "0px"
			});
			$("#arrow_gif").attr("src", arrow_down);
		} else {
			$("#main_footer").animate({
				bottom: bot
			});
			$("#arrow_gif").attr("src", arrow_up);
		}
	});
}
function menu_images(){ //imposta le immagini di sfondo dei pulsanti
	image_num = 0;
	$("#top_menu li a").each(function(){
		image_num++;
		//$(this).css("background","url("+theme_url+"css/images/menu_"+image_num+".jpg) no-repeat center");
		$(this).css({
			background: "url("+theme_url+"css/images/menu_"+image_num+".jpg) no-repeat center",
			overflow:"hidden"
		});
//		$(this).html("<div class='sfondo_opaco'>"+$(this).html()+"</div>");
//		$(".sfondo_opaco").css({
//			opacity: 0.5
//		});
	});
}
function sub_menu() { // con allineamento normale
	// si attiva sugli ID=TESTO
	$("div#testo a").clone()
	.appendTo("#my_breadcrumb")
	.addClass("separatore")
	.last().removeClass("separatore");
}

function back_image_dir() {

	dim_foto = {
		1:{w:532,h:354},
		2:{w:851,h:556},
		3:{w:1170,h:779},
		4:{w:1490,h:991},
		5:{w:1809,h:1204},
		6:{w:2128,h:1416}
	};

	$.each(dim_foto, function(i,dim){
		if ( dim.w > $(document).width() && dim.h > $(document).height() ) {
			if (misura==6) {
				misura=i;
			}
		}
	});
	return misura;
}

function internal_background(){
	if (id_page==2) return; // non in home page
	dir = back_image_dir();
	$("body").css({
		background: "#002846 center 100% no-repeat fixed url("+theme_url+"css/images/bg_slide/"+dir+"/1.jpg)"
	});

}
