
menu0 = new Image();
menu0.src = "/img/flet_blanc.gif";

menu1 = new Image();
menu1.src = "/img/rec_vermell.gif";

menu2 = new Image();
menu2.src = "/img/cds_gris_fort.gif";

function menu_on(num){
	if(num=="3")document.getElementById('mlat').src="/img/cds_gris_fort.gif";
	document.getElementById('f'+num).src="/img/flet_blanc.gif";
	document.getElementById('m'+num).style.backgroundColor='#999999';
}

function menu_off(num){
	if(num=="3")document.getElementById('mlat').src="/img/cds_blanc.gif";
	document.getElementById('f'+num).src="/img/flet_gris.gif";
	document.getElementById('m'+num).style.backgroundColor='#FFFFFF';
}

function menubotiga_on(num){
	document.getElementById('ff'+num).src="/img/rec_vermell.gif";
	document.getElementById('mm'+num).style.backgroundColor='#ed2d38';
}

function menubotiga_off(num){
	document.getElementById('ff'+num).src="/img/rec_negre.gif";
	document.getElementById('mm'+num).style.backgroundColor='#FFFFFF';
}


function obrirmapa() {
	window.open('/mapa.php', 'mapa_t1muntanya' ,'width= 760 ,height= 500');
}

function obrirpresentacio(id_galeria){

	winWidth = 400; // sets a default width for browsers who do not understand screen.width below
	winheight = 400; // ditto for height

	if (screen){ // weeds out older browsers who do not understand screen.width/screen.height
	   winWidth = screen.width;
	   winHeight = screen.height;
	}
	var direccio="/presentacio/"+id_galeria;
	newWindow = window.open(direccio,id_galeria,'toolbar=no,location=no,scrollbars=no,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow.focus();

}


function zoom_fotografia(id_foto,w,h){

	//var winWidth = 800; // sets a default width for browsers who do not understand screen.width below
	//var winheight = 600; // ditto for height

	//if (screen){ // weeds out older browsers who do not understand screen.width/screen.height
	//   winWidth = screen.width;
	//   winHeight = screen.height;
	//}
	
	var direccio="/zoom/"+id_foto;
	newWindow = window.open(direccio,"zoom_"+id_foto,'toolbar=no,location=no,scrollbars=no,resizable=yes,width='+w+',height='+h+',left=15,top=15');
	newWindow.focus();

}

function presentacio(id_galeria){

	var winWidth = 800; // sets a default width for browsers who do not understand screen.width below
	var winheight = 600; // ditto for height

	if (screen){ // weeds out older browsers who do not understand screen.width/screen.height
	   winWidth = screen.width;
	   winHeight = screen.height;
	}
	
	var direccio="/presentacio/"+id_galeria;
	newWindow = window.open(direccio,"presentacio_"+id_galeria,'toolbar=no,location=no,scrollbars=no,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow.focus();

}


function ajax_afegir_comentari(){
	var c_id = document.afegir_comentaris.c_id.value;
	var c_nom = document.afegir_comentaris.c_nom.value;
	var c_comentaris = document.afegir_comentaris.c_comentaris.value;

	var d = new Date() 
	var parametres= 'c_id='+ encodeURI(c_id) + '&c_nom=' + encodeURI(c_nom) + '&c_comentaris=' + encodeURI(c_comentaris) + '&time=' + d.getTime();

	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_afegir_comentari(pagina_requerida)
	}
	pagina_requerida.open('POST', '/afegir_comentari.php', true); // asignamos los métodos open y send
	pagina_requerida.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	pagina_requerida.setRequestHeader('Content-Length',parametres.length);
	pagina_requerida.setRequestHeader('Connection',"close");
	pagina_requerida.send(parametres);




}

function cargarpagina_afegir_comentari(pagina_requerida) {

	if (pagina_requerida.readyState == 4) {
	    if (pagina_requerida.status == 200) {
		document.getElementById("contingut").innerHTML = pagina_requerida.responseText

	    } 
	    else {
		alert('Hubo problemas con la petición.');
	    }
	}
}


function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}


function afegir_comentari(){
	ShowContent('capa_afegir');
	HideContent('capa_llistar');
}

function llistar_comentaris(){
	HideContent('capa_afegir');
	ShowContent('capa_llistar');
}
