var idPhoto;
var contaPhoto=0;
var contaLink=0;

function apriFotoGallery(){
	if(idPhoto!=""){
		winGallery=window.open("showGallery.php?idPhoto=" + idPhoto, "gallery", "left=100, top=80, scrollbars=0, status=0, resizable=0, directories=0, toolbars=0, menubar=0");
		winGallery.focus();
	}
}



function mostraBordo(imageName, idLink){
	sommaLink = eval(idLink) + eval(contaLink);

	idPhoto=arrayId[sommaLink];
	
	if(document.all){
		tempObj = document.all[imageName].offsetParent;
		posTop = document.all[imageName].offsetTop;
		posLeft = document.all[imageName].offsetLeft;
		while (tempObj != null) {
  			posLeft += tempObj.offsetLeft;
			posTop += tempObj.offsetTop;
	  		tempObj = tempObj.offsetParent;
  		}
		document.all['bordoGallery'].style.posTop = posTop - 5;
		document.all['bordoGallery'].style.posLeft = posLeft - 5;
		document.all['bordoGallery'].style.visibility = 'visible';
	}
	
	else if(document.layers){
		for(var i=0; i<document.images.length; i++){
			if(document.images[i].name == imageName) nameImage=document.images[i];
		}
		alert(nameImage.y);
		
		document.layers['bordoGallery'].top = coord.y - 5;
		document.layers['bordoGallery'].left = coord.x - 5;
		document.layers['bordoGallery'].style.visibility = 'visible';
	}
	
	else if(document.getElementById){
		tempObj=document.getElementById(imageName).offsetParent;
		posTop=document.getElementById(imageName).offsetTop;
		posLeft=document.getElementById(imageName).offsetLeft;
		while (tempObj != null) {
  			posLeft += tempObj.offsetLeft;
			posTop += tempObj.offsetTop;
	  		tempObj = tempObj.offsetParent;
  		}
		
		document.getElementById('bordoGallery').style.top = posTop - 5;
		document.getElementById('bordoGallery').style.left = posLeft - 5;
		document.getElementById('bordoGallery').style.visibility = 'visible';
	}
	
}

function nascondiBordo(){
	if(document.all)
		document.all['bordoGallery'].style.visibility = 'hidden';
	
	else if(document.layers)
		document.layers['bordoGallery'].style.visibility = 'hide';
	
	else if(document.getElementById)
		document.getElementById('bordoGallery').style.visibility = 'hidden';
	
	idPhoto="";
}

function avanti(){
	nascondiBordo();
	if (contaImage >= totalImage) contaImage=0;
	contaLink = contaLink + 7;
	if(contaLink >= totalImage) contaLink=0;
	if (document.images) {
		for(var i = 0; i < 7; i++){
			linkName = "link" + i;
			if(contaImage < totalImage){
				nomeTemp=eval("foto" + contaImage).src;
				document.images["thumb" + i].src = nomeTemp;
				document.images["thumb" + i].style.visibility = "visible";
				if(document.all) document.all["link" + i].style.visibility = "visible";
				else if(document.layer) {
					for (var p = 0; p < document.anchors.length; p++) {
						if (document.anchors[p].name==linkName) document.anchors[p].style.visibility = "visible";
					}
				}
				else if(document.getElementById) document.getElementById(linkName).style.visibility = "visible";
			}
			else {
				document.images["thumb" + i].style.visibility = "hidden";
				if(document.all) document.all["link" + i].style.visibility = "hidden";
				else if(document.layer) {
					for (var p = 0; p < document.anchors.length; p++) {
						if (document.anchors[p].name == linkName) document.anchors[p].style.visibility = "hidden";
					}
				}
				else if(document.getElementById) document.getElementById(linkName).style.visibility = "hidden";
			}
			contaImage ++;
		}
	}
}


