function muestraFoto(path)
{
	var vent = window.open("", "", "top=200,left=300,width=246,height=241,status=no,resizable=no,scrollbars=no,menubar=no,toolbar=no")
	vent.document.write("<html><head><title>Fotografía del Producto</title></head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='imgs_web/" + path + "'></body></html>");
}

//Recibe una cadena con un texto en varios idiomas, separado por caracteres "ç"
//y devuelve el texto en el idioma indicado
function sacaIdioma(cad, idioma)
{
	if(cad.indexOf("ç")==-1)
		return(cad);
	else
	{
		var vecIdiomas = cad.split("ç");
		if(vecIdiomas.length < idioma)
			return(vecIdiomas[0]);
		else
			if(vecIdiomas[idioma-1] == "") 
				return("(No introducido)"); 
			else 
				return(vecIdiomas[idioma-1]);
	}
}







/* ====================================   menú derecha   ==================================== */

function menuDerechaSoluciones()
{	var cadMenu = "";

	for(var i=0; 2*i<vIndiceSoluciones.length; i++)
	{
		cadMenu += ('<tr><td width="125"><div align="right"><a href="soluciones' + idiomaActual + '.asp?id=' + vIndiceSoluciones[2*i] + '" class="menu_derecha" >' + sacaIdioma(vIndiceSoluciones[2*i+1],idiomaActual) + '</a></td>');
		cadMenu += ('<td width="10" background="imgs_web/i9.gif" valign="top"><img src="imgs_web/i6.gif" width="10" height="13"></td></tr>');

		if(2*i<vIndiceSoluciones.length-2)
			cadMenu += ('<tr height="7"><td><div align="right"></div></td><td width="10" background="imgs_web/i9.gif" valign="top"></td></tr>');
		else
			cadMenu += ('<tr><td colspan="2"><div align="right"><img src="imgs_web/i7.gif" width="76" height="6"></div></td></tr>');
	}
	return cadMenu;
}









/* ====================================   Obras   ==================================== */


function muestraObras(indice)
{
	document.getElementById("spanTitulo").innerHTML = sacaIdioma(vIndiceObras[indice][0],idiomaActual);
	document.getElementById("divTexto").innerHTML = generaTablaObras(indice);

	for(var i=0; i<vIndiceObras.length; i++)
		document.getElementById("obra" + i).className = (i == indice) ? "menu_derecha_selected" : "menu_derecha";

}


function generaTablaObras(indice)
{
	var cadTabla;

	var vCabecera = new Array;

	switch(idiomaActual)
	{
		case 1: vCabecera[0] = "Obra"; vCabecera[1] = "Localidad"; vCabecera[2] = "Superficie"; vCabecera[3] = "Foto"; vCabecera[4] = "Cliente"; break;
		case 2: vCabecera[0] = "Work"; vCabecera[1] = "Location"; vCabecera[2] = "Surface"; vCabecera[3] = "Photo"; vCabecera[4] = "Client"; break;
		case 3: vCabecera[0] = "LAGE DER ARBEIT"; vCabecera[1] = "ORTLICHKEIT"; vCabecera[2] = "m<sup>2</sup>"; vCabecera[3] = "Fotographie"; vCabecera[4] = "Kunde"; break;
		default: break;
	}
	cadTabla = '<table width="465" border="0" cellspacing="2" cellpadding="2" class="peque"><tr class="tabla_head"><td width="240">' + vCabecera[0] + '</td><td width="100">' + vCabecera[1] + '</td><td width="80">' + vCabecera[2] + '</td><td width="40"><p>' + vCabecera[3] + '</p></td></tr>'; 
	for(var i=1;5*i<vIndiceObras[indice].length;i++)
	{
		cadTabla += '<tr><td class="tabla_linea" align="center" style="font-size:7pt;">' + vIndiceObras[indice][5*i-4] + '<br><b>' + vCabecera[4] + ':</b>&nbsp;' + vIndiceObras[indice][5*i-3] + '</td><td class="tabla_linea" align="center" style="font-size:7pt;">' + vIndiceObras[indice][5*i-2] + '</td><td class="tabla_linea" align="center" style="font-size:7pt;">' + vIndiceObras[indice][5*i-1] + ' m<sup>2</sup></td><td class="tabla_linea" align="center" style="font-size:7pt;">';
		if (vIndiceObras[indice][5*i] != '')
			cadTabla += '<a href="javascript:muestraFotoObra(' + indice + "," + i + ');"><img src="imgs_web/flecha.gif" width="10" height="10" border="0"></a>';
		cadTabla += '</td></tr>';
	}
	cadTabla += '</table><p>&nbsp;</p>';


	return cadTabla;
}

function muestraFotoObra(indice,num)
{
//	document.getElementById("fotoObra_titulo").innerHTML = vIndiceObras[indice][5*num-4];
//	document.getElementById("fotoObra_tabla").style.display = 'block';
//	document.getElementById("fotoObra_foto").innerHTML = '<img src="imgs_obras/' + vIndiceObras[indice][5*num] + '">'; 
	window.open("obras_foto.asp?indice=" + indice + "&num=" + num, true, "height=500,width=450,status=no,resizable=no");
}


function menuDerechaObras()
{	var cadMenu = "";

	for(var i=0; i<vIndiceObras.length; i++)
	{
		cadMenu += ('<tr><td width="125"><div align="right"><a href="javascript:muestraObras(' + i + ');" class="menu_derecha" id="obra' + i + '">' + sacaIdioma(vIndiceObras[i][0],idiomaActual) + '</a></td>');
		cadMenu += ('<td width="10" background="imgs_web/i9.gif" valign="top"><img src="imgs_web/i6.gif" width="10" height="13"></td></tr>');

		if(i<vIndiceObras.length-1)
			cadMenu += ('<tr height="7"><td><div align="right"></div></td><td width="10" background="imgs_web/i9.gif" valign="top"></td></tr>');
		else
			cadMenu += ('<tr><td colspan="2"><div align="right"><img src="imgs_web/i7.gif" width="76" height="6"></div></td></tr>');
	}
	return cadMenu;
}









/* ====================================   Productos   ==================================== */




/* ======   menú izquierda   ====== */

function creaMenuIzq(idProducto)
{
	var menu = "";
	for(var i=0; i<vIndiceProductos.length; i++)
		for(var j=4; j<vIndiceProductos[i].length; j+=2)
			menu += creaItemIzq(i,j,idProducto);

	document.write(menu);
}

function creaItemIzq(i,j,idProducto)
{
	var cad = '<tr><td bgcolor="' + vIndiceProductos[i][2] + '" width="9"></td>';
	cad += '<td bgcolor="#FFFFFF" width="1"></td>';
	if(vIndiceProductos[i][j] == idProducto)
	{
		cad += '<td bgcolor="#B91C10" height="15" class="celdaMenu" style="color:#FFFFFF;">';
		cad += sacaIdioma(vIndiceProductos[i][j+1], idiomaActual);
		cad += '</td>';
	}
	else
	{
		cad += '<td bgcolor="' + vIndiceProductos[i][3] + '" height="15" class="celdaMenu"';
		cad += ' onMouseOver="destaca(this);"';
		cad += ' onMouseOut="nodestaca(this,\'' + vIndiceProductos[i][3] + '\');"';
		cad += ' onClick="abreProducto(' + vIndiceProductos[i][j] + ');">';
		cad += sacaIdioma(vIndiceProductos[i][j+1], idiomaActual);
		cad += '</td>';
	}
	cad += '</tr>';
	cad += '<tr height="1"><td colspan="3" bgcolor="#ffffff"></td></tr>';

	return (cad);
}

		function destaca(celda)
		{
			celda.style.backgroundColor='#B91C10';
			celda.style.color='#FFFFFF';
		}

		function nodestaca(celda,color)
		{
			celda.style.backgroundColor=color;
			celda.style.color='#000000';
		}


function abreProducto(idProducto)
{
	document.location.href = "productos" + idiomaActual + ".asp?id=" + idProducto;
}



/* ======   menú derecha   ====== */

function menuDerechaProductos()
{	var cadMenu = "";

	for(var i=1; i<=vPropiedades[0]; i++)
	{
		cadMenu += ('<tr><td width="125"><div align="right"><a href="javascript:muestraItemProducto(' + i + ');" class="menu_derecha" id="car' + i + '">' + vPropiedades[2*i-1] + '</a></td>');
		cadMenu += ('<td width="10" background="imgs_web/i9.gif" valign="top"><img src="imgs_web/i6.gif" width="10" height="13"></td></tr>');

		if(i<vPropiedades[0])
			cadMenu += ('<tr height="7"><td><div align="right"></div></td><td width="10" background="imgs_web/i9.gif" valign="top"></td></tr>');
		else
			cadMenu += ('<tr><td colspan="2"><div align="right"><img src="imgs_web/i7.gif" width="76" height="6"></div></td></tr>');
	}

	return cadMenu;
}

			function muestraItemProducto(indice)
			{
				document.getElementById("spanTitulo").innerHTML = unescape(vPropiedades[2*indice-1]);
				document.getElementById("divTexto").innerHTML = unescape(vPropiedades[2*indice]);

				for(var i=1; 2*i<vPropiedades.length; i++)
					document.getElementById("car" + i).className = (i == indice) ? "menu_derecha_selected" : "menu_derecha";

				document.location.href = "#";
			}

function muestraOpcionesAbajo()
{
	var cadMenu = "";

	for(var i=1; i<=vPropiedades[0]; i++)
		cadMenu += ('<a href="javascript:muestraItemProducto(' + i + ');" class="menu_derecha" id="car' + i + '">[' + vPropiedades[2*i-1] + ']</a>&nbsp;&nbsp;');

	document.getElementById("divAbajo").innerHTML = cadMenu;
}
