
var pstatus = "hide";
var pInZonatoclose="DatiLocalita";
var pPortolanotoclose="SchedaPortolano";
var ptabtoHide="tab1Portoa";
var ptabToShow="tab1Porto";

function hideshowPanel(panel,imageDiv,ImageName){
	
	if (document.getElementById(panel).style.display=="none"){
		document.getElementById(panel).style.display="block";
		document.getElementById(imageDiv).className=ImageName + "C";
		
	}else if (document.getElementById(panel).style.display=="block"){ 
		document.getElementById(panel).style.display="none";
		document.getElementById(imageDiv).className=ImageName + "A";
		
	}
}

function hideshowPanelPortolano(panelName,tabnameToShow)
{
		
		
		document.getElementById(pPortolanotoclose).style.display="none";
		document.getElementById(ptabtoHide).style.display="none";
		document.getElementById(ptabToShow).style.display="block";	
		
		if(document.getElementById(panelName).style.display=="none")
		{
			document.getElementById(panelName).style.display="block";
			document.getElementById(tabnameToShow+"a").style.display="block";
			document.getElementById(tabnameToShow).style.display="none";
			ptabtoHide=tabnameToShow+"a";
			ptabToShow=tabnameToShow
		}
		else
		{
		document.getElementById(panelName).style.display="none";
			document.getElementById(tabnameToShow+"a").style.display="none";
			document.getElementById(tabnameToShow).style.display="block";
			ptabtoHide=tabnameToShow;
			ptabToShow=tabnameToShow+"a";
		}
		
				
		pPortolanotoclose=panelName;
			
		
}


function hideshowPanelInZona(panelName)
{
	
		document.getElementById(pInZonatoclose).style.display="none";
		document.getElementById("link" + pInZonatoclose).className='linkmenuInZona'
		document.getElementById("link" + panelName).className='linkmenuInZonaSelected'
		document.getElementById(panelName).style.display="block";
		pInZonatoclose=panelName;
}


function showMeta(){
	document.getElementById('tab1').style.display="none";
	document.getElementById('tab1a').style.display="inline";
	document.getElementById('tab2').style.display="none";
	document.getElementById('tab2a').style.display="inline";
	document.getElementById('oggiCrociera').style.display="none";
	document.getElementById('oggiMeta').style.display="block";
	document.getElementById('tabbi').className="tabbi2";
}

function showCrociera(){
	document.getElementById('tab1a').style.display="none";
	document.getElementById('tab1').style.display="inline";
	document.getElementById('tab2a').style.display="none";
	document.getElementById('tab2').style.display="inline";
	document.getElementById('oggiCrociera').style.display="block";
	document.getElementById('oggiMeta').style.display="none";
	document.getElementById('tabbi').className="tabbi1";
}
/*
var xmlDoc;
var supplierXMLHTTPRequest;

function caricaSupplier(url, vettoreParametri)
function loadSupplier()
*/
   var xmlDoc;
   var supplierXMLHTTPRequest = null;
    var vettoreServizi = new Array;
    var vettoreServiziMarina = new Array;
 var vettoreServiziBarca = new Array;
  
  ///skippercms/resources/img/servizi/<c:out value="${harbourService.serviceId}" />.gif
  ///skippercms/resources/img/servizi/<c:out value="${harbourService.serviceId}" />_s.gif
 
   function caricaSupplier(url){

    hideSupplier('supplier');
    supplierXMLHTTPRequest = makeRequest(url, 'html');
    if (supplierXMLHTTPRequest.readyState != 4)
     supplierXMLHTTPRequest.onreadystatechange = loadSupplier;   
    else 
     loadSupplier();
   }
   

   function loadSupplier(){
    if (supplierXMLHTTPRequest.readyState == 4){
     gb = getObject('supplier');
     gb.innerHTML = supplierXMLHTTPRequest.responseText;
     risp = supplierXMLHTTPRequest.responseText;
     showSupplier('supplier');
     document.getElementById('port').style.height='auto';
     if(serviceId==19){
     	document.getElementById('supplier').className="testoServiziRistoPortoDisplay";
     	document.getElementById('testoServiziPortolano').style.overflowY='hidden';
     	
     	parseJavascripts(risp,'<script type="text/javascript">','</script>','<script type="text/javascript">');
     	
     	//Questa è una porcata ma funziona, le due variabili deviazioneRistorante e 
     	//cantiereDeviante sono globali e impostate in portolano     	
     	if (deviazioneRistorante)
     	{
     		showDescrSupplier('divSupplier','risto_',ristoranteDeviante,1);     		
     		deviazioneRistorante=0;
     	}     		
     	else
     	   	showDescrSupplier('divSupplier','risto_',vettoreSupplier[0],1);

	 }
	 if(serviceId==8){
	 	document.getElementById('supplier').className="testoServiziRistoPortoDisplay";
	 	document.getElementById('testoServiziPortolano').style.overflowY='hidden';
	 	parseJavascripts(risp,'<script type="text/javascript">','</script>','<script type="text/javascript">');
	 	
	 	//Questa è una porcata ma funziona, le due variabili deviazioneCantiere e 
     	//cantiereDeviante sono globali e impostate in portolano     	
     	if (deviazioneCantiere)
     	{
     		showDescrSupplier('divSupplier','cantieri_',cantiereDeviante,2);
     		deviazioneCantiere=0;
     	}
     	else
	 		showDescrSupplier('divSupplier','cantieri_',vettoreSupplierCantieri[0],2);
		
	 }
	
    }
   }
  

   var serviceId;
   function settaServizio(id, vettoreServizi, idHarb){
 	 hide('Selectsupplier');
   serviceId=id;
   
   disattivaIcone(vettoreServizi, id);
   
	 idTipo = "chk"+ id;
	 o = getObject(idTipo);
	 if (o!=null)
	 {
	 	if (o.checked==true){
	 
	  	o.checked = false;
	  	idImg = "imgServizio_chk" + id;
	  	img_o = getObject(idImg);
	  	if (img_o!=null)
	  		img_o.src = "/skippercms/resources/img/servizi/" + id + ".gif";
	  	show('Selectsupplier');
	  	hideSupplier('supplier');
	  	}
	  	else
	  	{
	  	  o.checked = true;
	  	  idImg = "imgServizio_chk" + id;
	  	  img_o = getObject(idImg);
	  	  if (img_o!=null)
	  	    	img_o.src = "/skippercms/resources/img/servizi/" + id + "-sel.gif";
	  	  var url;
	  	 }
	  }
		
	  	if(serviceId=='19' || serviceId=='8')
	  	{
	  		url='/porto.do?method=showRistoEcantieri&idHarbour='+idHarb +'&idService=' +id;
	  		caricaSupplier(url);
	  	}
	  	else
	  	{
	  		url='/porto.do?method=showSupplier&idHarbour='+idHarb +'&idService=' +id;
	  		caricaSupplier(url);
	    }
	
	
	 return false;
	}
  
   function disattivaIcone(vettoreServizi, id){
  
	 for(i=0;i<vettoreServizi.length;i++){
	 	idTipo = "imgServizio_chk"  + vettoreServizi[i];
	 	
	 	try{
	 	    if (vettoreServizi[i] != id)
	 	    {
		 	 img_o = getObject(idTipo);
		 	 img_o.src = "/skippercms/resources/img/servizi/" + vettoreServizi[i] + ".gif";
		 	 idTipo1 = "chk" +  vettoreServizi[i];
		 	 o = getObject(idTipo1);
		 	 o.checked=false; 
		 	} 
	 	}
	 	catch(e){
	 		//alert(e.message);
	 	}
	 	 
	}
	return false;
 
   }
    function showSupplier(id)
    { 
     my_object = getObject(id);
     my_object.className = 'testoServiziTabPortoDisplay';
    }
 
    function hideSupplier(id)
    { 
     my_object = getObject(id);
     my_object.className = 'testoServiziTabPortoNone';
    }
    
    var accessoXMLRequest =null;

    function salvaAccesso(url, memberId, resourceUrl){
	    //alert('memberId ' +memberId);
	    //alert('resourceUrl ' +resourceUrl);
        vettoreParametri = new Array();
        vettoreParametri[vettoreParametri.length] = "memberId=" +  encodeURIComponent(memberId);
        vettoreParametri[vettoreParametri.length] = "resourceUrl=" +  encodeURIComponent(resourceUrl);
    	accessoXMLRequest = makeRequest(url, 'html',vettoreParametri);
    }
    
     function salvaAccessoGis( memberId, latitude, longitude, serverUrl, zoom){
	    //alert('memberId ' +memberId);
	    //alert('resourceUrl ' +resourceUrl);
        vettoreParametri = new Array();
        vettoreParametri[vettoreParametri.length] = "memberId=" +  encodeURIComponent(memberId);
        vettoreParametri[vettoreParametri.length] = "resourceUrl=" +  encodeURIComponent(resourceUrl);
    	accessoXMLRequest = makeRequest('/porto.do?method=salvaAccessoGis', 'html',vettoreParametri);
    	
    	init(latitude,longitude,zoom, serverUrl);
    }
    
    
    vettoreSupplierCantieri = new Array();
    vettoreSupplier = new Array();
    var linkRistoShown='risto_0';
	var divRistoShown='itemDxRisto_0'; 
	var ristoId;
	
	var linkCantieriShown='cantieri_0';
	var divCantieriShown='itemDxCantieri_0'; 
	var cantieriId;
	
    function showTestoSupplier(divName, linkName,id, tipoId){
    	if(tipoId==1){
    	//visualizzazione ristoranti
    	ristoId=id;
    	var indiceSupplier=vettoreSupplier.length;
    	divRisto=divName +ristoId;
	    linkRisto=linkName +ristoId;
    	
    	for(var indice=0; indice<=indiceSupplier; indice++){	
    		if(ristoId==indice){
    			document.getElementById(divRisto).style.display="block";
    			document.getElementById(linkRisto).className='linkRistorantiSel';
    		}else{
    			document.getElementById(divRistoShown).style.display="none";
    			document.getElementById(linkRistoShown).className='linkRistoranti';
    			
    		}
    	}
    	divRistoShown=divRisto;
	    linkRistoShown=linkRisto;
    	}
    	//visualizzazione cantieri
    	else{
    		cantieriId=id;
    		
	    	var indiceCantieri=vettoreSupplierCantieri.length;
	    	divCantieri=divName +cantieriId;
		    linkCantieri=linkName +cantieriId;
	    
	    	for(var indiceC=0; indiceC<=indiceCantieri; indiceC++){	
	    		if(cantieriId==indiceC){
	    			document.getElementById(divCantieri).style.display="block";
	    			document.getElementById(linkCantieri).className='linkCantieriSel';
	    		}else{
	    			document.getElementById(divCantieriShown).style.display="none";
	    			document.getElementById(linkCantieriShown).className='linkCantieri';
	    			
	    		}
	    	}
	    	divCantieriShown=divCantieri;
		    linkCantieriShown=linkCantieri;
    	}
    	
    	
    	
}



   
 


