function Trim(value){
	var texto=value.replace(/^\s+/, '');
	texto=texto.replace(/\s+$/, '');
	return(texto)
}

function cambiarIdioma(){
	tmp = document.location.href;
	if (tmp.indexOf("/es/") != -1)
		tmp = tmp.replace("/es/","/eu/");
	else
		tmp = tmp.replace("/eu/","/es/");
	location.href=tmp;
}	

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 dividir(mitexto,tamanio){
    texto="";
    var palabras = mitexto.split(" ");
    for(k=0;k<palabras.length;k++){
        if(palabras[k].length>tamanio){
            var j=0;
            while(j<palabras[k].length){
                if(j+tamanio>palabras[k].length){
                    texto+=palabras[k].substring(j,palabras[k].length-1)+" ";
                }else{
                    texto+=palabras[k].substring(j,j+tamanio)+"<br>";
                }
                j=j+tamanio;
            }
        }else{
            texto+=palabras[k]+" ";
        }
 
    }
   return texto;
}

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(){	
	params = document.location.search.substring(1,255) 
	
	TheParametersArray = params.split ("&") 
	valor=""
	u = TheParametersArray.length 
	for (f= 0 ; f < u; f++) {
		elem = unescape(TheParametersArray[f]);
		if (elem!="")
			valor=(elem.split("="))[1];
	}
	return valor;
}




function popUp(URL,ancho,alto){
	abrepop(URL, 'hacer', ancho, alto, 'auto');
}

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();
    }
}

