fotoMostra = 1;

function rollOver(capa)
{
	obj = document.getElementById(capa+"ref");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"producto");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"localidad");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"tipo");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"precio");
	obj.style.backgroundColor = "#B7E727";
}

function noRollOver(capa)
{
	obj = document.getElementById(capa+"ref");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"producto");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"localidad");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"tipo");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"precio");
	obj.style.backgroundColor = "#FFFFFF";
}

function rollOverPromotoras(capa)
{
	obj = document.getElementById(capa+"Promotora");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"Web");
	obj.style.backgroundColor = "#B7E727";
	obj = document.getElementById(capa+"VerProductos");
	obj.style.backgroundColor = "#B7E727";
}

function noRollOverPromotoras(capa)
{
	obj = document.getElementById(capa+"Promotora");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"Web");
	obj.style.backgroundColor = "#FFFFFF";
	obj = document.getElementById(capa+"VerProductos");
	obj.style.backgroundColor = "#FFFFFF";
}

function canvia_foto_galeria(foto_seleccionada, num_fotos)
{	
	fotoMostra = foto_seleccionada;
	foto = "foto" + foto_seleccionada;
	obj = document.getElementById(foto);
	if (obj.style.visibility != "visible")
	{
		obj.style.visibility = "visible";
	
		for (i=1;i<=num_fotos;i++)
		{
			it = String(i);
			foto_noseleccionada = "foto" + it;
			if (foto != foto_noseleccionada)
			{	
				obj = document.getElementById(foto_noseleccionada);
				obj.style.visibility = "hidden";
			}
		}
	}
}

function fotoAnterior(num_fotos) {
	fotoMostra = (fotoMostra - 1)%num_fotos;
	if (fotoMostra == 0)
		fotoMostra = num_fotos;
	canvia_foto_galeria(fotoMostra, num_fotos);
}

function fotoSiguiente(num_fotos) {
	fotoMostra = (fotoMostra + 1)%num_fotos;
	if (fotoMostra == 0)
		fotoMostra = num_fotos;
	canvia_foto_galeria(fotoMostra, num_fotos);
}

function ocultarFotos() {
	obj = document.getElementById("galeria");
	obj.style.visibility = "hidden";
	
	obj = document.getElementById("transparenciaGaleria");
	obj.style.visibility = "hidden";
	
	obj = document.getElementById("transparenciaMostrarFotos");
	obj.style.visibility = "visible";
	
	obj = document.getElementById("flechasMostrarFotos");
	obj.style.visibility = "visible";
	
	obj = document.getElementById("mostrarFotos");
	obj.style.visibility = "visible";
}

function mostrarFotos() {
	obj = document.getElementById("transparenciaMostrarFotos");
	obj.style.visibility = "hidden";
	
	obj = document.getElementById("mostrarFotos");
	obj.style.visibility = "hidden";
	
	obj = document.getElementById("flechasMostrarFotos");
	obj.style.visibility = "hidden";
	
	obj = document.getElementById("galeria");
	obj.style.visibility = "visible";
	
	obj = document.getElementById("transparenciaGaleria");
	obj.style.visibility = "visible";
}

// FUNCIONS AJAX
// Esta función cargará las paginas
function llamarasincrono(url, id_contenedor){
	var pagina_requerida = false
	if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
		pagina_requerida = new XMLHttpRequest()
	} 
	else if (window.ActiveXObject){ // pero si es IE
		try {
			pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){ // en caso que sea una versión antigua
			try{
				pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	
	pagina_requerida.onreadystatechange=function(){ // función de respuesta
		cargarpagina(pagina_requerida, id_contenedor)
	}
	pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
	pagina_requerida.send(null)
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor){
	if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
}
