// JavaScript Document

//funciones para menú principal

function montar(id) {
	if (document.getElementById) {
		document.getElementById(id).style.display="block";
	} else if (document.all) {
		document.all[id].style.display="block";
	} else if (document.layers) {
		document.layers[id].display="block";
	} 
	/*  OCULTAR LOS SELECTS CUANDO DESPLIEGO MENU PARA QUE NO SE VEAN SOBRE EL MENU EN IEXPLORER */
	/*svn=document.getElementsByTagName("select");
	for (a=0;a<svn.length;a++){		svn[a].style.visibility="hidden";	}*/
}

function desmontar(id) {
   if (document.getElementById) {
	 document.getElementById(id).style.display="none";
   } else if (document.all) {
	 document.all[id].style.display="none";
   } else if (document.layers) {
	 document.layers[id].display="none";
   } 
   svn=document.getElementsByTagName("select");
	for (a=0;a<svn.length;a++){
	  svn[a].style.visibility="visible";
	}
}
	
function color(id){
	switch (id){
	case "inicio" :
			coloractual="#9FBFE0";
	  break;
	case "institucional" :
			coloractual="#993366";
	  break;
	case "comunidad" :
			coloractual="#66892D";
	break;
	case "profesionales" :
			coloractual="#EDA51B";
	break;
	case "pacientes" :
			coloractual="#006699";
	break;	}
	if (document.getElementById) {
	  document.getElementById("lineas").style.borderTopColor=coloractual;
	} else if (document.all) {
	  document.all["lineas"].style.borderTopColor=coloractual;
	} else if (document.layers) {
	  document.layers["lineas"].style.borderTopColor=coloractual;
	} 
}

function extraer_titulo(titulopag){
	bolita=String.fromCharCode(8226); // carga en bolita el caracter &bull; de html
	if (titulopag.indexOf(bolita)!=-1){
		titulo=titulopag.substring(titulopag.indexOf(bolita)+2,titulopag.length);// quita del titulo de la pagina el "Incucai . "
	}else{titulo=titulopag;}
	return titulo;
}

function imprimir(){	
		var tiene_var = document.URL.indexOf('?');
		if (tiene_var != -1){ 
			url_destino=document.URL +"&imprimir=si";
		}else{
			url_destino=document.URL +"?imprimir=si";
		}
		window.open(url_destino,'Imprimir', 'menubar=no, scrollbars=yes, width=760, height=420, top=50, left=50')
}

//Tamaño fuentes 
var factual = 1;
var fmenor = 0.5;
var fmayor = 1.5;

function aumentarFontSize(elemento){
	factual = (factual >= fmayor) ? fmayor : factual + 0.1;
	var txt = document.getElementById(elemento);
	txt.style.fontSize = factual +"em";
	//txt.style.lineHeight = (factual + 0.1) + "em";
}

function reducirFontSize(elemento){
	factual = (factual <= fmenor) ? fmenor : factual - 0.1;
	var txt = document.getElementById(elemento);
	txt.style.fontSize = factual + "em";
	//txt.style.lineHeight = (factual + 0.1) + "em";
}

function esteAnio(){
	var hoy= new Date();
	var anio= hoy.getYear();
	if(anio < 2000) { anio = anio + 1900; }
	document.write(anio);
}

function hoy(){
	var d = new Date();
	var curr_date = dosdigitos(d.getDate()+"");
	var curr_month = dosdigitos(d.getMonth()+1+"");
	var curr_year = dosdigitos(d.getFullYear()+"");
	var curr_hour = dosdigitos(d.getHours()+"");
	var curr_min = dosdigitos(d.getMinutes()+"");
	document.write(curr_date + "/" + curr_month + "/" + curr_year+" "+curr_hour + ":" + curr_min );
}

function cambiarCssxResolucion(archivocss) {
    if (screen.width<=800) {
    	document.write("<link href=\"/css/incucai800.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\"/>");
	    document.write("<link href=\"/css/"+archivocss+"800.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\"/>");
    } else {
        document.write("<link href=\"/css/incucai.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\"/>");
        document.write("<link href=\"/css/"+archivocss+".css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\"/>");
    }
}

function dosdigitos(texto){
	if (texto.length == 1)
   {
   texto = "0" + texto;
   }
	 return texto;
}

function rand ( n )
{  
    return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
	
function tamaniocabecera() 
{
	var cssdocs;
	if (document.all) {
	  cssdocs = 'rules';
	}
	else if (document.getElementById) {
	  cssdocs = 'cssRules';
	}
	 
	var imagenazar;
	imagenazar = dosdigitos('' + rand(3));
 	 
	for (var i = 0; i < document.styleSheets.length; i++){
		for (var j = 0; j < document.styleSheets[i][cssdocs].length; j++) {
			//
			if (document.styleSheets[i][cssdocs][j].selectorText == '#tope') {
				switch (true){
					case (screen.width<=800):
						document.styleSheets[i][cssdocs][j].style['background'] = 'url(/media/img/foto_cabecera'+imagenazar+'800.jpg) top left no-repeat';
						break;
					default:
						document.styleSheets[i][cssdocs][j].style['background'] = 'url(/media/img/foto_cabecera'+imagenazar+'.jpg) top left no-repeat';
				}
			}
        }
	}	
}
	 
function mostrarsubsecciones()
{
	oSecciones = document.getElementById("secciones");
	oSubSec=oSecciones.getElementsByTagName("div");
	for (var i=0; i<oSubSec.length; i++) {
		oSubSec[i].style.display="block";
	}
}

function verresultados(valor)
{
	//function changecss(theClass,element,value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssReglas;
	 if (document.all) {
	  cssReglas = 'rules';
	 }
	 else if (document.getElementById) {
	  cssReglas = 'cssRules';
	 }
	 for (var i = 0; i < document.styleSheets.length; i++){
		for (var j = 0; j < document.styleSheets[i][cssReglas].length; j++) {
			//
	   	if (document.styleSheets[i][cssReglas][j].selectorText == '#contenido .resultados') {
				//alert(document.styleSheets[i].href+' - href');
	    	document.styleSheets[i][cssReglas][j].style['display'] = valor;
	   	}
	  }
	 }	
}

