//javascript

titoli_array = new Array("tit_azienda.gif","tit_gallery.gif" ,"tit_servizi.gif" , "tit_laboratorio_bw.gif", "tit_dove_siamo.gif")
id_pagina =0;

function swapImageCategory_over(id,base_src1, base_src2)
{
	dest_txt_obj = document.getElementById("txt0" + id)
	dest_pic_obj = document.getElementById("pic0" + id)
	dest_txt_obj.src = base_url + "category_selection_b_" + base_src1 + ".gif"
	dest_pic_obj.src = base_url + "category_selection_c_" + base_src2 + ".gif"
	updateTitleAndSubtitle(descrizioni_categorie_array[id-1][0],descrizioni_categorie_array[id-1][1])
	updateBigImage(descrizioni_categorie_array[id-1][2])
	updateCatTitleImage(id-1)
}

function swapImageCategory_out(id,base_src1, base_src2)
{
	dest_txt_obj = document.getElementById("txt0" + id)
	dest_pic_obj = document.getElementById("pic0" + id)
	dest_txt_obj.src = base_url + "category_selection_" + base_src1 + ".gif"
	dest_pic_obj.src = base_url + "category_selection_" + base_src2 + ".gif"
	
	resetTitleAndSubtitle()
	resetBigImage()
	resetCatTitleImage()
}

function updateCatTitleImage(id,set)
{
	dest_img_cat = document.getElementById("imgCat")
	dest_img_cat.src =descrizioni_categorie_array[id][3]

	if (typeof(set)!="undefined")
	{
		if (set)
		{
			def_cat =  descrizioni_categorie_array[id][3]
		}
	}
}

function resetCatTitleImage()
{
	dest_img_cat = document.getElementById("imgCat")
	dest_img_cat.src = def_cat
}


function updateBigImage(src,set,resize)
{
	my_bgfotoImageImage = document.getElementById("bgfotoImageImage");
	my_bgfotoImageImage.style.backgroundImage =  "url(img/caricamento.gif)"
	my_bgfotoImageImage.style.backgroundImage = "url("+src+")"

	my_tempImage = document.getElementById("tempImage");
	my_tempImage.src = "img/spessore.gif"
	my_tempImage.src = src
	
	top.intervallo_img = setInterval(checkImageSize,1000)


	if (typeof(set)!="undefined")
	{
		if (set)
		{
			def_img_src =  src
		}
	}
}

function checkImageSize()
{
	my_tempImage = document.getElementById("tempImage");

	if (my_tempImage.width>30)
	{
		
//		alert(my_tempImage.width + "," + my_tempImage.height);
		
		spessoreImmagine_obj = document.getElementById("spessoreImmagine");		
		spessoreImmagine.width = my_tempImage.width;

//		spessoreImmagine.height = my_tempImage.height;
		if (my_tempImage.height>328)
		{
			spessoreImmagine.height = 328;			
		}
		else
		{
			spessoreImmagine.height = my_tempImage.height;
		}

		if (my_tempImage.width>495)
		{
			spessoreImmagine.width = 495;			
		}
		else
		{
			top.spessoreImmagine.height = my_tempImage.height;
		}
		window.status = intervallo_img + " - " + new Date();
		window.clearInterval(top.intervallo_img);
	}
}

function resetBigImage()
{
	updateBigImage(def_img_src)
}

function updateTitleAndSubtitle(title, subtitle, set)
{
	titCat  = document.getElementById('titCat')
	descCat = document.getElementById('descCat')

	titCat.value = title
	descCat.value = subtitle
	
	if (typeof(set)!="undefined")
	{
		if (set)
		{
			def_tit =  title
			def_desc = subtitle
		}
	}
}

function resetTitleAndSubtitle()
{
	titCat  = document.getElementById('titCat')
	descCat = document.getElementById('descCat')

	titCat.value = def_tit
	descCat.value = def_desc
}

function swapTitolo_over(id,set)
{
	//updateTitoloPagina(id,set)
}

function updateTitoloPagina(id,set)
{
	var cellaTitolo = document.getElementById("cellaTitolo")
	cellaTitolo.style.backgroundImage = "url(img/"+titoli_array[id]+")"
	if (typeof(set)!="undefined")
	{
		if (set)
		{
			id_pagina =  id
		}
	}
}

function resetTitoloPagina(id)
{
	var cellaTitolo = document.getElementById("cellaTitolo")
	cellaTitolo.style.backgroundImage = "url(img/"+titoli_array[id_pagina]+")"
}



function swapTitolo_out(id)
{
//	resetTitoloPagina(id)
}

function tamb_click(id,titolo, descrizione, big_src)
{
	updateBigImage(big_src,true)
	updateTitleAndSubtitle(titolo, descrizione, true)
}

function tamb_over(id)
{
	cella_pattern = document.getElementById('callaPattern'+id)
	cella_pattern.style.backgroundImage = 'url(img/photogallery/fotina/pattern.gif)'
}

function tamb_out(id)
{
	cella_pattern = document.getElementById('callaPattern'+id)
	cella_pattern.style.backgroundImage = 'none'
}

function mostraListaCategorie()
{
	div_lista_categorie = document.getElementById("listaCategorie")

	clientWidth = document.body.clientWidth;
	clientHeight = document.body.clientHeight;
	
	def_width  = 1024
	def_height = 768
	
	div_pos_x = 754
	div_pos_y = 258

	offset_x = 0
	offset_y = 0
	
	new_div_x_pos = Math.ceil((((clientWidth - def_width)/2) + div_pos_x - offset_x))    
	new_div_y_pos = Math.ceil((((clientHeight - def_height)/2) + div_pos_y  - offset_y)) 


	if (div_lista_categorie.style.visibility == "visible")
	{
		div_lista_categorie.style.visibility = "hidden"
	}
	else
	{
			div_lista_categorie.style.left = new_div_x_pos +  " px";
			div_lista_categorie.style.top  = (new_div_y_pos)  +  " px";
			div_lista_categorie.clipVal = 300;
			moviDivCategorie();
			div_lista_categorie.style.visibility = "visible"
	}

	
	div_bottoneCategorie = document.getElementById("bottoneCategorie")
	div_contenuto = document.getElementById("contenuto")
}

function moviDivCategorie()
{
	spostamentoDiv = function()
	{
		div_lista_categorie = document.getElementById("listaCategorie")
		if (div_lista_categorie.clipVal>0)
		{
			div_lista_categorie.clipVal-=10
			div_lista_categorie.style.clip = "rect( "+div_lista_categorie.clipVal+"px auto auto 0px)"
		}
		else
		{
			clearInterval(intervallo)
		}
	}
	intervallo = setInterval(spostamentoDiv,1);
}



function apriMain()
{
	finestra = window.open("l_azienda.php", "vatteroni", "width="+(screen.availWidth-3)+", height="+(screen.availHeight-3)+", status=yes, resizable=yes")
	finestra.moveTo(0,0)
	finestra.resizeTo(screen.availWidth,screen.availHeight)
//	finestra.resizeTo(1024,768)
}

function apriComeRaggiungerci()
{
	win_come_raggiungerci = window.open("come_raggiungerci.htm","comeRaggiungerci", "width=490 height =550, status=yes, resizable=yes")
}





