/*****************************************************************************************************************************\

| Fecha de la actualización: 22-abr-2008

| Autor: Nacho Ordóñez Álvarez

|

| Actualización: 

| 

| Se crean tres variables globales: minsize,maxsize y actual para establecer el tamaño de texto.

| se crean dos funciones que serán llamadas desde los enlaces de la web para incrementar ó disminuir el tamaño de texto de la

| capa central de la página, es decir, donde se muestra el contenido en sustitución del método anterior que consistía en

| mostrar una nueva página (a través del enlace que se modifica) en la que se muestran las instrucciones necesarias para que el

| usuario cambie el tamaño de texto mediante la manipulación de los menús del navegador.

|

Fecha de Actualización 14-Ene-2010

Autor: Nacho Ordóñez Álvarez

Actualización:

Se incorpora una función llamada contraste que cambia el fondo de las capas contenedoras de texto y el color del texto
para cambiarlos entre blanco y negro en función de la opcion de contraste seleccionada. Esta función se la llama desde la barra de control de texto.
******************************************************************************************************************************/

minsize=12;

maxsize=28;

actual=13;



function Mastexto(div){

	actual = actual+1;

	if (actual > maxsize) {

		actual = maxsize

	}

	var divID = document.getElementById(div);

	divID.style.fontSize = actual+"px";

// px porque estoy usando css

}

function Menostexto(div) {

	actual = actual-1;

	if (actual < minsize) {

		actual = minsize

	}

	var divID = document.getElementById(div);

	divID.style.fontSize = actual+"px";

}

function Contraste(opcion){
/*Esto funciona FIJO*/
switch(opcion){
	case 'blanco':
		document.getElementById('noticias').style.color='white';
		document.getElementById('noticias').style.background='black';
		
		document.getElementById('noticias').style.color='white';
		document.getElementById('noticias').style.background='black';
		break;
	case 'negro':
		document.getElementById('noticias').style.color='black';
		document.getElementById('noticias').style.background='white';
		break;
	}


/*CODIGO EXPERIMENTAL

Se trataría de cambiar el fondo y el color de texto en base al contraste, pero de todas las capas de la misma página, para lo cual podría utilizarse un array de elementos web en un bucle
similar a este:

while document.elements(i).id = "div"
	document.getelement(i).style.color='white';
	document.getemelent(i).style.background='black'
	i= i+1;
	
es decir, mientras el elemento que ocupa la posición i sea una etiqueta DIV le cambio el color de fondo y del texto. 

Buscar algo relacionado con document.elements.... 
*/
}
function Gestiona_Capas(n_capa){
	
	Cerrar();
	
	switch(n_capa){
		case 'control_texto':
                document.getElementById('control_texto').style.visibility='visible';
				document.getElementById('boton_barra_texto').style.visibility='hidden';
                break;
	}
	
}

function Cerrar(){
	
    if (document.getElementById('control_texto') != null)   
        document.getElementById('control_texto').style.visibility ='hidden';
	
}

function load() {

	if (GBrowserIsCompatible()) {

		//plano_situacion.setMapType(G_SATELLITE_TYPE);

		var pla = new GMap2(document.getElementById("datos_plano_situacion"));

		pla.addControl(new GSmallMapControl()); 

		pla.addControl(new GMapTypeControl());       

		pla.setCenter(new GLatLng(43.370656,-5.871431), 17);

		//asturias

		var point = new GPoint(-5.871431,43.370656);

		var marker = new GMarker(point);

		GEvent.addListener(marker, "click", function() {

    			marker.openInfoWindowHtml("<strong>Instituto Oftalmol&oacute;gico Fern&aacute;ndez-Vega</strong><br>Avenida Doctores Fern&aacute;ndez-Vega 114<br>33012, OVIEDO (ASTURIAS)");

  			});

		pla.addOverlay(marker);

		pla.setMapType(G_HYBRID_TYPE);

	}

}



function borrar_imagen(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar la imagen?")) {

        self.location = '../gestion/cambiar_imagen.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}



function borrar_unidad(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar la unidad?")) {

        self.location = '../gestion/cambiar_unidad.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}



function borrar_doctor(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar el doctor?")) {

        self.location = '../gestion/cambiar_doctor.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}



function borrar_enfermedad(id, nombre) {

    if (confirm("¿Está seguro de que desea eliminar la enfermedad " + nombre + "?")) {

        self.location = '../gestion/cambiar_enfermedad.php?accion=borrar&eid=' + id + '\n';

    }

}



function borrar_apartado(id, nombre) {

    if (confirm("¿Está seguro de que desea eliminar este apartado?")) {

        self.location = '../gestion/cambiar_datos_utiles.php?accion=borrar&id=' + id + '\n';

    }

}



function quitar_doctor(pagina, id, id_unidad) {

    if (confirm("¿Está seguro de que desea quitar el doctor de esta unidad?")) {

		self.location = '../gestion/asignar_doctor.php?accion=borrar&pagina=' + pagina + '&id=' + id + '&id_unidad=' + id_unidad + '\n';
    }

}



function borrar_faq(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar esta entrada?")) {

        self.location = '../gestion/cambiar_faq.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}


function borrar_glosario(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar esta entrada?")) {

        self.location = '../gestion/cambiar_glosario.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}



function borrar_noticia(pagina, id) {

    if (confirm("¿Está seguro de que desea eliminar esta noticia?")) {

        self.location = '../gestion/cambiar_noticia.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';

    }

}



function borrar_evento(pagina, id, tipo) {

    if (confirm("¿Está seguro de que desea eliminar este evento?")) {

        self.location = '../gestion/cambiar_evento.php?accion=borrar&pagina=' + pagina + '&id=' + id + '&tipo=' + tipo + '\n';       

    }

}



/*popup*/



function op_lasik() {

	window.open("../popup/op_lasik.htm", "a", "height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");

}



function op_cataratas() {

	window.open("../popup/op_cataratas.htm","a","height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");

}



function formulario(){

	window.open("formulario.htm","a","height=300,width=520,menubar=0,scrollbars=1,resizable=0,status=0,titlebar=0,toolbar=0")

}



function privacidad(){

	window.open("privacidad.htm","a","height=300,width=520,menubar=0,scrollbars=1,resizable=0,status=0,titlebar=0,toolbar=0")

}



/*visita virtual*/



function cambiar2(cual, planta) {

	self.location = "visita_virtual.php?lugar=" + cual + "&pl=" + planta;

}



function cambiar(cual) {

	document.applets[0].stop();

	texto = "<applet name='ptviewer' id='MyApplet' archive=ptviewer.jar code=ptviewer.class width=195 height=120 mayscript=true>";

	texto += "<param name=file id='file' value='../img/visita/360/" + cual + ".jpg'>";

	texto +=  "<param name=pan value='179'>";

	texto += "<param name=tilt value='0'>";

	texto += "<param name=fov value='70'>";

	texto += "<param name=fovmax value='70'>";

	texto += "<param name=fovmin value='30'>";

	texto += "<param name=auto value='0.5'>";

	texto += "<param name=bar_x value='30'>";

	texto += "<param name=bar_y value='180'>";

	texto += "<param name=bar_width value='255'>";

	texto += "<param name=bar_height value='9'>";

	texto += "<param name=tiltmin value='-70'>";

	texto += "<param name=wait value='../img/visita/360/images/wait_p.jpg'>";

	texto += "</applet>";

	document.getElementById("up").innerHTML = texto;

	document.getElementById("down").innerHTML = "<a href='javascript:abrir_popup(\"" + cual + "\")' title='ampliar panor&aacute;mica'>[ ampliar panor&aacute;mica ]</a>";

	document.applets[0].start();

}



function inicio() {

	document.applets[0].stop();

	document.applets[0].start();

}



function abrir_popup(cual) {

	window.open("../img/visita/360/" + cual + ".htm","a","height=230,width=330,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0")

}



function foto01(){

	window.open("informacion/foto_01.htm","a","height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0")

}



function foto02(){

	window.open("informacion/foto_02.htm","a","height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0")

}



function foto03(){

	window.open("informacion/foto_03.htm","a","height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0")

}



function foto04(){

	window.open("informacion/foto_04.htm","a","height=280,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0")

}



/*imagenes*/



function MM_swapImgRestore() { //v3.0

	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a = MM_swapImage.arguments;

  document.MM_sr = new Array;

  for(i = 0; i < (a.length - 2); i += 3 )

		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];

  }

}



//gestion



// pasa el texto seleccionado de un textarea a negrita => hay que diferenciar entre IEXPLORER y otro

function negrita(n_texto){

	browser=navigator.appName;

	if (browser.indexOf('Microsoft')!=-1) { 

		//CÓDIGO PARA IEXPLORER

		if (document.selection.type==0){

			alert("Debes de seleccionar un texto para ponerlo en negrita.");

		} else {

			document.getElementById(n_texto).focus();

			document.selection.createRange().text="<strong>"+document.selection.createRange().text+"</strong>";

		}

	} else {

		//CÓDIGO PARA EL FIREFOX

		texto=document.getElementById(n_texto).value;

		if (document.getElementById(n_texto).selectionStart==document.getElementById(n_texto).selectionEnd){

			alert("Debes de seleccionar un texto para ponerlo en negrita.");

		} else {

			inicio=document.getElementById(n_texto).selectionStart;

			fin=document.getElementById(n_texto).selectionEnd;

			t1=texto.substring(0,inicio);

			t2="<strong>"+texto.substring(inicio,fin)+"</strong>";

			t3=texto.substring(fin);

			texto=t1+t2+t3;

			document.getElementById(n_texto).value=texto;

		}

	}	

}





function abrir_ventana(url, x, y, n_texto){

	sel=0;

	a=url;

	a=a.substring(0,16);

	if (a=="nueva_imagen.php"){

		sel=1;

	} else {

		browser=navigator.appName;

		if (browser.indexOf('Microsoft')!=-1) { //CÓDIGO PARA IEXPLORER

			if (document.selection.type==0){

				alert("Para insertar un PDF o un ENLACE debes seleccionar antes el texto que servirá de enlace.");

			} else sel=1;

		} else { //CÓDIGO PARA EL FIREFOX

			texto=document.getElementById(n_texto).value;

			if (document.getElementById(n_texto).selectionStart==document.getElementById(n_texto).selectionEnd){

				alert("Para insertar un PDF o un ENLACE debes seleccionar antes el texto que servirá de enlace.");

			} else sel=1;

		}

	}

	if (sel==1){

		ventana=window.open(url,'nueva_ventana',"width="+x+",height="+y+",menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");

	}

}



function cambiar_enlace_padre(n_texto){

	enlace = document.getElementById('enlace').value; // valor del enlace

	target = document.getElementById('target').checked; // miro si la ventana se abre en esta o en otra ventana

	titulo = document.getElementById('titulo').value;

	if (target == 1) {

		target = "target=\"_blank\"";

	} else target = "";

	if (titulo != "") {

		title = "title=\"" + titulo + "\"";

	} else title = "";

	padre = self.opener; //esta es la ventana donde está el formulario

	//creo el TAG "<A HREF..." con el enlace para meterlo en el formulario de la ventana padre

	tag = "<a href=\"" + enlace + "\" " + target + " " + title + ">";

	if (enlace != "") {

		browser = navigator.appName;

		if (browser.indexOf('Microsoft') != -1) { 

			//CÓDIGO PARA IEXPLORER

			padre.document.getElementById(n_texto).focus();

			padre.document.selection.createRange().text = tag + padre.document.selection.createRange().text + "</a>";

		} else {

			//CÓDIGO PARA EL FIREFOX

			texto = padre.document.getElementById(n_texto).value;

			inicio = padre.document.getElementById(n_texto).selectionStart;

			fin = padre.document.getElementById(n_texto).selectionEnd;

			t1 = texto.substring(0, inicio);

			t2 = tag + texto.substring(inicio, fin) + "</a>";

			t3 = texto.substring(fin);

			texto = t1 + t2 + t3;

			padre.document.getElementById(n_texto).value = texto;

		}

	}

	self.close();

}



// para insertar un enlace en un texto => igual que el anterior, hay que diferenciar entre IEXPLORER y otro

function cambiar_imagen_padre(imagen,titulo, alineacion, n_texto) {

	if (alineacion == 'izquierda') {

		tag = "<img src=\"../img/" + imagen + "\" style=\"float: left; margin-right: 5px; margin-bottom: 5px;\" title=\"" + titulo + "\" />";

	} else {

		tag = "<img src=\"../img/" + imagen + "\" style=\"float: right; margin-left: 5px; margin-bottom: 5px;\" title=\"" + titulo + "\" />";

	}

	padre = self.opener; //esta es la ventana donde está el formulario

	if (tag != "") {

		browser = navigator.appName;

		if (browser.indexOf('Microsoft') != -1) { 

			//CÓDIGO PARA IEXPLORER

			padre.document.getElementById(n_texto).focus();

			padre.document.selection.createRange().text = tag + padre.document.selection.createRange().text;

		} else {

			//CÓDIGO PARA EL FIREFOX

			texto = padre.document.getElementById(n_texto).value;

			inicio = padre.document.getElementById(n_texto).selectionStart;

			fin = padre.document.getElementById(n_texto).selectionEnd;

			t1 = texto.substring(0, inicio);

			t2 = tag + texto.substring(inicio, fin);

			t3 = texto.substring(fin);

			texto = t1 + t2 + t3;

			padre.document.getElementById(n_texto).value = texto;

		}

	}

	self.close();

}







// para insertar un PDF/FICHERO en un texto => igual que el anterior, hay que diferenciar entre IEXPLORER y otro

function cambiar_pdf_padre(pdf,titulo,n_texto){

	enlace=pdf; // valor del enlace

	padre=self.opener; //esta es la ventana donde está el formulario

	//creo el TAG "<A HREF..." con el enlace para meterlo en el formulario de la ventana padre

	tag="<a href=\"../pdf/"+enlace+"\" title=\""+titulo+"\" >";

	if (tag!=""){

		browser=navigator.appName;

		if (browser.indexOf('Microsoft')!=-1) { 

			//CÓDIGO PARA IEXPLORER

			padre.document.getElementById(n_texto).focus();

			padre.document.selection.createRange().text=tag+padre.document.selection.createRange().text+"</a>";

		} else {

			//CÓDIGO PARA EL FIREFOX

			texto=padre.document.getElementById(n_texto).value;

			inicio=padre.document.getElementById(n_texto).selectionStart;

			fin=padre.document.getElementById(n_texto).selectionEnd;

			t1=texto.substring(0,inicio);

			t2=tag+texto.substring(inicio,fin)+"</a>";

			t3=texto.substring(fin);

			texto=t1+t2+t3;

			padre.document.getElementById(n_texto).value=texto;

		}

	}

	self.close();

}



/*abre la ventana de la revista

function abrir_revista(){

	window.open('revista/revista.html','revista','width=1580, height=850%, toolbar=no, status=no, location=no, scrollbars=yes, menubar=no, directories=no');

}*/

