var ua = navigator.userAgent.toLowerCase();
function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
}	

// Corrector de Bug PNG para Explorer. Opera y Mozilla funcionan correctamente sin este JS
function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }

   }

if (detect('opera')) {
	 
 } else if (detect('firefox')){
	 
} else if (detect('msie')){
	 window.attachEvent("onload", correctPNG);	
}	

function Carga () {
	Capas = document.getElementsByTagName("div");
	NumeroCapas = Capas.length;
	Links = document.getElementsByTagName("a");
	NumeroLinks = Links.length;
}

function MostrarOcultarDiv(divId) {
	var state = document.getElementById(divId).style.display;
	if(state== 'none'){
		document.getElementById(divId).style.display = 'block';
	}else{
		document.getElementById(divId).style.display = 'none';
	}
}	




/* ONBLUR DESDE JAVASCRIPT DE TODOS LOS FORMULARIOS. */			

function MarcadoresDeFormularios() {
	var inputes=document.getElementsByTagName('input');
	var textareas=document.getElementsByTagName('textarea');
	var selectes=document.getElementsByTagName('select');
	var numElementosInput = inputes.length;
	var numElementosTextareas = textareas.length;
	var numElementosSelect = selectes.length;
	for (contador=0; contador<numElementosInput; contador++) {
		if (inputes[contador].type=='radio' || inputes[contador].type=='checkbox') {
			inputes[contador].style.border="0px"
		}
		if (inputes[contador].type!='radio' && inputes[contador].type!='checkbox' && inputes[contador].type!='submit' && inputes[contador].readOnly!=true) {
			inputes[contador].onfocus= function() { this.style.border= '2px solid #6cc0ed'; this.style.color= '#000'; this.style.padding= '1px';}
			inputes[contador].onblur= function() { this.style.border= '1px solid #bbb'; this.style.color= '#666'; this.style.padding= '2px';}
		}
	}
	for (contador=0; contador<numElementosTextareas; contador++) {
		textareas[contador].onfocus= function() { this.style.border= '2px solid #6cc0ed'; this.style.color= '#000'; this.style.padding= '1px';}
		textareas[contador].onblur= function() { this.style.border= '1px solid #bbb'; this.style.color= '#666'; this.style.padding= '2px';}
	}		
	for (contador=0; contador<numElementosSelect; contador++) {
		selectes[contador].onfocus= function() { this.style.border= '1px solid #6cc0ed'; this.style.color= '#000';}
		selectes[contador].onblur= function() { this.style.border= '1px solid #bbb'; this.style.color= '#666';}
	}			
}


function MostrarOcultarCaja(divId,ClassDiv,idPestana) {
	OcultaDivs (ClassDiv);	
	var state = document.getElementById(divId).style.display;
	if(state== 'none'){
		document.getElementById(divId).style.display = 'block';
	}else{
		document.getElementById(divId).style.display = 'none';
	}
}	

/* OCULTA TODOS LOS DIVS CON UN CLASS DETERMINADO */

function OcultaDivs(ClassDiv) {
	for (var i=0; i<NumeroCapas; i++) {
		if (detect('msie')){
			if (Capas[i].getAttribute("className")==ClassDiv) {
				Capas[i].style.display='none';
			}			
		}else{
			if (Capas[i].getAttribute("class")==ClassDiv) {
				Capas[i].style.display='none';
			}			
		}
	}
}

/* SUSTITUYE UN CLASS POR OTRO EN TODOS LOS LINKS CON UN CLASS DETERMINADO */

function CambiaClassLinks(ClassDiv,ClassDiv2) {
	
	for (var i=0; i<NumeroLinks; i++) {
		if (detect('msie')){
			if (Links[i].getAttribute("className")==ClassDiv) {
				Links[i].className=ClassDiv2;
			}			
		}else{
			if (Links[i].getAttribute("class")==ClassDiv) {
				Links[i].className=ClassDiv2;
			}			
		}
	}
}


var ContadorFotos = 1;
var TransparenciaFoto = 100;
var TiempoCambio = 3000;
var NumeroTotalFotos = 1;
var VelocidadEfecto = 25;
var path = "/";

function CarrusellCatalogos(NumFotos, pathX) {
	path = pathX;
	NumeroTotalFotos=NumFotos;
	setTimeout ('FadeOut()',TiempoCambio);
}

function FadeOut() {
	if (TransparenciaFoto>0) {
		TransparenciaFoto--;
		if (detect('msie')){
			document.getElementById('CajaFotos').style.filter = 'alpha(opacity=' + TransparenciaFoto + ')';
		}else{
			document.getElementById('CajaFotos').style.opacity = (TransparenciaFoto/100);
		}
		setTimeout ('FadeOut()',VelocidadEfecto);
	}else{
		CambioDeFoto();
	}
}

function FadeIn() {
	if (TransparenciaFoto<100) {
		TransparenciaFoto++;
		if (detect('msie')){
			document.getElementById('CajaFotos').style.filter = 'alpha(opacity=' + TransparenciaFoto + ')';
		}else{
			document.getElementById('CajaFotos').style.opacity = (TransparenciaFoto/100);
		}
		setTimeout ('FadeIn()',VelocidadEfecto);
	}else{
		setTimeout ('FadeOut()',TiempoCambio);
	}
}

function CambioDeFoto() {
	if (ContadorFotos<NumeroTotalFotos) {
		ContadorFotos++;
	}else{
		ContadorFotos=1;
	}	
	document.getElementById('CajaFotos').src=path + 'img/visor/foto'+ContadorFotos+'.jpg';
	document.getElementById('CajaFotos').onload = function () {
		setTimeout ('FadeIn()',500);
	}
}


function MostrarAccesoProfesionales( ) {
	if(document.getElementById('AccesoAProfesionales').style.display!='block'){
		document.getElementById('AccesoAProfesionales').style.display = 'block';
		//document.getElementById('BannerAccesoAProfesionales').style.display = 'none';		
	}else{
		document.getElementById('AccesoAProfesionales').style.display = 'none';
		//document.getElementById('BannerAccesoAProfesionales').style.display = 'block';		
	}
}



function MuestraCajaOpinion( ) {
	if(document.getElementById('FormularioInsercionComentario').style.display!='block'){
		document.getElementById('FormularioInsercionComentario').style.display = 'block';
	}else{
		document.getElementById('FormularioInsercionComentario').style.display = 'none';
	}
}

