// JavaScript Document
/*
/* <script type="text/javascript" src="jsLib.js"><!--// js utility //--></script> */

function visualizzaScheda(idDiv, id, keyword){
	tagCall('schedaContent', '../script/scheda.php', id, keyword);
	displayBlock(idDiv);
}

function displayBlock(id){
	document.getElementById(id).style.display="block";
}

function displayNone(id){
	document.getElementById(id).style.display="none";
}

function moveUp(obj){
	obj.style.marginTop="0";
	obj.getElementsByTagName('ul')[0].style.display="block";
}

function moveDown(obj){
	obj.style.marginTop="18px";
	obj.getElementsByTagName('ul')[0].style.display="none";
}

function resizeContent(footer){
	//height=document.documentElement.clientHeight-footer;
	//if (height>418) document.getElementById("content").style.height=height+"px";
	//else document.getElementById("content").style.height=418+"px";
	//alert(height);
	//tweakGallery();
}

/* Resize function right box */

var resizeDiv_originale=0;
function resizeDiv_fixed(id){
	resizeDiv_originale=0;
	document.getElementById(id).style.height="auto";
	//alert(document.getElementById(id).style.height);
}

function resizeDiv_widen(id){
	resizeDiv_originale=document.getElementById(id).style.height;
	document.getElementById(id).style.height="auto";
	//document.getElementById(id).style.overflow="visible";
	//alert(document.getElementById(id).style.height);
}

function resizeDiv_narrow(id){
	//alert("resizeDiv_narrow "+resizeDiv_originale);
	if (resizeDiv_originale!="auto" && resizeDiv_originale!=0){
		document.getElementById(id).style.height=65+"px";
	}
	//alert(document.getElementById(id).style.height);
}

function setHeight(id){
	document.getElementById(id).style.height=65+"px";
}

function setHeightMax(id){
	document.getElementById(id).style.height="auto";
}

  /*-----------------*/
 /* funzione SCROLL */
/*-----------------*/

var marginGalleria=0;
var scrollId;
var scrollI;
var temporizzazioneId;

function setMarginLeft(id, margin){
	document.getElementById(id).style.marginLeft=margin+"px";	
}

function scrollToRight(){
	//alert(marginGalleria+">= -"+(document.getElementById(scrollId).style.width.replace("px", "")+"-"+document.documentElement.clientWidth));
	//if (marginGalleria>=-(document.getElementById(scrollId).style.width.replace("px", "")-document.documentElement.clientWidth)){
	if (marginGalleria>=-(document.getElementById(scrollId).style.width.replace("px", "")-924)){
		marginGalleria-=1;
		setMarginLeft(scrollId, marginGalleria);
	}
	else {
		marginGalleria=-34;
		setMarginLeft(scrollId, marginGalleria);
		//stopTemporizza();
	}
}

function scrollToLeft(){
	if (marginGalleria<0){
		marginGalleria+=1;
		setMarginLeft(scrollId, marginGalleria);
	}
	else {
		marginGalleria=-(document.getElementById(scrollId).style.width.replace("px", "")-924)+34;
		setMarginLeft(scrollId, marginGalleria);
		//stopTemporizza();
	}
}

function temporizza(id, i){
	scrollId=id;
	scrollI = i;
	window.clearInterval(temporizzazioneId);
	if (i==1)
		temporizzazioneId=window.setInterval("scrollToRight()", 10);
	else
		temporizzazioneId=window.setInterval("scrollToLeft()", 10);
	
}

function startTemporizza(){
	temporizza(scrollId, scrollI);
}

function stopTemporizza(){
	window.clearInterval(temporizzazioneId);
}


function tweakGallery(){
var conto = 0;
if (document.links.length  > 0){

var contenitore = document.getElementById("contentListaFoto");
if (contenitore != null){
contenitore.style.width="950px";
contenitore.style.overflow="hidden";
contenitore.style.position="relative";
for (i=0; i<document.links.length; i++){

var oc = document.links[i].onclick;
if ((oc != null) && (oc != "") && (oc != void(0))){

if ((oc+"").indexOf("visualizzaScheda") > -1){
document.links[i].onmouseover = stopTemporizza;
document.links[i].onmouseout = startTemporizza;

//ora applica un numerino all'interno dell'immagine contenuta nel link
var nmu = document.createElement('div');
nmu.style.position="relative";
nmu.style.top="-13px";
nmu.style.left="-24px";
nmu.style.height="13px";
nmu.style.width="16px";
nmu.style.background="#707070";
nmu.style.fontSize="10px";
nmu.style.fontWeight="bold";
nmu.style.color="#FFFFFF";
nmu.style.textAlign="center";
nmu.style.textDecoration="none";
var nmutxt = "0" + (conto++);
nmutxt = nmutxt.substr(nmutxt.length-2, 2);
nmutxt = document.createTextNode(nmutxt);
nmu.appendChild(nmutxt);
document.links[i].appendChild(nmu);
//document.links[i].innerHTML+="<div style='position:relative; top:-13px; left:-24px; height:13px; width:16px; background:#707070; font-size:10px; font-weight:bold; color:#FFFFFF; text-align:center; text-decoration:none'>"+nmutxt+"</div>";


}

}
}
}

//document.getElementById("contentListaFoto").style.position="relative";
}
}



