	//var DEFAULT_LANGUAGE = "es";	
	

	// Obtains value of a token from the Information Service
	function GetToken( token_name ) {
		try {
	      var obj = ialEnv.createInformationObject( token_name );
	    } catch (ex) {
	      var obj = ialEnv.getInformationObject( token_name );
	    }
	    return obj.getValue();
	}

	// Obtains value of a token from the Information Service, and catches any exceptions
	function GetTokenNoThrow( token_name ) {
	    var value;
	    try {
	        value = GetToken( token_name );
	    }
	    catch ( ex ) {
	        value = "";
	        //alert( "Error: leyendo \"" + token_name + "\"\n"+GetExceptionName(ex));
	    }
	    return value;
	}

	// Display value of a token from the Information Service
	function DisplayToken( token_name ) {
	    document.write( "<i>" + token_name + "</i> = " + GetTokenNoThrow( token_name ) + "<br>" );
	}

	// Sets a new value on a token in the Information Service
	function SetToken( token_name, new_value ) {
		try {
	      var obj = ialEnv.createInformationObject( token_name );
	    } catch (ex) {
	      var obj = ialEnv.getInformationObject( token_name );
	    }
	    try {
	    	obj.setValue( new_value.toLowerCase(), StorageType(obj) );
	    } catch (ex) {
			//alert ("Token: "+obj.getName()+" no se puede almacenar como: "+StorageType(obj));
	    	//alert ("Error de Escritura. Revise los Valores.");
	    }
	}
	
	
	// Sets a new value on a token in the Information Service, and catches any exceptions
	function SetTokenNoThrow( token_name, new_value ) {
	    try {
	        SetToken( token_name, new_value );
	    }
	    catch ( ex ) {
	        //alert( "Error: escribiendo \"" + token_name + "\"\n"+GetExceptionName(ex));
	        //alert ("Error de Escritura");
	    }
	}

	// Clears value of a token in the Information Service
	function DelToken( token_name ) {
		try {
	      var obj = ialEnv.createInformationObject( token_name );
	    } catch (ex) {
	      var obj = ialEnv.getInformationObject( token_name );
	    }
	    try {
	    	obj.unset( StorageType (obj) );
	    } catch (ex) {
	    	//alert ("Token: "+token_name+" no se puede restaurar como: "+StorageType(obj));
	    	//alert ("Error de Escritura");
	    }
	}

	// Clears value of a token in the Information Service, and catches any exceptions
	function DelTokenNoThrow( token_name ) {
	    try {
	        DelToken( token_name );
	    }
	    catch ( ex ) {
	        //alert( "Error: restaurando \"" + token_name + "\"\n"+GetExceptionName(ex));
	        //alert ("Error de Escritura");
	    }
	}

	// Returns token edit box object that resides in the document
	function GetElement( token_name ) {
	    return document.forms[0][token_name];
	}

	// Returns the type of storage of a given token
	function StorageType ( token ) {
		switch (token.getName()) {
		  case "cfg.ip.eth0.mode" :
		  case "cfg.locale.ui" :
		  case "cfg.locale.keyboard" :
		  case "cfg.locale.timezone" :
		  case "cfg.ip.eth0.multicast" :
		  case "cfg.browser.portalurls" :
		  case "cfg.browser.proxylist" :
		  case "cfg.ip.eth0.addr" :
		  case "cfg.ip._eth1.addr" :
		  case "cfg.ip.eth0.mask" :
		  case "cfg.ip._eth1.mask" :
		  case "cfg.ip.gateway" :
		  case "cfg.ip.dns1" :
		  case "cfg.ip.dns2" :
		  case "cfg.ip.metachannel" :
		  case "cfg.media.audio.mode" :
		  case "cfg.media.tv.aspectratio" :
		  case "cfg.media.video.4_3method" :
		  case "cfg.media.tv.colorsystem" :
		  case "cfg.media.tv.output" :
		  case "cfg.media.audio.lang1" :
		  case "cfg.media.audio.lang2" :
		  case "cfg.media.sub.lang1" :
		  case "cfg.media.sub.lang2" :
		  case "cfg.media.sub.enabled" :
		  case "cfg.media.sub.hoh" : 
		  case "cfg.browser.home.portal" : return token.STORAGE_PERMANENT; break

		  case "config.mem.cache" : return token.STORAGE_VOLATILE; break

		  case "const.hw.serialnumber" :
		  case "var.utctime" :
		  case "const.hw.manufacturer" :
		  case "const.hw.productname" :
		  case "config.hw.version" :
		  case "const.sw.version" :
		  case "const.sw.date" :
		  case "const.sw.time" :
		  case "const.capabilities.ip" :
		  case "const.capabilities.dtt" :
		  case "const.capabilities.sat" :
		  case "cfg.browser.ident" :
		  case "cfg.browser.home.local" :
		  case "var.memfree" : return "None"; break
		  default : return "New Token"; break;
		}
	}

	function getHora() {
		var now  = new Date();
		var sec  = now.getSeconds();
		var min  = now.getMinutes();
		var hour = now.getHours();
		return ((((""+hour).length<2)?("0"+hour):hour)+":"+(((""+min).length<2)?("0"+min):min)+":"+(((""+sec).length<2)?("0"+sec):sec));
	}

	function getHoraNoSecs() {
		var now  = new Date();
		var min  = now.getMinutes();
		var hour = now.getHours();
		return ((((""+hour).length<2)?("0"+hour):hour)+":"+(((""+min).length<2)?("0"+min):min));
	}
	
	function getFecha() {
		var today = new Date();
		var day   = today.getDate();
		var month = today.getMonth() + 1;
		var year  = today.getYear();
		if (year < 1000) year += 1900;
		return ((((""+day).length<2)?("0"+day):day)+"/"+(((""+month).length<2)?("0"+month):month)+"/"+year);
	}

	function nada() {
		return;
	}

	// Changes current configuration page
	function setOption (i) {
		top.data.location.href="config-"+i+".html?"+Math.random();
	}

	function setBootMode(bm) {
		try {
			ialEnv.system.bootMode(bm);
		} catch (ex) {}							
	}
	
	function changeImage(img)
	{
//		alert(img);
		top.document.getElementById("pestana").src = img;
	}

	function carga (page) {
		top.window.location.href = page+"?"+Math.random();
	}

	// Translate exception code
	function GetExceptionName( ex )
	{
	    var err = "ERROR!!!\n";
	
	    switch ( ex.code ) {
	    case 1001:  err += "Permiso Denegado";               break;
	    case 1002:  err += "Argumento NO Válido";            break;
	    case 1003:  err += "Operación NO Soportada";         break;
	    case 1004:  err += "No hay Suficientes Recursos";    break;
	    case 1005:  err += "Objeto Destruido";               break;
	    case 1006:  err += "Nombre Incorrecto";              break;
	    case 1007:  err += "NO hay Datos";                   break;
	    case 1008:  err += "Violación de Sesión";            break;
	    case 1009:  err += "Sesión NO Iniciada";             break;
	    case 1010:  err += "Función NO Implementada";        break;
	    default:    err += "Código Desconocido: " + ex.code; break;
	    }
	    return err;
	}