//************************************************
//  BOX DI RICERCA PRODOTTI/AZIENDE (su lato Dx)
//************************************************
var CoordX, CoordY
var TabSearchSelected = 'TabProdotti'

function ShowTab(NumTab){
    var Tab_Aziende       = document.getElementById("TabAziende")
    var Tab_Prodotti      = document.getElementById("TabProdotti")        
    var Cont_Tab_Aziende  = document.getElementById("Cont_TabAziende")        
    var Cont_Tab_Prodotti = document.getElementById("Cont_TabProdotti")
    
    if (NumTab==1){
        TabSearchSelected = 'TabProdotti'
        Cont_Tab_Aziende.style.display  = 'none'
        Cont_Tab_Prodotti.style.display = 'block'
        
        Tab_Aziende.style.backgroundPosition  = '-150px 0px'
        Tab_Prodotti.style.backgroundPosition = 'left -60px'        
    }
    if (NumTab==2){
        TabSearchSelected = 'TabAziende'
        Cont_Tab_Aziende.style.display  = 'block'
        Cont_Tab_Prodotti.style.display = 'none'
        
        Tab_Aziende.style.backgroundPosition  = '-150px -60px'
        Tab_Prodotti.style.backgroundPosition = 'left 0px'        
    }                
}      

function SetCoordX(OggettoTab){
    if (OggettoTab.id=='TabAziende'){
        CoordX = '-150px '
    }else{
        CoordX = 'left '
    }    
}
    
function Tab_Over(OggettoTab){
    SetCoordX(OggettoTab)
    CoordY = '-30px'  
    if (OggettoTab.id!=TabSearchSelected) {
        OggettoTab.style.backgroundPosition = CoordX + CoordY
    }    
}    

function Tab_Out(OggettoTab){
    SetCoordX(OggettoTab)
    CoordY = '0px' 
    if (OggettoTab.id!=TabSearchSelected){
        OggettoTab.style.backgroundPosition = CoordX + CoordY        
    }
}     


function ControlloInvioProdotti(){                    		                    				                   	                    		
    var KeyVuota=false
    if ((document.Form3.keyword.value == 'cerca un prodotto per parola chiave') || (document.Form3.keyword.value == '')) {
        KeyVuota=true
    }
           
    if (document.Form3.CatRicerca.value.indexOf("1-") != -1) 
    {        
        if (KeyVuota){
            alert("Inserire il prodotto da cercare!")
            return false
        }else{	
            window.document.location.href = "/prodotti/prodotti.asp?H=1" + 
            "&keyword=" + document.Form3.keyword.value.replace("&","%26");                    				
            return false		
        }
    }	                    		                    	
		
    if (document.Form3.CatRicerca.value.indexOf("3-") != -1) 
      {
        var percorso = window.location.toString();
        if ( (KeyVuota))
        {                    	            
            if (KeyVuota) 
                {
                    window.document.location.href = "/prodotti/Categorie_prodotti.asp?idcat=" + 
	                    document.Form3.CatRicerca.value.replace("3-", "")
			                   
                }
            else
                {
                    window.document.location.href = "/prodotti/prodotti.asp?CatRicerca=" + 
	                    document.Form3.CatRicerca.value +
	                    "&keyword=" +  document.Form3.keyword.value 											
                }
     
            return false 
        }
        if ((percorso.indexOf("prodotti.asp") == "-1") && (KeyVuota))
        {
            // alert(percorso.indexOf("Prodotti.asp"))
            alert("Inserire il prodotto da cercare!")
            document.Form3.keyword.focus()
            return false 
         }
    }	                    	                        	   		
 }            	     
          	     


 function verificaselezione(OggettoForm){
    OggettoForm.keyword.value == ""
    if (OggettoForm.CatRicerca.options[OggettoForm.CatRicerca.selectedIndex].value=='-'){
        OggettoForm.CatRicerca.selectedIndex = OggettoForm.CatRicerca.selectedIndex - 1
    }
    if (OggettoForm.CatRicerca.options[OggettoForm.CatRicerca.selectedIndex].value=='--'){
        OggettoForm.CatRicerca.selectedIndex = OggettoForm.CatRicerca.selectedIndex - 2
    }    			
    if ((OggettoForm.CatRicerca.options[OggettoForm.CatRicerca.selectedIndex].value).indexOf("3-") != -1) 
    {
        //document.form2.submit ()
        window.document.location.href = "/prodotti/Categorie_prodotti.asp?idcat=" + (OggettoForm.CatRicerca.options[OggettoForm.CatRicerca.selectedIndex].value).replace("3-", "") +
                                        "&DESCR=" + OggettoForm.CatRicerca.options[OggettoForm.CatRicerca.selectedIndex].text.replace(/ /g,"_")				
    }
 }    	  
 
 function ResetKeyword(){
    document.Form3.keyword.value = 'cerca un prodotto per parola chiave'
 }

 function ResetCategorie(){
    document.Form3.CatRicerca.selectedIndex = 0
 }
 
 function ControlloInvioAziende(){         
        if ((document.FrmAzienda.keyword.value == 'Cerca un\'azienda...') || (document.FrmAzienda.keyword.value == '')) {
	        alert('Inserire l\'azienda da cercare!')
	        return false
	    }            	                        	            
 }     
 
 
//*****************************************
//          BOX SPECIALE TECNICO
//*****************************************
var Index_Speciale   = 1
var ID_Speciale      = "SpecialeTecnico_"
var ID_Speciale_Corr = ID_Speciale + Index_Speciale
var Num_Speciali     = 0
        
function HideDisplayButton(Index_M){
    if (Index_M==1){
        document.getElementById("Speciale_Prec").className = 'off' 
    }else{
        document.getElementById("Speciale_Prec").className = 'on' 
    }          
      
    if ((Index_M==Num_Speciali) || (Num_Speciali==1)){
        document.getElementById("Speciale_Succ").className = 'off' 
    }else{
        document.getElementById("Speciale_Succ").className = 'on'                      
    }            
}
 
function NextSpeciale(){
    var ID_Speciale_Cal 
    var Elem_Speciale_Corr = document.getElementById(ID_Speciale_Corr)                          
    
    Index_Speciale   += 1
    ID_Speciale_Corr = ID_Speciale + Index_Speciale
                
    if (document.getElementById(ID_Speciale_Corr)){
        Elem_Speciale_Corr.style.display = 'none'
        document.getElementById(ID_Speciale_Corr).style.display = 'block'
    }else{
        Index_Speciale   -= 1
        ID_Speciale_Corr = ID_Speciale + Index_Speciale
    }    
    
    HideDisplayButton(Index_Speciale)                        
}

function PrevSpeciale(){
    var ID_Speciale_Cal 
    var Elem_Speciale_Corr = document.getElementById(ID_Speciale_Corr)                      
    
    Index_Speciale   -= 1
    ID_Speciale_Corr = ID_Speciale + Index_Speciale
    
    if (document.getElementById(ID_Speciale_Corr)){
        Elem_Speciale_Corr.style.display = 'none'
        document.getElementById(ID_Speciale_Corr).style.display = 'block'
    }else{
        Index_Speciale   += 1
        ID_Speciale_Corr = ID_Speciale + Index_Speciale
    }
    
    HideDisplayButton(Index_Speciale)                        
}        


//*****************************************
//      BOX ARCHIVIO PRODOTTI (sotto)
//*****************************************
function ClearKeyword_Azienda(){
    document.Form_SearchProdotti.k2.value = 'cerca un\'Azienda'
}

function ClearKeyword_Prodotti(){
    document.Form_SearchProdotti.k1.value = 'cerca un Prodotto'    
}

function InvioSearchProdotti(){
    var FormSearch = document.Form_SearchProdotti
    var key1       = FormSearch.k1.value
    var key2       = FormSearch.k2.value
    
    if (key1 == 'cerca un Prodotto') { key1 = '' }
    if (key2 == 'cerca un\'Azienda') { key2 = '' }
    
    if (key1 != '') { 
        FormSearch.keyword.value = key1
        FormSearch.idTipo.value  = ''
    }    
    if (key2 != '') {
        FormSearch.keyword.value = key2
        FormSearch.idTipo.value  = '1'
    }    
    
    if (FormSearch.keyword.value == '') {
        alert('Inserisci la parola chiave da ricercare!')
        return false 
    }            
}        
    

//*****************************************
//      BOX ARCHIVIO Libri (sotto)
//*****************************************    
 function ControlloInvioLibri()
    {    				   
        if ((document.formLibri.keyword.value == "") || (document.formLibri.keyword.value == "cerca un Libro"))                
        {
            alert("Inserire la parola da ricercare")
            return false
        }		      		    	    				    	        
    }    
 function inviaLibri(){	
    document.formLibri.keyword.value = ""
    document.formLibri.submit()	
 }   


//*****************************************
//      BOX ARCHIVIO Software (sotto)
//*****************************************    
function ControlloInvioSoftware()
 {    				   
        if ((document.formSoftware.keyword.value == "") || (document.formSoftware.keyword.value == "cerca un Software"))
        {
            alert("Inserire la parola da ricercare")
            return false
        }		      		    	    				    	        
 }    
 
 function inviaSoftware(){	
    document.formSoftware.keyword.value = ""
    document.formSoftware.submit()	
 }            