// Biblioteca que contiene funciones javascripts mas usadas en del depto. de diseño
// 11/05/2005

/* Funcion GoLink: usada casi siempre en popups, haciendo que al clickear el link dentro */
/* del popup, éste se cierre y abra el enlace en otra ventana. */

function golink() {
   window.opener.location="http://direccion.web.com"; /* poner ahi la dirección real */
   window.close();
   return 1;
}

//funcion para agrandar o achicar el tamaño de letra
		var max_size = 150;
		var min_size = 50;
		
		
		function dzIncreaseFontSize(idElemento) {
			if (document.all || document.getElementById) {	
				var elemento = document.all ? document.all[idElemento] : document.getElementById(idElemento);
				if (elemento) {	
					// el valor está; indicado en porcentaje:
					if(tamagnoLetras[idElemento] >= max_size){
						alert("No es posible aumentar más el texto.")
					}else{
						tamagnoLetras[idElemento] += 10;
						if (elemento.length) 
							for (i=0; i < elemento.length; i++) {
								elemento[i].style.fontSize = (tamagnoLetras[idElemento]+'%');
							}
						else
							elemento.style.fontSize = (tamagnoLetras[idElemento]+'%');
					}
				}
			}
		}
		
		function dzDecreaseFontSize(idElemento) {
			if (document.all || document.getElementById) {	
				var elemento = document.all ? document.all[idElemento] : document.getElementById(idElemento);
				if (elemento) {	
					// el valor est&aacute; indicado en porcentaje:
					if(tamagnoLetras[idElemento] <= min_size){
						alert("No es posible disminuir más el texto.")
					}else{
						tamagnoLetras[idElemento] -= 5;
						if (elemento.length) 
							for (i=0; i < elemento.length; i++) {
								elemento[i].style.fontSize = (tamagnoLetras[idElemento]+'%');
							}
						else
							elemento.style.fontSize = (tamagnoLetras[idElemento]+'%');	
					}
				}
			}
		}
		
		function dzResetFontSize(idElemento) {
			var elemento = document.all[idElemento];
			elemento.body.style.fontSize = '100';
			document.body.style.fontSize = '100';
		}
// Function Oculta Tabla ID
isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
isIE    = (document.all && !isOPERA)? true : false;
isDOM   = (document.getElementById && !isIE && !isOPERA)? true : false;

var cantidad	= new Array(); 
var entrada	= new Array();
var content	= new Array ();
function initArray(llave) {
	for (x=0; x < cantidad[llave]; x++){
		entrada [llave + "_"+x] = true;
	}
}

/* Aqui va el ID de la o las tablas que ocultaremos */

var cantidad	= new Array(); 
cantidad["nombre_id"] = "1"; // Valor generico parte con 1 y al ID se le da el valor 0
var entrada	= new Array();
var content	= new Array ();

initArray("nombre_id"); // Se aplica el ID

function show (llave, id, displayValue){
	if (isDOM)
		document.getElementById(llave+'_'+id).style.display = (displayValue)? displayValue: "block";
	else if (isIE)
	document.all[llave+'_'+id].style.display = "block";
}

function menu(llave, id){
	hide_all(llave);
	if (entrada[llave + "_"+id]){
		show (llave, id, 'table-row');
		for (x=0; x < cantidad[llave]; x++){
			entrada [llave + "_"+x] = true;
		}
		entrada[llave + "_"+id] = true;
	}else{
		entrada[llave + "_"+id]=true;
	} 
}
 
function hide (id){
	if (isDOM)
		document.getElementById(id).style.display = "none";
	else if (isIE)
		document.all[id].style.display = "none";
}
 
function hide_all(llave) {
	for (i=0; i<cantidad[llave];i++){
		hide(llave + "_" + i);
	}
}
/* --- Fin funcion oculta tablas --- */

/* Funcion Precarga de imagenes */

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_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_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];}
}

/* Funciones para cambiar de comportamiento (colores de fondo) en TD's. Por ejemplo en titulos, menus. */

function mOvr(src,clrOver){ 
 if (!src.contains(event.fromElement)){ 
  src.style.cursor = 'hand'; 
  src.className = clrOver; 
 } 
} 
function mOut(src,clrIn){ 
 if (!src.contains(event.toElement)){ 
  src.style.cursor = 'hand'; 
  src.className = clrIn; 
 } 
}
function mClk(src) 
{
if(event.srcElement.tagName=='TD')
	{
 	src.children.tags('A')[0].click();
	}
}

/* Funcion Volver a la página anterior */

function volver2(pag){
	window.history.go(pag)
}

/* Funcion abre un popup */

function MM_openBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

/* Funcion para limpiar un formulario */

function limpia_form(nom){
	window.document[nom].reset();
}

/* Funcion para imprimir */

function imprimir(){
	window.print();
}

/* Funcion para introducir la fecha en una pagina */

function fecha(){
	mes = new Array();
	diasem = new Array();
	fechas = new Date();
	diasemana = fechas.getDay();
	diasem[0] = "Domingo";
	diasem[1] = "Lunes";
	diasem[2] = "Martes";
	diasem[3] = "Miercoles";
	diasem[4] = "Jueves";
	diasem[5] = "Viernes";
	diasem[6] = "Sabado";
	dia = fechas.getDate();
	nomes = fechas.getMonth();
	anio = fechas.getYear();
	mes[0] = 'Enero';
	mes[1] = 'Febrero';
	mes[2] = 'Marzo';
	mes[3] = 'Abril';
	mes[4] = 'Mayo';
	mes[5] = 'Junio';
	mes[6] = 'Julio';
	mes[7] = 'Agosto';
	mes[8] = 'Septiembre';
	mes[9] = 'Octubre';
	mes[10] = 'Noviembre';
	mes[11] = 'Diciembre';
	if (anio < 1000) anio = anio + 1900;
	document.write(diasem[diasemana]+" "+ dia +" de "+ mes[nomes] +" de "+ anio);
}

/* Funcion Random para imágenes - J. Yevenes */

function img_random() { 
var imgs = ["img1.gif", "img2.gif", "img3.gif"]; 
document.getElementById("foto").src = imgs[Math.floor(Math.random()*imgs.length)]; 
}

function cerrar(){
	window.close();
	}


/* Funcion Go To */
function go_to(pag){
 window.location=pag

}
//Para el buscador: Cuando haces click se limpian los campos
function limpiar(){
	if(document.busqueda.palabra.value=="¡ Busque Aquí !"){
		document.busqueda.palabra.value="";
	}
}

function llenar(){
	if(document.busqueda.palabra.value==""){
		document.busqueda.palabra.value="¡ Busque Aquí !";
	}
}

//Funcion pull down vitas
function gothere() {	
    var index=document.corporacion.vitas.selectedIndex;
    
    if (index !=0) {
		var remote=document.corporacion.vitas.options[index].value.substring(0,1);
	    var url=document.corporacion.vitas.options[index].value.substring(1);		
		if (remote == "a") {
			window.open(url,"newwindow","toolbar=yes,location=yes,derectories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes");
		} else {				
			document.location.href = document.corporacion.vitas.options[index].value;
		}
	}
}



