﻿
	
	function trim(str){
        return str.replace(/^\s+|\s+$/g,"");
    } 
	
	function getSelectedText()
	{
		  if (window.getSelection){
			txt = window.getSelection();
		  }
		  else if (document.getSelection) {
			txt = document.getSelection();
		  }
		  else if (document.selection){
			txt = document.selection.createRange().text;
		  }
		  else
		  {
			return false;
			}
		  return txt;
	}
	
	
	function getValue(id)
	{
		if(document.getElementById(id)){ return document.getElementById(id).value; }
		return false;
	}
	
	function onCopy3()
	{ 
            //var selection = window.getSelection(); 
			var selection = getSelectedText();

			var Insert=getValue('alt_token_copy_id');
			
			var  textToClipboard=selection+Insert;
			
			var success = true;

			alert(textToClipboard);
			
			if(window.clipboardData)
			{
				window.clipboardData.setData("Text", textToClipboard ); 
				//window.clipboardData.setData("Text",""+getSelectedText()+" "+getValue('alt_token_copy_id')+""); 
				window.preventDefault(); 
			}
	}
	

	




	
	function getArraySelected(ob)
{
	selected = new Array(); 
	for (var i = 0; i < ob.options.length; i++)
	{	
		//if (ob.options[ i ].selected) selected.push(ob.options[ i ].value);
		if (ob.options[ i ].selected) selected.push(i);
	}
	return selected;
}

function SelectAll(ob)
{
	if(ob!=null)
	{
		if(ob.options.length > 0)
		{
			for (var i = 0; i < ob.options.length; i++)
			{	
				
				ob.options[ i ].selected=true;
			}
		}
	}
}

function SelectAll_ie(id_ob)
{
	var ob=document.getElementById(id_ob);
	if(ob!=null && ob.options.length!=null)
	{
		if(ob.options.length > 0)
		{
			for (var i = 0; i < ob.options.length; i++)
			{	
				
				ob.options[ i ].selected=true;
			}
		}
	}
}

function DeselectAll(ob)
{
	if(ob!=null)
	{
		if(ob.options.length > 0)
		{
			for (var i = 0; i < ob.options.length; i++)
			{	
				
				ob.options[ i ].selected=false;
			}
		}
	}
}

function DeselectAll_ie(id_ob)
{
	var ob=document.getElementById(id_ob);
	if(ob!=null && ob.options.length!=null)
	{
		if(ob.options.length > 0)
		{
			for (var i = 0; i < ob.options.length; i++)
			{	
				
				ob.options[ i ].selected=false;
			}
		}
	}
}

function removeOption(id)
{
	if(document.getElementById(id)!=undefined)
	{
		  var elSel = document.getElementById(id);
		  var i;
		  for (i = elSel.length - 1; i>=0; i--) {
			if (elSel.options[i].selected && elSel.options[i].text!="") {
			  elSel.remove(i);
			}
		  }
  }
}

function sortOptions(id) 
{
	if(document.getElementById(id)!=null)
	{
	var lb = document.getElementById(id);
	var arrTexts = new Array();
	var arrIDs = new Array();
	var i=0;
	
	for(i=0; i<lb.length; i++)
	{
	  arrTexts[i] = lb.options[i].text;
	  arrIDs[i] = lb.options[i].value;
	}

	arrTexts.sort();
	var j=0;
	for(j=0; j<lb.length; j++)
	{
	  lb.options[j].text = arrTexts[j];
	  lb.options[j].value = arrIDs[j];
	}
	}
}



function addOption(from_id,to_id)
{
	var from_element=document.getElementById(from_id);
	
	var to_element=document.getElementById(to_id);
	var i=0;
	for(i=0; i<from_element.options.length;i++)
	{
		if(from_element.options[i].selected==true && from_element.options[i].text!=""){	
			var elNew = document.createElement('option');
				elNew.text = from_element.options[i].text;
				elNew.value = from_element.options[i].value;

			try {to_element.add(elNew, null); } // standards compliant; doesn't work in IE		  			
			catch(ex) {to_element.add(elNew); } // IE only					
		} 
	}
	
	sortOptions(to_id);
	
	removeOption(from_id);
	sortOptions(from_id);
	

			
}

/*
function suggestOption(from_id)
{

	//var suggest=document.getElementById('Suggest').checked;
	var suggest=true;
	var str_alert="";
	if(suggest==true)
	{
		if(from_id.indexOf("Autori")!=-1)
		{
			//autori
			if(from_id.indexOf("Linked")!=-1)
			{
				//sono su LinkedAutori
				//sto scollegando
				var to_sugg_id="LinkedOpere";
				var dest_sugg="Opere";
				str_alert=str_alert+"Scollegare anche tutte le opere di questo autore ";
			}
			else
			{
				//sn su Autori
				//sto scollegando
				var to_sugg_id="Opere";
				var dest_sugg="LinkedOpere";
				str_alert=str_alert+"Collegare anche tutte le opere di questo autore ";
			}	
			//suggestOption(from_id,from_suggest,to_suggest,str_alert);
		}
	}
		//from_id = autori che si stanno aggiungendo
		//to_id = opere da suggerire
	
			var from_element=document.getElementById(from_id);
			
			var to_element=document.getElementById(to_sugg_id);
			var i=0;
			var x=0;
			for(i=0; i<from_element.options.length;i++)
			{
				if(from_element.options[i].selected==true && from_element.options[i].text!="")
				{	
				var id=from_element.options[i].value;
				id.toUpperCase();
					for(var j=0,x=0; j<to_element.options.length;j++)
					{
						var rel=to_element.options[j].rel;
						rel.toUpperCase();
							if(rel.indexOf(id)!=-1)
							{
								to_element.options[j].selected=true;
								x++;
							}
							else
							{
								to_element.options[j].selected=false;
							}
					}
					
					if(x > 0)
					{
						if(!confirm(alert+" "+from_element.options[i].text+" ?"))
						{}else
						{
							addOption(to_sugg_id,dest_sugg);
							sortOptions(dest_sugg);
							removeOption(to_sugg_id);
							sortOptions(to_sugg_id);
						}
					}
				} 
			}
		
		
		
		
		
}*/
	
function ControllaCF(cf)
{
    var validi, i, s, set1, set2, setpari, setdisp;
    if( cf == '' )  return false;
    cf = cf.toUpperCase();
    if( cf.length != 16 )
		{
        alert("La lunghezza del codice fiscale non è corretta: il codice fiscale dovrebbe essere lungo esattamente 16 caratteri.");
		return false;
		}
    validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    for( i = 0; i < 16; i++ ){
        if( validi.indexOf( cf.charAt(i) ) == -1 )
			{
			alert("Il codice fiscale contiene un carattere non valido '"+cf.charAt(i)+"'. I caratteri validi sono le lettere e le cifre.");
			return false;
			}
    }
    set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
    s = 0;
    for( i = 1; i <= 13; i += 2 )
        s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    for( i = 0; i <= 14; i += 2 )
        s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
		{
		alert("Il codice fiscale non è corretto: il codice di controllo non corrisponde.");
		return false;
        
		}
    return true;
}

function ControllaPIVA(pi)
{
//pi=trim(pi);
    if( pi == '' )  return false;
    if( pi.length != 11 )
		{
		alert("La lunghezza della partita IVA non è corretta: la partita IVA dovrebbe essere lunga esattamente 11 caratteri.");
		return false;
		}
    validi = "0123456789";
    for( i = 0; i < 11; i++ ){
        if( validi.indexOf( pi.charAt(i) ) == -1 )
		{
		alert("La partita IVA contiene un carattere non valido '"+pi.charAt(i)+ "'. I caratteri validi sono le cifre.");
		return false;  
		}
    }
    s = 0;
    for( i = 0; i <= 9; i += 2 )
        s += pi.charCodeAt(i) - '0'.charCodeAt(0);
    for( i = 1; i <= 9; i += 2 ){
        c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
        if( c > 9 )  c = c - 9;
        s += c;
    }
    if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
	{
	alert("La partita IVA non è valida: il codice di controllo non corrisponde.");
	return false; 
	}
			
    return true;
}


function ControllaTel(campo)
{
		if(campo.length==0){return false;}
		var consentiti= "1234567890.,-+";
				var ControllaTel = true;
				var cifre = '';
				for ( n = 0; n < campo.length; n++ )
				{
					vl = campo.charAt( n );
					for ( s = 0; s < consentiti.length; s++ )
					{
						if ( vl == consentiti.charAt( s ))
						break;
						if ( s == consentiti.length )
							{ControllaTel = false;break;}
					}
				cifre += vl;
				}
		if(!ControllaTel)return false; else return true;
}

function ControllaMail(str)
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false;
		 }

 		 return true;					
}


function ControllaReqPwd(str)
{
var spazio=" ";

	if (!(str.match(/[A-Z]/)))
	{
		return false;
	}
	if (str.indexOf(spazio) > -1)
	{
		return false;
		
	}
	if (!(str.match(/\d/)))
	{
		return false;
	}
	return true;
}

function ControllaReqPeriodo(anno1,anno2)
{
	if( anno2 <= anno1 )
	{
		return false;
	}
	return true;
}

function onkeyup_check_pwd(str,campoinput,idbox,alert_lunghezza,alert_requisiti,alert_true,_return)
{

	if (str.length<8)
	{
	//  document.getElementById(idbox).innerHTML="";
  	document.getElementById(idbox).innerHTML=alert_lunghezza;
	document.getElementById(campoinput+'_check').value='false';
		if(_return==1) return false;
	}
	else
	{
		if(!ControllaReqPwd(str))
		{
			document.getElementById(idbox).innerHTML=alert_requisiti;
			document.getElementById(campoinput+'_check').value='false';
			if(_return==1) return false;
		}
		else
		{
			document.getElementById(idbox).innerHTML=alert_true;
			document.getElementById(campoinput+'_check').value='true';
			if(_return==1) return true;
		}
		
	}
	
return true;
}
	
	function check_requisiti(campo)
	{//alert(document.getElementById(campo).value);
		if(document.getElementById(campo)!=undefined)
		{
			if(!ControllaReqPwd(trim(document.getElementById(campo).value)))
			{ 
				document.getElementById(campo+'_requisiti').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_requisiti').style.display='none';
				
			}
		}
	return true;
	}
	
	function check_req_periodo(id_campo_anno1,id_campo_anno2,id_box_alert)
	{
		//ControllaReqPeriodo(anno1,anno2)
		if(document.getElementById(id_campo_anno1)!=undefined && document.getElementById(id_campo_anno1)!=undefined)
		{
		
			var anno1=eval(trim(document.getElementById(id_campo_anno1).value));
			var anno2=eval(trim(document.getElementById(id_campo_anno2).value));
		
			if(!ControllaReqPeriodo(anno1,anno2))
			{ 
				document.getElementById(id_box_alert).style.display='block';
				
			}
			else
			{
				document.getElementById(id_box_alert).style.display='none';
				
			}
		}
	return true;
	}
	
	function check_obbligatorio(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(trim(document.getElementById(campo).value)=="")
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	return true;
	}
	
	function check_obbligatorio_2(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(document.getElementById(campo).checked==false)
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	return true;
	}
	
	function check_obbligatorio_3(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(document.getElementById(campo).selectedIndex==0)
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	}
	
	function check_checkbox(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(document.getElementById(campo).checked==false)
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	}
	
	function check_select(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(document.getElementById(campo).selectedIndex==0)
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	}
	
	function check_cob_multiselect(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(document.getElementById(campo).options.length==0)
			{ 
				document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	}
	
	
	
	function check_req_blur(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(ControllaReqPwd(trim(document.getElementById(campo).value)))
			{ 
				document.getElementById(campo+'_requisiti').style.display='none';
			}
			/*else
			{
				document.getElementById(campo+'_cob').style.display='block';
			}*/
		}
	}
	
	function check_valid_mail(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(trim(document.getElementById(campo).value)=="")
			{ 
				//document.getElementById(campo+'_cob').style.display='block';
				
			}
			else
			{
				if(!ControllaMail(document.getElementById(campo).value))
				{
					document.getElementById(campo+'_cvm').style.display='block';
				}
				else
				{
					document.getElementById(campo+'_cvm').style.display='none';
				}
				//document.getElementById(campo+'_cob').style.display='none';
				
			}
		}
	}
	
	function check_cvm_blur(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(trim(document.getElementById(campo).value)!="")
			{ 
				if(ControllaMail(document.getElementById(campo).value))
				{
					document.getElementById(campo+'_cvm').style.display='none';
				}
			}
			/*else
			{
				document.getElementById(campo+'_cob').style.display='block';
			}*/
		}
	}

	function check_cob_blur(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
			if(trim(document.getElementById(campo).value)!="")
			{ 
				document.getElementById(campo+'_cob').style.display='none';
			}
			/*else
			{
				document.getElementById(campo+'_cob').style.display='block';
			}*/
		}
	}
	
	function check_obbligatorio_ae(campo,campo_2,campo_select,value_2)
	{
		if( document.getElementById(campo)!=undefined && document.getElementById(campo_select)!=undefined )
		{
				if(trim(document.getElementById(campo).value)!="" || document.getElementById(campo_select).selectedIndex==0)
				{ 
					document.getElementById(campo+'_cob').style.display='none';
				}
				else
				{
					document.getElementById(campo+'_cob').style.display='block';
				}
				if(trim(document.getElementById(campo_2).value)!="" || document.getElementById(campo_select).selectedIndex==value_2)
				{
					document.getElementById(campo+'_cob').style.display='none';
				}
				else
				{
					document.getElementById(campo+'_cob').style.display='block';
				}
		}
	}
	
	function check_cob_blur_ae(campo,campo_2,campo_select,value_2)
	{
		if( document.getElementById(campo)!=undefined && document.getElementById(campo_select)!=undefined )
		{
				if(trim(document.getElementById(campo).value)!="" || document.getElementById(campo_select).selectedIndex==0)
				{ 
					document.getElementById(campo+'_cob').style.display='none';
				}
				/*else
				{
					document.getElementById(campo+'_cob').style.display='block';
				}*/
				if(trim(document.getElementById(campo_2).value)!="" || document.getElementById(campo_select).selectedIndex==value_2)
				{
					document.getElementById(campo+'_cob').style.display='none';
				}
				/*else
				{
					document.getElementById(campo+'_cob').style.display='block';
				}*/
		}
	}
	
	function check_cob_onclick(campo)
	{
		if(document.getElementById(campo)!=undefined)
		{
				document.getElementById(campo+'_cob').style.display='none';
		}
	}
	
function check_pwd(campo,modulo)
{
//MEditPwd=1  -> EditPwd=1;  EditPwd=0 -> ExpirePwd=0
if(campo=='EditPwd' && modulo.EditPwd.checked==false)
{
modulo.EditPwd.checked=false;
modulo.ExpirePwd.selectedIndex=0;
modulo.MEditPwd.checked=false;
return;
}

if( (modulo.ExpirePwd.selectedIndex>0 || modulo.MEditPwd.checked==true) && modulo.EditPwd.checked==false  )
{modulo.EditPwd.checked=true;}
}

function ControllaUtente(modulo)
{
	/*if(modulo.ruolo[0].checked==false && modulo.ruolo[1].checked==false && modulo.ruolo[2].checked==false ){alert("Definisci il tipo di utente");return false;}*/
	var icheck = -1;
	for (i=modulo.ruolo.length-1; i > -1; i--) {
	if (modulo.ruolo[i].checked) {
	icheck = i; i = -1;
	}
	}
	if (icheck == -1 && modulo.CURRENT_navigator.value!=modulo.id.value) {alert("Definisci il tipo di utente");return false;}

	/*if(document.getElementById('Nome')!=undefined)
	{
		if(trim(modulo.nome.value)==''){alert("Inserisci il Nome");modulo.nome.focus();return false;}
		//if(trim(modulo.Cognome.value)==''){alert("Inserisci il Cognome");modulo.Cognome.focus();return false;}
		
		//if(modulo.Nazione.selectedIndex==0){alert("Inserisci la Nazione");modulo.Nazione.focus();return false;}
	}*/
	
	if(trim(modulo.nome_utente.value)==''){alert("Inserisci lo username per l'accesso dell'utente");modulo.nome_utente.focus();return false;}
	if(modulo.nome_utente_check.value=='false'){alert("Inserisci un\'username disponibile");modulo.nome_utente.focus();return false;}
	
	if(trim(modulo.chiave_accesso.value)==''){alert("Inserisci la password per l'accesso dell'utente");modulo.chiave_accesso.focus();return false;}
	
	if(modulo.chiave_accesso_check.value=='false'){alert("Inserisci una password corretta");modulo.chiave_accesso.focus();return false;}
	if(modulo.chiave_accesso.value.length<8){alert("Inserisci una password di almeno 8 caratteri");modulo.chiave_accesso.focus();return false;}
	
	if(document.getElementById('Email')!=undefined)
	{
		if(trim(modulo.Email.value)==''){alert("Inserisci l'e-mail");modulo.Email.focus();return false;}
	}
	
	if(modulo.sendmail.checked==true && trim(modulo.Email.value)=="")
	{
		alert("Se vuoi inviare un'email di notifica, inserisci l'e-mail a cui mandarla.");modulo.Email.focus();return false;
	}
	
	if( (modulo.ExpirePwd.selectedIndex>0 || modulo.MEditPwd.checked==true) && modulo.EditPwd.checked==false){modulo.EditPwd.checked=true;}
modulo.submit();
return true;
}

function user_display(modulo)
{
	var icheck = -1;
	var vcheck = "";
	for (i=modulo.ruolo.length-1; i > -1; i--)
	{
		if (modulo.ruolo[i].checked)
		{
			icheck = i; vcheck=modulo.ruolo[i].value; i = -1;
		}
	}
	
	if(vcheck=="3")
	{
		if(modulo.ruolo[icheck].checked)
		{
			document.getElementById("box_password").style.display='none';
		}
		else
		{
			document.getElementById("box_password").style.display='block';
		}
	}
	else if(icheck>0)
	{
		document.getElementById("box_password").style.display='block';
	}
}


// creates an XMLHttpRequest instance
function createXmlHttpRequestObject() 
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    {
      try 
 
      { 
        // try to create XMLHttpRequest object
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }
  }
  // return the created object or display an error message
  if (!xmlHttp){
    alert("Error creating the XMLHttpRequest object.");return false;}
  else{ 
    return xmlHttp;}
}

var xmlHttp = createXmlHttpRequestObject();
var xmlhttp = createXmlHttpRequestObject();
//var xmlhttp_2 = createXmlHttpRequestObject();



function upNOrdine(tabella,campoid,idrecord,campotoup,valore,alert1,alert2,url_base)
{


//alert("tbl="+tabella+"&campoid="+campoid+"&id='"+idrecord+"'&campo="+campotoup+"&value="+valore);
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById(idrecord+'_NOrdine').value=valore;
		
		}
	else
		{
		
		}*/
		if(document.forms['xup']!=undefined)
		{
			document.forms['xup'].id.value=idrecord;
			document.forms['xup'].submit();
		}
		else
		{
		document.location.href=url_base;
		}
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campoid+"&id="+idrecord+"&campo="+campotoup+"&value="+valore,true);
xmlhttp.send();

}

function upNOrdine2(tabella,campo_id,id_record,campo_id_2,id_record_2,campotoup,valore,url_base)
{


//alert("tbl="+tabella+"&campoid="+campoid+"&id='"+idrecord+"'&campo="+campotoup+"&value="+valore);
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById(idrecord+'_NOrdine').value=valore;
		
		}
	else
		{
		
		}*/
		document.location.href=url_base;
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campo_id+"&id="+id_record+"campoid2="+campo_id_2+"&id2="+id_record_2+"&campo="+campotoup+"&value="+valore,true);
xmlhttp.send();

}

function upNOrdineIdStr(tabella,campoid,idrecord,campotoup,valore,alert1,alert2,url_base)
{

if(valore=='') valore=0;
//alert("tbl="+tabella+"&campoid="+campoid+"&id='"+idrecord+"'&campo="+campotoup+"&value="+valore);
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	if(xmlhttp.responseText>=0)
		{
		document.getElementById(idrecord+'_NOrdine').value=valore;
		
		}
	/*else
		{
		
		}*/
		//document.location.href=url_base;
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campoid+"&id='"+idrecord+"'&campo="+campotoup+"&value="+valore,true);
xmlhttp.send();

}

function upState(tabella,campoid,idrecord,campotoup,valore,alert1,alert2,url_base)
{



  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById(idrecord+'_NOrdine').value=valore;
		
		}
	else
		{
		
		}*/
		document.location.href=url_base;
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campoid+"&id="+idrecord+"&campo="+campotoup+"&value="+valore,true);
xmlhttp.send();

}

function upState_g_testi(tabella,campoid,idrecord,campotoup,valore,alert1,alert2,current_pag)
{

idrecord=idrecord.replace("'","");

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById(idrecord+'_NOrdine').value=valore;
		
		}
	else
		{
		
		}*/
		//alert(xmlhttp.responseText);return;
		document.getElementById('current_anchor').value=idrecord;
		var token_area=document.xaction_publish.current_g_record.value;
		pag_g_record(current_pag,token_area);
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campoid+"&id='"+idrecord+"'&campo="+campotoup+"&value="+valore,true);
xmlhttp.send();

}

function upStato(tabella,campoid,idrecord,campostato,stato,alert1,alert2,url_base)
{



  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	if(xmlhttp.responseText==1)
		{
		document.getElementById('stato_'+idrecord).src='img/1.png';
		document.getElementById('stato_'+idrecord).alt=alert1;
		document.getElementById('stato_'+idrecord).title=alert1;
		}
	else
		{
		document.getElementById('stato_'+idrecord).src='img/0.png';
		document.getElementById('stato_'+idrecord).alt=""+alert2+"";
		document.getElementById('stato_'+idrecord).title=""+alert2+"";
		}
		document.location.href=url_base;
    }
  }
xmlhttp.open("GET","inc/upStato.php?tbl="+tabella+"&campoid="+campoid+"&id="+idrecord+"&campo="+campostato+"&value="+stato,true);
xmlhttp.send();

}

function Cambia_lingua_archivio(language,URL)
{
	document.forms['archivio'].lang.value=language;
	
		document.forms['archivio'].action=URL;
		//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/'+URL;
	
	document.forms['archivio'].submit();
}

function upLang(language,url_base)
{

if(url_base=='testi.php' || url_base=='opera.php' || url_base=='autore.php' || url_base=='biblio.php')
		{
			Cambia_lingua_archivio(''+language+'',url_base);
			return;
		}
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById('stato_'+idrecord).src='img/1.png';
		document.getElementById('stato_'+idrecord).alt=alert1;
		document.getElementById('stato_'+idrecord).title=alert1;
		}
	else
		{
		document.getElementById('stato_'+idrecord).src='img/0.png';
		document.getElementById('stato_'+idrecord).alt=""+alert2+"";
		document.getElementById('stato_'+idrecord).title=""+alert2+"";
		}*/
		
		if(url_base=='testi.php' || url_base=='opera.php' || url_base=='autore.php')
		{}else{
			document.location.href=xmlhttp.responseText;
		}
    }
  }
xmlhttp.open("GET","inc/upLang.php?lang="+language+"&url_base="+url_base,true);
xmlhttp.send();
}

function upCat(filtra_c,url_base)
{

  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
			document.location.href=xmlhttp.responseText;
			//document.location.href=url_base;
    }
  }
xmlhttp.open("GET","inc/upCat.php?filtra_c="+filtra_c+"&u="+url_base,true);
xmlhttp.send();
}

function upToken(token,translate_it,translate_en)
{
	/*04.03.2011*/
	
	//if(translate_it==undefined || translate_it==null )
	if(translate_it==undefined || translate_it==null || translate_it=="")
	{
		if(document.getElementById(token+'_it')!=undefined) translate_it=document.getElementById(token+'_it').value;
	}
	
	
	//if(translate_en==undefined || translate_en==null)
	if(translate_en==undefined || translate_en==null || translate_en=="")
	{
		if(document.getElementById(token+'_en')!=undefined) translate_en=document.getElementById(token+'_en').value;
	}
	
	translate_it=trim(translate_it);
	translate_en=trim(translate_en);
	if(translate_it=="") translate_it="''";
	if(translate_en=="") translate_en="''";
	//alert(translate_it);
	
  if(!confirm("Sicuro di voler salvare questo record? Questa parola chiave verrà modificata in tutte le aree del sito. Per salvare più di una modifica utilizzare il pulsante \"Salva modifiche\"."))
  {
	return false;
  }
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			/*if(xmlhttp.responseText==1)
				{
				document.getElementById('stato_'+idrecord).src='img/1.png';
				document.getElementById('stato_'+idrecord).alt=alert1;
				document.getElementById('stato_'+idrecord).title=alert1;
				}
			else
				{
				document.getElementById('stato_'+idrecord).src='img/0.png';
				document.getElementById('stato_'+idrecord).alt=""+alert2+"";
				document.getElementById('stato_'+idrecord).title=""+alert2+"";
				}*/
				//document.location.href="g_token.php";
			}
		  }
		xmlhttp.open("GET","inc/upToken.php?token="+token+"&translate_it="+translate_it+"&translate_en="+translate_en,true);
		xmlhttp.send();
	//}
	return true;
}

function stop_spinning(token)
					{
					document.getElementById(token+'_upload').style.display='none';
					}
function start_spinning(token)
					{
					document.getElementById(token+'_upload').style.display='block';
					}

function upParam(token)
{
	//alert(token);
	var valore;
	if(token==undefined || token==null || trim(token)=="")
	{return false;}
	
	if(token!="")
	{
		valore=document.getElementById(token+'_valoreid').value;
	}
	
	valore=trim(valore);
	
	if(valore==undefined || valore==null || valore=="")
	{alert("Nessun valore inserito");}
	
	
	
	
  if(!confirm("Sicuro di voler salvare questo parametro? Questo parametro verrà salvato nella basedati del sito. Per salvare più di una modifica utilizzare il pulsante \"Salva modifiche\"."))
  {
  document.getElementById(token+'_upload').style.display='none';
  }
  else
  {
	document.getElementById(token+'_upload').style.display='block';
	
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			//alert("response["+xmlhttp.responseText+"]");
			if(xmlhttp.responseText!="")
				{
					
					setTimeout("stop_spinning('"+xmlhttp.responseText+"')","3000");
				/*document.getElementById('stato_'+idrecord).alt=alert1;
				document.getElementById('stato_'+idrecord).title=alert1;*/
				}
			/*else
				{
				document.getElementById('stato_'+idrecord).src='img/0.png';
				document.getElementById('stato_'+idrecord).alt=""+alert2+"";
				document.getElementById('stato_'+idrecord).title=""+alert2+"";
				}*/
				//document.location.href="g_setup.php";
			}
		  }
		xmlhttp.open("GET","inc/upParam.php?token="+token+"&value="+valore,true);
		xmlhttp.send();
	}
	/*else
	{document.getElementById(token+'_upload').style.display='none';}*/
	return true;
}

function upToken1(token,translate_it,translate_en)
{

	if(translate_it==undefined || translate_it==null || translate_it=="")
	//if(translate_it==undefined || translate_it==null )
	{
		translate_it=document.getElementById(token+'_it').value;
	}
	
	if(translate_en==undefined || translate_en==null || translate_en=="")
	//if(translate_en==undefined || translate_en==null)
	{
		translate_en=document.getElementById(token+'_en').value;
	}
	
	translate_it=trim(translate_it);
	translate_en=trim(translate_en);
	if(translate_it=="") translate_it="''";
	if(translate_en=="") translate_en="''";
  if(!confirm("Sicuro di voler salvare questo record? Questa parola chiave verrà modificata in tutte le aree del sito. Per salvare più di una modifica utilizzare il pulsante \"Salva modifiche\"."))
  {return false;}
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			/*if(xmlhttp.responseText==1)
				{
				document.getElementById('stato_'+idrecord).src='img/1.png';
				document.getElementById('stato_'+idrecord).alt=alert1;
				document.getElementById('stato_'+idrecord).title=alert1;
				}
			else
				{
				document.getElementById('stato_'+idrecord).src='img/0.png';
				document.getElementById('stato_'+idrecord).alt=""+alert2+"";
				document.getElementById('stato_'+idrecord).title=""+alert2+"";
				}*/
				//document.location.href="g_token.php";
			}
		  }
		xmlhttp.open("GET","inc/upToken1.php?token="+token+"&translate_it="+translate_it+"&translate_en="+translate_en,true);
		xmlhttp.send();
	//}
return true;}

function Redirecting(Url,Seconds)
{
Seconds=Seconds*1000;
setTimeout("gotourl('"+Url+"');",""+Seconds+"");
}
/*
function Elimina(where)
{
if(!confirm("Sicuro di voler eliminare?"))
{}else{
document.del_xaction.where.value=where;
document.del_xaction.submit();
}
}*/



function xaction_func(idvalue,actionvalue)
{
document.xaction.id.value=idvalue;
if(actionvalue==""){actionvalue="inc/upMembro.php";}
document.xaction.action=actionvalue;
document.xaction.submit();
}

function xaction_func_2(idvalue,curr_pag,actionvalue)
{
document.xaction.id.value=idvalue;
document.xaction.pag.value=curr_pag;
document.xaction.action=actionvalue;
document.xaction.submit();
}

function xactiondata_func(idvalue,actionvalue)
{
document.xactiondata.id.value=idvalue;
document.xactiondata.action=actionvalue;
document.xactiondata.submit();
}

function invia_modulo(modulo,idvalue,action)
{
modulo.id.value=idvalue;
modulo.action=action;
modulo.submit();
}

function send_modulo(modulo,action)
{
modulo.action=action;
modulo.submit();
}

function shut_ordine(redirect)
{
	if(confirm("Si sta per abbandonare la procedura di inserimento ordine, i dati finora inseriti andranno persi. Cancellare l'ordine?"))
	{
	document.shut_xaction.redirect.value=redirect;
	document.shut_xaction.submit();
	}
}

function cambialingua(vlingua){
document.cl.filtro_lingua.value=vlingua;
document.cl.submit();
}

/*function cambiaarea(varea){
document.farea.area.value=varea;
document.farea.submit();
}*/

function cambiaarea(varea)
{
document.location.href=''+varea+'';
}


function addcart(){
document.c2.submit();
}

function reqinfo()
{
document.c2.action='inc/sendtoreqinfo.php';
document.c2.submit();
}



function numeri_interi(evt) 
{
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || (charCode > 57 && charCode < 96) || (charCode > 57 && charCode > 105)) )
	{
        alert("Inserisci un numero intero."); 
        return false;
    }
return true;
}


function numeri_interi2(evt,alerttext) 
{
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) 
	{
        alert(alerttext); 
        return false;
    }
return true;
}

function dotab(evt)
{
	evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
	if(charCode == 9)
	{
				
				document.form_Articolo.prezzo.focus();
		return;
	}
}



function mailcheck(str)
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false;
		 }

 		 return true;					
}

function fqnt()
{//alert(document.getElementById('quantitaid').value);
	if(document.getElementById('quantitaid').value!='')
	{
		//var qnt=
		//eccezione
		if(document.getElementById('idtipo').value=='Q' && eval(document.getElementById('quantitaid').value)<1)
		{
		//alert("Quantità minima accettata 1 confezione.");
		document.getElementById('quantitaid').value='';
		document.getElementById('quantitaid').focus();
		}
		else if(document.getElementById('idtipo').value=='M' && eval(document.getElementById('quantitaid').value)<50)
		{
		//alert("Quantità minima accettata 50 cm.");
		document.getElementById('quantitaid').value='';
		document.getElementById('quantitaid').focus();
		}
		else
		{
		document.form1.quantita.value=document.getElementById('quantitaid').value;
		document.form1.submit();
		}
	}

}

function onload1()
{
if(document.form1.quantita.value!='' && document.form1.quantita.value!=undefined){document.getElementById('quantitaid').value=document.form1.quantita.value;}
}

function cercano()
{
document.formfiltri.filtro_cerca.value='';
document.formfiltri.cerca_no.value='TRUE';
document.formfiltri.submit;
}


function delp_cart(posiz)
{
document.location.href='inc/svuota_cart.php?posizione='+posiz;
}

function up_qnt(posizione,qntid)
{
var quant=document.getElementById(qntid).value;
document.location.href='inc/upqntcart.php?p='+posizione+'&qnt='+quant;
}

function up_qnt2(posizione,qntid)
{
var quant=document.getElementById(qntid).value;
document.location.href='inc/upqntcart2.php?p='+posizione+'&qnt='+quant;
}

function up_scat(ID_SCAT)
{
if(document.getElementById('cat_'+ID_SCAT).selectedIndex==''){document.getElementById('cat_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_it_'+ID_SCAT).value==''){document.getElementById('scat_it_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_fr_'+ID_SCAT).value==''){document.getElementById('scat_fr_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_en_'+ID_SCAT).value==''){document.getElementById('scat_en_'+ID_SCAT).focus();return false;}
else{
document.xscat.id.value=ID_SCAT;
document.xscat.cat.value=document.getElementById('cat_'+ID_SCAT).options[document.getElementById('cat_'+ID_SCAT).selectedIndex].value;
document.xscat.scat_it.value=document.getElementById('scat_it_'+ID_SCAT).value;
document.xscat.scat_fr.value=document.getElementById('scat_fr_'+ID_SCAT).value;
document.xscat.scat_en.value=document.getElementById('scat_en_'+ID_SCAT).value;
document.xscat.submit();
}
return true;
}

function add_scat(ID_SCAT)
{
if(document.getElementById('cat_'+ID_SCAT).selectedIndex==''){document.getElementById('cat_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_it_'+ID_SCAT).value==''){document.getElementById('scat_it_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_fr_'+ID_SCAT).value==''){document.getElementById('scat_fr_'+ID_SCAT).focus();return false;}
else if(document.getElementById('scat_en_'+ID_SCAT).value==''){document.getElementById('scat_en_'+ID_SCAT).focus();return false;}
else{
document.xscat.id.value=ID_SCAT;
document.xscat.cat.value=document.getElementById('cat_'+ID_SCAT).options[document.getElementById('cat_'+ID_SCAT).selectedIndex].value;
document.xscat.scat_it.value=document.getElementById('scat_it_'+ID_SCAT).value;
document.xscat.scat_fr.value=document.getElementById('scat_fr_'+ID_SCAT).value;
document.xscat.scat_en.value=document.getElementById('scat_en_'+ID_SCAT).value;
document.xscat.action='inc/ins_scat.php';
document.xscat.submit();
}
return true;}

function del_scat(ID_SCAT)
{
if(confirm("Attenzione: Si desidera eliminare definitivamente la sottocategoria?"))
{
document.xscat.id.value=ID_SCAT;
document.xscat.action='inc/del_scat.php';
document.xscat.submit();
}
}

function up_cat(ID_CAT)
{

if(document.getElementById('cat_it_'+ID_CAT).value==''){document.getElementById('cat_it_'+ID_CAT).focus();return false;}
else if(document.getElementById('cat_fr_'+ID_CAT).value==''){document.getElementById('cat_fr_'+ID_CAT).focus();return false;}
else if(document.getElementById('cat_en_'+ID_CAT).value==''){document.getElementById('cat_en_'+ID_CAT).focus();return false;}
else{
document.xcat.id.value=ID_CAT;
document.xcat.cat_it.value=document.getElementById('cat_it_'+ID_CAT).value;
document.xcat.cat_fr.value=document.getElementById('cat_fr_'+ID_CAT).value;
document.xcat.cat_en.value=document.getElementById('cat_en_'+ID_CAT).value;
document.xcat.submit();
}
return true;}

function add_cat(ID_CAT)
{

if(document.getElementById('cat_it_'+ID_CAT).value==''){document.getElementById('cat_it_'+ID_CAT).focus();return false;}
else if(document.getElementById('cat_fr_'+ID_CAT).value==''){document.getElementById('cat_fr_'+ID_CAT).focus();return false;}
else if(document.getElementById('cat_en_'+ID_CAT).value==''){document.getElementById('cat_en_'+ID_CAT).focus();return false;}
else{
document.xcat.id.value=ID_CAT;
document.xcat.cat_it.value=document.getElementById('cat_it_'+ID_CAT).value;
document.xcat.cat_fr.value=document.getElementById('cat_fr_'+ID_CAT).value;
document.xcat.cat_en.value=document.getElementById('cat_en_'+ID_CAT).value;
document.xcat.action='inc/ins_cat.php';
document.xcat.submit();
}
return true;}

function del_cat(ID_CAT)
{
if(confirm("Attenzione: Si desidera eliminare definitivamente la sottocategoria?"))
{
document.xcat.id.value=ID_CAT;
document.xcat.action='inc/del_cat.php';
document.xcat.submit();
}
}

function check_qnt(new_qnt,curr_qnt,vtipo,qntid)
{
//var curr_qnt=document.getElementById('prev_qnt').value;
//var curr_qnt=val_qnt;
if(new_qnt==0 || (vtipo=='Q' && new_qnt<1) || new_qnt=='' || (vtipo=='M' && new_qnt<50))
{
document.getElementById(qntid).value=curr_qnt;
}
}

function del_art(artid)
{
	if(confirm("Sei sicuro di voler eliminare?"))
	{
	document.location.href='inc/del_art.php?id='+artid;
	}
}



function mod_art(artid)
{
	//document.location.href='mod_articoli.php';
	document.xmod.idart.value=artid;
	document.xmod.action='mod_articoli.php';
	document.xmod.submit();
}

/*function ins_art(artid)
{
	//document.location.href='ins_articoli.php';
	document.location.href='#';
}*/

function redirect1()
{
document.location.href='../panel.php';
}

function redirect2()
{
document.location.href='logout.php?page=accesso.php';
}

function redirect3()
{
document.location.href='inc/logout.php?page=accesso.php';
}

function redirect4()
{
document.location.href='validate.php';
}

function rereqinfo()
{
document.location.href='reqinfo.php';
}

function recart()
{
document.location.href='carrello.php';
}

function gotourl(pagina)
{
document.location.href=pagina;
}

function gotourl_adv(pagina,categoria)
{
document.archivio.action=pagina;
document.archivio.id.value="";
document.archivio.pag.value=1;
document.archivio.c.value=categoria;
document.archivio.submit();
}

function conta(campo,campobox,max)
{
	if(document.getElementById(campo)!=undefined && document.getElementById(campobox)!=undefined)
	{
		var lenMax=eval(max);
		var strlength=document.getElementById(campo).value.length;
		var total = eval(""+max+"");
		var chara = eval(document.getElementById(campo).value.length);
		var left = eval(total - chara);
		/*var lenMax=eval(max);
		var str=document.getElementById(campo).value;
		var strlength=str.length;
		var total = eval(""+max+"");
		var chara = eval(strlength);
		var left = eval(total - chara);*/
		if (left <= "-1")
		{
		var dif = eval(chara - lenMax);
		var value = document.getElementById(campo).value.substr(0,chara-dif);
		document.getElementById(campo).value = value;
		var left = "0";
		}
		var value = document.getElementById(campo).value.substr(0,lenMax);
		document.getElementById(campobox).innerHTML=" "+left+" caratteri ancora disponibili";

	}
}

function conta2(campo2,campobox2,max2){
if(document.getElementById(campo2)!=undefined && document.getElementById(campobox2)!=undefined)
	{
var lenMax=eval(max2);
var strlength=document.getElementById(campo2).value.length;
var total = eval(""+max2+"");
var chara = eval(document.getElementById(campo2).value.length);
var left = eval(total - chara);
if (left <= "-1")
{
var dif = eval(chara - lenMax);
var value = document.getElementById(campo2).value.substr(0,chara-dif);
document.getElementById(campo2).value = value;
var left = "0";
}
document.getElementById(campobox2).innerHTML=left;
	}
}

/*function mustSelcat()
{
if(document.ins_articoli.cat.selectedIndex==0){alert("Seleziona la categoria");ins_articoli.cat.focus();}
}*/

function caricaCategorie(selectedCat)
{
document.getElementById('filtro_tipo1').value=document.getElementById('cat').options[document.getElementById('cat').selectedIndex].value;
document.getElementById('filtro_tipo2').value=document.getElementById('scat').options[document.getElementById('scat').selectedIndex].value;
//document.ins_articoli.action='ins_articoli.php';
document.getElementById('cat').form.submit();
}

function boxmex(campo,messaggio)
{
document.getElementById(campo+'_box').innerHTML="<font style='font-size:9px;'>"+messaggio+"</font>";
}

function boxmex_out(campo)
{
document.getElementById(campo+'_box').innerHTML="";
}

function img_box(box)
{
//document.getElementById(box).innerHTML="<font color='#BB171D' style='font-size:9px;'>L'immagine non deve superare i 2 Megabyte di dimensione e deve avere estensione jpg</font>";
document.getElementById(box).innerHTML="<font style='font-size:9px;'>Selezionare un'immagine jpg non superiore ai 2 Megabyte di dimensione</font>";
}


function tipo_box(box)
{
document.getElementById(box).innerHTML="<font style='font-size:9px;'>Indica come deve essere venduto l'articolo </font>";
}

function desc_box(box)
{
document.getElementById(box).innerHTML="<font style='font-size:9px;'>Per andare a capo digita <b>&lt;br /&gt;</b> </font>";
}

function prezzo_info(indice)
{
var indexmisura=document.getElementById('misura_'+indice).selectedIndex;
if(indexmisura=='0')
	{document.getElementById('prezzo_info_'+indice).innerHTML="<font color='#BB171D' style='font-size:9px;'>Seleziona la misura prima di indicare il prezzo</font>";}
else
	{
	var misura=document.getElementById('misura_'+indice).options[indexmisura].text;
	document.getElementById('prezzo_info_'+indice).innerHTML="<font style='font-size:9px;'>Indica il prezzo relativo alla misura "+misura+", (es sintassi 49,90)</font>";
	}	
}

function selezMisura(indice,index)
{
if(index>0)
{
var tot=document.getElementById('misure').value;
var misura1=document.getElementById('misura_'+indice).options[index].text;
var misura2="";
var indmisura2="";
var i;
var j;
	for(i=0,j=1;i<tot;i++,j++)
	{
	indmisura2=document.getElementById('misura_'+j).selectedIndex;
	misura2=document.getElementById('misura_'+j).options[indmisura2].text;
	//if(indice!=j){document.getElementById('misura_'+j).remove(index);}
		if(indice!=j && indmisura2>0 && misura1==misura2)
		{
		//document.getElementById('misura_'+indice).selectedIndex=0;
		document.getElementById('prezzo_info_'+indice).innerHTML="<font color='#BB171D' style='font-size:9px;'>Misura "+misura2+" già utilizzata, selezionarne un'altra</font>";
		}
	}
}
}

function upPermessi(idcategoria)
{



  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.getElementById('upPermessi').innerHTML=xmlhttp.responseText;
	/*if(xmlhttp.responseText==1)
		{
		document.getElementById('stato_'+idrecord).src='img/1.png';
		document.getElementById('stato_'+idrecord).alt=alert1;
		document.getElementById('stato_'+idrecord).title=alert1;
		}
	else
		{
		document.getElementById('stato_'+idrecord).src='img/0.png';
		document.getElementById('stato_'+idrecord).alt=""+alert2+"";
		document.getElementById('stato_'+idrecord).title=""+alert2+"";
		}
		document.location.href=url_base;*/
    }
  }
xmlhttp.open("GET","inc/upPermessi.php?id="+idcategoria,true);
xmlhttp.send();

}

function switch_upPermessi()
{
	if(document.getElementById('upPermessi').style.display=='none')
	{
		document.getElementById('upPermessi').style.display='block';
		//document.getElementById('switch').innerHTML="Nascondi i permessi della categoria "+document.getElementById('categoria').options[document.getElementById('categoria').selectedIndex].text;
		document.getElementById('switch').innerHTML="Nascondi i permessi della categoria ";
	}
	else if(document.getElementById('upPermessi').style.display=='block')
	{
		document.getElementById('upPermessi').style.display='none';
		//document.getElementById('switch').innerHTML="Visualizza i permessi della categoria "+document.getElementById('categoria').options[document.getElementById('categoria').selectedIndex].text;
		document.getElementById('switch').innerHTML="Visualizza i permessi della categoria ";
	}
}

function box_out(box)
{
document.getElementById(box).innerHTML="";
}

function add_colore(indice,url_base)
{

if(document.getElementById('codart_'+indice).value==''){document.getElementById('codart_'+indice).focus();}
else if(document.getElementById('colore_it_'+indice).value==''){document.getElementById('colore_it_'+indice).focus();}
else if(document.getElementById('colore_fr_'+indice).value==''){document.getElementById('colore_fr_'+indice).focus();}
else if(document.getElementById('colore_en_'+indice).value==''){document.getElementById('colore_en_'+indice).focus();}
else
{

var colori=eval(eval(document.getElementById('colori').value)+eval(1));
document.getElementById('colori').value=colori;

//document.ins_articoli.action=''+url_base+'';
document.getElementById('colore_it_'+indice).form.submit();
}

}

function del_img(artid,n)
{
	if(!confirm("Sei sicuro di voler eliminare l'immagine?"))
	{}else{
	//document.xmod.idart.value=artid;
	document.mod_articoli.del_img.value='true';
	document.mod_articoli.del_n.value=n;
	var colori=eval(document.getElementById('colori').value);
	document.getElementById('colori').value=colori;
	document.mod_articoli.action='mod_articoli.php';
	document.mod_articoli.submit();
	//document.location.href='inc/del_img.php?id='+artid+'&n='+n;
	}
}

function rem_colore()
{
var colori=eval(eval(document.getElementById('colori').value)-1);
document.getElementById('colori').value=colori;
//document.ins_articoli.action='ins_articoli.php';
document.getElementById('colori').form.submit();
}

/*function vedi_misure(tipo)
{
document.getElementById('misure_'+tipo).style='display:block;';
if(tipo=='Q'){document.getElementById('misure_M').style='display:none;';}
else{document.getElementById('misure_Q').style='display:none;';}
}*/

function box_prezzo(tipo)
{
if(tipo==''){tipo=document.getElementById('tipo').options[document.getElementById('tipo').selectedIndex].value;}
var tot=document.getElementById('misure').value;
var i;
var j;
	for(i=0,j=1;i<tot;i++,j++)
	{
	if(tipo=='all'){document.getElementById('prezzo_box_'+j).innerHTML="";}
	else if(tipo=='Q'){document.getElementById('prezzo_box_'+j).innerHTML="<font style='font-size:9px;'> &euro;</font>";}
	else if(tipo=='M'){document.getElementById('prezzo_box_'+j).innerHTML="<font style='font-size:9px;'> &euro;/metro</font>";}
	}
}


function ApriFinestra(Url,Title)
{
	if(confirm("Si sta per aprire una nuova finestra per visualizzare il collegamento:\n"+Title+".\nPer proseguire fare cliccare su OK altrimenti su Annulla."))
	{
	window.open(Url,Title,'width=800,height=600');
	}
}



/*VALIDAZIONE INSERIMENTO ARTICOLO*/
function controllaInserimento(modulo)
{
if(modulo.cat.selectedIndex==0){alert("Seleziona la categoria");modulo.cat.focus();return false;}

if(modulo.scat.selectedIndex==0){alert("Seleziona la sottocategoria");modulo.scat.focus();return false;}

if(modulo.titolo_it.value==''){alert("Inserisci il titolo");modulo.titolo_it.focus();return false;}

if(modulo.titolo_fr.value==''){alert("Inserisci il titolo");modulo.titolo_fr.focus();return false;}

if(modulo.titolo_en.value==''){alert("Inserisci il titolo");modulo.titolo_en.focus();return false;}

if(modulo.desc_it.value==''){alert("Inserisci la descrizione");modulo.desc_it.focus();return false;}

if(modulo.desc_fr.value==''){alert("Inserisci la descrizione");modulo.desc_fr.focus();return false;}

if(modulo.desc_en.value==''){alert("Inserisci la descrizione");modulo.desc_en.focus();return false;}

/*if(document.getElementById('img_1').value=='')
{
	
	alert("Inserisci ");
	document.getElementById("img_1").value="";
	document.getElementById("img_1").focus();
	return false;
	
}*/



var colori=eval(modulo.colori.value);
var newcolori=0;
var i;
var j;
for(j=0,i=1;j<colori;i++,j++)
	{
		if(document.getElementById('colore_it_'+i)!=null)
			{
				if(document.getElementById('codart_'+i).value!='' || document.getElementById('colore_it_'+i).value!='' || document.getElementById('colore_fr_'+i).value!='' || document.getElementById('colore_en_'+i).value!='')
				{
					if(document.getElementById('codart_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_it_'+i).focus();return false;}
					
					if(document.getElementById('colore_it_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_it_'+i).focus();return false;}

					if(document.getElementById('colore_fr_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_fr_'+i).focus();return false;}

					if(document.getElementById('colore_en_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_en_'+i).focus();return false;}
				}
				
				if(document.getElementById('codart_'+i).value!='' && document.getElementById('colore_it_'+i).value!='' && document.getElementById('colore_fr_'+i).value!='' && document.getElementById('colore_en_'+i).value!='')
				{
				newcolori++;
				}
			}
	}


if(modulo.filtro_tipo.selectedIndex==0){alert("Seleziona il tipo di vendita");modulo.filtro_tipo.focus();return false;}

var misure=eval(modulo.misure.value);
var newmisure=0;
var i;
var j;
for(j=0,i=1;j<misure;i++,j++)
	{
		if(document.getElementById('misura_'+i)!=null)
			{
				if(document.getElementById('misura_'+i).selectedIndex!='0' || document.getElementById('prezzo_'+i).value!='' )
				{
					if(document.getElementById('misura_'+i).selectedIndex=='0')
						{alert("Seleziona a quale misura attribuire il prezzo "+document.getElementById('prezzo_'+i).value+"");
						document.getElementById('misura_'+i).focus();return false;}
					
					if(document.getElementById('prezzo_'+i).value=='')
						{alert("Inserisci il prezzo da attribuire alla misura "+document.getElementById('misura_'+i).options[document.getElementById('misura_'+i).selectedIndex].text+"");document.getElementById('prezzo_'+i).focus();return false;}

					
				}
				
				if(document.getElementById('misura_'+i).selectedIndex!='0' && document.getElementById('prezzo_'+i).value!='' )
				{
				newmisure++;
				}
			}
	}
	
if(document.getElementById('img_1').value!='')
{
	var stringa=document.getElementById('img_1').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_1").value="";
	document.getElementById("img_1").focus();
	return false;
	}
}

if(document.getElementById('img_2').value!='')
{
	var stringa=document.getElementById('img_2').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_2").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_2").value="";
	document.getElementById("img_2").focus();
	return false;
	}
}

if(document.getElementById('img_3').value!='')
{
	var stringa=document.getElementById('img_3').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_3").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_3").value="";
	document.getElementById("img_3").focus();
	return false;
	}
}

if(document.getElementById('img_4').value!='')
{
	var stringa=document.getElementById('img_4').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_4").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_4").value="";
	document.getElementById("img_4").focus();
	return false;
	}
}
	
modulo.colori.value=newcolori;
modulo.misure.value=newmisure;

modulo.action='ins_articolo.php';
return true;
}

function ControllaPilota(modulo)
{
		if(trim(modulo.Nome.value)==''){alert("Inserisci il Nome");modulo.Nome.focus();return false;}
		if(trim(modulo.Cognome.value)==''){alert("Inserisci il Cognome");modulo.Cognome.focus();return false;}
		if(trim(modulo.Email.value)!=""){if(!ControllaMail(trim(modulo.Email.value))){alert("Inserisci un'indirizzo e-mail corretto");modulo.Email.focus();return false;}}
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
			alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
			document.getElementById("img_1").value="";
			document.getElementById("img_1").focus();
			return false;
			}
		}
return true;}

function ControllaPilota_bool(modulo)
{
		if(trim(modulo.Nome.value)==''){return false;}
		if(trim(modulo.Cognome.value)==''){return false;}
		if(trim(modulo.Email.value)!=""){if(!ControllaMail(trim(modulo.Email.value))){return false;}}
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
			
			return false;
			}
		}
return true;}

function ControllaVettura(modulo)
{
		if(trim(modulo.Titolo.value)==''){alert("Inserisci il Nome della vettura");modulo.Titolo.focus();return false;}
		
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
			alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
			document.getElementById("img_1").value="";
			document.getElementById("img_1").focus();
			return false;
			}
		}
return true;}

function ControllaVettura_bool(modulo)
{
		if(trim(modulo.Titolo.value)==''){return false;}
		
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
			
			return false;
			}
		}
return true;}

function ControllaCampionato(modulo)
{
		if(trim(modulo.Titolo.value)==''){alert("Inserisci il Nome del Campionato");modulo.Titolo.focus();return false;}
		
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
			alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
			document.getElementById("img_1").value="";
			document.getElementById("img_1").focus();
			return false;
			}
		}
return true;}

function ControllaCampionato_bool(modulo)
{
		if(trim(modulo.Titolo.value)==''){return false;}
		
		if(document.getElementById('img_1').value!='')
		{
			var stringa=document.getElementById('img_1').value;
			var pos=stringa.lastIndexOf('.') +1;
			var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
			if(ext=='jpg')
			{}
			//else if(ext=='png'){}
			else
			{
		
			return false;
			}
		}
return true;}

function ControllaGara(modulo)
{
	if(trim(modulo.Data.value)=="" ){alert("Inserisci la data della gara, inserire la data nel formato: GG/MM/AAAA");modulo.Data.focus();return false;}
	if(trim(modulo.Citta.value)==''){alert("Inserisci la Città o il nome del Circuito in cui si svolge la gara");modulo.Citta.focus();return false;}
	if(modulo.Paese.selectedIndex==0){alert("Seleziona la Nazione in cui si svolge la gara");modulo.Paese.focus();return false;}
	if(modulo.Campionato.selectedIndex==0){alert("Seleziona il Campionato al quale appartiene la gara");modulo.Campionato.focus();return false;}
return true;}

function ControllaGara_bool(modulo)
{
	if(trim(modulo.Data.value)=="" ){return false;}
	if(trim(modulo.Citta.value)==''){return false;}
	if(modulo.Paese.selectedIndex==0){return false;}
	if(modulo.Campionato.selectedIndex==0){return false;}
return true;}

function ControllaMembro(modulo)
{
	
	
	//if(modulo.tipologia.selectedIndex==0){alert("Seleziona il tipo");modulo.tipologia.focus();return false;}
	var icheck = -1;
	for (i=modulo.tipologia.length-1; i > -1; i--) {
	if (modulo.tipologia[i].checked) {
	icheck = i; i = -1;
	}
	}
	if (icheck == -1) {alert("Definisci il tipo di membro");return false;}
	
	
	if(trim(modulo.Azienda.value)=='' && trim(modulo.Nome.value)=='' && trim(modulo.Cognome.value)=='')
	{
		alert("Inserisci il Nome e Cognome e/o il nome dell'Azienda");modulo.Nome.focus();return false;
	}
	
	if(trim(modulo.Azienda.value)=='')
	{
		if(trim(modulo.Nome.value)==''){alert("Inserisci il Nome");modulo.Nome.focus();return false;}
		if(trim(modulo.Cognome.value)==''){alert("Inserisci il Cognome");modulo.Cognome.focus();return false;}
	}
	
	if(trim(modulo.Qualifica_it.value)==''){alert("Inserisci la Qualifica");modulo.Qualifica_it.focus();return false;}
	
	//if(trim(modulo.Nominativo.value)==''){alert("Inserisci il Nominativo");modulo.Nominativo.focus();return false;}
	if(trim(modulo.Email.value)==''){alert("Inserisci l'email");modulo.Email.focus();return false;}
	if(!ControllaMail(trim(modulo.Email.value))){alert("Inserisci un'indirizzo e-mail corretto");modulo.Email.focus();return false;}
	//if(trim(modulo.DBreve.value)==''){alert("Inserisci una breve descrizione dell'Attività del Membro");modulo.DBreve.focus();return false;}
	
	/*if(modulo=='ins_membro' && trim(modulo.nome_utente.value)==''){alert("Inserisci la Username ");modulo.nome_utente.focus();return false;}
	if(modulo=='ins_membro' && trim(modulo.chiave_accesso.value)==''){alert("Inserisci la Password ");modulo.chiave_accesso.focus();return false;}*/
	
	
	/*if(trim(modulo.Azienda.value)==''){alert("Inserisci il nome dell'Azienda");modulo.Azienda.focus();return false;}*/
	if(document.getElementById('img_1').value!='')
	{
		var stringa=document.getElementById('img_1').value;
		var pos=stringa.lastIndexOf('.') +1;
		var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
		if(ext=='jpg')
		{}
		//else if(ext=='png'){}
		else
		{
		alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
		document.getElementById("img_1").value="";
		document.getElementById("img_1").focus();
		return false;
		}
	}
	
	if(document.getElementById("Utente")!=undefined)
	{
		if(document.getElementById("Utente").selectedIndex==0)
		{
			modulo.sendmail.checked=false;
		}
	}
	
	/*if(trim(modulo.rEmail.value)!="" && !ControllaMail(trim(modulo.rEmail.value))){alert("Inserisci un'indirizzo e-mail corretto");modulo.rEmail.focus();return false;}
	if(trim(modulo.rEmail2.value)!="" && !ControllaMail(trim(modulo.rEmail2.value))){alert("Inserisci un'indirizzo e-mail corretto");modulo.rEmail2.focus();return false;}*/
	
return true;
}

function ControllaOspite(modulo)
{
	/*if(modulo.tipologia.selectedIndex==0){alert("Seleziona il tipo");modulo.tipologia.focus();return false;}*/
	if(trim(modulo.Nome.value)==''){alert("Inserisci il Nome");modulo.Nome.focus();return false;}
	if(trim(modulo.Cognome.value)==''){alert("Inserisci il Cognome");modulo.Cognome.focus();return false;}
	//if(trim(modulo.Nominativo.value)==''){alert("Inserisci il Nominativo");modulo.Nominativo.focus();return false;}
	if(trim(modulo.Email.value)==''){alert("Inserisci l'email");modulo.Email.focus();return false;}
	if(!ControllaMail(trim(modulo.Email.value))){alert("Inserisci un'indirizzo e-mail corretto");modulo.Email.focus();return false;}
	//if(trim(modulo.DBreve.value)==''){alert("Inserisci una breve descrizione dell'Attività del Membro");modulo.DBreve.focus();return false;}
	
	
	return true;
}

function ControllaPartecipa(modulo)
{
	if(trim(modulo.azienda.value)==''){alert("Inserisci il nome dell'Azienda o Società");modulo.azienda.focus();return false;}
	if(trim(modulo.settore.value)==''){alert("Specificare il settore (categoria professionale) dell'Azienda o Società");modulo.settore.focus();return false;}
	if(trim(modulo.dbreve.value)==''){alert("Inserire una breve descrizione dell'attività svolta dall'Azienda o Società");modulo.dbreve.focus();return false;}
	if(trim(modulo.nome.value)==''){alert("Inserisci il tuo Nome");modulo.nome.focus();return false;}
	if(trim(modulo.cognome.value)==''){alert("Inserisci il tuo Cognome");modulo.cognome.focus();return false;}
	if(trim(modulo.email.value)==''){alert("Inserisci l'indirizzo della tua e-mail, alla quale potrai essere ricontattato");modulo.email.focus();return false;}
	if(!ControllaMail(trim(modulo.email.value)) && trim(modulo.email.value)!=""){alert("Inserisci l'indirizzo di posta elettronica in modo corretto");modulo.email.focus();return false;}
	if(trim(modulo.tel.value)==''){alert("Inserisci un contatto telefonico, alla quale potrai essere ricontattato");modulo.tel.focus();return false;}
	if(!ControllaTel(trim(modulo.tel.value)) ){alert("Inserisci il numero di telefono in modo corretto (caratteri consentiti . , - +) ");modulo.tel.focus();return false;}
	if(trim(modulo.messaggio.value)==''){alert("Inserisci il testo del messaggio ");modulo.messaggio.focus();return false;}
return true;
}

function ControllaCat(modulo)
{
	if(trim(modulo.Nome.value)==''){alert("Inserisci il nome della Galleria");modulo.Nome.focus();return false;}
	
	//alert(document.getElementById('LimitaI_T').options.length);
	/*
	if(modulo.LimitaI[1].checked==true)//T
		{
			var check1=false;
			for(var i=0;i<document.getElementById('LimitaI_T').options.length;i++)
			{
				if(document.getElementById('LimitaI_T').options[i].selected==true){check1=true;}
			}
			
			if(check1==false){alert("Seleziona almeno una tipologia di Membro");modulo.LimitaI_T.focus();return false;}
		}
	else if(modulo.LimitaI[2].checked==true)//M
		{
			var check2=false;
			for(i=0;i<document.getElementById('LimitaI_M').options.length;i++)
			{
				if(document.getElementById('LimitaI_M').options[i].selected==true){check2=true;}
			}
			
			if(check2==false){alert("Seleziona almeno un Membro");modulo.LimitaI_M.focus();return false;}
		}
		
	if(modulo.LimitaV[1].checked==true)//T
		{
			var check1=false;
			for(var i=0;i<document.getElementById('LimitaV_T').options.length;i++)
			{
				if(document.getElementById('LimitaV_T').options[i].selected==true){check1=true;}
			}
			
			if(check1==false){alert("Seleziona almeno una tipologia di Membro");modulo.LimitaV_T.focus();return false;}
		}
	else if(modulo.LimitaV[2].checked==true)//M
		{
			var check2=false;
			for(i=0;i<document.getElementById('LimitaV_M').options.length;i++)
			{
				if(document.getElementById('LimitaV_M').options[i].selected==true){check2=true;}
			}
			
			if(check2==false){alert("Seleziona almeno un Membro");modulo.LimitaV_M.focus();return false;}
		}*/
		
return true;	
}


/*VALIDAZIONE MODIFICA ARTICOLO*/
function controllaModifica(modulo)
{
if(modulo.cat.selectedIndex==0){alert("Seleziona la categoria");modulo.cat.focus();return false;}

if(modulo.scat.selectedIndex==0){alert("Seleziona la sottocategoria");modulo.scat.focus();return false;}

if(modulo.titolo_it.value==''){alert("Inserisci il titolo");modulo.titolo_it.focus();return false;}

if(modulo.titolo_fr.value==''){alert("Inserisci il titolo");modulo.titolo_fr.focus();return false;}

if(modulo.titolo_en.value==''){alert("Inserisci il titolo");modulo.titolo_en.focus();return false;}

if(modulo.desc_it.value==''){alert("Inserisci la descrizione");modulo.desc_it.focus();return false;}

if(modulo.desc_fr.value==''){alert("Inserisci la descrizione");modulo.desc_fr.focus();return false;}

if(modulo.desc_en.value==''){alert("Inserisci la descrizione");modulo.desc_en.focus();return false;}

/*if(document.getElementById('img_1').value=='')
{
	
	alert("Inserisci ");
	document.getElementById("img_1").value="";
	document.getElementById("img_1").focus();
	return false;
	
}*/



var colori=eval(modulo.colori.value);
var newcolori=0;
var i;
var j;
for(j=0,i=1;j<colori;i++,j++)
	{
		if(document.getElementById('colore_it_'+i).value!=null)
			{
			
				if(document.getElementById('codart_'+i).value!='' || document.getElementById('colore_it_'+i).value!='' || document.getElementById('colore_fr_'+i).value!='' || document.getElementById('colore_en_'+i).value!='')
				{
					if(document.getElementById('codart_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_it_'+i).focus();return false;}
					
					if(document.getElementById('colore_it_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_it_'+i).focus();return false;}

					if(document.getElementById('colore_fr_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_fr_'+i).focus();return false;}

					if(document.getElementById('colore_en_'+i).value=='')
						{alert("Inserisci la descrizione del colore");document.getElementById('colore_en_'+i).focus();return false;}
				}
				
				if(document.getElementById('codart_'+i).value!='' && document.getElementById('colore_it_'+i).value!='' && document.getElementById('colore_fr_'+i).value!='' && document.getElementById('colore_en_'+i).value!='')
				{
				newcolori++;
				}
			}
	}


if(modulo.filtro_tipo.selectedIndex==0){alert("Seleziona il tipo di vendita");modulo.filtro_tipo.focus();return false;}

var misure=eval(modulo.misure.value);
var newmisure=0;
var i;
var j;
for(j=0,i=1;j<misure;i++,j++)
	{
		if(document.getElementById('misura_'+i)!=null)
			{
				if(document.getElementById('misura_'+i).selectedIndex!='0' || document.getElementById('prezzo_'+i).value!='' )
				{
					if(document.getElementById('misura_'+i).selectedIndex=='0')
						{alert("Seleziona a quale misura attribuire il prezzo "+document.getElementById('prezzo_'+i).value+"");
						document.getElementById('misura_'+i).focus();return false;}
					
					if(document.getElementById('prezzo_'+i).value=='')
						{alert("Inserisci il prezzo da attribuire alla misura "+document.getElementById('misura_'+i).options[document.getElementById('misura_'+i).selectedIndex].text+"");document.getElementById('prezzo_'+i).focus();return false;}

					
				}
				
				if(document.getElementById('misura_'+i).selectedIndex!='0' && document.getElementById('prezzo_'+i).value!='' )
				{
				newmisure++;
				}
			}
	}
	
if(document.getElementById('img_1').value!='')
{
	var stringa=document.getElementById('img_1').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_1").value="";
	document.getElementById("img_1").focus();
	return false;
	}
}

if(document.getElementById('img_2').value!='')
{
	var stringa=document.getElementById('img_2').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_2").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_2").value="";
	document.getElementById("img_2").focus();
	return false;
	}
}

if(document.getElementById('img_3').value!='')
{
	var stringa=document.getElementById('img_3').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_3").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_3").value="";
	document.getElementById("img_3").focus();
	return false;
	}
}

if(document.getElementById('img_4').value!='')
{
	var stringa=document.getElementById('img_4').value;
	var pos=stringa.lastIndexOf('.') +1;
	var ext = document.getElementById("img_4").value.substr(pos,3).toLowerCase();  
	if(ext=='jpg')
	{}
	//else if(ext=='png'){}
	else
	{
	alert("I file non possono avere estensione "+ext+",\n l'estensione accettata è jpg");
	document.getElementById("img_4").value="";
	document.getElementById("img_4").focus();
	return false;
	}
}
	
modulo.colori.value=newcolori;
modulo.misure.value=newmisure;
//alert(newcolori);
//return false;
modulo.action='mod_articolo.php';
return true;
}

function ControllaDoc(modulo)
{
if(modulo.Titolo.value=="" ){alert("Inserisci il Titolo del documento ");modulo.Titolo.focus();return false;}

if(document.modulo.action.value=='ins_doc' && document.getElementById('doc_1').value!=''){alert("Seleziona il file da caricare ");document.getElementById("doc_1").focus();return false;}

if(document.getElementById('doc_1').value!='')
			{
				var stringa=document.getElementById('doc_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("doc_1").value.substr(pos,3).toLowerCase();  
				//pdf,doc,wiz,xls,ppt,rtf,odt,odc,odd,xml,htm,html 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();;
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("doc_1").value="";
				document.getElementById("doc_1").focus();
				return false;
				}
			
			}
return true;}

function ControllaImg(modulo)
{
if(trim(modulo.Titolo.value)=="" ){alert("Inserisci il Titolo/Nome dell'immagine ");modulo.Titolo.focus();return false;}

if(modulo.action.value=='ins_immagine' && document.getElementById('img_1').value==''){alert("Seleziona il file da caricare ");document.getElementById("img_1").focus();return false;}

if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				//pdf,doc,wiz,xls,ppt,rtf,odt,odc,odd,xml,htm,html 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();;
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("img_1").value="";
				document.getElementById("img_1").focus();
				return false;
				}
			
			}
return true;}

function ControllaVideo(modulo)
{
if(trim(modulo.Titolo.value)=="" ){alert("Inserisci il Titolo/Nome del video ");modulo.Titolo.focus();return false;}

if(trim(modulo.Url.value)=="" ){alert("Inserisci l'indirizzo del video ");modulo.Url.focus();return false;}

//if(document.modulo.action.value=='ins_video' && document.getElementById('img_1').value!=''){alert("Seleziona il file da caricare ");document.getElementById("img_1").focus();return false;}

if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				//pdf,doc,wiz,xls,ppt,rtf,odt,odc,odd,xml,htm,html 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();;
				if(ext_accepted=="") ext_accepted="jpg";
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("img_1").value="";
				document.getElementById("img_1").focus();
				return false;
				}
			
			}
return true;}


function ControllaPartner(modulo)
{
	if(modulo.Titolo.value=="" ){alert("Inserisci nome del Partner ");modulo.Titolo.focus();return false;}
	
	/*if(document.getElementById('img_1').value=='')
	{
	alert("Inserisci il logo del Partner ");document.getElementById('img_1').focus();
	return false;
	}*/
	
			if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				if(ext=='jpg')
				{}
				//else if(ext=='png'){}
				else
				{
				alert("Le immagini non possono avere estensione "+ext+", l'estensione accettata è jpg");
				document.getElementById("img_1").value="";
				document.getElementById("img_1").focus();
				return false;
				}
			
			}
	modulo.action='xaction.php';
return true;
}

function ControllaPartner_bool(modulo)
{
	if(modulo.Titolo.value=="" ){return false;}
	
	
			if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				if(ext=='jpg')
				{}
				//else if(ext=='png'){}
				else
				{
				
				return false;
				}
			
			}
	modulo.action='xaction.php';
return true;
}


function ControllaBanner(modulo)
{
	//if(modulo.Titolo.value=="" ){alert("Inserisci nome del Banner ");modulo.Titolo.focus();return false;}
	
	if(document.getElementById('img_1').value=='' && modulo.action.value=='ins_banner')
	{
	alert("Inserisci l'immagine del Banner");document.getElementById('img_1').focus();
	return false;
	}
	
			if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				if(ext=='gif')
				{}
				else if(ext=='jpg'){}
				else
				{
				alert("Le immagini non possono avere estensione "+ext+", l'estensioni accettate sono: gif o jpg");
				document.getElementById("img_1").value="";
				document.getElementById("img_1").focus();
				return false;
				}
			
			}
	modulo.action='xaction.php';
return true;
}

function ControllaNew(modulo)
{
//if(modulo.testo.value==''){alert("Inserisci il testo della news");modulo.testo.focus();return false;}
if(trim(modulo.Data.value)=="" ){alert("Inserisci la data della notizia, si consiglia di inserire la data di inserimento (formato: GG/MM/AAAA)");modulo.Data.focus();return false;}/*
		var Data_str=modulo.Data.value;
		
		arr_Data=Data_str.split("/");

		Data=new Date(arr_Data[2],arr_Data[1]-1,arr_Data[0]);
		
		var oggi = new Date();
		oggi.setHours(0,0,0,0);	
		
		/*if (Data < oggi)
		{
			alert("La data della news non può essere antecedente a oggi (formato: GG/MM/AAAA)");modulo.Data.focus();return false;
		}*/
		
		
		/*	var DataFine_str=modulo.DataFine.value;
		if(DataFine_str!="")
		{		
			arr_DataFine=DataFine_str.split("/");
			
			
			DataFine=new Date(arr_DataFine[2],arr_DataFine[1]-1,arr_DataFine[0]);
			
			
			if (DataFine <= Data)
			{
				alert("La data di fine evento non può essere antecedente o uguale all'inizio (formato: GG/MM/AAAA)");modulo.DataFine.focus();return false;
			}
		}
		*/
	if(trim(modulo.Titolo.value)=="" ){alert("Inserisci il Titolo della news ");modulo.Titolo.focus();return false;}	
	if(trim(modulo.Testo.value)=="" ){alert("Inserisci il testo della news ");modulo.Testo.focus();return false;}	
	
	
	if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				if(ext=='jpg')
				{}
				//else if(ext=='png'){}
				else
				{
				alert("Le immagini non possono avere estensione "+ext+", l'estensione accettata è jpg");
				document.getElementById("img_1").value="";
				document.getElementById("img_1").focus();
				return false;
				}
			
			}
	/*
	if(document.getElementById('img_2').value!='')
			{
				var stringa=document.getElementById('img_2').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_2").value.substr(pos,3).toLowerCase();  
				if(ext=='jpg')
				{}
				//else if(ext=='png'){}
				else
				{
				alert("Le immagini non possono avere estensione "+ext+", l'estensione accettata è jpg");
				document.getElementById("img_2").value="";
				document.getElementById("img_2").focus();
				return false;
				}
			
			}
	
	if(document.getElementById('doc_1').value!='')
			{
				var stringa=document.getElementById('doc_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("doc_1").value.substr(pos,3).toLowerCase();  
				 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();;
				
				if(ext_accepted.search(ext)==-1){
				alert("Le immagini non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("doc_1").value="";
				document.getElementById("doc_1").focus();
				return false;
				}
			
			}
		*/
		//modulo.action='xaction.php';
return true;
}

function ControllaNew_bool(modulo)
{

if(trim(modulo.Data.value)=="" ){return false;}
	if(trim(modulo.Titolo.value)=="" ){return false;}	
	if(trim(modulo.Testo.value)=="" ){return false;}	
	
	
	if(document.getElementById('img_1').value!='')
			{
				var stringa=document.getElementById('img_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("img_1").value.substr(pos,3).toLowerCase();  
				if(ext=='jpg')
				{}
				//else if(ext=='png'){}
				else
				{
				
				return false;
				}
			
			}

return true;
}

function ControllaApp(modulo)
{

if(trim(modulo.Data.value)=="" ){alert("Inserisci la data dell'appuntamento (formato: GG/MM/AAAA)");modulo.Data.focus();return false;}/*
		var Data_str=modulo.Data.value;
		
		arr_Data=Data_str.split("/");

		Data=new Date(arr_Data[2],arr_Data[1]-1,arr_Data[0]);
		
		var oggi = new Date();
		oggi.setHours(0,0,0,0);	
		//alert(Data+" < "+oggi+"  diff"+diff);return false;
		
		
		//if (Data < oggi)
		/*if(diff > 1 )
		{
			alert("La data della news non può essere antecedente a oggi (formato: GG/MM/AAAA)");modulo.Data.focus();return false;
		}*/
		
		
		/*	var DataFine_str=modulo.DataFine.value;
		if(DataFine_str!="")
		{		
			arr_DataFine=DataFine_str.split("/");
			
			
			DataFine=new Date(arr_DataFine[2],arr_DataFine[1]-1,arr_DataFine[0]);
			
			if (DataFine <= Data)
			{
				alert("La data di fine evento non può essere antecedente o uguale all'inizio (formato: GG/MM/AAAA)");modulo.DataFine.focus();return false;
			}
		}
		*/

	if(trim(modulo.Testo.value)=="" ){alert("Inserisci la descrizione dell'appuntamento ");modulo.Testo.focus();return false;}	

return true;
}


function ControllaOff(modulo)
{
	if(document.getElementById('Membro')!=undefined)
	{
		if(document.getElementById('Membro').selectedIndex==0)
		{
		alert("Seleziona il Membro");modulo.Membro.focus();return false;
		}
	}

	if(modulo.Validita[1].checked==true)
	{
		//data e datafine
		if(modulo.Data.value=="" ){alert("Inserisci la data di inizio validità dell'Offerta, si consiglia di inserire la data di inserimento (formato: GG/MM/AAAA)");modulo.Data.focus();return false;}
			var Data_str=modulo.Data.value;
			arr_Data=Data_str.split("/");
			Data=new Date(arr_Data[2],arr_Data[1]-1,arr_Data[0]);
			Data=Data.getTime()/10000000;
			var oggi = new Date();
			oggi.setHours(0,0,0,0);
			diff=oggi-Data;
			//Data=Math.round(Data);
			//oggi=Math.round(oggi);
			/*
			if( diff > 1 )
			{
				alert("La data di inizio pubblicazione dell'Offerta non può essere antecedente a oggi (formato: GG/MM/AAAA)");modulo.Data.focus();return false;
			}
			*/
		if(modulo.DataFine.value=="" ){alert("Inserisci la data di fine validità dell'Offerta (formato: GG/MM/AAAA)");modulo.DataFine.focus();return false;}	
			var Data_str=modulo.Data.value;
			arr_Data=Data_str.split("/");
			Data=new Date(arr_Data[2],arr_Data[1]-1,arr_Data[0]);
			Data=Data.getTime();
			var DataFine_str=modulo.DataFine.value;
			arr_DataFine=DataFine_str.split("/");
			DataFine=new Date(arr_DataFine[2],arr_DataFine[1]-1,arr_DataFine[0]);
			DataFine=DataFine.getTime();
			diff2=Data-DataFine;
			diff2=Math.round(diff2);
			diff2=diff2/86400000;//giorni di differenza tra le due date
			//alert(diff2);return false;
			if( diff2 > 0 )
			{
				alert("La data di fine pubblicazione dell'Offerta ("+modulo.DataFine.value+") non può essere antecedente alla data di inizio pubblicazione ("+modulo.Data.value+") (formato: GG/MM/AAAA)");modulo.Data.focus();return false;
			}
	}
	
	if(modulo.Titolo.value=="" ){alert("Inserisci il Titolo dell'Offerta");modulo.Titolo.focus();return false;}	
	if(modulo.Testo.value=="" ){alert("Inserisci il testo di presentazione dell'Offerta ");modulo.Testo.focus();return false;}	
	
	if(modulo.name=='ins_offerta' && document.getElementById('doc_1').value=="")
		{alert("Inserisci il file ");document.getElementById('doc_1').focus();return false;}
	
	if(document.getElementById('doc_1').value!='')
			{
				var stringa=document.getElementById('doc_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("doc_1").value.substr(pos,3).toLowerCase();  
				 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();;
				
				if(ext_accepted.search(ext)==-1){
				alert("Le immagini non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("doc_1").value="";
				document.getElementById("doc_1").focus();
				return false;
				}
			
			}
return true;
}


function ControllaLink(modulo)
{
	if(modulo.Nome.value=="" ){alert("Inserisci il nome del link ");modulo.Nome.focus();return false;}
	if(modulo.Url.value=="" ){alert("Inserisci l'indirizzo del collegamento ipertestuale ");modulo.Url.focus();return false;}
return true;
}

function dis_new(id_new,attiva)
{
document.xnew.id.value=id_new;
document.xnew.attiva.value=''+attiva+'';
document.xnew.action='inc/attivanew.php';
document.xnew.submit();
}

function mod_new(id_new)
{
document.xnew.id.value=id_new;

//document.xnew.action='mod_news.php';
document.xnew.submit();
}

function Copertina(id)
{
document.del_xaction.id.value=id;
document.del_xaction.action.value='copertina';
document.del_xaction.c.value=1;
//document.del_xaction.action='xaction.php';
document.del_xaction.submit();
}

function ApriGalleria(id)
{
	document.archivio.id.value=id;
	document.archivio.action='gallerie.php';
	document.archivio.submit();
}

function ApriGalleria2(id)
{
	document.archivio.id.value=id;
	document.archivio.action='galleries.php';
	document.archivio.submit();
}

function ApriGallerie(c)
{
	document.archivio.id.value="";
	document.archivio.c.value=c;
	
	document.archivio.action='gallerie.php';
	document.archivio.submit();
}

function ApriGallerie2(c)
{
	document.archivio.id.value="";
	document.archivio.c.value=c;
	document.archivio.action='galleries.php';
	document.archivio.submit();
}

function ApriVideo(id)
{
	document.archivio.id.value=id;
	document.archivio.action='videos.php';
	document.archivio.submit();
}

function ApriScheda(id,pagina)
{
	document.archivio.id.value=id;
	document.archivio.action=pagina;
	document.archivio.submit();
}

function Modifica(id)
{
document.xnew.id.value=id;
document.xnew.submit();
}

function Elimina(where_value)
{
	if(!confirm("Sicuro di voler eliminare, e perdere definitivamente il record?")){}else{
		document.del_xaction.where.value=where_value;
		document.del_xaction.action.value="elimina";
		document.del_xaction.submit();
		}
}

function Pubblica(id,action)
{
	if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.id_news.value=id;
		document.xaction_publish.action.value=action;
		//document.xaction_publish.Responsabile.value=document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value;
		/*1.40D*/
		//document.xaction_publish.Responsabile.value=document.getElementById(id+'_sel_Responsabile').options[document.getElementById(id+'_sel_Responsabile').selectedIndex].value;
		document.xaction_publish.submit();
		}
}

function Pubblica_f1(id,action)
{
	document.getElementById(id+'_details').style.display='block';
	//document.getElementById(id+'_sel_resp').focus();
	//document.getElementById(id+'_sel_Responsabile').focus();
	
	/*if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{*/
		document.xaction_publish.id.value=id;
		document.xaction_publish.id_news.value=id;
		document.xaction_publish.action.value=action;
		/*document.xaction_publish.submit();
		}*/
}

function DelTmp(id,action)
{
	if(!confirm("Sicuro di voler annullare, e perdere definitivamente le modifiche apportate?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.id_news.value=id;
		document.xaction_publish.action.value=action;
		document.xaction_publish.submit();
		}
}
/*g_record*/
function Modifica_g_record(id,token_sezione)
{
document.form_current_g_record.id.value=id;
document.form_current_g_record.current_g_record.value=token_sezione;
document.form_current_g_record.submit();
}

function Inserisci_g_record(token_sezione)
{

document.form_current_g_record.id.value='';
document.form_current_g_record.current_g_record.value=token_sezione;
document.form_current_g_record.submit();
}

function Elimina_g_record(where_value,id_record)
{
	if(!confirm("Sicuro di voler eliminare, e perdere definitivamente il record?")){}else{
		document.del_xaction.where.value=where_value;
		document.del_xaction.current_id_record.value=id_record;
		document.del_xaction.action.value="elimina";
		document.del_xaction.submit();
		}
}

function Pubblica_g_record(id,action)
{
	
	if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.current_id_record.value=id;
		document.xaction_publish.action.value=action;
		document.xaction_publish.submit();
		}
}

function Pubblica_g_record_getResp_f1(id,action)
{
	document.getElementById(id+'_details').style.display='block';
	document.getElementById(id+'_sel_Curatore').focus();
	/*if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{*/
		document.xaction_publish.id.value=id;
		document.xaction_publish.current_id_record.value=id;
		document.xaction_publish.action.value=action;
		/*document.xaction_publish.submit();
		
		}*/
}

function Pubblica_g_record_getCuratori_f1(id,action)
{
	document.getElementById(id+'_details').style.display='block';
	//document.getElementById(id+'_sel_resp').focus();
	document.getElementById(id+'_sel_Responsabile').focus();
	
	/*if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{*/
		document.xaction_publish.id.value=id;
		document.xaction_publish.current_id_record.value=id;
		document.xaction_publish.action.value=action;
		/*document.xaction_publish.submit();
		
		}*/
}


function Pubblica_g_record_getResp_f2(id)
{
	
	if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.current_id_record.value=id;
		//alert(document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value);return false;
		//document.xaction_publish.Responsabile.value=document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value;
/*1.40d*/
		document.xaction_publish.Responsabile.value=document.getElementById(id+'_sel_Responsabile').options[document.getElementById(id+'_sel_Responsabile').selectedIndex].value;
		//document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value;
		//document.xaction_publish.action.value=action;
		document.xaction_publish.submit();
		}
		
}

function Pubblica_g_record_getCuratori_f2(id,action)/*1.53 aggiunto action*/
{
	
	if(!confirm("Sicuro di voler procedere con l'operazione?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.current_id_record.value=id;
		//alert(document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value);return false;
		//alert(document.getElementById(id+'_sel_Responsabile').options[document.getElementById(id+'_sel_Responsabile').selectedIndex].value);return false;
		/*Curatore, Immagini ...*/
		/*`Curatore`, `Immagini`, `Correzione1`, `Correzione2`, `FormatoTEI`, `FormatoBeta`, `Responsabile`*/
		document.xaction_publish.Curatore.value=document.getElementById(id+'_sel_Curatore').options[document.getElementById(id+'_sel_Curatore').selectedIndex].value;
		document.xaction_publish.Immagini.value=document.getElementById(id+'_sel_Immagini').options[document.getElementById(id+'_sel_Immagini').selectedIndex].value;
		document.xaction_publish.Correzione1.value=document.getElementById(id+'_sel_Correzione1').options[document.getElementById(id+'_sel_Correzione1').selectedIndex].value;
		document.xaction_publish.Correzione2.value=document.getElementById(id+'_sel_Correzione2').options[document.getElementById(id+'_sel_Correzione2').selectedIndex].value;
		document.xaction_publish.FormatoTEI.value=document.getElementById(id+'_sel_FormatoTEI').options[document.getElementById(id+'_sel_FormatoTEI').selectedIndex].value;
		document.xaction_publish.FormatoBeta.value=document.getElementById(id+'_sel_FormatoBeta').options[document.getElementById(id+'_sel_FormatoBeta').selectedIndex].value;
		document.xaction_publish.Responsabile.value=document.getElementById(id+'_sel_Responsabile').options[document.getElementById(id+'_sel_Responsabile').selectedIndex].value;
		//alert(document.getElementById(id+'_sel_Responsabile').options[document.getElementById(id+'_sel_Responsabile').selectedIndex].value);return false;
		//document.getElementById(id+'_sel_resp').options[document.getElementById(id+'_sel_resp').selectedIndex].value;
		/*1.53*/document.xaction_publish.action.value=action;
		document.xaction_publish.submit();
		}
}

function DelTmp_g_record(id,action)
{
	if(!confirm("Sicuro di voler annullare, e perdere definitivamente le modifiche apportate?")){}else{
		document.xaction_publish.id.value=id;
		document.xaction_publish.action.value=action;
		document.xaction_publish.submit();
		}
}


/*g_record*/

function Indietro()
{
	if(!confirm("Sicuro di voler tornare indietro, senza salvare le modifiche apportate?")){}else{
	document.back_xaction.submit();
	}
}

function Ancora(id_value,action_page)
{
	document.xaction.id.value=id_value;
	document.xaction.action=action_page;
	document.xaction.submit();
}

function del_new(id_new)
{
document.xnew.id.value=id_new;
document.xnew.action='inc/del_new.php';
document.xnew.submit();
}

function switch_lib(dir_img,id_cat)
{
var src_ico=document.getElementById('ico_'+id_cat).src;
	if(src_ico.indexOf('docs_open.gif') > 0)
	{
		document.getElementById('ico_'+id_cat).src=dir_img+'docs_closed.gif';
		document.getElementById('docs_'+id_cat).style.display='none';
		document.getElementById('ico_'+id_cat).alt="Espandi";
		document.getElementById('ico_'+id_cat).title="Espandi";
	}
	else if(src_ico.indexOf('docs_closed.gif') > 0)
	{
		document.getElementById('ico_'+id_cat).src=dir_img+'docs_open.gif';
		document.getElementById('docs_'+id_cat).style.display='block';
		document.getElementById('ico_'+id_cat).alt="Contrai";
		document.getElementById('ico_'+id_cat).title="Contrai";
	}
}

function controllaReqinfo(modulo)
{
if(modulo.nominativo.value==''){alert("Inserisci il tuo nominativo");modulo.nominativo.focus();return false;}
if(!mailcheck(modulo.email.value)){alert("Inserisci un indirizzo di posta elettronica corretto");modulo.email.focus();return false;}
if(modulo.ptel.value=='' || modulo.ntel.value==''){alert("Inserisci un contatto telefonico compilando corretamente i campi");modulo.ptel.focus();return false;}
if(modulo.oggetto.value==''){alert("Inserisci l'oggetto del messaggio");modulo.oggetto.focus();return false;}
if(modulo.messaggio.value==''){alert("Inserisci il testo del messaggio");modulo.messaggio.focus();return false;}
return true;
}

function vis_codice(checkato,ildiv)
{
//alert(checkato);
if(checkato=='true' || checkato==true)
	{
	document.getElementById(''+ildiv+'').style.visibility='visible';
	}
else if(checkato=='false' || checkato==false)
	{
	document.getElementById(''+ildiv+'').style.visibility='hidden';
	}
}

/*function start_vis_codice(checkato,ildiv)
{
//alert(checkato);
if(checkato=='true' || checkato==true)
	{
	document.getElementById(ildiv).style.visibility='visible';
	}
else if(checkato=='false' || checkato==false)
	{
	document.getElementById(ildiv).style.visibility='hidden';
	}
}*/



function controllaPersonal(modulo)
{
//'titolo' => $dato[1],'p_nome' => $dato[2],'p_cognome' => $dato[3],'ind1' => $dato[4],'ind2' => $dato[5],'ind3' => $dato[6],'ind4' => $dato[7],'paese' => $dato[8],'email' => $dato[9],'pte11' => $dato[10],'ntel1' => $dato[11],'ptel2' => $dato[12],'ntel2' => $dato[13]
if(modulo.p_nome.value==''){modulo.p_nome.focus();return false;}
if(modulo.p_cognome.value==''){modulo.p_cognome.focus();return false;}
if(modulo.ind1.value==''){modulo.ind1.focus();return false;}
if(modulo.ind2.value==''){modulo.ind2.focus();return false;}
if(modulo.ind3.value==''){modulo.ind3.focus();return false;}
if(modulo.ind4.value==''){modulo.ind4.focus();return false;}
if(modulo.paese.selectedIndex==0){modulo.paese.focus();return false;}
if(modulo.email.value==''){modulo.email.focus();return false;}
if(modulo.ptel1.value==''){modulo.ptel1.focus();return false;}
if(modulo.ntel1.value==''){modulo.ntel1.focus();return false;}
modulo.action='spedizione.php';
modulo.submit();
return true;
}

function controllaSpedizione()
{
//same, ind1, ind2, ind3, ind4, paese, consegna
		document.getElementById('ind1').disabled=false;
		document.getElementById('ind2').disabled=false;
		document.getElementById('ind3').disabled=false;
		document.getElementById('ind4').disabled=false;
		document.getElementById('paese').disabled=false;
if(document.spedizione.same.checked==false && document.spedizione.ind1.value==''){document.spedizione.ind1.focus();return false;}
if(document.spedizione.same.checked==false && document.spedizione.ind2.value==''){document.spedizione.ind2.focus();return false;}
if(document.spedizione.same.checked==false && document.spedizione.ind3.value==''){document.spedizione.ind3.focus();return false;}
if(document.spedizione.same.checked==false && document.spedizione.ind4.value==''){document.spedizione.ind4.focus();return false;}
if(document.spedizione.same.checked==false && document.spedizione.paese.selectedIndex==0){document.spedizione.paese.focus();return false;}
if(document.spedizione.consegna.value==''){document.spedizione.consegna.focus();return false;}

document.spedizione.action='conferma.php';
document.spedizione.submit();
return true;
}

function sameaspersonal()
{
//ind1, ind2, ind3, ind4, paese
	if(document.getElementById('same').checked==false)
	{
		
		document.getElementById('ind1').disabled=false;
		document.getElementById('ind2').disabled=false;
		document.getElementById('ind3').disabled=false;
		document.getElementById('ind4').disabled=false;
		document.getElementById('paese').disabled=false;
	}
	else if(document.getElementById('same').checked==true)
	{
		document.getElementById('ind1').disabled=true;
		document.getElementById('ind2').disabled=true;
		document.getElementById('ind3').disabled=true;
		document.getElementById('ind4').disabled=true;
		document.getElementById('paese').disabled=true;
	}
}


function switch_Permessi(Permesso,valore)//Permesso= LimitaI, LimitaV; valore= N, T, M
{
	if(valore=='T')
	{
	document.getElementById(Permesso+'_'+valore).disabled=false;
	document.getElementById(Permesso+'_M').disabled=true;
	}
	else if(valore=='M')
	{
	document.getElementById(Permesso+'_'+valore).disabled=false;
	document.getElementById(Permesso+'_T').disabled=true;
	}
	else
	{
	document.getElementById(Permesso+'_M').disabled=true;
	document.getElementById(Permesso+'_T').disabled=true;
	}
}

function switch_Validita(modulo)
{
	//alert(modulo);return;
	if(document.forms[modulo].Validita[0].checked==true)
	{
	document.getElementById('Data').disabled=true;
	document.getElementById('DataFine').disabled=true;
	document.getElementById('box_date').style.color='#A1A1A1';
	}
	else if(document.forms[modulo].Validita[1].checked==true)
	{
	document.getElementById('Data').disabled=false;
	document.getElementById('DataFine').disabled=false;
	document.getElementById('box_date').style.color='#000';
	}
//return true;
}


function getxmlData(id_cliente)
{
var i;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlHttp.onreadystatechange=function()
  {
  if (xmlHttp.readyState==4 && xmlHttp.status==200)
    {
    document.getElementById("dati_cliente_1").innerHTML=xmlHttp.responseText;
	//
	if(id_cliente!='new' && id_cliente!='')
	{	
			for(i=0;i<document.getElementById('c1').length;i++)
			{
			 if(id_cliente==document.getElementById('c1').options[i].value)
					{document.getElementById('c1').selectedIndex=i;}
			}
	}
			
	
	if(document.getElementById("fatt_sugg").value!='')
		{ 
			var toSel="";
			for(i=0;i<document.getElementById('c2').length;i++)
			{
			 if(document.getElementById("fatt_sugg").value==document.getElementById('c2').options[i].value)
					{toSel=i;}
			}
			document.getElementById('c2').selectedIndex=toSel;
			
			
			
			getDatiCliente2(document.getElementById("fatt_sugg").value);
		}
    }
  }
  

if(document.form1.CdInd.value!=undefined )
{
//alert(document.form1.CdInd.value);
  
var cdindsel=document.form1.CdInd.selectedIndex;

var cdind=document.form1.CdInd.options[cdindsel].value;
}

xmlHttp.open("GET","inc/send_dati_cliente.php?id="+id_cliente+"&sufx=c1&cdind="+cdind,true);
xmlHttp.send();
	
}

function getxmlData2(id_cliente)
{


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp2=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlHttp2.onreadystatechange=function()
  {
  if (xmlHttp2.readyState==4 && xmlHttp2.status==200)
    {
    document.getElementById("dati_cliente_2").innerHTML=xmlHttp2.responseText;
    }
  }
  
//var cdind=document.getElementById("CdInd").value;
  
xmlHttp2.open("GET","inc/send_dati_cliente2.php?id="+id_cliente+"&sufx=c2",true);
xmlHttp2.send();
	
}


function getResultArt(codice_art,focuscampo)
{

if(focuscampo==""){focuscampo="prezzo";}

if(focuscampo=="prezzo_listino"){focuscampo="prezzo";}

if(codice_art.length==0)
{
codice_art='null';
}

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp2=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlHttp2.onreadystatechange=function()
  {
  if (xmlHttp2.readyState==4 && xmlHttp2.status==200)
    {
		if(xmlHttp2.responseText!="" && xmlHttp2.responseText!=null){
		//document.getElementById(focuscampo).focus();
		document.getElementById("result_art").innerHTML=xmlHttp2.responseText;
		/*if(focuscampo=="codice"){}else{
		document.getElementById(focuscampo).focus();}*/
		//document.getElementById(focuscampo).focus();
		/*if(focuscampo=="codice" && document.getElementById('reqcodice').value==document.getElementById('codice').value)
		{
		document.getElementById('prezzo_listino').value=document.getElementById('prezzo_base').value;
		}*/
		document.getElementById(focuscampo).focus();
		}
    }
  }
  //if(focuscampo=="codice"){}else{
		//document.getElementById(focuscampo).focus();
		//}
  if(document.getElementById('reqcodart')!=null) {var reqcodice=document.getElementById('reqcodart').value;}
  var sconto1_perc=document.getElementById('sconto1_perc').value;
  var sconto2_perc=document.getElementById('sconto2_perc').value;
  //if(document.getElementById('prezzo').value!=document.getElementById('prezzo_listino').value)
  var prezzo_base=document.getElementById('prezzo_base').value;
  var prezzo=document.getElementById('prezzo').value;
  var quantita=document.getElementById('quantita').value;
  var sconto_merce=document.getElementById('sconto_merce').value;
  var idordine=document.getElementById('idordine').value;
  var data_consegna=document.getElementById('data_consegna').value;
  var indice=document.getElementById('indice').value;
	
	//document.getElementById(focuscampo).focus();
	
xmlHttp2.open("GET","inc/calcola_art.php?id="+codice_art+"&sconto1_perc="+sconto1_perc+"&sconto2_perc="+sconto2_perc+"&quantita="+quantita+"&sconto_merce="+sconto_merce+"&idordine="+idordine+"&data_consegna="+data_consegna+"&indice="+indice+"&prezzo="+prezzo+"&focuscampo="+focuscampo+"&prezzo_base="+prezzo_base+"&reqcodice="+reqcodice,true);


xmlHttp2.send();


}


function checkModuloArticolo(modulo)
{
		if(modulo.codice.value==""){modulo.codice.focus();return false;}
		if(modulo.prezzo.value==""  || modulo.prezzo.value<0){modulo.prezzo.focus();return false;}
		if(modulo.quantita.value==""){modulo.quantita.focus();return false;}
		if(modulo.sconto_merce.value==""){modulo.sconto_merce.focus();return false;}
		if((modulo.quantita.value + modulo.sconto_merce.value)<=0){modulo.sconto_merce.focus();return false;}
		if(modulo.sconto1_perc.value=="" || modulo.sconto1_perc.value>=100 || modulo.sconto1_perc.value<0){modulo.sconto1_perc.focus();return false;}
		if(modulo.sconto2_perc.value=="" || modulo.sconto2_perc.value>=100|| modulo.sconto1_perc.value<0){modulo.sconto2_perc.focus();return false;}
		//valida data consegna
		var data_ordine_str=modulo.data_ordine.value;
		
		arr_data_ordine=data_ordine_str.split("/");

		data_ordine=new Date(arr_data_ordine[2],arr_data_ordine[1]-1,arr_data_ordine[0]);
		
		var oggi = new Date();
		var ieri = new Date();
		ieri.setDate(oggi.getDate()-1);		
		
		data_ordine=data_ordine.getTime();
		ieri=ieri.getTime();
		
		var data_consegna_str=modulo.data_consegna.value;
		arr_data_consegna=data_consegna_str.split("/");

		data_consegna=new Date(arr_data_consegna[2],arr_data_consegna[1]-1,arr_data_consegna[0]);
		
		data_consegna=data_consegna.getTime();
		
		//alert(data_consegna+" < "+data_ordine);
		
		if (data_consegna < data_ordine)
		{
			alert("La data di consegna non può essere antecedente alla data di ordine (formato: GG/MM/AAAA)");modulo.data_consegna.focus();return false;
		}
		
modulo.action='inc/ins_tmp_art_ordine.php';
modulo.submit();
return true;}


function checkModuloArticoloMod(modulo)
{

		if(modulo.codice.value==""){modulo.codice.focus();return false;}
		if(modulo.quantita.value==""){modulo.quantita.focus();return false;}
		if(modulo.sconto_merce.value==""){modulo.sconto_merce.focus();return false;}
		if((modulo.quantita.value + modulo.sconto_merce.value)<=0){modulo.sconto_merce.focus();return false;}
		if(modulo.sconto1_perc.value=="" || modulo.sconto1_perc.value>=100){modulo.sconto1_perc.focus();return false;}
		if(modulo.sconto2_perc.value=="" || modulo.sconto2_perc.value>=100){modulo.sconto2_perc.focus();return false;}
		//valida data consegna
		var data_ordine_str=modulo.data_ordine.value;
		
		arr_data_ordine=data_ordine_str.split("/");

		data_ordine=new Date(arr_data_ordine[2],arr_data_ordine[1]-1,arr_data_ordine[0]);
		
		var oggi = new Date();
		var ieri = new Date();
		ieri.setDate(oggi.getDate()-1);		
		
		data_ordine=data_ordine.getTime();
		ieri=ieri.getTime();
		
		var data_consegna_str=modulo.data_consegna.value;
		arr_data_consegna=data_consegna_str.split("/");

		data_consegna=new Date(arr_data_consegna[2],arr_data_consegna[1]-1,arr_data_consegna[0]);
		
		data_consegna=data_consegna.getTime();
		
		//alert(data_consegna+" < "+data_ordine);
		
		if (data_consegna < data_ordine)
		{
			alert("La data di consegna non può essere antecedente alla data di ordine (formato: GG/MM/AAAA)");modulo.data_consegna.focus();return false;
		}
		
		/*if(modulo.codice.value==""){modulo.codice.focus();return false;}
		if(modulo.quantita.value=="" || modulo.quantita.value<=0){modulo.quantita.focus();return false;}
		if(modulo.sconto_merce.value=="" || (modulo.quantita.value-modulo.sconto_merce.value)<=0){modulo.sconto_merce.focus();return false;}
		if(modulo.sconto1_perc.value=="" || modulo.sconto1_perc.value>=100){modulo.sconto1_perc.focus();return false;}
		if(modulo.sconto2_perc.value=="" || modulo.sconto2_perc.value>=100){modulo.sconto2_perc.focus();return false;}*/
		
modulo.action='inc/mod_tmp_art_ordine.php';
modulo.submit();
return true;}


function checkModuloNote(modulo)
{
		//if(modulo.note_documento.value==""){modulo.note_documento.focus();return false;}
		//if(modulo.note_commerciali.value==""){modulo.note_commerciali.focus();return false;}

modulo.action='inc/ins_ordine_f3_save.php';
modulo.submit();		
}

function modIndice(indice,idordine)
{
	document.xaction.ordine.value=idordine;
	document.xaction.indice.value=indice;
	document.xaction.submit();
}

function DeleteTmpArt(indice,ordine)
{
	document.xaction.ordine.value=ordine;
	document.xaction.indice.value=indice;
	document.xaction.action='inc/del_tmp_art_ordine.php';
	document.xaction.submit();
}


function checkModuloClienti(modulo)
{
		if(modulo.data_ordine.value=="" ){alert("Inserisci la data dell'ordine (formato: GG/MM/AAAA)");modulo.data_ordine.focus();return false;}
		//controllo data ordine
		
		var data_ordine_str=modulo.data_ordine.value;
		
		arr_data_ordine=data_ordine_str.split("/");

		data_ordine=new Date(arr_data_ordine[2],arr_data_ordine[1]-1,arr_data_ordine[0]);
		
		var oggi = new Date();
		var ieri = new Date();
		ieri.setDate(oggi.getDate()-1);		
		
		data_ordine=data_ordine.getTime();
		ieri=ieri.getTime();

		//alert(data_ordine+" < "+ieri+");
		
		if (data_ordine > oggi)
		{
			alert("La data dell'ordine non può essere successiva a oggi (formato: GG/MM/AAAA)");modulo.data_ordine.focus();return false;
		}
		
		if (data_ordine < ieri)
		{
			alert("La data dell'ordine non può essere antecedente a ieri (formato: GG/MM/AAAA)");modulo.data_ordine.focus();return false;
		}
		
		//if(modulo.stato.selectedIndex==0){alert("Seleziona lo stato dell'ordine");modulo.stato.focus();return false;}
		if(modulo.c1_code.value!="" && modulo.c1.selectedIndex==0)
		{
			for(var i=0;i<modulo.c1.length;i++)
			{
			 if(modulo.c1_code.value==modulo.c1.options[i].value){modulo.c1.selectedIndex=i;}
			}
		}
		
		if(modulo.c1.selectedIndex==0)
		{
			if(modulo.c1_ragione_sociale.value==""){alert("Inserisci la ragione sociale");modulo.c1_ragione_sociale.focus();return false;}
			//if(modulo.c1_ragione_sociale_2.value==""){alert("Inserisci la ragione sociale");modulo.c1_ragione_sociale_2.focus();return false;}
			if(modulo.c1_indirizzo.value==""){alert("Inserisci l'indirizzo");modulo.c1_indirizzo.focus();return false;}
			if(modulo.c1_cap.value=="" || modulo.c1_cap.length>5){alert("Inserisci il cap");modulo.c1_cap.focus();return false;}
			if(modulo.c1_citta.value==""){alert("Inserisci la città");modulo.c1_citta.focus();return false;}
			if(modulo.c1_provincia.selectedIndex==0){alert("Seleziona la provincia");modulo.c1_provincia.focus();return false;}
			//if(modulo.c1_piva.value==""){alert("Inserisci la partita IVA");modulo.c1_piva.focus();return false;}
			//ControllaPIVA(modulo.c1_piva.value);
			if(modulo.c1_piva.value!="")
				{
				if(!ControllaPIVA(modulo.c1_piva.value)){modulo.c1_piva.focus();return false;}
				}
			//if(modulo.c1_cfiscale.value==""){alert("Inserisci il codice fiscale");modulo.c1_cfiscale.focus();return false;}
			//ControllaCF(modulo.c1_cfiscale.value);
			if(trim(modulo.c1_cfiscale.value)!="")
				{
					var stringa=trim(modulo.c1_cfiscale.value);
					var primocarattere=stringa.slice(0,1);
					var validacon="";
					var numeri = "0123456789";
					//if( modulo.c1_cfiscale.value.length == 11 )
					for( i = 0; i < numeri.length; i++ )
					{
						if( primocarattere == numeri.charAt(i) )
						{
						validacon="PIVA";
						}
						
					}
					
					var lettere = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
					
					for( i = 0; i < lettere.length; i++ )
					{
						if( primocarattere == lettere.charAt(i) )
						{
						validacon="CF";
						}
						
					}
					
					
					if(validacon=="PIVA")
					{
						if(!ControllaPIVA(modulo.c1_cfiscale.value))
						{
						modulo.c1_cfiscale.focus();
						return false;
						}
					}
					else if(validacon=="CF")
					{
						if(!ControllaCF(modulo.c1_cfiscale.value))
						{
						modulo.c1_cfiscale.focus();
						return false;
						}
					}
					else
					{
					alert("Inserisci il codice fiscale correttamente");
					modulo.c1_cfiscale.focus();
					return false;
					}
				
				}
			/*if(!ControllaTel(modulo.c1_tel.value) && modulo.c1_tel.value!=""){alert("Inserisci il numero di telefono in modo corretto (caratteri consentiti . , - +) ");modulo.c1_tel.focus();return false;}
			if(!ControllaTel(modulo.c1_fax.value) && modulo.c1_fax.value!=""){alert("Inserisci il numero di fax in modo corretto (caratteri consentiti . , - +) ");modulo.c1_fax.focus();return false;}*/
			if(!ControllaMail(modulo.c1_email.value) && modulo.c1_email.value!=""){alert("Inserisci il numero di fax in modo corretto (caratteri consentiti . , - +) ");modulo.c1_email.focus();return false;}
			
			if(modulo.c1_abi.value==""){alert("Inserisci il codice ABI");modulo.c1_abi.focus();return false;}
			if(modulo.c1_cab.value==""){alert("Inserisci il codice CAB");modulo.c1_cab.focus();return false;}
			if(modulo.c1_banca.value==""){alert("Inserisci la descrizione della Banca");modulo.c1_banca.focus();return false;}
			
			
			
		}else
		{
		
		var c1_abicab=''+modulo.c1_abi.value+''+modulo.c1_cab.value+'';
		if(document.getElementById('c1_pre_abicab').value!=c1_abicab)
		{
			if(modulo.c1_abi.value==""){alert("Inserisci il codice ABI");modulo.c1_abi.focus();return false;}
			if(modulo.c1_cab.value==""){alert("Inserisci il codice CAB");modulo.c1_cab.focus();return false;}
			if(modulo.c1_banca.value==""){alert("Inserisci la descrizione della Banca");modulo.c1_banca.focus();return false;}
			
			
		}
			if(modulo.CdInd.length>1 && modulo.CdInd.selectedIndex==0){alert("Seleziona l'indirizzo di cosegna");modulo.CdInd.focus();return false;}
		}
		

		if(modulo.data_consegna.value==""){alert("Inserisci la data di consegna dell'ordine prevista");modulo.data_consegna.focus();return false;}
		//controllo data consegna
		var data_consegna_str=modulo.data_consegna.value;
		arr_data_consegna=data_consegna_str.split("/");

		data_consegna=new Date(arr_data_consegna[2],arr_data_consegna[1]-1,arr_data_consegna[0]);
		
		data_consegna=data_consegna.getTime();
		
		//alert(data_consegna+" < "+data_ordine);
		
		if (data_consegna < data_ordine)
		{
			alert("La data di consegna non può essere antecedente alla data di ordine (formato: GG/MM/AAAA)");modulo.data_consegna.focus();return false;
		}
		
		
		
		
		if(modulo.c2.selectedIndex==0)
		{
			if(modulo.c2_ragione_sociale.value==""){alert("Inserisci la ragione sociale");modulo.c2_ragione_sociale.focus();return false;}
			//if(modulo.c2_ragione_sociale_2.value==""){alert("Inserisci la ragione sociale");modulo.c2_ragione_sociale_2.focus();return false;}
			if(modulo.c2_indirizzo.value==""){alert("Inserisci l'indirizzo");modulo.c2_indirizzo.focus();return false;}
			if(modulo.c2_cap.value=="" || modulo.c2_cap.length>5){alert("Inserisci il cap");modulo.c2_cap.focus();return false;}
			if(modulo.c2_citta.value==""){alert("Inserisci la città");modulo.c2_citta.focus();return false;}
			if(modulo.c2_provincia.selectedIndex==0){alert("Seleziona la provincia");modulo.c2_provincia.focus();return false;}
			if(modulo.c2_piva.value!="")
				{
				if(!ControllaPIVA(modulo.c2_piva.value)){modulo.c2_piva.focus();return false;}
				}
			//if(modulo.c1_cfiscale.value==""){alert("Inserisci il codice fiscale");modulo.c1_cfiscale.focus();return false;}
			//ControllaCF(modulo.c1_cfiscale.value);
			if(trim(modulo.c2_cfiscale.value)!="")
				{
					var stringa=trim(modulo.c2_cfiscale.value);
					var primocarattere=stringa.slice(0,1);
					var numeri = "0123456789";
					var validacon="";
					//if( modulo.c1_cfiscale.value.length == 11 )
					for( i = 0; i < numeri.length; i++ )
					{
						if( primocarattere == numeri.charAt(i) )
						{
						validacon="PIVA";
						}
						
					}
					
					var lettere = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
					
					for( i = 0; i < lettere.length; i++ )
					{
						if( primocarattere == lettere.charAt(i) )
						{
						validacon="CF";
						}
						
					}

					if(validacon=="PIVA")
					{
						if(!ControllaPIVA(modulo.c2_cfiscale.value))
						{
						modulo.c2_cfiscale.focus();
						return false;
						}
					}
					else if(validacon=="CF")
					{
						if(!ControllaCF(modulo.c2_cfiscale.value))
						{
						modulo.c2_cfiscale.focus();
						return false;
						}
					}
					else
					{
					alert("Inserisci il codice fiscale correttamente");
					modulo.c2_cfiscale.focus();
					return false;
					}
				
				}
			/*if(!ControllaTel(modulo.c2_tel.value) && modulo.c2_tel.value!=""){alert("Inserisci il numero di telefono in modo corretto (caratteri consentiti . , - +) ");modulo.c2_tel.focus();return false;}
			if(!ControllaTel(modulo.c2_fax.value) && modulo.c2_fax.value!=""){alert("Inserisci il numero di fax in modo corretto (caratteri consentiti . , - +) ");modulo.c2_fax.focus();return false;}*/
			if(!ControllaMail(modulo.c2_email.value) && modulo.c2_email.value!=""){alert("Inserisci il numero di fax in modo corretto (caratteri consentiti . , - +) ");modulo.c2_email.focus();return false;}
			if(modulo.c2_abi.value==""){alert("Inserisci il codice ABI");modulo.c2_abi.focus();return false;}
			if(modulo.c2_cab.value==""){alert("Inserisci il codice CAB");modulo.c2_cab.focus();return false;}
			if(modulo.c2_banca.value==""){alert("Inserisci la descrizione della Banca");modulo.c2_banca.focus();return false;}
		}
		else
		{

		/*if(modulo.c2_abi.value==""){alert("Inserisci il codice ABI");modulo.c2_abi.focus();return false;}
		if(modulo.c2_cab.value==""){alert("Inserisci il codice CAB");modulo.c2_cab.focus();return false;}*/

		var c2_abicab=''+modulo.c2_abi.value+''+modulo.c2_cab.value+'';
		if(document.getElementById('c2_pre_abicab').value!=c2_abicab)
		{
			if(modulo.c2_abi.value==""){alert("Inserisci il codice ABI");modulo.c2_abi.focus();return false;}
			if(modulo.c2_cab.value==""){alert("Inserisci il codice CAB");modulo.c2_cab.focus();return false;}
			if(modulo.c2_banca.value==""){alert("Inserisci la descrizione della Banca");modulo.c2_banca.focus();return false;}
		}
		
		}
modulo.submit();
return true;}

function checkABICAB(sufx)
{
	//alert(sufx+'_abi');
	var abi=document.getElementById(sufx+'_abi').value;
	var cab=document.getElementById(sufx+'_cab').value;
	var abicab=''+trim(abi)+''+trim(cab)+'';
	//alert(abicab);
	//alert('box_'+sufx+'_banca');
	if(document.getElementById(sufx+'_pre_abicab').value!=abicab)
	{
		
		document.getElementById('box_'+sufx+'_banca').style.visibility='visible';
		document.getElementById(sufx+'_ast_abi').style.visibility='visible';
		document.getElementById(sufx+'_ast_cab').style.visibility='visible';
	}
	else
	{
		document.getElementById('box_'+sufx+'_banca').style.visibility='hidden';
		document.getElementById(sufx+'_ast_abi').style.visibility='hidden';
		document.getElementById(sufx+'_ast_cab').style.visibility='hidden';
	}
}


function selectCliente(codicecli,idcampo)
{
	//alert(codicecli);
	//alert(idcampo);
	//alert(document.getElementById(idcampo).options[document.getElementById(idcampo).selectedIndex].value);
	for(i=0;i<document.getElementById(idcampo).length;i++)
	{
	if(document.getElementById(idcampo).options[i].value==codicecli)
		{//alert(document.getElementById(idcampo).options[i].value+"=="+codicecli);
		document.getElementById(idcampo).selectedIndex=i;
		}
	}
}

function ChangeCampo(nuovovalore,campo)
{
	//alert(campo);
	//alert(document.getElementById(''+ilcampo+'').value);
	document.getElementById(campo).value=nuovovalore;
}


function cutcodice(value)
{
	if(value!="")
	{
		if(value.indexOf(" ")>0)
		{
		//Hello world
		//pos 5+1 lung 11
		var lung=value.length;
		
		var pos1=value.indexOf(" ");
		var new_val=value.substr(0,(pos1));
		//alert("pos1["+pos1+"] length["+lung+"] new_val["+new_val+"]");
			if(document.getElementById('codice').value!=new_val)
			{
			document.getElementById('codice').value=new_val;
			//document.getElementById('prezzo').focus();
			//document.getElementById('prezzo_listino').value=document.getElementById('prezzo_base').value;
			}
		}
	
	}
	
}

function cambia_codice(codiceval)
{
//document.getElementById('prezzo').value=document.getElementById('prezzo_base').value;
document.getElementById('codice').value=codiceval;
}

function getDatiCliente(option_val)
{//ragione_sociale, ragione_sociale_2, indirizzo, cap, citta, provincia, piva, cfiscale, tel, fax, email, note_chiusura,  note_pagamento, abi, cab
			
			
			
			/**/
			var toSel="";
			for(var i=0;i<document.getElementById('c1').length;i++)
			{
			 if(option_val==document.getElementById('c1').options[i].value || document.getElementById('c1_code').value==document.getElementById('c1').options[i].value || document.form1.c1_code.value==document.form1.c1.options[i].value)
					{
					toSel=i;
					document.getElementById('c1').selectedIndex=toSel;
						if(option_val!="new")
						{
						document.getElementById('c1_code').value=option_val;
						}
						
					}
			}
			
			if(toSel==""){document.getElementById('c1').selectedIndex=0;}
			
			if(document.getElementById('c1_code').value=="new")document.getElementById('c1_code').value="";
			
			//if(toSel==""){return;}
			
			
			
			getxmlData(option_val);
		
}

function checkClienteCons()
{
var codice=document.getElementById('c1_code').value;
var curr_codice=document.getElementById('c1').options[document.getElementById('c1').selectedIndex].value
		if(codice!="")
		{
		codice=eval(document.getElementById('c1_code').value);
			var toSel="";
			for(var i=0;i<document.getElementById('c1').length;i++)
			{
			curr_codice=document.getElementById('c1').options[i].value;
			 if(codice==curr_codice)
					{
					
					toSel=i;
					document.getElementById('c1').selectedIndex=toSel;
						/*if(document.getElementById('c1_code').value!="new")
						{
						document.getElementById('c1_code').value=option_val;
						}*/
					}
			}
			
			if(toSel==""){document.getElementById('c1').selectedIndex=0;}
			
			//if(document.getElementById('c1_code').value=="new")document.getElementById('c1_code').value="";
		}
}

function getDatiCliente2(option_val)
{//ragione_sociale, ragione_sociale_2, indirizzo, cap, citta, provincia, piva, cfiscale, tel, fax, email, note_chiusura,  note_pagamento, abi, cab

			var toSel="";
			for(var i=0;i<document.getElementById('c2').length;i++)
			{
			 if(option_val==document.getElementById('c2').options[i].value || document.getElementById('c2_code').value==document.getElementById('c2').options[i].value)
					{
					
					toSel=i;
					document.getElementById('c2').selectedIndex=toSel;
					if(option_val!="new")
					{
					document.getElementById('c2_code').value=option_val;
					}
					
					}
			}
			
			if(toSel==""){document.getElementById('c2').selectedIndex=0;}
			
			if(document.getElementById('c2_code').value=="new")document.getElementById('c2_code').value="";
			
			//if(toSel==""){return;}
			
			
			
			getxmlData2(option_val);
	
}


/*function getDatiCliente3(option_val)
{//ragione_sociale, ragione_sociale_2, indirizzo, cap, citta, provincia, piva, cfiscale, tel, fax, email, note_chiusura,  note_pagamento, abi, cab

			var toSel="";
			for(i=0;i<document.getElementById('c2').length;i++)
			{
			 if(option_val==document.getElementById('c2').options[i].value)
					{
					
					toSel=i;
					document.getElementById('c2').selectedIndex=toSel;
					if(option_val!="new")
					{
					document.getElementById('c2_code').value=option_val;
					}
					
					}
			}
			
			if(toSel==""){document.getElementById('c2').selectedIndex=0;}
			
			if(document.getElementById('c2_code').value=="new")document.getElementById('c2_code').value="";
			
			//if(toSel==""){return;}
			
			
			
			getxmlData2(option_val);
	
}*/

function checkdefault(idinput,value,value_def)
{
if(value==''){document.getElementById(idinput).value=value_def;}
else{}
}

function checkTempo(idinput,value,value_def)
{
if(value=='' || value<5 || value>30){document.getElementById(idinput).value=value_def;}
}


function CopiaDatiCliente()
{
	document.form1.duplicato.value='si';
	document.form1.c1_code.value="";
	document.form1.c2_code.value="";
	document.form1.c2.SelectedIndex=0;
	document.form1.c1.SelectedIndex=0;
	document.form1.c2_ragione_sociale.value=document.form1.c1_ragione_sociale.value;
	document.form1.c2_indirizzo.value=document.form1.c1_indirizzo.value;
	document.form1.c2_cap.value=document.form1.c1_cap.value;
	document.form1.c2_citta.value=document.form1.c1_citta.value;
	document.form1.c2_provincia.value=document.form1.c1_provincia.value;
	document.form1.c2_piva.value=document.form1.c1_piva.value;
	document.form1.c2_cfiscale.value=document.form1.c1_cfiscale.value;
	document.form1.c2_tel.value=document.form1.c1_tel.value;
	document.form1.c2_fax.value=document.form1.c1_fax.value;
	document.form1.c2_email.value=document.form1.c1_email.value;
	//alert(document.form1.c1_chiusura1.selectedIndex);
	document.form1.c2_chiusura1.selectedIndex=document.form1.c1_chiusura1.selectedIndex;
	document.form1.c2_chiusura2.selectedIndex=document.form1.c1_chiusura2.selectedIndex;
	document.form1.c2_pagamento.selectedIndex=document.form1.c1_pagamento.selectedIndex;
	document.form1.c2_abi.value=document.form1.c1_abi.value;
	document.form1.c2_cab.value=document.form1.c1_cab.value;
	document.form1.c2_banca.value=document.form1.c1_banca.value;
}

function switch_legend()
{
	if(document.getElementById('legenda').style.display=='none')
	{
		document.getElementById('legenda').style.display='block';
		document.getElementById('switch_legend').innerHTML='Nascondi legenda pulsanti';
	}
	else
	{
		document.getElementById('legenda').style.display='none';
		document.getElementById('switch_legend').innerHTML='Visualizza legenda pulsanti';
	}
}

function switch_guida(id_box_guida)
{
	if(document.getElementById(id_box_guida).style.display=='none')
	{
		document.getElementById(id_box_guida).style.display='block';
		document.getElementById('switch_guida').innerHTML='Nascondi la Guida';
	}
	else
	{
		document.getElementById(id_box_guida).style.display='none';
		document.getElementById('switch_guida').innerHTML='Visualizza la Guida';
	}
}


/************************************* HINTBOX	Finestra di aiuto compilazione modulo***********************************************/
var horizontal_offset="9px" //horizontal offset of hint box from anchor link
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all
var dropmenuobj;

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
//var dropmenuobj="";
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox;
/************************************* FINE HINTBOX	Finestra di aiuto compilazione modulo***********************************************/


function check_log_1(modulo)
{
if(trim(modulo.username.value)==''){check_obbligatorio('username1');modulo.username.focus();return false;}
if(modulo.username.value=='*'){modulo.username.value='';check_obbligatorio('username1');modulo.username.focus();return false;}
if(trim(modulo.password.value)==''){check_obbligatorio('password1');modulo.password.focus();return false;}
if(modulo.password.value=='*'){modulo.password.value='';check_obbligatorio('password1');modulo.password.focus();return false;}
if(trim(modulo.pass_code.value)==''){check_obbligatorio('pass_code');modulo.pass_code.focus();return false;}
return true;
}

function check_log_2(modulo)
{

if(trim(modulo.username.value)==''){check_obbligatorio('username1');modulo.username.focus();return false;}
if(modulo.username.value=='*'){modulo.username.value='';check_obbligatorio('username1');modulo.username.focus();return false;}
/*if(trim(modulo.email.value)==''){modulo.email.focus();return false;}
if(modulo.email.value=='*'){modulo.email.value='';modulo.email.focus();return false;}
*/
if(trim(modulo.pass_code.value)==''){check_obbligatorio('pass_code');modulo.pass_code.focus();return false;}
return true;
}

function check_log_3(modulo)
{
/*if(trim(modulo.username.value)==''){modulo.username.focus();return false;}
if(modulo.username.value=='*'){modulo.username.value='';modulo.username.focus();return false;}*/
if(trim(modulo.email.value)==''){check_obbligatorio('email1');modulo.email.focus();return false;}
if(modulo.email.value=='*'){modulo.email.value='';check_obbligatorio('email1');modulo.email.focus();return false;}
if(!ControllaMail(trim(modulo.email.value))){check_valid_mail('email1');modulo.email.focus();return false;}
//if(trim(modulo.pass_code.value)==''){modulo.pass_code.focus();return false;}
return true;
}

function check_log_4(modulo)
{

if(trim(modulo.pass_code.value)==''){check_obbligatorio('pass_code');modulo.pass_code.focus();return false;}
if(modulo.licenza.checked==false){check_obbligatorio_2('licenza');modulo.licenza.focus();return false;}
return true;
}

function endloading()
{
	if(document.getElementById('divLoad')!=undefined)
	{
		document.getElementById('divLoad').style.display='none';
	}
}

function prev_permissions(utente_id)
{

if (utente_id==0)
  {
  
  document.getElementById('prev_permissions').style.display='none';
  return;
  } 

	
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	/*if (str.length<8 && campoinput=='chiave_accesso')
		{
		document.getElementById(idbox).innerHTML="<font color='#BB171D' size=1><b>La password deve essere di almeno 8 caratteri</b></font>";
		document.getElementById(campoinput+'_check').value='false';
		}
		else
		{
			if(xmlhttp.responseText=='true')
				{
				document.getElementById(idbox).innerHTML=alerttrue;
				document.getElementById(campoinput+'_check').value='false';
				}
			else
				{
				document.getElementById(idbox).innerHTML=alertfalse;
				document.getElementById(campoinput+'_check').value='true';
				}
		}*/
		
		document.getElementById('prev_permissions').style.display='block';
		document.getElementById('prev_permissions').innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","inc/print_permissions.php?ajax_utente="+utente_id,true);
xmlhttp.send();

}

/*ins_utenti*/
function str_exists(str,tbl,campoinput,campo,idbox,alerttrue,alertfalse)
{

if (str.length==0)
  {
  document.getElementById(idbox).innerHTML="";
  return;
  }
  
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	
		if (str.length<8 && campoinput=='chiave_accesso')
		{
		document.getElementById(idbox).innerHTML="<font color='#BB171D' size=1><b>La password deve essere di almeno 8 caratteri</b></font>";
		document.getElementById(campoinput+'_check').value='false';
		}
		else
		{
			if(xmlhttp.responseText=='true')
				{
				document.getElementById(idbox).innerHTML=alerttrue;
				document.getElementById(campoinput+'_check').value='false';
				}
			else
				{
				document.getElementById(idbox).innerHTML=alertfalse;
				document.getElementById(campoinput+'_check').value='true';
				}
		}
	}
  }
xmlhttp.open("GET","inc/str_exists.php?tbl="+tbl+"&campo="+campo+"&str="+str,true);
xmlhttp.send();

}





function ControllaRegistrati(modulo)
{
	if(trim(modulo.Nome.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('Nome');modulo.Nome.focus();return false;}
	if(trim(modulo.Cognome.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('Cognome');modulo.Cognome.focus();return false;}
	
	if(modulo.Nazione.selectedIndex==0){/*alert("Inserisci il tuo Nome");*/check_obbligatorio_3('Nazione');modulo.Nazione.focus();return false;}
	
	if(trim(modulo.nome_utente.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('nome_utente');modulo.nome_utente.focus();return false;}
	if(trim(modulo.nome_utente_check.value)=='false'){/*alert("Inserisci il tuo Nome");*/modulo.nome_utente.focus();return false;}
	
	if(trim(modulo.chiave_accesso.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('chiave_accesso');modulo.chiave_accesso.focus();return false;}
	if(trim(modulo.chiave_accesso_check.value)=='false'){/*alert("Inserisci il tuo Nome");*/modulo.chiave_accesso.focus();return false;}
	if(!ControllaReqPwd(trim(modulo.chiave_accesso.value))){/*alert("Inserisci una password valida");check_requisiti('chiave_accesso');*/modulo.chiave_accesso.focus();return false;}
	
	if(trim(modulo.email.value)==''){/*alert("Inserisci l'email");*/check_obbligatorio('email1');modulo.email.focus();return false;}
	if(!ControllaMail(trim(modulo.email.value))){/*alert("Inserisci un'indirizzo e-mail corretto");*//*document.getElementById('email1').className='input_error';*/check_valid_mail('email1');modulo.email.focus();return false;}else{/*document.getElementById('email1').className='';*/check_valid_mail('email1');}
	
	if(trim(modulo.pass_code.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('pass_code');modulo.pass_code.focus();return false;}
	
	if(modulo.privacy.checked==false){/*alert("Inserisci il tuo Nome");check_obbligatorio('pass_code');*/check_obbligatorio_2('privacy');modulo.privacy.focus();return false;}
return true;}

function ControllaContatti(modulo)
{
	/*var icheck = -1;
	for (i=modulo.oggetto.length-1; i > -1; i--) {
	if (modulo.oggetto[i].checked) {
	icheck = i; i = -1;
	}
	}
	if (icheck == -1) {check_obbligatorio('oggetto');return false;}*/
	if(trim(modulo.Oggetto.value)==''){/*alert("Inserisci il tuo Oggetto");*/check_obbligatorio('Oggetto');modulo.Oggetto.focus();return false;}
	if(trim(modulo.Nome.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('Nome');modulo.Nome.focus();return false;}
	if(trim(modulo.Cognome.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('Cognome');modulo.Cognome.focus();return false;}
	if(trim(modulo.email.value)==''){/*alert("Inserisci l'email");*/check_obbligatorio('email1');modulo.email.focus();return false;}
	if(!ControllaMail(trim(modulo.email.value))){/*alert("Inserisci un'indirizzo e-mail corretto");document.getElementById('email1').className='input_error';*/check_valid_mail('email1');modulo.email.focus();return false;}else{/*document.getElementById('email1').className='';*/check_valid_mail('email1');}
	if(trim(modulo.Testo.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('Testo');modulo.Testo.focus();return false;}

	
	if(trim(modulo.pass_code.value)==''){/*alert("Inserisci il tuo Nome");*/check_obbligatorio('pass_code');modulo.pass_code.focus();return false;}
	
	if(modulo.privacy.checked==false){/*alert("Inserisci il tuo Nome");check_obbligatorio('pass_code');*/check_obbligatorio_2('privacy');modulo.privacy.focus();return false;}
return true;}

function UpField(campo,valore,id)
{
	document.ajax_xaction.c.value=campo;
	document.ajax_xaction.v.value=valore;
	document.ajax_xaction.id.value=id;
	document.ajax_xaction.submit();
}

function cambia_gruppo(modulo,ivalueRadio)
{
	//var icheck = -1;
	for (i=modulo.gruppo.length-1; i > -1; i--)
	{
		if (modulo.gruppo[i].value==ivalueRadio)
		{
			modulo.gruppo[i].checked=true;
		}
		else
		{
			modulo.gruppo[i].checked=false;
		}
	}
	document.forms['archivio'].id.value="";
	document.forms['archivio'].iniziale.value="";
	document.forms['archivio'].secolo.value="";
	document.forms['archivio'].opere_crono_xml.value=0;
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	modulo.submit();
}

function cambia_secolo(iSecolo)
{
	document.forms['archivio'].id.value="";
	document.forms['archivio'].secolo.value=iSecolo;
	document.forms['archivio'].opere_crono_xml.value=0;
	document.forms['archivio'].iniziale.value="";
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function cambia_biblio_filtro(str)
{
	document.forms['archivio'].biblio_crono_filtro.value=str;
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function cambia_iniziale(str)
{
	document.forms['archivio'].id.value="";
	document.forms['archivio'].iniziale.value=str;
	document.forms['archivio'].secolo.value="";
	document.forms['archivio'].opere_crono_xml.value=0;
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function completo_crono()
{
	document.forms['archivio'].id.value="";
	document.forms['archivio'].iniziale.value="";
	document.forms['archivio'].secolo.value="all";
	document.forms['archivio'].opere_crono_xml.value=0;
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function opere_xml()
{
	for (i=document.forms['archivio'].gruppo.length-1; i > -1; i--)
	{
		if (document.forms['archivio'].gruppo[i].value=='opere')
		{
			document.forms['archivio'].gruppo[i].checked=true;
		}
		else
		{
			document.forms['archivio'].gruppo[i].checked=false;
		}
	}
	document.forms['archivio'].id.value="";
	document.forms['archivio'].iniziale.value="";
	document.forms['archivio'].secolo.value="all";
	document.forms['archivio'].opere_crono_xml.value=1;
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function completo_alfa()
{
	document.forms['archivio'].id.value="";
	document.forms['archivio'].iniziale.value="all";
	document.forms['archivio'].secolo.value="";
	document.forms['archivio'].opere_crono_xml.value=0;
	document.forms['archivio'].pag.value=1;
	document.forms['archivio'].bpag.value=1;
	//document.forms['archivio'].action='http://digiliblt.lett.unipmn.it/testi.php';
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function pag_archivio(iPag)
{
	document.forms['archivio'].id.value="";
	document.forms['archivio'].pag.value=iPag;
	document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='testi.php';
	document.forms['archivio'].submit();
}

function pag_biblio(iPag,token_link)
{
	if(token_link=="") token_link="autore";
	document.forms['archivio'].bpag.value=iPag;
	document.forms['archivio'].action=token_link+'.php';
	document.forms['archivio'].submit();
}



function pag_g_record(iPag,token_area)
{
	//document.forms['switch_orderby'].id.value="";
	if(iPag!="") document.forms['switch_orderby'].pag.value=iPag;
	document.forms['switch_orderby'].current_g_record.value=token_area;
	document.forms['switch_orderby'].action='g_testi.php';
	document.forms['switch_orderby'].submit();
}

function Scheda_notizie(value)
{
	document.forms['archivio'].id.value=value;
	//document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='notizia.php';
	document.forms['archivio'].submit();
}

function BackNotizia(value)
{
	document.forms['archivio'].id.value=value;
	//document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='notizie.php';
	document.forms['archivio'].submit();
}

function Back(action)
{
	//document.forms['archivio'].id.value=value;
	//document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action=''+action+'';
	document.forms['archivio'].submit();
}


function Scheda_autori(value)
{
	document.forms['archivio'].id.value=value;
	document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='autore.php';
	document.forms['archivio'].submit();
}

function Scheda_autori2(value)
{
	document.forms['archivio'].id.value=value;
	document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='../autore.php';
	document.forms['archivio'].submit();
}


function Scheda_opere(value)
{
	document.forms['archivio'].id.value=value;
	document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='opera.php';
	document.forms['archivio'].submit();
}

function Scheda_opere2(value)
{
	document.forms['archivio'].id.value=value;
	document.forms['archivio'].bpag.value=1;
	document.forms['archivio'].action='../opera.php';
	document.forms['archivio'].submit();
}

function Scheda_biblio(value)
{
	document.forms['archivio'].id.value=value;
	document.forms['archivio'].action='biblio.php';
	document.forms['archivio'].submit();
}



function Do_working_area()
{
	document.forms['archivio'].dw.value=1;
	document.forms['archivio'].action='working.php';
	document.forms['archivio'].submit();
}

function Scheda_biblio_popup(Id,Title)
{
	var Url="inc/pop_biblio.php?code="+Id;
		var browserName=navigator.appName; 
		if (browserName.indexOf("Microsoft")>=0)
		{ 
			//alert("sono qui");
			finestra=window.open(Url,"_blank","width=780,height=500,scrollbars=yes");
			intervWin=setInterval(function() {
			   if(finestra.document.body)
			   {clearInterval(intervWin);}},100); 
			//open(Url,Title,'width=800,height=600');
			//finestra_principale.location.href=Url;
			//finestra_principale.open(Url);
		}
		else
		{
			window.open(Url,Title,'width=780,height=500,scrollbars=yes');
		}
	
}

function Scheda_biblio_popup2(Id,Title)
{
	var Url="pop_biblio.php?code="+Id;
		var browserName=navigator.appName; 
		if (browserName.indexOf("Microsoft")>=0)
		{ 
			//alert("sono qui");
			finestra=window.open(Url,"_blank","width=780,height=500,scrollbars=yes");
			intervWin=setInterval(function() {
			   if(finestra.document.body)
			   {clearInterval(intervWin);}},100); 
			//open(Url,Title,'width=800,height=600');
			//finestra_principale.location.href=Url;
			//finestra_principale.open(Url);
		}
		else
		{
			window.open(Url,Title,'width=780,height=500,scrollbars=yes');
		}
	
}

function Scheda_autore_switch(Id)
{
	if(document.getElementById(Id+'_details').style.display=='none')
	{
		document.getElementById(Id+'_details').style.display='block';
	}
	if(document.getElementById(Id+'_details').style.display=='block')
	{
		document.getElementById(Id+'_details').style.display='none';
	}
	else
	{
		document.getElementById(Id+'_details').style.display='block';
	}

}

function back_archivio()
{
	document.forms['archivio'].action='testi.php';
	//document.forms['archivio'].pag.value=iPag;
	document.forms['archivio'].submit();
}

function back_results_biblio()
{
	//document.forms['back_rbiblio_form'].action='rbiblio.php';
	//document.forms['archivio'].pag.value=iPag;
	document.forms['back_rbiblio_form'].submit();
}

function Download(url_file,campo)
{
	if(url_file!="")
	{
		document.forms['archivio'].file_url_download.value=url_file;
		document.forms['archivio'].file_field_download.value=campo;
		document.forms['archivio'].action='download.php';
		document.forms['archivio'].submit();
	}
}

function upConsenso()
{
		document.forms['archivio'].action='upConsenso.php';
		document.forms['archivio'].submit();
}

function Autenticati()
{
		document.forms['archivio'].action='accesso.php';
		document.forms['archivio'].submit();
}

function Registrati()
{
		document.forms['archivio'].action='register.php';
		document.forms['archivio'].submit();
}

function backDownload()
{
	
		document.forms['archivio'].action='download.php';
		document.forms['archivio'].submit();
	
}


function Ordinamento(sort,sort_order)
{
	if(sort_order=="") sort_order="asc";
	
	document.switch_orderby.sort.value=sort;
	document.switch_orderby.sort_order.value=sort_order;
	document.forms['switch_orderby'].submit();
}

function xssezioni(campo)
{
	if(campo.checked==true)
	{
		document.mod_utente.g_sezioni_select.checked=true;
	}
}

function xselect(campo,campo_update,campo_delete,campo_insert)
{
	if(campo.checked==false)
	{
		if(campo_insert!=undefined) campo_insert.checked=false;
		if(campo_update!=undefined) campo_update.checked=false;
		if(campo_delete!=undefined) campo_delete.checked=false;
	}
}

function xupdate(campo,campo_select)
{
	if(campo.checked==true)
	{
		campo_select.checked=true;
		
		/*1.36
		perchè nella modifica o inserimento della bibliografia posso inserire le riviste
		*/
		if(campo.name=="g_biblio_update" || campo.name=="g_biblio_insert")
		{
			document.mod_utente.g_riviste_insert.checked=true;
		}
	}
	
	
}


function check_g_users(campo)
{
	var value=campo.value;
	
	if(value=='2')
	{
		if(document.mod_utente!=undefined)
		{
			if(document.mod_utente.g_utenti_select!=undefined)
			{
				document.mod_utente.g_utenti_select.checked=false;
				document.mod_utente.g_utenti_select.disabled=true;
				
				document.mod_utente.g_utenti_insert.checked=false;
				document.mod_utente.g_utenti_insert.disabled=true;
				
				document.mod_utente.g_utenti_update.checked=false;
				document.mod_utente.g_utenti_update.disabled=true;
				
				document.mod_utente.g_utenti_delete.checked=false;
				document.mod_utente.g_utenti_delete.disabled=true;
			}
		}
	}
	else
	{
				document.mod_utente.g_utenti_select.disabled=false;
				document.mod_utente.g_utenti_insert.disabled=false;
				document.mod_utente.g_utenti_update.disabled=false;
				document.mod_utente.g_utenti_delete.disabled=false;
	}
}

function switch_g_record(token_area)
{
	if(document.form_current_g_record.current_id_membro.value=='')
	{
		alert("Solo i membri possono gestire l'Archivio Testi, indipendentemente dai permessi posseduti.");
	}
	else
	{
		if(token_area!="")
		{
			document.form_current_g_record.current_g_record.value=token_area;
			var id_str=document.form_current_g_record.id.value;
			if(id_str=='autori' || id_str=='opere' || id_str=='opere_xml' || id_str=='biblio')
			{document.form_current_g_record.id.value='';}
			document.form_current_g_record.submit();
		}
	}
}

function switch_g_risorse(token_area)
{
	/*if(document.form_current_g_record.current_id_membro.value=='')
	{
		alert("Solo i membri possono gestire l'Archivio Testi, indipendentemente dai permessi posseduti.");
	}
	else
	{*/
		if(token_area!="")
		{
			document.form_current_g_record.id.value=token_area;
			var id_str=document.form_current_g_record.id.value;
			/*if(id_str=='autori' || id_str=='opere' || id_str=='opere_xml' || id_str=='biblio')
			{document.form_current_g_record.id.value='';}*/
			document.form_current_g_record.submit();
		}
	//}
}

function switch_start_page(token_area)
{
	
		if(token_area!="")
		{
			document.form_current_g_record.id.value=token_area;
			var current_g_record=document.form_current_g_record.current_g_record.value;
			if(current_g_record!="")
			{document.form_current_g_record.current_g_record.value='';}
			document.form_current_g_record.submit();
		}
	
}

function switch_g_record_iniziale(iniziale,token_area)
{
	if(document.form_current_g_record.current_id_membro.value=='')
	{
		alert("Solo i membri possono gestire l'Archivio Testi, indipendentemente dai permessi posseduti.");
	}
	else
	{
			
			document.form_current_g_record.iniziale.value=iniziale;
			document.form_current_g_record.current_g_record.value=token_area;
			//uso un filtro per volta
			if(iniziale!=""){ document.form_current_g_record.search.value=''; }
			document.form_current_g_record.submit();
		
	}
}

function switch_g_record_search(stringa,token_area)
{
	if(document.form_current_g_record.current_id_membro.value=='')
	{
		alert("Solo i membri possono gestire l'Archivio Testi, indipendentemente dai permessi posseduti.");
	}
	else
	{
			
			stringa=stringa.replace("&","[amp]");
			
			
			document.form_current_g_record.search.value=stringa;
			document.form_current_g_record.current_g_record.value=token_area;
			//uso un filtro per volta
			if(stringa!=""){ document.form_current_g_record.iniziale.value=''; }
			document.form_current_g_record.submit();
		
	}
}

function switch_g_record_clear_filtri(token_area)
{
	if(document.form_current_g_record.current_id_membro.value=='')
	{
		alert("Solo i membri possono gestire l'Archivio Testi, indipendentemente dai permessi posseduti.");
	}
	else
	{
			
			document.form_current_g_record.search.value='';
			document.form_current_g_record.iniziale.value='';
			document.form_current_g_record.current_g_record.value=token_area;
			document.form_current_g_record.submit();
		
	}
}

function ControllaAutore(modulo)
{
	
	
	//if(modulo.tipologia.selectedIndex==0){alert("Seleziona il tipo");modulo.tipologia.focus();return false;}
	/*var icheck = -1;
	for (i=modulo.tipologia.length-1; i > -1; i--) {
	if (modulo.tipologia[i].checked) {
	icheck = i; i = -1;
	}
	}
	if (icheck == -1) {alert("Definisci il tipo di membro");return false;}
	*/
	
	if(trim(modulo.NickName.value)=='')
	{
		alert("Inserisci il nome pubblico dell'Autore");modulo.NickName.focus();return false;
	}
	/*
	if(trim(modulo.FullName.value)=='')
	{
		alert("Inserisci il Nominativo dell'Autore");modulo.FullName.focus();return false;
	}
	*/
	
	if(trim(modulo.Sec1.value)!="" || trim(modulo.Sec2.value)!="")
	{
		if(modulo.Sec1.value>10 || modulo.Sec1.value<0 )
		{
				alert("Inserisci un valore per indicare il secolo compreso tra 0 e 10.");modulo.Sec1.focus();return false;
		}
		
		if(modulo.Sec2.value>10 || modulo.Sec2.value<0)
		{
				alert("Inserisci un valore per indicare il secolo compreso tra 0 e 10.");modulo.Sec2.focus();return false;
		}
		
		if(modulo.Sec2.value==modulo.Sec1.value && modulo.Sec2.value>0 && modulo.Sec1.value>0)
		{
				alert("Inserisci un valore solo per indicare un secolo di competenza dell'autore diverso da "+modulo.Sec1.value+".");modulo.Sec2.focus();return false;
		}
		
		if(((modulo.Sec2.value>0 && modulo.Sec1.value>0) && modulo.Sec2.value < modulo.Sec1.value) )
		{
				alert("Incongruenza nei dati");modulo.Sec2.focus();return false;
		}
		/*
		if((modulo.Sec2.value>0 && modulo.Sec1.value>0) && trim(modulo.Datazione.value)=="" )
		{
				alert("Incongruenza nei dati");modulo.Datazione.focus();return false;
		}
		*/
		/*
		if((modulo.Sec2.value==0 && modulo.Sec1.value==0) && trim(modulo.Datazione.value)!="" )
		{
				alert("Incongruenza nei dati");modulo.Sec1.focus();return false;
		}
		*/
	}
	
	/*if(trim(modulo.Datazione.value)=='' && (trim(modulo.Sec1.value)>0 && trim(modulo.Sec2.value)>0)){alert("Inserisci la Datazione");modulo.Datazione.focus();return false;}*/
	
	/*
	if(document.getElementById("Responsabile")!=undefined)
	{
		if(document.getElementById("Responsabile").selectedIndex==0)
		{
			modulo.sendmail.checked=false;
		}
	}
	*/
	
	
	
	return true;
}

function ControllaOpera(modulo)
{
	
	
	
	
	if(trim(modulo.Titolo.value)=='')
	{
		alert("Inserisci il Titolo dell'Opera");modulo.Titolo.focus();return false;
	}
	
	
	if(trim(modulo.Sec1.value)!="" || trim(modulo.Sec2.value)!="")
	{
		if(modulo.Sec1.value>10 || modulo.Sec1.value<0 )
		{
				alert("Inserisci un valore per indicare il secolo compreso tra 0 e 10.");modulo.Sec1.focus();return false;
		}
		
		if(modulo.Sec2.value>10 || modulo.Sec2.value<0)
		{
				alert("Inserisci un valore per indicare il secolo compreso tra 0 e 10.");modulo.Sec2.focus();return false;
		}
		
		if(modulo.Sec2.value==modulo.Sec1.value && modulo.Sec2.value>0 && modulo.Sec1.value>0)
		{
				alert("Inserisci un valore solo per indicare un secolo di competenza dell'autore diverso da "+modulo.Sec1.value+".");modulo.Sec2.focus();return false;
		}
		
		if(((modulo.Sec2.value>0 && modulo.Sec1.value>0) && modulo.Sec2.value < modulo.Sec1.value) )
		{
				alert("Incongruenza nei dati");modulo.Sec2.focus();return false;
		}
		/*
		if((modulo.Sec2.value>0 && modulo.Sec1.value>0) && trim(modulo.Datazione.value)=="" )
		{
				alert("Incongruenza nei dati");modulo.Datazione.focus();return false;
		}
		*/
		/*
		if((modulo.Sec2.value==0 && modulo.Sec1.value==0) && trim(modulo.Datazione.value)!="" )
		{
				alert("Incongruenza nei dati");modulo.Sec1.focus();return false;
		}
		*/
	}
	
	/*if(trim(modulo.Datazione.value)=='' && (trim(modulo.Sec1.value)>0 && trim(modulo.Sec2.value)>0)){alert("Inserisci la Datazione");modulo.Datazione.focus();return false;}*/
	/*
	if(document.getElementById('XMLFile').value!='')
			{
				var stringa=document.getElementById('XMLFile').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("XMLFile").value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted="xml";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("XMLFile").value="";
				document.getElementById("XMLFile").focus();
				return false;
				}
			
			}
			
	if(document.getElementById('TXTFile').value!='')
			{
				var stringa=document.getElementById('TXTFile').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("TXTFile").value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted="txt";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("TXTFile").value="";
				document.getElementById("TXTFile").focus();
				return false;
				}
			
			}
			
			if(document.getElementById('BETAFile').value!='')
			{
				var stringa=document.getElementById('BETAFile').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("BETAFile").value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted="bet";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("BETAFile").value="";
				document.getElementById("BETAFile").focus();
				return false;
				}
			
			}
			
			if(document.getElementById('PDFFile').value!='')
			{
				var stringa=document.getElementById('PDFFile').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("PDFFile").value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted="pdf";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("PDFFile").value="";
				document.getElementById("PDFFile").focus();
				return false;
				}
			
			}
			
			if(document.getElementById('PUBFile').value!='')
			{
				var stringa=document.getElementById('PUBFile').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("PUBFile").value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted="pub";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("PUBFile").value="";
				document.getElementById("PUBFile").focus();
				return false;
				}
			
			}*/
	
	var arr_campi_nome=new Array("TXTFile", "XMLFile", "BETAFile",  "PDFFile", "PUBFile");
	var arr_campi_ext=new Array( "txt",  "xml", "bet",  "pdf",  "pub");
	var arr_campi_str=new Array( "TXT",  "TEI", "BETA",  "PDF", "E-PUB");
	
	for(var i=0;i<arr_campi_nome.length;i++)
	{
	if(document.getElementById(arr_campi_nome[i]).value!='')
			{
				var stringa=document.getElementById(arr_campi_nome[i]).value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById(arr_campi_nome[i]).value.substr(pos,3).toLowerCase();  
				 
				//var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				var ext_accepted=arr_campi_ext[i];
				
				if(ext_accepted.search(ext)==-1){
				alert("I file "+arr_campi_str[i]+" non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById(arr_campi_nome[i]).value="";
				document.getElementById(arr_campi_nome[i]).focus();
				return false;
				}
			
			}
	}
		
	
	/*
	if(document.getElementById("Responsabile")!=undefined)
	{
		if(document.getElementById("Responsabile").selectedIndex==0)
		{
			modulo.sendmail.checked=false;
		}
	}
	*/
	
	var multiselect=modulo.TipoTesto;
	SelectAll(multiselect);
	
	return true;
}



function prev_datazione(sec1,sec2,datazione,idboxresult)
{


//alert("sec1["+sec1+"] sec2["+sec2+"] datazione["+datazione+"]");
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	
		if(xmlhttp.responseText!="")
		{
			var str_response=xmlhttp.responseText;
			str_response=str_response.replace("\'","");
			str_response=str_response.replace('\"',"");
			document.getElementById(idboxresult).innerHTML=str_response;
			
		}
		
	}
  }
xmlhttp.open("GET","inc/prevDatazione.php?sec1="+sec1+"&sec2="+sec2+"&datazione='"+datazione+"'",true);
xmlhttp.send();

}

function prev_autori_opere(aut1,aut2,idboxresult)
{



if(aut1!='' && aut2!='' &&  aut1==aut2)
{
	document.getElementById('Autore2_check').innerHTML="Seleziona un autore diverso da quello principale o non selezionare alcun autore secondario.";
	return;
}
else
{
	document.getElementById('Autore2_check').innerHTML="";
}

//alert("sec1["+sec1+"] sec2["+sec2+"] datazione["+datazione+"]");
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp_2=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp_2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 
xmlhttp_2.onreadystatechange=function(){
 
  if (xmlhttp_2.readyState==4 && xmlhttp_2.status==200)
    {//alert("["+aut1+"]");*/
		//alert("["+aut1+"] ["+xmlhttp_2.responseText+"]");
		if(xmlhttp_2.responseText!="")
		{
			var str_response_2=xmlhttp_2.responseText;
			str_response_2=str_response_2.replace("\'","");
			str_response_2=str_response_2.replace('\"',"");
			document.getElementById(idboxresult).innerHTML=str_response_2;
			
		}
		
	}
  }
xmlhttp_2.open("GET","inc/prevAutoriOpera.php?aut1="+aut1+"&aut2="+aut2+"",true);
xmlhttp_2.send();

}

function prev_rivista(sigla,titolo,idboxresult)
{
		sigla=sigla.replace("&","[amp]");
		titolo=titolo.replace("&","[amp]");
		if(document.getElementById('TitoloPeriodico_insert')!=undefined)
		{
			if(document.getElementById('TitoloPeriodico_insert').style.display=="block")
			{
			document.getElementById('propInsRivista').style.display="none";
			}
		}
		if(sigla=="")
		{
			//document.getElementById('Periodico_check').innerHTML="Inserire la sigla della Rivista";
			
			if(document.getElementById('TitoloPeriodico_insert').style.display=="block")
			{
			document.getElementById('Periodico_id').focus();
			document.getElementById('Sigla_check').innerHTML="Inserire la sigla della Rivista";
			document.getElementById('boolean_insrivista').value=1;
			document.getElementById('propInsRivista').style.display="none";
			return;}
			else
			{
			document.getElementById('Sigla_check').innerHTML="Inserire la sigla della Rivista";
			document.getElementById('TitoloPeriodico_insert').style.display="none";
			document.getElementById(idboxresult).style.display="block";
			document.getElementById(idboxresult).innerHTML="";
			document.getElementById('propInsRivista').style.display="block";
			document.getElementById('boolean_insrivista').value=0;
			return;
			}
		}

		/*
		if(sigla!='' && titolo!='' &&  sigla==titolo && document.getElementById('TitoloPeriodico_insert').style.display=="block")
		{
			document.getElementById('Periodico_check').innerHTML="Inserire la sigla della Rivista ed il Titolo, i campi non possono coincidere.";
			return;
		}
		*/
		
		/*else
		{
			document.getElementById('Periodico_check').innerHTML="";
		}*/

		//alert("sec1["+sec1+"] sec2["+sec2+"] datazione["+datazione+"]");
		  
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp_2=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp_2=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		 
		xmlhttp_2.onreadystatechange=function(){
		 
		  if (xmlhttp_2.readyState==4 && xmlhttp_2.status==200)
			{//alert("["+aut1+"]");*/
				//alert("["+aut1+"] ["+xmlhttp_2.responseText+"]");
				if(xmlhttp_2.responseText!="")
				{
					var str_response_2=xmlhttp_2.responseText;
					str_response_2=str_response_2.replace("\'","'");
					str_response_2=str_response_2.replace('\"','"');
					document.getElementById('TitoloPeriodico_insert').style.display="none";
					document.getElementById(idboxresult).style.display="block";
					document.getElementById(idboxresult).innerHTML=str_response_2;
					document.getElementById('Periodico_check').innerHTML="";
					document.getElementById('Sigla_check').innerHTML="";
					
					document.getElementById('reminder').style.display="block";
					document.getElementById('propInsRivista').style.display="none";
					
					document.getElementById('boolean_insrivista').value=0;
				}
				else
				{
					if(document.getElementById('TitoloPeriodico_insert').style.display=="none")
					{
					document.getElementById('propInsRivista').style.display="block";
					document.getElementById('boolean_insrivista').value=0;
					document.getElementById(idboxresult).innerHTML="";
					//document.getElementById(idboxresult).style.display="block";
					}
					else
					{
					document.getElementById('propInsRivista').style.display="none";
					document.getElementById('boolean_insrivista').value=1;
					document.getElementById(idboxresult).innerHTML="";
					document.getElementById(idboxresult).style.display="none";
					}
					
					/*
					document.getElementById('TitoloPeriodico_insert').style.display="block";
					
					document.getElementById('Periodico_check').innerHTML="Inserire il titolo della Rivista.";
					*/
					
				}
				
			}
		  }
		
		sigla=sigla.replace("&","[amp]");
		titolo=titolo.replace("&","[amp]");
		
		xmlhttp_2.open("GET","inc/prevRivista.php?sigla="+sigla+"&titolo="+titolo+"",true);
		xmlhttp_2.send();

}

function InsRivista()
{
					document.getElementById('TitoloPeriodico_insert').style.display="block";
					
					document.getElementById('anteprima_titolo_rivista').innerHTML="";
					document.getElementById('anteprima_titolo_rivista').style.display="none";
					
					if(document.getElementById('TitoloPeriodico_id').value=='') document.getElementById('Periodico_check').innerHTML="Inserire il titolo della Rivista."; else document.getElementById('Periodico_check').innerHTML="";
					
					document.getElementById('reminder').style.display="none";
					
					if(document.getElementById('Periodico_id').value=='') document.getElementById('Periodico_id').focus();
					
					document.getElementById('propInsRivista').style.display="none";
					
					document.getElementById('boolean_insrivista').value=1;
}

function AnnullaInsRivista()
{
					document.modulo_xaction_biblio_mod.Periodico.value='';
					document.modulo_xaction_biblio_mod.TitoloPeriodico.value='';
					document.modulo_xaction_biblio_mod.Periodico.focus();
					document.getElementById('TitoloPeriodico_insert').style.display="none";
					document.getElementById('anteprima_titolo_rivista').style.display="block";
					
					document.getElementById('propInsRivista').style.display="block";
					document.getElementById('boolean_insrivista').value=0;
}

function sendRifiutoRichiedente(token_area,id_record)
{


//alert("sec1["+sec1+"] sec2["+sec2+"] datazione["+datazione+"]");
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	
		/*if(xmlhttp.responseText!="")
		{
			var str_response=xmlhttp.responseText;
			str_response=str_response.replace("\'","");
			str_response=str_response.replace('\"',"");
			document.getElementById(idboxresult).innerHTML=str_response;
			
		}*/
		//if(reload==1){document.location.href=token_area+'.php?#'+id_record;}
		/*1.53*/

		document.form_current_g_record.current_g_record.value=token_area;
		document.form_current_g_record.ANCORANAME.value=id_record;
		document.form_current_g_record.submit();

			/*1.53*/
	}
  }
xmlhttp.open("GET","inc/mailRichiedente.php?token="+token_area+"&id="+id_record,true);
xmlhttp.send();

}




function RicercaSemplice()
{
	var keyword=document.ricerca.keyword.value;
	var url=document.ricerca.action;
	var collegamento = url + keyword;
	if(keyword=='') document.ricerca.keyword.focus();
	else document.location.href=collegamento;
}


function ControllaBiblio(modulo)
{
	
	/*`ID`, `Autore`, `Titolo`, `LuogoEdizione`, `Editore`, `AnnoEdizione`, `AnnoEdizione2`, `TipoEdizione`, `Periodico`, `IDMisc`, `Annata`, `Anno`, `Anno2`, `Pagine`, `Curatore`, `LinkEsterno`, `Disponibile`, `Responsabile`, `MetaTitle-IT`, `MetaTitle-EN`, `MetaKey-IT`, `MetaKey-EN`, `MetaDescr-IT`, `MetaDescr-EN`, `KeyWords`, `Note`, `Recensioni`*/
	
	if(modulo.TipoEdizione.selectedIndex==0)
	{
		alert("Seleziona la tipologia editoriale della Bibliografia");modulo.TipoEdizione.focus();return false;
	}
	
	if(trim(modulo.Titolo.value)=='')
	{
		alert("Inserisci il Titolo della Bibliografia");modulo.Titolo.focus();return false;
	}
	
	if(trim(modulo.Autore.value)=='')
	{
		alert("Inserisci l'Autore della Bibliografia");modulo.Autore.focus();return false;
	}
	
	var str_tipo=modulo.TipoEdizione.options[modulo.TipoEdizione.selectedIndex].value;
	
	if( str_tipo=="AR" && trim(modulo.Periodico.value)=="" )
	{
		alert("Inserisci la Sigla della Rivista");
		modulo.Periodico.focus();
		return false;
	}
	
	if( str_tipo=="AR" && (modulo.insrivista.value==1 || document.getElementById('TitoloPeriodico_insert').style.display=="block"))
	{
		if(trim(modulo.Periodico.value)=="" || trim(modulo.TitoloPeriodico.value)=="")
		{
			alert("Per inserire una nuova Rivista, è necessario inserire obbligatoriamente Sigla e Titolo.");
			if(trim(modulo.Periodico.value)==""){modulo.Periodico.focus();}else{modulo.TitoloPeriodico.focus();}
			return false;
		}
	}
	
	if( (modulo.AnnoEdizione.value > 0 && modulo.AnnoEdizione2.value > 0) && modulo.AnnoEdizione2.value < modulo.AnnoEdizione.value)
	{
		alert("Inserisci gli anni, tra i quali dovrebbe essere uscita la bibliografia, nel formato Dal - Al.");modulo.AnnoEdizione2.focus();return false;
	}
	
	/*
	if( str_tipo=="AM" && modulo.IDMisc.selectedIndex==0 )
	{
		alert("Seleziona la Miscellanea");modulo.IDMisc.focus();return false;
	}
	*/
	
			if(document.getElementById('doc_1').value!='')
			{
				var stringa=document.getElementById('doc_1').value;
				var pos=stringa.lastIndexOf('.') +1;
				var ext = document.getElementById("doc_1").value.substr(pos,3).toLowerCase();  
				 
				var ext_accepted=document.getElementById('ext_accepted').value.toLowerCase();
				//var ext_accepted="pdf";
				
				if(ext_accepted.search(ext)==-1){
				alert("I file non possono avere estensione "+ext+", le estensioni accettate sono: "+ext_accepted+".");
				document.getElementById("doc_1").value="";
				document.getElementById("doc_1").focus();
				return false;
				}
			
			}
	
	/*
	if(document.getElementById("Responsabile")!=undefined)
	{
		if(document.getElementById("Responsabile").selectedIndex==0)
		{
			modulo.sendmail.checked=false;
		}
	}
	*/
	
	var j=0;
	var LinkedAutori=modulo.LinkedAutori;
	if(LinkedAutori.options.length > 0)
	{
		SelectAll(LinkedAutori);
	}
	
	var LinkedOpere=modulo.LinkedOpere;
	if(LinkedOpere.options.length > 0)
	{
		SelectAll(LinkedOpere);
	}
	
	if(LinkedAutori.options.length==0 && LinkedOpere.options.length==0)
	{
		alert("Collegare la bibliografia almeno ad un autore o ad un'opera");/*to_element.focus();*/
		LinkedAutori.focus();
		return false;
	}
	
	var KeyWords=modulo.KeyWords;
	if(KeyWords.options.length > 0)
	{
		SelectAll(KeyWords);
	}
	return true;
}

function switch_display_biblio()
{
	var str_tipo="";
	if(document.getElementById('TipoEdizione_id')!=undefined)
	{
		str_tipo=document.getElementById('TipoEdizione_id').options[document.getElementById('TipoEdizione_id').selectedIndex].value;
	}
	/*MO,LE,BI,ED,MI,AR,AM*/
	/*AR box_Periodico*/
	/*MO,LE,BI,ED box_Editore*/
	/*AM box_IDMisc*/
	/*MO,LE,BI,ED,MI,AM box_LuogoEdizione*/
	/*AR box_AnnataAnno*/
	/* MO,LE,BI,ED,MI,AR box_Recensioni*/
	/**/
	/*switch(str_tipo)
	{
		*/
		/*1.40d togliere AnnoEdizione ad AR*/
	if(str_tipo=="MO")
	{
		//case 'MO':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
	}
	else if(str_tipo=="LE")
	{
		//case 'LE':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
		//break;
	}
	else if(str_tipo=="BI")
	{
		//case 'BI':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
		//break;
	}
	else if(str_tipo=="ED")
	{
		//case 'ED':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Editore";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
		//break;
	}
	else if(str_tipo=="MI")
	{
		//case 'MI':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Curatore miscellanea";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo miscellanea";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
		//break;
	}
	else if(str_tipo=="AR")
	{
		//case 'AR':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="block";
			
			if(document.getElementById('Periodico_id')!=undefined){prev_rivista(document.getElementById('Periodico_id').value,document.getElementById('TitoloPeriodico_id').value,'anteprima_titolo_rivista');}
			
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="none";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="none";
			
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="none";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="block";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="block";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica in quali pagine della <b>Rivista</b> &egrave; contenuto l'<b>Articolo Rivista</b>.";
		//break;
	}
	else if(str_tipo=="AM")
	{
		//case 'AM':
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="block";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="block";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="block";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="none";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica in quali pagine della raccolta <b>Miscellanea</b> &egrave; contenuto l'<b>Articolo Miscellanea</b>.";
			
		//break;
	}
	else
	{	
		//default:
			if(document.getElementById('box_Periodico')!=undefined) document.getElementById('box_Periodico').style.display="none";
			if(document.getElementById('box_Editore')!=undefined) document.getElementById('box_Editore').style.display="none";
			if(document.getElementById('box_AnnoEdizione')!=undefined) document.getElementById('box_AnnoEdizione').style.display="block";
			if(document.getElementById('box_IDMisc')!=undefined) document.getElementById('box_IDMisc').style.display="none";
			if(document.getElementById('box_LuogoEdizione')!=undefined) document.getElementById('box_LuogoEdizione').style.display="none";
			//if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="none";
			if(document.getElementById('box_AnnataAnno')!=undefined) document.getElementById('box_AnnataAnno').style.display="block";
			if(document.getElementById('box_Annata')!=undefined) document.getElementById('box_Annata').style.display="block";
			if(document.getElementById('box_Anno')!=undefined) document.getElementById('box_Anno').style.display="none";
			/**/
			if(document.getElementById('box_Recensioni')!=undefined) document.getElementById('box_Recensioni').style.display="none";
			
			if(document.getElementById('Autore_label')!=undefined) document.getElementById('Autore_label').innerHTML="Autore moderno";
			if(document.getElementById('Titolo_label')!=undefined) document.getElementById('Titolo_label').innerHTML="Titolo";
			if(document.getElementById('Pagine_tips')!=undefined) document.getElementById('Pagine_tips').innerHTML="Specifica di quante pagine si compone.";
	}
	
}



function onload_riviste()
{
	if(document.getElementById('Sigla')!=undefined) conta('Sigla','Sigla_conta',32);
	conta('Titolo','Titolo_conta',240);
}




function onload_biblio()
{
	switch_display_biblio();
	/*if(document.getElementById('Titolo')!=undefined) conta('Titolo','Titolo_conta',150);*/
	if(document.getElementById('Autore')!=undefined) conta('Autore','Autore_conta',80);
	if(document.getElementById('Periodico_id')!=undefined) conta('Periodico_id','Periodico_conta',32);
	if(document.getElementById('TitoloPeriodico_id')!=undefined) conta('TitoloPeriodico_id','TitoloPeriodico_conta',240);
	if(document.getElementById('AnnoEdizione')!=undefined) conta('AnnoEdizione','AnnoEdizione_conta',40);
	if(document.getElementById('Pagine')!=undefined) conta('Pagine','Pagine_conta',16);
	if(document.getElementById('Recensioni')!=undefined) conta('Recensioni','Recensioni_conta',240);
	if(document.getElementById('Note')!=undefined) conta('Note','Note_conta',240);
	sortOptions('AllLinkedAutori');
	sortOptions('LinkedAutori');
	sortOptions('AllLinkedOpere');
	sortOptions('LinkedOpere');
	sortOptions('AllKeyWords_id');
	sortOptions('KeyWords_id');
	//prev_rivista(document.getElementById('Periodico_id').value,document.getElementById('TitoloPeriodico_id').value,'anteprima_titolo_rivista');
	//if(document.getElementById('divLoad')!=undefined){ endloading();}
}

function ControllaRivista(modulo)
{
	if(document.getElementById('Sigla')!=undefined){if(trim(modulo.Sigla.value)==''){alert("Inserisci la Sigla");modulo.Sigla.focus();return false;}
	if(modulo.Sigla_check.value=='false'){modulo.Sigla.focus();return false;}}
	if(trim(modulo.Titolo.value)==''){alert("Inserisci il nome della Rivista");modulo.Titolo.focus();return false;}
	return true;
}

function check_id_rivista(str,tbl,campoinput,campo,idbox,alerttrue,alertfalse)
{

if (str.length==0)
  {
  document.getElementById(idbox).innerHTML="";
  return;
  }
  
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	
		/*if (str.length<8 && campoinput=='chiave_accesso')
		{
		document.getElementById(idbox).innerHTML="<font color='#BB171D' size=1><b>La password deve essere di almeno 8 caratteri</b></font>";
		document.getElementById(campoinput+'_check').value='false';
		}
		else
		{*/
			if(xmlhttp.responseText=='true')
				{
				document.getElementById(idbox).innerHTML=alertfalse;
				document.getElementById(campoinput+'_check').value='false';
				}
			else if(xmlhttp.responseText=='false')
				{
				document.getElementById(idbox).innerHTML=alerttrue;
				document.getElementById(campoinput+'_check').value='true';
				}
		//}
	}
  }
xmlhttp.open("GET","inc/str_exists.php?tbl="+tbl+"&campo="+campo+"&str="+str,true);
xmlhttp.send();

}


function changeAnnoEdizione(value)
{
	//alert(value);
	/*if(document.getElementById('box_AnnoEdizione2')!=undefined)
	{*/
		if(value==2 || value=='2')
		{
			document.getElementById('box_AnnoEdizione2').style.display="block";
		}
		else if(value==0 || value=='')
		{
			document.getElementById('AnnoEdizione').value="";
			document.getElementById('AnnoEdizione2').value="";
		}
		else
		{
			document.getElementById('box_AnnoEdizione2').style.display="none";
			document.getElementById('AnnoEdizione2').value="";
		}
		
	//}
}

function onload_rbiblio()
{
	changeAnnoEdizione(document.getElementById('switch_AnnoEdizione_id').options[document.getElementById('switch_AnnoEdizione_id').selectedIndex].value);
}


function doResSearch(modulo,idbox)
{

/*
if (str.length==0)
  {
  document.getElementById(idbox).innerHTML="";
  return;
  }
*/ 
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	
		/*if (str.length<8 && campoinput=='chiave_accesso')
		{
		document.getElementById(idbox).innerHTML="<font color='#BB171D' size=1><b>La password deve essere di almeno 8 caratteri</b></font>";
		document.getElementById(campoinput+'_check').value='false';
		}
		else
		{*/
			if(xmlhttp.responseText!="")
				{
				document.getElementById('box_modulo').display="none";
				document.getElementById(idbox).display="block";
				document.getElementById(idbox).innerHTML=xmlhttp.responseText;
				}
			/*else if(xmlhttp.responseText=='false')
				{
				document.getElementById(idbox).innerHTML=alerttrue;
				document.getElementById(campoinput+'_check').value='true';
				}*/
		//}
	}
  }
  
  /* Autore NickName Titolo TitoloOpera Rivista switch_AnnoEdizione AnnoEdizione AnnoEdizione2*/
  var str_sendData="";
  var to_element_k;
  var j=0;
  str_sendData=str_sendData+"Autore="+modulo.Autore.value;
  str_sendData=str_sendData+"&NickName="+modulo.NickName.value;
  str_sendData=str_sendData+"&Titolo="+modulo.Titolo.value;
  str_sendData=str_sendData+"&TitoloOpera="+modulo.TitoloOpera.value;
  
    var str_TipoEdizione="";
    to_element_k=modulo.TipoEdizione;
	for(j=0; j<to_element_k.options.length;j++)
	{
								to_element_k.options[j].selected=true;	
								str_TipoEdizione=str_TipoEdizione+to_element_k.options[j].value;
								if( ((j + 1) < to_element_k.options.length) && (to_element_k.options.length > 1) )
								{
									str_TipoEdizione=str_TipoEdizione+";";
								}
	}
  str_sendData=str_sendData+"&TipoEdizione="+str_TipoEdizione;
  
  str_sendData=str_sendData+"&Rivista="+modulo.Rivista.value;
  
  
  if(modulo.righe_per_pagina!=undefined) str_sendData=str_sendData+"&righe_per_pagina="+modulo.righe_per_pagina.value;
  if(modulo.ordina_per!=undefined) str_sendData=str_sendData+"&ordina_per="+modulo.ordina_per.value;
  if(modulo.ordina_ascdesc!=undefined) str_sendData=str_sendData+"&ordina_ascdesc="+modulo.ordina_ascdesc.value;
  
  if(modulo.rbpag!=undefined) str_sendData=str_sendData+"&rbpag="+modulo.rbpag.value;
  if(modulo.pag!=undefined) str_sendData=str_sendData+"&pag="+modulo.pag.value;
  if(modulo.id_biblio!=undefined ){ if(modulo.id_biblio.value!=''){ str_sendData=str_sendData+"&id_biblio="+modulo.id_biblio.value; }}
  
  
    var str_KeyWords="";
   // to_element_k=modulo.KeyWords;
	to_element_k=document.getElementById('KeyWords_id');
	for(j=0; j<to_element_k.options.length;j++)
	{
								to_element_k.options[j].selected=true;	
								str_KeyWords=str_KeyWords+to_element_k.options[j].value;
								if( ((j + 1) < to_element_k.options.length) && (to_element_k.options.length > 1) )
								{
									str_KeyWords=str_KeyWords+";";
								}
	}
    str_sendData=str_sendData+"&KeyWords="+str_KeyWords;
  
  
  str_sendData=str_sendData+"&switch_AnnoEdizione="+modulo.switch_AnnoEdizione.value;
  str_sendData=str_sendData+"&AnnoEdizione="+modulo.AnnoEdizione.value;
  str_sendData=str_sendData+"&AnnoEdizione2="+modulo.AnnoEdizione2.value;
  
  
  var str_Secoli="";
    to_element_k=modulo.Secoli;
	for(j=0; j<to_element_k.options.length;j++)
	{
								to_element_k.options[j].selected=true;	
								str_Secoli=str_Secoli+to_element_k.options[j].value;
								if( ((j + 1) < to_element_k.options.length) && (to_element_k.options.length > 1) )
								{
									str_Secoli=str_Secoli+";";
								}
	}
  str_sendData=str_sendData+"&Secoli="+str_Secoli;
  
xmlhttp.open("GET","inc/resSearch.php?"+str_sendData,true);
xmlhttp.send();

}

function pag_rbiblio(iPag)
{
	if(iPag=="" || iPag==0) iPag=1;
	var modulo=document.rbiblio_form;
	modulo.id.value="";
	modulo.rbpag.value=iPag;
	modulo.pag.value=iPag;
	//alert(modulo.rbpag.value);
	//modulo.pag.value=1;
	//modulo.action='testi.php';
	//modulo.submit();
	doResSearch(modulo,'risultati_ricerca');
}

function pag_rbiblio2(iPag)
{
	if(iPag=="" || iPag==0) iPag=1;
	var modulo=document.forms['rbiblio_form'];
	modulo.id.value="";
	modulo.rbpag.value=iPag;
	//modulo.pag.value=1;
	//modulo.action='testi.php';
	//modulo.submit();
	
	//doResSearch(modulo,'risultati_ricerca');
}

function tipsDisponibile(id_select,id_file_exists,id_campo_file,id_box_alert)
{
	var disponibile=document.getElementById(id_select).options[document.getElementById(id_select).selectedIndex].value;
	var file_exists=document.getElementById(id_file_exists).value;
	var file=document.getElementById(id_campo_file).value;
	
	if( disponibile!="S" && ( file_exists==1 || file!="") )
	{
		document.getElementById(id_box_alert).style.display="block";
	}
	else
	{
		document.getElementById(id_box_alert).style.display="none";
	}
	
}



function ControllaRicerca(modulo)
{
	/*1.40 tolgo obbligatorietà tipologia biblio*/
	/*
	if(document.getElementById('TipoEdizione').options.length==0)
	{
		check_cob_multiselect('TipoEdizione');
		modulo.TipoEdizione.focus();
		return false;
	}
	*/
	AutoRivista(modulo.Rivista.value);
	
	if(modulo.switch_AnnoEdizione.selectedIndex > 0)
	{
		if((trim(modulo.AnnoEdizione.value)=="") || ( modulo.switch_AnnoEdizione.selectedIndex == 2 && trim(modulo.AnnoEdizione2.value)=="" ) )
		{
		//check_cob_multiselect('TipoEdizione');
		check_obbligatorio_ae('AnnoEdizione','AnnoEdizione2','switch_AnnoEdizione_id',2);
		modulo.AnnoEdizione.focus();
		return false;
		}
		
		var anno1=eval(trim(modulo.AnnoEdizione.value));
		var anno2=eval(trim(modulo.AnnoEdizione2.value));
		
		var id_campo_anno1=modulo.AnnoEdizione.id;
		var id_campo_anno2=modulo.AnnoEdizione2.id;
		
		//check_req_periodo(id_campo_anno1,id_campo_anno2,'AnnoEdizione_alert');
		
		if( modulo.switch_AnnoEdizione.selectedIndex == 2 && anno2 <= anno1)
		{
			check_req_periodo(id_campo_anno1,id_campo_anno2,'AnnoEdizione_alert');
			return false;
		}
	}
	
	var str_rivista=modulo.Rivista.value;
	str_rivista=str_rivista.replace("&","[amp]");
	//modulo.Rivista_2.value=str_rivista;
	modulo.Rivista.value=str_rivista;
	
	modulo.action="inc/pop_data_lists.php";
	
	doResSearch(modulo,'risultati_ricerca');
	
	
	if( document.getElementById('box_modulo')!=undefined )
	{
		document.getElementById('box_modulo').style.display="none";
		document.getElementById('risultati_ricerca').style.display="block";
		
	}
	return false;
	
}

function Scheda_rbiblio(modulo,value)
{
	modulo.id_biblio.value=value;
	modulo.action='biblio.php';
	modulo.submit();
}

function ResetRicercaBiblio(modulo)
{
	modulo.Autore.value="";
	modulo.NickName.value="";
	modulo.Titolo.value="";
	modulo.TitoloOpera.value="";
	var TipoEdizione=modulo.TipoEdizione;
	if(TipoEdizione.options.length > 0)
	{
		SelectAll(TipoEdizione);
		addOption('TipoEdizione','AllTipoEdizione');
	}
	modulo.Rivista.value="";
	//var theKeyWords=modulo.KeyWords_;
	var theKeyWords=document.getElementById('KeyWords_id');
	if(theKeyWords.options.length > 0)
	{
		SelectAll(theKeyWords);
		addOption('KeyWords_id','AllKeyWords_id');
	}
	modulo.switch_AnnoEdizione.selectedIndex=0;
	modulo.AnnoEdizione.value="";
	modulo.AnnoEdizione2.value="";
	var Secoli=modulo.Secoli;
	if(Secoli.options.length > 0)
	{
		SelectAll(Secoli);
		addOption('Secoli','AllSecoli');
	}
}

function IndietroModuloRicerca()
{
	var str_rivista=document.rbiblio_form.Rivista.value;
	str_rivista=str_rivista.replace("[amp]","&");
	//document.rbiblio_form.Rivista_2.value=str_rivista;
	document.rbiblio_form.Rivista.value=str_rivista;
	document.getElementById('box_modulo').style.display="block";
	document.getElementById('risultati_ricerca').style.display="none";
}

function AutoRivista(value)
{
	var found=0;
	if(value!="")
	{
		var sSel = document.getElementById('AllTipoEdizione');
		var elSel = document.getElementById('TipoEdizione');
		var i;
		
		for (i = elSel.length - 1; i>=0; i--)
		{
			if (elSel.options[i].value=="AR")
			{
				found=1;
				//sSel.options[i].selected=true;
				//se lo trovo non devo far niente
			}
			else
			{
				//sSel.options[i].selected=false;
			}
		}
		
		if(found==0)
		{
			for (i = sSel.length - 1; i>=0; i--)
			{
				if (sSel.options[i].value=="AR")
				{
					//found=1;
					sSel.options[i].selected=true;
					//se lo trovo non devo far niente
				}
				else
				{
					sSel.options[i].selected=false;
				}
			}
		
		
			addOption('AllTipoEdizione','TipoEdizione');
		}
	}
}

function subModule(modulo,valore_Action)
{
	/*
	if(valore_Action!='del_tmp_new' && valore_Action!='del_tmp_opera' && valore_Action!='del_tmp_autore' && valore_Action!='del_tmp_biblio')
	{
		if(modulo.name=='modulo_xaction_opere_mod')
		{
			result = ControllaOpera(modulo);
		}
		
		if(modulo.name=='modulo_xaction_autori_mod')
		{
			result = ControllaAutore(modulo);
		}
		
		if(modulo.name=='modulo_xaction_biblio_mod')
		{
			result = ControllaBiblio(modulo);
		}
		
		if(modulo.name=='modulo_xaction_news_mod')
		{
			result = ControllaNew(modulo);
		}
		
	}
	else
	{
		result=true;
	}
	
	if(result===false) return false;
	*/
		result=true;


		if(modulo.name=='modulo_xaction_news_mod')
		{
			result = ControllaNew_bool(modulo);
		}
		else if(modulo.name=='modulo_xaction_partners_mod')
		{
			result = ControllaPartner_bool(modulo);
		}
		else if(modulo.name=='modulo_xaction_campionati_mod')
		{
			result = ControllaCampionato_bool(modulo);
		}
		else if(modulo.name=='modulo_xaction_gare_mod')
		{
			result = ControllaGara_bool(modulo);
		}
		else if(modulo.name=='modulo_xaction_vetture_mod')
		{
			result = ControllaVettura_bool(modulo);
		}
		else if(modulo.name=='modulo_xaction_piloti_mod')
		{
			result = ControllaPilota_bool(modulo);
		}
		
		
		
		

	if(result===false) return false;

	modulo.action.value=valore_Action;
	
		if(valore_Action=='del_tmp_new' || valore_Action=='del_tmp_opera' || valore_Action=='del_tmp_autore' || valore_Action=='del_tmp_biblio')
		{
			if(!confirm("Sicuro di voler eliminare le modifiche?"))
			{}else{
				modulo.action.value=valore_Action;
				modulo.submit();
			}
		}
		else
		{
		modulo.action.value=valore_Action;
		modulo.submit();
		}
	return true;
}

function changeOrderBy(value,idNew,elNewValue,elNewText)
{
	
		var found=0;
		if(value!="")
		{
		
			
			//var sSel = document.getElementById(idNew);
			var elSel = document.getElementById(idNew);
			var i;
			
			for (i = elSel.length - 1; i>=0; i--)
			{
				if (elSel.options[i].value=="DESC")
				{
					found=1;
				}
				else
				{

				}
			}
			
			
			if(value=="biblio.AnnoEdizione")
			{
				if(found==0)
				{
					//addOption('AllTipoEdizione','TipoEdizione');
					var elNew = document.createElement('option');
					elNew.text = elNewText;
					elNew.value = elNewValue;

					try {elSel.add(elNew, null); } // standards compliant; doesn't work in IE		  			
					catch(ex) {elSel.add(elNew); } // IE only
				}
			}
			else
			{
				if(found==1)
				{
					  
					  for (i = elSel.length - 1; i>=0; i--) {
						if (elSel.options[i].value=="DESC") {
						  elSel.remove(i);
						}
					  }
					  
				}
			}
		}
		
	
}




function openReminder(code)
{
	if(document.xaction_pop_data_lists!=undefined)
	{
		document.xaction_pop_data_lists.code.value=code;
	}
		var url_action=document.xaction_pop_data_lists.action
		var Url=url_action+"?code="+code;
		var Title="";
		var browserName=navigator.appName; 
		if (browserName.indexOf("Microsoft")>=0)
		{ 
			//alert("sono qui");
			finestra=window.open(Url,"_blank","width=780,height=500,scrollbars=yes");
			intervWin=setInterval(function() {
			   if(finestra.document.body)
			   {clearInterval(intervWin);}},100); 
			//open(Url,Title,'width=800,height=600');
			//finestra_principale.location.href=Url;
			//finestra_principale.open(Url);
		}
		else
		{
			window.open(Url,Title,'width=780,height=500,scrollbars=yes');
		}
}


function ShowHideId(id_box)
{

	if( document.getElementById(id_box)!=undefined )
	{
		if(document.getElementById(id_box).style.display=="block")
		{
			document.getElementById(id_box).style.display="none";
		}
		else
		{
			document.getElementById(id_box).style.display="block";
		}
	}
	
}

function goPagina(iPag)
{
	//document.forms['do_pagination'].id.value="";
	document.forms['do_pagination'].pag.value=iPag;
	document.forms['do_pagination'].submit();
}

function Paginaz(pag)
{

	document.forms['archivio'].pag.value=pag;
	//document.forms['archivio'].action=''+action+'';
	document.forms['archivio'].submit();
}

