var wndExternal = null;

function openExternalWindow(url) {
  if(wndExternal == null || wndExternal.closed)  {
    wndExternal = window.open(url, "link", "toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,height="+h+",width="+w);
  } else {
    window.blur();
    wndExternal.location.href=url;
    wndExternal.focus();
  }
}

var wndPrint = null;

function openPrintWindow(url) {
  if(wndPrint == null || wndPrint.closed)  {
    wndPrint = window.open(url, "printer", "toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,width=750,height=500");
  } else {
    window.blur();
    wndPrint.location.href=url;
    wndPrint.focus();
  }
}

var wndPhoto = null;

function openPhotoWindow(url,w,h) {
  if(wndPhoto == null || wndPhoto.closed)  {
    wndPhoto = window.open(url, "photo", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,height="+h+",width="+w);
  } else {
    window.blur();
    wndPhoto.location.href=url;
    wndPhoto.focus();
  }
}

var wndTool = null;

function openToolWindow(url) {
  if(wndTool == null || wndTool.closed)  {
    wndTool = window.open(url, "tool", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,width=750,height=500");
  } else {
    window.blur();
    wndHerramienta.location.href=url;
    wndHerramienta.focus();
  }
}


var tamanyoBody = "11px";
var tamanyo = 1.0;

var aElmDiv = new Array();
aElmDiv[0] = 'colContenido';
aElmDiv[1] = 'colCentro';

function fijarTamanyo(tamanyo) {
  	tamanyoTexto=tamanyo+'em';

  	var elmDiv = null;
  	for(var i=0; i < aElmDiv.length; i++) {
		elmDiv = document.getElementById(aElmDiv[i]);
   	if(elmDiv != null) {
   		elmDiv.style.fontSize=tamanyoTexto;
		}
	}
}

function aumentarTamanyo() {
  if (tamanyo==null)
	tamanyo=1.0;
  if (tamanyo<1.6)
	tamanyo=eval(tamanyo)+0.1;
  fijarTamanyo(tamanyo);
}

function disminuirTamanyo() {
  if (tamanyo==null)
	tamanyo=1.0;
  if (tamanyo>0.7)
	tamanyo=eval(tamanyo)-0.1;
  fijarTamanyo(tamanyo);
}

function iniciarTamanyo() {
  if (tamanyo==null)
	tamanyo=tamanyoBody;
  fijarTamanyo(tamanyo);
}

function reestablecerTamanyo() {
  tamanyo = 1.0;
  fijarTamanyo(tamanyo);
}

function  changeNavigatorLocale(urlbase,url){
	var lg = navigator.language;
	if(null == lg) lg = navigator.browserLanguage;
	if(null == lg) lg = navigator.navigator.userLanguage;
	if(null == lg) lg = 'es';
	lg = lg.substring(0,2);
	if( ('es' != lg) && ('en' != lg)){
	    lg='en';
	}
    window.location = urlbase +"?locale="+lg+"&url="+url;
}
//FUNCION PARSEO
  function parseo(texto){
        var txt = texto;
        txt = txt.replace(/á/g,"a");
        txt = txt.replace(/é/g,"e");
        txt = txt.replace(/í/g,"i");
        txt = txt.replace(/ó/g,"o");
        txt = txt.replace(/ú/g,"u");

        txt = txt.replace(/Á/g,"A");
        txt = txt.replace(/É/g,"E");
        txt = txt.replace(/Í/g,"I");
        txt = txt.replace(/Ó/g,"O");
        txt = txt.replace(/Ú/g,"U");

        return txt;
  }

//FUNCION PRINCIPAL DE CONVERSION
    function convertir(contenido,lorigen,ldestino){
     var text =  contenido.innerHTML;
     google.language.translate(text,lorigen,ldestino,function(result) {
         if (result.translation) {
                contenido.innerHTML = result.translation;
          }
      });

}

//FUNCION QUE TRADUCE LOS ELEMENTOS DEL MENU NAVEGABLE DE LA CABECERA
    function initializeMenuNav(size,lorigen,ldestino) {
        var imas=0;
         //convierte los li
          while(imas < size){
            var id = "menu"+imas;

            var content =  document.getElementById(id);

            convertir(content,lorigen,ldestino);
          imas = imas +1;
         }
      }


//FUNCION QUE TRADUCE LOS ELEMENTOS DEL MENU NAVEGABLE DE LA CABECERA
    function initializeListadoNot(size,lorigen,ldestino) {
        var imas=0;
         //convierte los li
          while(imas < size){
            var id = "lnot"+imas;
            var content =  document.getElementById(id);
            convertir(content,lorigen,ldestino);
          imas = imas +1;
         }
      }

//FUNCION QUE TRADUCE LOS ELEMENTOS DE LA MIGA
    function initializeMigas(lorigen,ldestino) {
          var content =  document.getElementById("migas");
          convertir(content,lorigen,ldestino);

      }

//FUNCION QUE TRADUCE EL MENU IZQUIERDO

    function initializeIzquierda(size,lorigen,ldestino) {
        var imas=0;
       //convierte los li
        while(imas < size){
             var id = "li"+imas;
             var content =  document.getElementById(id);
             convertir(content,lorigen,ldestino);
           imas = imas +1;
         }
        //convierte el titulo
        convertir(document.getElementById("titulo_menu"),lorigen,ldestino);

       }



//FUNCION QUE TRADUCE EL PIE

    function initializePieEnlacesExternos(size,lorigen,ldestino) {
        var imas=0;
       //convierte los enlaces externos
        while(imas < size){
             var id = "externo-"+imas;
             var content =  document.getElementById(id);
             convertir(content,lorigen,ldestino);
           imas = imas +1;
         }

       }


    function initializePie(size,sizea,sizeb,lorigen,ldestino) {
       //   var ni    = 0;
        //  var sb    = sizeb;
         // var array = sb.split('-');
        //  while(ni < sizea){
         //     var id = "ep"+ni;
          //    var sub = array[ni];
              convertir(document.getElementById('branding'),lorigen,ldestino);
          //    var nj=0;
           //   while(nj< sub ){
            //       var id2 = "epe"+ni+"-"+nj;
             //      convertir(document.getElementById(id2),lorigen,ldestino);
             //      nj = nj +1;
             // }
             // ni = ni+1;
        //  }
         // initializePieEnlacesExternos(size,lorigen,ldestino);
       }


//FUNCION QUE TRADUCE LA CABECERA

    function initializeCabecera(size,lorigen,ldestino){
        var ip=0;
        //convierte los li
         while(ip < size){
            var id = "cab"+ip;
            var content =  document.getElementById(id);
            convertir(content,lorigen,ldestino);
            ip = ip +1;
        }
        convertir(document.getElementById("cs1"),lorigen,ldestino);
        convertir(document.getElementById("cs2"),lorigen,ldestino);
    }

      //funcion que traduce el Destacado

     function initializeDestacado(pos,lorigen,ldestino) {
           var ida = "titNoticia"+pos;
           var idb = "CabeceraColDerIntDer"+pos;
           var idb = "txtLateralInterno"+pos;
           convertir(document.getElementById(ida),lorigen,ldestino);
           convertir(document.getElementById(idb),lorigen,ldestino);
           convertir(document.getElementById(idc),lorigen,ldestino);

      }

//FUNCION PARA TRADUCIR
    function traduce(rt,ro){
   	    if(confirm("TRADUCIR?")) {
   		  window.location = rt;
    	  }
     }





