/* hack del puto IE para evitar el parpadeo en los rollovers */
if(document.uniqueID && !window.XMLHttpRequest ){
document.execCommand("BackgroundImageCache",false,true)
}

/* 
	esta función es un hack para I5+/IE6
	"añade" la capacidad de hover a los elementos LI, claseándolos
*/
startList = function()
{
	if (document.all&&document.getElementById) 
	{

		// para el menú principal
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() 
				{
					this.className+=" over";
				}
				
				node.onmouseout=function() 
				{
					this.className=this.className.substring(0,this.className.indexOf(" "));
				}
   		}
  		}

		// lo mismo para el desplegable azul
		navRoot = document.getElementById("nav2");
		if (document.getElementById("nav2")!=null) {
			for (i=0; i<navRoot.childNodes.length; i++) 
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") 
				{
					node.onmouseover=function() 
					{
						this.className+=" over";
					}
					
					node.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				}
	  		}
		}

	 	/* hack para IE6, evitando que quite una imagen del menu si tienes el ratón sobre el menú, al cargar la página */
	 	document.getElementById("nav").style.display = "block";

 	}
}
window.onload=startList;

/* 
	Aumentar el tamaño de la letra
*/

/*
function zoom() {
	//document.body.style.zoom='130%'
	document.all.tags('body')[0].style.setAttribute('zoom','120%','false');
}
*/

function putFont(sizeper){
	fontByTag('a',sizeper);
	fontByTag('p',sizeper);
	fontByTag('span',sizeper);
	fontByTag('td',sizeper);
	fontByTag('div',sizeper);
	fontByTag('li',sizeper);
	switch (sizeper) {
		case 0: document.getElementById('titulardreta').getElementsByTagName('p')[0].style.fontSize="18px"; break;
		case 1: document.getElementById('titulardreta').getElementsByTagName('p')[0].style.fontSize="19px"; break;
		case 2: document.getElementById('titulardreta').getElementsByTagName('p')[0].style.fontSize="20px"; break;
	}
}

function fontByTag (tag,size) {
	var divElements = document.getElementsByTagName(tag); 
	for (i=0;i<divElements.length;i++){
		obj=divElements[i];
		if (obj.style.fontSize==""){
			obj.style.fontSize="100%";
		}	
		valor=11+size;
		obj.style.fontSize=valor+"px";
		if(size==0){
			obj.style.fontSize="";
		}
	}
}




/*
function putFont(tipo) {
		switch (tipo) {
			case 0: tamany = 100; break;
			case 1: tamany = 110; break;
			case 2: tamany = 120; break;
		}
		document.all.tags('body')[0].style.setAttribute('zoom',tamany+'%','false');
}
*/

function visible(idd) {
	vis = document.getElementById(idd).style['display'];
	if (vis=='' || vis=='none') {
		document.getElementById(idd).style['display']='block';
	} else {
		document.getElementById(idd).style['display']='none';
	}
}
function invisible(idd) {
	document.getElementById(idd).style['display']='none';
}


function centrescanvi(npag) {
	document.forms[0].npag.value=npag;
	document.forms[0].submit();
}

function canviprovincia1() {
	form = document.forms['f1'];		
	var prov;
	prov = form.f1_provincia[form.f1_provincia.selectedIndex].value;
	if (prov != 0) {
		txt_pob=eval("txt_pob1_" + prov);
		cod_pob=eval("cod_pob1_" + prov);
		num_pob=txt_pob.length;
		form.f1_poblacio.length = num_pob;
		for(i=0;i<num_pob;i++){
			form.f1_poblacio.options[i].value=cod_pob[i];
			form.f1_poblacio.options[i].text=txt_pob[i];
		}
	} else {
	   form.f1_poblacio.length = 1
	   form.f1_poblacio.options[0].value = "-"
	   form.f1_poblacio.options[0].text = "-"
	}
	form.f1_poblacio.options[0].selected = true 
}

function canviprovincia2() {
	form = document.forms['f2'];		
	var prov;
	prov = form.f2_provincia[form.f2_provincia.selectedIndex].value;
	if (prov != 0) {
		txt_pob=eval("txt_pob2_" + prov);
		cod_pob=eval("cod_pob2_" + prov);
		num_pob=txt_pob.length;
		form.f2_poblacio.length = num_pob;
		for(i=0;i<num_pob;i++){
			form.f2_poblacio.options[i].value=cod_pob[i];
			form.f2_poblacio.options[i].text=txt_pob[i];
		}
	} else {
	   form.f2_poblacio.length = 1
	   form.f2_poblacio.options[0].value = "-"
	   form.f2_poblacio.options[0].text = "-"
	}
	form.f2_poblacio.options[0].selected = true 
}

function enviament(lang) {
	switch (lang) {
		case 'es':
			missatge1 = 'Es obligatorio llenar todos los datos';
			missatge2 = 'Es obligatorio leer y aceptar la Política de protección de datos';
			break;
		default:
			missatge1 = 'Es obligatori emplenar totes les dades';
			missatge2 = 'Es obligatori llegir i acceptar la Política de protecció de dades';
	}

	form = document.forms['f4'];
	bvalido = true;
	if (form.f4_nomicognoms.value=='' || form.f4_correu.value=='' || (form.f4_pertany[0].checked==false && form.f4_pertany[1].checked==false) || form.f4_motiu.value=='' || form.f4_consulta.value=='') {
		alert(missatge1); bvalido = false;
	}
	if (bvalido && form.f4_hellegit.checked==false) {
		alert(missatge2); bvalido = false;
	}
	if (bvalido) { form.submit(); }
}

var ventana = null;
function imprimir_centres() {
	f = document.forms['f1'];
	id1 = f.f1_nomcentre.value;
	id2 = f.f1_provincia.value;
	id3 = f.f1_poblacio.value;
	CerrarVentana();
	posx = 10; posy = 10; vent_x = 500; vent_y = 500;
	ventana = window.open('centres_rs_print.php?id1='+id1+'&id2='+id2+'&id3='+id3,'Ventana');
	ventana.focus();
}
function imprimir_especialistes() {
	f = document.forms['f2'];
	id1 = f.f2_nom.value;
	id2 = f.f2_cognom.value;
	id3 = f.f2_especialitat.value;
	id4 = f.f2_provincia.value;
	id5 = f.f2_poblacio.value;
	id6 = f.f2_codipostal.value;
	CerrarVentana();
	posx = 10; posy = 10; vent_x = 500; vent_y = 500;
	ventana = window.open('especialistes_rs_print.php?id1='+id1+'&id2='+id2+'&id3='+id3+'&id4='+id4+'&id5='+id5+'&id6='+id6,'Ventana');
	ventana.focus();
}
function CerrarVentana() { 
  if (ventana != null && ventana.closed == false) { ventana.close(); }
}

