function cambiarIdioma(idioma){
	if (bloqueActual[0]==0)
		location.href="../../../"+idioma+"/html/";
	else{		
		if (bloquesSec[bloqueActual[0]].indexOf(idioma+"|") != -1){
			location.href="../../../"+idioma+"/html/"+getSeccion()+"/"+getPagina();
		}else{
			location.href="../../../"+idioma+"/html/comun/aviso.shtml";
		}
	}
}		

function getInicio(texto,tam){
	cadena = new Array()
    cadena[0] = texto.substring(0,tam);
    if (texto.substring(tam,tam+1)!=" "){
        i=tam
        while (texto.substring(i,i+1)!=" " && i<texto.length){
            cadena[0] += texto.substring(i,i+1);
            i++;
        }
    }
    cadena[1] = " "+texto.substring(i,texto.length-1);
    //alert("Tam "+tam+" = "+(i)+"\n-"+cadena[0]+"-\n-"+cadena[1]+"-\n\n"+texto);
    return cadena;
}

function quitarEntradilla(texto){
	resul = ""
	if (texto.indexOf("<br>") != -1){
		pos=texto.indexOf("<br>");
		resul = texto.substring(0,pos);
	}else resul = texto;
    //alert("texto original"+texto+"\nResultado"+resul);
    return resul;
}

function ltrim(cadena){
	while (cadena.substring(0, 1) == ' ')
		cadena = cadena.substring(1, cadena.length);
	return cadena;		
}

function getIdioma(){
	var tmp="";
	tmp = document.location.href;
	TheParametersArray = tmp.split("/");
	return TheParametersArray[TheParametersArray.length-4];
}	

function getSeccion(){
	var tmp="";
	tmp = document.location.href;
	TheParametersArray = tmp.split("/");
	return TheParametersArray[TheParametersArray.length-2];
}	

function getPagina(){
	var tmp="";
	tmp = document.location.href;
	TheParametersArray = tmp.split("/");
	return TheParametersArray[TheParametersArray.length-1];
}

function estamosIndex(){
	if (getPagina()=="inicio.html")
		return true;
	else
		return false;
}


function parametros(){	
	
	var enlaces = document.getElementsByTagName('a');
	
 	for(i=0; (enlace = enlaces[i]); i++) {
 		
		TheParametersArray = enlace.href.split ("&")
		valor=""
		u = TheParametersArray.length 
		
		if(u>1){
			for (f= 0 ; f < u; f++) {				
				elem = TheParametersArray[f];
				if (elem!=""){
					if(f+1 != u){
						valor=valor+elem+"&amp;";
					}else{
						valor=valor + elem;
					}	
				}
				
			}
			enlaces[i].href=valor;
		}
		
		
	}
	
		
			
}
	
	




function popUp(URL,ancho,alto){
	abrepop(URL, 'hacer', ancho, alto, 'auto');
}

// Función para abrir popup window
function abrepop (url,nombre,ancho,alto,barrascroll,status) { 
 var posx = (screen.width - ancho) / 2;
 var posy = (screen.height - alto) / 2;
 window.open (url,nombre,"width="+ancho+", height="+alto+",top="+posy+",left="+posx+",scrollbars="+barrascroll+",status=yes")
}


function escribir(texto){
	document.write(texto);
}

function recorrer(){
	theelements = document.getElementsByTagName("TD");
    
    for (i = 0; i < theelements.length; i++) {
        var obj = theelements[i];
        if (obj.id != ""){
        	alert (obj.id)
        }
    }
}

function custom_print() {
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}


function buscarParrafo(texto, tamanio){
	resul = ""
	if (texto.indexOf("<p") != -1){
		alert("Le mete el tamaño en la funcion");
		resul =texto.replace("<p", "<p style={height:"+tamanio+"}");
	}    
    return resul;
}


function EnviaPagina() {		
			
	var CadenaMail = "mailto:?subject=" + document.title
	
	//CadenaMail += "&body=tucodigoweb te recomienda esta página: " + document.title
	
	CadenaMail += ". &body=" + location.href
	
	location.href = CadenaMail
	
}
var contadorMaximo = 1;
var contadorMinimo = 1;
	
function increaseFontSize(){
	
	
	var cel=null;
	if(contadorMaximo <=4){
		var size = document.getElementsByTagName('body')[0].style.fontSize;		
		
		//document.getElementById('colIzquierda').style.top='0px';
		var newSize = parseInt(size.replace('%', ''))
	
		newSize = newSize +5,2;
	
		document.getElementsByTagName('body')[0].style.fontSize=newSize+"%";
		
		contadorMaximo++;
		contadorMinimo++;
	}
	
	

}

function decreaseFontSize(){

	if(contadorMaximo >=0){
	
		var size = document.getElementsByTagName('body')[0].style.fontSize;		
		
	
		var newSize = parseInt(size.replace('%', ''))
	
		newSize = newSize -5,2;
		
		
		document.getElementsByTagName('body')[0].style.fontSize=newSize+"%";

		contadorMaximo--;
		contadorMinimo--;
			
	}
			
}
