/*
funzioni di supporto alla classe di amministrazione delle foto / files
mostraDati => serve solo per dirmi se dirmi se mi va bene il file che sto mettendo dentro nel form
cancella file
*/

		
function cancellaFile(URL){
	if(confirm("Vuoi cancellare il file?")){
		if(arguments[1]==true){
			document.location.href=URL;
		}else{
			apriFinestra(URL,'file',500,400,1,1);
		}
	}
}
	
function oc(a){
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}
	
	
function mostraDati(nomeForm, campoFile, campoUserfile, nomeImg, nomeDir,inStrEXT){
	var a=inStrEXT.split(",");
	var F=eval("document."+nomeForm);
	var c1=eval("document."+nomeForm+"."+campoFile);
	var c2=eval("document."+nomeForm+"."+campoUserfile);
	var strC2=c2.value.toLowerCase();			
	var lunghStr=strC2.length;
	var posBarra=strC2.lastIndexOf("\\")+ 1;
	var posPunto=strC2.lastIndexOf(".")+ 1;
	var strEst=strC2.substring(posPunto,lunghStr);
	var realValue=strC2.substring(posBarra,lunghStr);
	c1.value = realValue;
	strEst=strEst.toLowerCase();
			if(nomeDir.substr(nomeDir.length - 3)=="img"){
				if( strEst in oc(a)== false ) {
					alert("si e\' tentato di caricare un file nella posizione sbagliata!\nCi potrebbero essere problemi di visualizzazione sul sito.");
					c1.value="";					
				}
			}else{
				if( strEst in oc(a)== false ) {
					alert("si e\' tentato di caricare un file nella posizione sbagliata!\nCi potrebbero essere problemi di visualizzazione sul sito.");
					c1.value="";					
				}else{
					document.getElementById(nomeImg).innerHTML="<strong>"+c2.value.substr(c2.value.lastIndexOf("\\")+1)+"</strong>";					
				}
			}
}