var switchtofoto = false;

function LayerGaristaObj(idlayer,idcontent) {
	
	var self = this;
	this.idlayer=idlayer;
	this.idcontent=idcontent;
	
	LayerGaristaObj.prototype.hide = function() {
		document.getElementById(this.idlayer).style.display = "none";
		document.getElementById(this.idcontent).style.display = "none";
	}
	
	LayerGaristaObj.prototype.show = function() {
		document.getElementById(this.idlayer).style.zIndex = mdlzindex++;
		document.getElementById(this.idlayer).style.display = "inline";
		document.getElementById(this.idcontent).style.display = "inline";
	}
	
	LayerGaristaObj.prototype.genGarista = function(foto,nome,descrizione,colore) {
	    var ret = "";
		ret += '<div style="width:100%;height:100%">';
        ret += "<table  CELLPADDING='5' CELLSPACING='0' WIDTH='100%' border='0' align='center' height='100%' >\n";
      	ret += "<tr height='160'>\n";
        ret += "<td width='100%' align='center'><IMG SRC='"+foto+"'/></td>\n";
      	ret += "</tr>\n";
      	ret += "<tr height='14'>\n";
        ret += "<td width='100%'><div style='position: absolute;float: left;width:96%;font-size:12px;font-weight:bold;background-color:#"+colore+";text-align:center;height:15px;vertical-align:middle;'>"+nome;
        ret += "<div style='position: relative;text-align:right;width:98%;vertical-align:middle;cursor:pointer;'><div id='imagexplain001' style='text-align:right;width:95%;font-size:10px;font-weight:normal;color:red;vertical-align:middle;display:none;'>Alterna descrizione e foto</div>\n<IMG SRC='img/switch.png' width='12' height='12' onclick='javascript:swiccia();' onmouseover='javascript:document.getElementById(\"imagexplain001\").style.display=\"inline\"' onmouseout='document.getElementById(\"imagexplain001\").style.display=\"none\"' /></div></div></td>\n";
      	ret += "</tr>\n";
      	ret += "<tr>\n";
        ret += "<td width='100%' height='180' align='center'></div><div id='descgarista' style='overflow: auto;overflow-x: hidden;height: 180px; display: inline;'>"+checknull(descrizione)+"</div><div id='fotocorrentegarista' style='display: none;font-size:12px;font-weight:bold;'><br>nessuna foto del percorso</div></td>\n";
      	ret += "</tr>\n";
		ret += "</table>\n";
		ret += '</div>';
		document.getElementById(this.idcontent).innerHTML = ret;
	}
	
	function checknull(s) {
		if (s=="null")
			s="";
		return s;	
	}
}
	
function swiccia() {
	if (switchtofoto) {
		document.getElementById("descgarista").style.display="inline";
		if (document.getElementById("fotocorrentegarista"))
			document.getElementById("fotocorrentegarista").style.display="none";
	} else {
		document.getElementById("descgarista").style.display="none";
		if (document.getElementById("fotocorrentegarista"))
			document.getElementById("fotocorrentegarista").style.display="inline";
	}
	switchtofoto = !switchtofoto;
}

