// JavaScript Document

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function admin_login()
{
	
    var d = document.login
	var error = ""
	
	if (!d.usr.value) error += "Manca la user.\n"
	if (!d.psw.value) error += "Manca la password.\n"
	
	if (error) alert("ATTENZIONE! Impossibile inviare la richiesta.\n\n" + error)
	else d.submit()
	

}



function login()
{
	
    var d = window.document.form_login
	var error = ""
	
	if (!d.e_mail.value) error += "Manca l'e-mail.\n"
	if (!d.passwd.value) error += "Manca la password.\n"
	
	if (error) alert("ATTENZIONE! Impossibile inviare la richiesta.\n\n" + error)
	else d.submit()
	

}






function cpi_user()
{
    
	var d = window.document.insert
	var error = ""

	if (!d.nome.value) error += "Inserire il nome.\n"
	if (!d.cognome.value) error += "Inserire il cognome.\n"
	if (!d.username.value) error += "Inserire lo username.\n"
	if (!d.password.value) error += "Inserire la password.\n"
	if (!d.email.value) error += "Inserire l'indirizzo email.\n"

	if (error){
		alert("Alcuni campi non sono stati compilati:\r\n\r\n"+error)
		return(false)
	}else{
		return(true)
	}
	
}

function cpi_prodotti()
{
    
	var d = window.document.insert
	var error = ""

	if (!d.idcategoria.value) error += "Selezionare una categoria.\n"
	if (!d.cod.value) error += "Inserire il codice prodotto.\n"
	if (!d.nome_ita.value) error += "Inserire il nome del prodotto.\n"
	if (!d.prezzo.value) error += "Inserire il prezzo.\n"
	if (!d.foto_small.value) error += "Inserire la foto piccola.\n"
	if (!d.foto_big.value) error += "Inserire la foto grande.\n"

	if (error){
		alert("Alcuni campi non sono stati compilati:\r\n\r\n"+error)
		return(false)
	}else{
		return(true)
	}
	
}

function cpi_cat()
{
    
	var d = window.document.insert
	var error = ""

	if (!d.descrizione_ita.value) error += "Inserire la descrizione in italiano.\n"
	if (!d.descrizione_eng.value) error += "Inserire la descrizione in inglese.\n"


	if (error){
		alert("Alcuni campi non sono stati compilati:\r\n\r\n"+error)
		return(false)
	}else{
		return(true)
	}
	
}

function cpi_news()
{
    
	var d = window.document.iscriviti
	var error = ""

	if (!d.email.value) error += "Inserire un indirizzo email.\n"

	if (error){
		alert(error)
		return(false)
	}else{
		return(true)
	}
	
}


function delete_single_rows(url){
	var x=window.confirm("Vuoi eliminare il record definitivamente?")
	if (x){
	document.location=url;
	}else{
	window.alert("Azione annullata")
	}
}





function view_popup_utenti(id) 
{  
    var path = 'utentidetail.php'
	//alert('test')
	window.open(path+"?id="+id,"","width=400,height=350,scrollbars=yes")  
}

function view_popup_prodotti(id) 
{  
    var path = 'prodottidetail.php'
	//alert('test')
	window.open(path+"?id="+id,"","width=550,height=650,scrollbars=yes")  
}




function no_submit()
{
	return 0  	
}

function show_pictures(file) 
{  
    var path = 'show_pic.php'
	
	
	window.open(path+"?file="+file,"","width=10,height=10,scrollbars=yes")  
}

function cpi_send()
{

    var d = document.nuova_mail
	var error_title = "Attenzione! Il modulo non è completo.\n\n"
	var error ="" 
	  
	var text = d.testo.value
	var mod = /\n/g
	var newText = text.replace(mod,"<br>")
	  
	if (!d.titolo.value) error += "Inserire il titolo della mail.\n"
	if (!d.testo.value) error += "Inserire il testo della mail.\n"
	   
	if (error) alert(error_title + error)
	  else 
		{
		   d.testo.value = newText
		   d.submit()
		}

}

function cpi_contatti()
{

    var d = document.richiesta
	var error_title = "Attenzione! Il modulo non è completo.\n\n"
	var error ="" 

	  
	if (!d.nome.value) error += "Inserire il nome.\n"
	if (!d.cognome.value) error += "Inserire il cognome.\n"
	if (!d.email.value) error += "Inserire la mail.\n"
	   
	if (error) alert(error_title + error)
	  else 
		{
		   d.submit()
		}

}










//-->