function controlPhotoInsert(){
	thisform = document.form_photo_insert;
	
	if(thisform.file.value==''){
		alert("inserire il file immagine");
		thisform.file.focus();
		return;
	}
	
	if(thisform.didascalia.value.length>255){
		alert("Hai superato il limite massimo di caratteri disponibili.");
		thisform.didascalia.focus();
		return;
	}
	
	thisform.action = "_class/azioni.class.php";
	thisform.submit();
}

function zoomGallery(fileimage, testo){
	document["zoom_image"].src = "images/spacer.gif";
	document["zoom_image"].src = fileimage;
	var oChild=photo_zoom.children(1);	
    if(oChild)
		photo_zoom.removeChild(oChild);
	var lastRow = document.getElementById('photo_zoom');
	var div = document.createElement('div');
    lastRow.appendChild(div);
    div.appendChild(document.createTextNode(testo));
	
	checkLoad();
}

function checkLoad(){
	if (document["zoom_image"].complete){
		if(document.documentElement){
			posx = document.documentElement.clientWidth;
			posy = document.documentElement.scrollTop;
		}
		else if(document.body){
			posx = document.body.clientWidth;
			posy = document.body.scrollTop;
		}
		else if(window){
			posx = window.innerWidth;
			posy = window.pageYOffset;
		}
		document.getElementById('photo_zoom').style.top = (posy+10) + 'px';
		document.getElementById('photo_zoom').style.left = ((posx-500)/2) + 'px';
		document.getElementById('photo_zoom').style.display = 'block';
	}
	else{
		timerID = setTimeout("checkLoad()",10);
	}
}

function zoomClose(){
	
	document.getElementById('photo_zoom').style.display = 'none';
	document["zoom_image"].src = "images/loading.gif";
	document.getElementById('photo_zoom').style.top = 0 + 'px';
	document.getElementById('photo_zoom').style.left = 0 + 'px';
	var oChild=photo_zoom.children(1);	
    photo_zoom.removeChild(oChild);

}
