//Cargar Javascript dinámicamente
function T3D_INCLUDEJs(js_file) {
       var js = document.createElement('script');
       js.setAttribute('type', 'text/javascript');
       js.setAttribute('src', js_file);
       js.file = js_file;
       (document.getElementsByTagName('head')[0]).appendChild(js);
       return false;
}

// JavaScript Document
// Help function
function _checkIt(strUA, strKeyWord)
{
    return strUA.indexOf(strKeyWord) != -1;
}

// Get OS
function GetOS()
{
    var strOS = '';

    var strUA = navigator.userAgent.toLowerCase();

    if (_checkIt(strUA, 'konqueror'))
    {
          strOS = "Linux";
    }

    if (!strOS)
    {
        if      (_checkIt(strUA, 'linux')) strOS = "Linux";
        else if (_checkIt(strUA, 'x11'))   strOS = "Unix";
        else if (_checkIt(strUA, 'mac'))   strOS = "Mac";
        else if (_checkIt(strUA, 'win'))   strOS = "Windows";
        else strOS = "an unknown operating system";
    }
    return strOS;
}

// Get browser
function GetBrowser()
{
    var strBrowser = '';

    var strUA = navigator.userAgent.toLowerCase();

    if (_checkIt(strUA, 'konqueror'))
    {
         strBrowser = "Konqueror";
    }
    else if  (_checkIt(strUA, 'safari'))  strBrowser= "Safari";
    else if  (_checkIt(strUA, 'omniweb')) strBrowser= "OmniWeb";
    else if  (_checkIt(strUA, 'opera'))   strBrowser= "Opera";
    else if  (_checkIt(strUA, 'webtv'))   strBrowser= "WebTV";
    else if  (_checkIt(strUA, 'icab'))    strBrowser= "iCab";
    else if  (_checkIt(strUA, 'msie'))    strBrowser= "Internet Explorer";
    else if (!_checkIt(strUA, 'compatible'))
    {
        strBrowser = "Netscape Navigator";
        //var strVersion = strDetect.charAt(8); // if required somewhere.
    }
    else strBrowser = "An unknown browser";

    return strBrowser;
}

//Parámetros client-side javascript
function IntroducirEspacios(cadena) {
var salida="";
for (var i=0;i<cadena.length;i++) {
	if (cadena.substring(i,i+1)=="+")
		salida=salida+" ";
	else
		salida=salida+cadena.substring(i,i+1);
	}
return salida;
}

function Get_parametros()  //Uso: eval(Get_parametros()) se crean tantas variables -tipo cadena- como parámetros se pasen y con el nombre del parámetro
	{
	var codigo=eval('"'+document.location+'"');
	var n,m,o;
	var variable;
	var valor;
	n=codigo.indexOf("?");
	var exec="";
	if (n!=-1)
		while (n<codigo.length) {
				m=codigo.indexOf("=",n);
				variable=codigo.substring(n+1,m);
				o=codigo.indexOf("&",m)
				if (o==-1)
					o=codigo.length;
				valor=unescape(IntroducirEspacios(codigo.substring(m+1,o)));
				exec +="var "+variable+"='"+valor+"';"
				n=o;
						}
    return exec;
	} 
//Pausa la ejecución un determinado número de milisegundos
function Pause(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 
//Completa la URL para documento vía http, los XML en FireFox lo necesitan, a veces¿¿???
function CompletarURL (archivo)
	{
	if (archivo.indexOf("http://")==-1 && archivo.indexOf("https://")==-1) //No es una URL completa
		{
		var loc=location.href;
		var ultimaAparicion=loc.lastIndexOf("/",loc.length);
		var url_parcial=loc.substr (0,ultimaAparicion+1);
		}
	else
		url_parcial="";
	return (url_parcial+archivo);
	}

//////////////////////////////////////////////////////////////////////////
iTimeoutID="";
function LayerWrite (capa,contenido,delayLayerWrite)
	{
		if (iTimeoutID) window.clearTimeout(iTimeoutID);
		document.getElementById(capa).innerHTML=contenido;
		if (contenido!='')
			iTimeoutID=window.setTimeout('LayerWrite("'+capa+'","")', delayLayerWrite);
		else
			window.clearTimeout(iTimeoutID);
	}	
//////////////////////////////////////////////////////////////////////////













