<!--

if (document.getElementById && document.getElementsByTagName) {
    document.write("<link type='text/css' rel='stylesheet' href='/extranet/styles/menujs.css' />");
}

function validar(form) {
  document.forms[form].submit();
}

function borrar(form) {
  document.forms[form].reset();
}

	function borraCampos(array)
	{
		var elem;
		for (var i=0;i<array.length;i++)
		{
			elem = document.getElementById(array[i]);
			if (elem!=null) elem.value='';
		}
	
	}
	
function goUrl (url) {
	document.location.href=url;
}

function limpiaFormulario(name)
{
	var form = document.getElementsByName(name)[0];
	if (form!=null)
	{
		var elements=form.elements;
		for (var i=0;i<elements.length;i++)
		{
			var elem = elements.item(i);
			if (elem.type!=null && elem.type=='text' && !elem.isDisabled) elem.value='';
			if (elem.type!=null && !elem.isDisabled) elem.selectedIndex=0;
		}
	}
}

function showDIV (idMenu, idImg) {
	var menu = document.getElementById(idMenu);
	var img = document.getElementById(idImg);
		
	var simatge = new String(img.src);
	var imatge = simatge.substring(0, simatge.length - 6);
	if (menu.style.display == 'inline') {
		menu.style.display = 'none';
		//img.src='images/topoint03.gif';
		img.src = imatge + '03.gif';
	} else {
		menu.style.display = 'inline';
		//img.src='images/topoint01.gif';
		img.src = imatge + '01.gif';
	}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x; 
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
    	d=parent.frames[n.substring(p+1)].document; 
    	n=n.substring(0,p);
    }
  	if(!(x=d[n])&&d.all) x=d.all[n]; 
  	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  	if(!x && d.getElementById) x=d.getElementById(n); 
  	
  	return x;
}

/*
function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) { 
  			v=args[i+2];
		    if (obj.style) { 
		    	obj=obj.style;
	    		v=(v=='show')?'visible':(v=='hide')?'hidden':v; 

		    }
		    obj.visibility=v; 
		}
	}
}
*/


/****************************************/
// FUNCIONES PARA LA GESTION DEL MENU

var dentro = false;
var L2 = null;
var L3 = null;

function mostrarMenuL2(origen, menuAMostrar) {
	// Escondemos todos los menus
	esconderAll();
	
	// Obtenemos el menu que tenemos que mostrar i lo posicionamos
	pintarMenu(origen, menuAMostrar);
	
	// Registramos el menu que estamos mostrando
	L2 = menuAMostrar;
	
	return false;
}

function mostrarMenuL3(origen, menuAMostrar) {
	// Escondemos si hay, el menu desplegable de nivel 3
	esconder(L3);
	
	// Obtenemos el menu que tenemos que mostrar y lo posicionamos
	//pintarMenu(origen, menuAMostrar);

	// Registramos el menu que estamos mostrando
	L3 = menuAMostrar;
	
	return false;
}

function pintarMenu(origen, menuAMostrar) {
	var menu = document.getElementById(menuAMostrar);
	var id = document.getElementById(origen);
	
	menu.style.position = 'absolute';
	
	var top = id.offsetTop;
	var left = id.offsetLeft + id.offsetWidth;

	var obj = id;
	while(obj.parentNode) {
		obj=obj.parentNode;
		if(obj.tagName == 'ul') {
			top += obj.offsetTop;
			left += obj.offsetWidth;
		}
	}
//alert('top=' + top + ', left=' + left)
	menu.style.top = top + "px";
	menu.style.left = (left + 5) + "px";

	menu.style.display = 'inline';
	menu.style.position = 'absolute';	
}


function retardar() {
	setTimeout('esconderTimeout()', 700);
	return false;
}

function esconderTimeout() {
	if(dentro == false) {
		esconderAll();
	}
	return false;
}

function esconderAll() {
	esconder(L2);
	esconder(L3);
	return false;
}

function esconder(id) {
	if(id != null) {
		var id2 = document.getElementById(id);
		id2.style.display = 'none';
		id = null;
	}
	return false;
}






/*****************************************/


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function submitEnter(e) {
	var keycode;
	var myfield; 
	var formulario = null;
	if (window.event) {
		keycode = window.event.keyCode;
		myfield = window.event.srcElement;
	} else if(e) {
		keycode = e.which;
		myfield = e.target;
	} else {
		return true;
	}
	if(myfield.type=='text' || myfield.type=='checkbox' 
			|| myfield.type=='select' //|| myfield.type=='textarea'
			|| myfield.type=='password' || myfield.type=='file') {
		formulario = myfield.form;
	}
	
	if (keycode==13 && formulario) {
		var tieneOnSubmit = (formulario.onsubmit)?true:false;
		if( tieneOnSubmit ) {
			if(formulario.onsubmit()) {
				formulario.submit();
				return false;
			} else {
				return false;
			}
		} else {
			formulario.submit();
			return false;
		}
	} else {
		return true;
	}
}

function initFocus() {
	try {
		var formulario = document.forms[2];//0 - locale, 1 - buscar
		if(!formulario) {
			if(document.forms[0] && document.forms[0].name!='frmLocale') {
				formulario = document.forms[0];
			}
		}
		if(formulario) {
			for(var i=0; i<formulario.elements.length; i++) {
				var campo = formulario.elements[i];
				var tipo = campo.type;
				if( (tipo=='text' || tipo=='select' || tipo=='textarea' || tipo=='password' || tipo=='file') && (!campo.disabled && !campo.readOnly)) {
					campo.focus();
					break;
				}
			}
		}
	} catch(e) {}
}

function goTo(path) {
	document.location.href = path;
}

function validateOneRequired(form, message, fields, messages) {
	var isValid = true;
	var focusField = null;
	var informado = false;
	for(var i=0; i<fields.length; i++) {
		if(form.elements[fields[i]].type=='text' || form.elements[fields[i]].type=='textarea') {
			if(form.elements[fields[i]].value!='') {
				informado = true;
			}
		} else if(form.elements[fields[i]].type=='select') {
			if( form.elements[fields[i]].options[form.elements[fields[i]].selectedIndex].value!='' ) {
				informado = true;
			}
		} else if(form.elements[fields[i]].type=='checkbox') {
			if(form.elements[fields[i]].checked) {
				informado = true;
			}
		} else if(form.elements[fields[i]].type=='radio') {
			for(var j=0; j<form.elements[fields[i]].length; j++) {
				if(form.elements[fields[i]][j].checked) {
					informado = true;
					break;
				}
			}
		}
		if(informado) {
			break;
		}
	}
	if(!informado) {
		isValid = false;
		if(messages) {
			var arg = messages[0];
			for(var k=1; k<messages.length; k++) {
				arg += ", " + messages[k];
			}
			message = message.replace(/null/g, arg);
		}
		alert(message);
		form.elements[fields[0]].focus();
	}
    return isValid;
}

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function getDocWidth(doc) {
  var docWt = 0, sh, oh;
  if (doc.width) docWt = doc.width;
  else if (doc.body) {
    if (doc.body.scrollWidth) docWt = sh = doc.body.scrollWidth;
    if (doc.body.offsetWidth) docWt = oh = doc.body.offsetWidth;
    if (sh && oh) docWt = Math.max(sh, oh);
  }

  return docWt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    var docHt = getDocHeight(iframeWin.document);
    var docWt = getDocWidth(iframeWin.document);
    // need to add to height to be sure it will all show
    if(docHt<300) docHt = 300;
    if (docHt) iframeEl.style.height = docHt + 7 + "px";
    if (docWt) iframeEl.style.width = docWt + 0 + "px";
  } else if(iframeEl) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    var docHt = getDocHeight(iframeEl.contentDocument);
    var docWt = getDocWidth(iframeEl.contentDocument);
    // need to add to height to be sure it will all show
    if(docHt<300) docHt = 300;
    if (docHt) iframeEl.style.height = docHt + 20 + "px";
    if (docWt) iframeEl.style.width = docWt + 20 + "px";
  }
}

function notInFrame() {
	if (parent != window) {
		var thisUrl = document.location.href;
		window.parent.location.href = thisUrl;
	}
}

// JavaScript Document
// script by Pony Smith :: pony_smith@yahoo.com
// initialize universal variables for cookie scripts
cookie_name = "fontSize";
var index; 
var num;
// create array of font sizes .. these percentages are applied to the <body> font-size
// all other font sizes are declared in 'em' and are inherited from the body
var sizes = new Array('70%','75%','80%','85%','90%','95%','100%','105%');

// function to change the size of the text
// called from increase/decrease font size buttons
// takes one argument 'inc' which is either 1 or -1 and advances the pointer in the sizes array
function textSize(inc) {
	// take the original number 'num' which is passed from or declared in the getCookie() script (triggered onLoad)
	add = '(' + num + ') + (' + inc + ')';
	// add the 'num' and 'inc' strings and evaluate them to get an integer
	var arr = eval(add);
	// if the integer is below the array minimum or above its maximum, set 'arr' to the min or max respectively
	if(arr < 0) {
		arr = 0;
	}
	if(arr > 7) {
		arr = 7;
	}
	// redefine 'num' as 'arr'
	// ensures that the function can work again, since it won't refresh and trigger getCookie() with each click
	num = arr;
	// retrieve the appropriate number from the array and set the <body> font-size to that percentage
	document.body.style.fontSize = sizes[arr];
	// run the setCookie() script to make sure that the current font-size is stored for other pages and future visits
	setCookie(arr);

	cambiaImagenTam();
	recargaCms();
}


// set cookie function .. called from within textSize()
function setCookie(arrNum) {
	// this checks to see if the new number matches the old one
	// if so, the function ends .. if not, it sets 'index = -1' which means that 'document.cookie.indexOf(cookie_name)' has a value of -1 .. ie. it doesn't exist.
	if(document.cookie != document.cookie) {
		index = document.cookie.indexOf(cookie_name);
	}
	else {
		index = -1;
	}
	// if the cookie does not match the new number called from textSize(), overwrite the cookie with the new number
	if(index == -1) {
		document.cookie = cookie_name + "=" + arrNum + "; path=/"
	}
}


// retrieve cookie function .. called in <body onLoad>
function getCookie() {
	var splits = document.cookie.split(';');
	// run through the various cookie entries to find the font size cookie
	for(i=0; i<splits.length; i++) {
		index = splits[i].indexOf(cookie_name);
		// check to see if cookie exists .. as long as 'index' does not equal -1, the cookie exists.
		if(index != -1) {
			// retrieve only the number
			num = splits[i].substring(splits[i].indexOf('=')+1, splits[i].length);
			// pull the corresponding value from the sizes array and set the <body> font-size to that percentage
		} else {
			// if there is no cookie present, set '2' as a default font size
			num = '0';
		}
	}
	if(num!='0') {
		document.body.style.fontSize = sizes[num];
	}
	cambiaImagenTam();
}

function cambiaImagenTam() {
	var img = document.getElementById('menos');
	if(img) {
		var simatge = new String(img.src);
		var imatge = simatge.substring(0, simatge.length - 5);
		if (num==0) {
			img.src = imatge + 'g.gif';
		} else {
			img.src = imatge + 'n.gif';
		}
	}
	img = document.getElementById('mas');
	if(img) {
		simatge = new String(img.src);
		imatge = simatge.substring(0, simatge.length - 5);
		if (num==7) {
			img.src = imatge + 'g.gif';
		} else {
			img.src = imatge + 'n.gif';
		}
	}
}

function recargaCms() {
	var contenido = document.getElementById('mainContent');
	if(contenido) {
    if(!contenido.contentDocument) {
  		contenido = window.frames['mainContent'];
  	}
  	if(contenido) {
    	try {
    		if(contenido.contentDocument) {
    			contenido.src = contenido.src;
    		} else if(contenido.document) {
    			contenido.src = contenido.location.reload(true);
    		}
    	} catch(err) {}
    }
  }
}

//legacy
var n4 = false;
var n6 = false;
var ie = false;
if (document.layers){
   //Netscape 4 specific code
   pre = 'document.';
   post = '';
   n4 = true;
}
if (document.getElementById){
   //Netscape 6 specific code
   pre = 'document.getElementById("';
   post = '").style';
   n6 = true;
}
if (document.all){
   //IE4+ specific code
   pre = 'document.all.';
   post = '.style';
   ie = true;
}
function enterToTab(ev) {
	var key = ev.keyCode;
	if(key==13) {
		//ev.keyCode = 9;
		var field;
		if(ie) {
			field = ev.srcElement;
		} else if(n4 || n6) {
			field = ev.target;
		}
		var nextField = getNextElement(field);
		nextField.focus();
		if(nextField.type=='text') {
			nextField.select();
		}
		return false;
	}
	return true;
}

function getNextElement(field) {
  var fieldFound = false;
  var form = field.form;
  for (var e = 0; e < form.elements.length; e++) {
    if (fieldFound && form.elements[e].type != 'hidden' && !form.elements[e].disabled)
      break;
    if (field == form.elements[e])
      fieldFound = true;
  }
  return form.elements[e % form.elements.length];
}

//funciones para validar numeros de documento
function validaNif(nif) {
	var num;
	var letra;
	var i;
	var tabla=new Array("T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E");
	var regexp=/^[[0-9]{7,8}[TRWAGMYFPDXBNJZSQVHLCKEtrwagmyfpdxbnjzsqvhlcke]{1}]*$/;
	
	if (!regexp.exec(nif)) {
		return false;
	} else {
		if (nif.length<8 || nif.length>9) {
			return false;
		} else {
			num=parseInt(nif.substring(0,nif.length-1),10);
			letra=nif.substring(nif.length-1,nif.length).toUpperCase();
	
			i=num%23;
	
			if (letra!=tabla[i]) {
				return false;
			}
		}
	}
	return true;
}

function validaNie(nie) {
	var num;
	var letra;
    var i;
    var tabla=new Array("T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E");
	var regexp=/^[[Xx]{1}[0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKEtrwagmyfpdxbnjzsqvhlcke]{1}]*$/;

	if (!regexp.exec(nie)) {
		return false;
	} else {
	    if (nie.length!=9) {
	    	return false;
		} else {
	    	if (nie.substring(0,1).toUpperCase()!="X") {
	        	return false;
			} else {
		           	
				num=parseInt(nie.substring(1,8),10);
			    letra=nie.substring(8,9).toUpperCase();
			            	
			    i=num%23;
		            	
				if (letra!=tabla[i]) {
		        	return false;
				}
			}
		}
	}
	return true;            
}

function validaNaf(naf) {
	var prov;
	var numero;
	var control;
	var factor;
	var dividend;
	var regexp=/^[[0-9]{5,12}]*$/;
		
	if (!regexp.exec(naf)) {
		return false;
	} else {
	    if(naf.length>12 || naf.length<5) {
			return false;
		} else {
	    	prov=naf.substring(0,2);
	        numero=naf.substring(2,naf.length-2);
	        control=naf.substring(naf.length-2,naf.length);
	        if (parseInt(numero,10) > 9999999) {
	        	factor = 100000000;
	        } else {
	        	factor = 10000000;
	        }
	        dividend = prov * factor + parseInt(numero,10);
	        if ( parseInt(control,10) != dividend % 97 ) {
				return false;
	        }
		}               
	}
	return true; 
}

function isValidCCC(provincia, ccc, control)
{
  try {
    if (provincia === undefined || provincia == null || 
	ccc === undefined || ccc == null ||
	control === undefined || control == null) {
      return false;
    }

    provincia = to_number(provincia);
    ccc = to_number(ccc);
    control = to_number(control);

    if (ccc > 9999999) {
      v_factor = 100000000;
    } else if (ccc > 999999) {
      v_factor = 10000000; 
    } else {
      v_factor = 1000000; 
    }

    var chk = (provincia * v_factor + ccc) % 97;
    return (chk == control);

  } catch (e) {
    return false
  }
}

function to_number(str)
{
  if (typeof str == "string") {
    return Number(str);
  } else if (typeof provincia == "number") {
    return str;
  } else {
    throw "No es un número válido: " + str;
  }
}


function popup(pag,nom,ample,alt){
        var options = 'top=100, left=100, toolbar=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + ample + ', height=' +alt;
        var myWindow = window.open(pag,nom,options);
        return false;
}
function assignaValoresDialogoSelEmprColabGrupoEmpresas(nom, cif,formName) {
		
		return 0;
	}

//********************************************************
// FUNCIONS DEL MENÚ DESPLEGABLE
//********************************************************

var menuids=["menuAA"] //Enter id(s) of menuAA UL menus, separated by commas

function buildsubmenus(){

	for (var i=0; i<menuids.length; i++){
		if(document.getElementById(menuids[i])==undefined) continue;
		var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")

    	for (var t=0; t<ultags.length; t++){
    		ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
    		
			if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
				ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
			else //else if this is a sub level submenu (ul)
		  		ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    		ultags[t].parentNode.onmouseover=function(){
    			this.getElementsByTagName("ul")[0].style.display="block"
    		}
    		ultags[t].parentNode.onmouseout=function(){
    			this.getElementsByTagName("ul")[0].style.display="none"
    		}
    		ultags[t].parentNode.getElementsByTagName("a")[0].onfocus=function(){
    			this.parentNode.getElementsByTagName("ul")[0].style.display="block"
   			}
   			var enlaces = ultags[t].parentNode.getElementsByTagName("a")
    		enlaces[enlaces.length-1].onblur=function(){
    			this.parentNode.parentNode.style.display="none"
                if(this.parentNode.parentNode && this.parentNode.parentNode.parentNode.parentNode && this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id=="menuAA") {
                    var opciones = this.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("li")
                    if(opciones && opciones.length>0) {
                        var ultima = null
                        for(var j=0; j<opciones.length; j++) {
                            if(opciones[j].parentNode && opciones[j].parentNode.parentNode.parentNode.id=="menuAA") {
                                ultima = opciones[j]
                            }
                        }
           				if(this.parentNode.parentNode.parentNode==ultima) {
           				        ultima.parentNode.style.display="none"
           				}
			        }
   				}
            }
    	}

		for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
			ultags[t].style.visibility="visible"
			ultags[t].style.display="none"
		}
    }
}



//********************************************************
//********************************************************

function inicializando()
{
	initFocus();
	getCookie();
}

//-->
//Funciones para las fechas
   function cerosIzq(sVal, nPos){ 
    var sRes = sVal; 
    for (var i = sVal.length; i < nPos; i++) 
     sRes = "0" + sRes; 
    return sRes; 
   } 

   function armaFecha(nDia, nMes, nAno){ 
   	var fecha = new Date();    
    fecha.setDate(cerosIzq(String(nDia), 2));
	fecha.setMonth(cerosIzq(String(nMes), 2));
	fecha.setYear(cerosIzq(String(nAno), 4));
	return fecha;
   } 

   function sumaMes(nDia, nMes, nAno, nSum){
   		nSum = parseInt(nSum, 10);
   		var nuevoMes = (nMes + nSum) % 12;
   		var nuevoAno = parseInt((nMes + nSum) / 12, 10) + nAno;

		return armaFecha(nDia, nuevoMes, nuevoAno); 
   } 
	
	function checkdate(d,m,y)
	{
		var yl=1990; // least year to consider
		var ym=2010; // most year to consider
		if (m<1 || m>12) return(false);
		if (d<1 || d>31) return(false);
		if (y<yl || y>ym) return(false);
		if (m==4 || m==6 || m==9 || m==11)
		if (d==31) return(false);
		if (m==2)
		{
		var b=parseInt(y/4, 10);
		if (isNaN(b)) return(false);
		if (d>29) return(false);
		if (d==29 && ((y/4)!=parseInt(y/4, 10))) return(false);
		}
		return(true);
	}
	
	
	function ultimoDia(mes,ano){ 
    var ultimo_dia=28; 
    while (checkdate(ultimo_dia + 1,mes,ano)){ 
       ultimo_dia=ultimo_dia+1; 
    } 
    return ultimo_dia; 
	} 

/*
 * Funciones para mostrar/ocultar el reloj de espera a pantalla completa. 
 */

/**
 * 
 * @return
 */
function hideReloj() {
	showReloj(false);
}

/**
 * Devuelve una URL a extranet.
 * 
 * @param pathname Ruta relativa a extranet. Puede ser <code>null</code>.
 * @return
 */
function extranetURL(pathName) {
	if (pathName == null)
		pathName = "";

	pathName = pathName.indexOf('/') == 0 ? pathName.substring(1) : pathName;

	return location.href.split(location.pathname)[0] + '/extranet/' + pathName;
}

function showReloj(visible, mensajeEsperaStr) {

	var relojImgID = "showReloj";
	var mensajeEsperaSpanID = relojImgID + "_mensajeEspera";
	var relojImg = document.getElementById(relojImgID);

	if (relojImg == null) {

		// Crear objeto
		var html;

		if (tt_ie) {

			html = '<div align="center" id="'+relojImgID+'" style="background-image:url(\'' + extranetURL("images/block.gif") + '\'); background-repeat:repeat; height: 100%; left: 0; right: 0; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#C0ffffff,endColorstr=#C0ffffff); position: fixed; top: 0; width: 100%; z-index: 100;">';

		} else {
			// ffox
			html = '<div align="center" id="'+relojImgID+'" style="background-color: white; height: 100%; left: 0; opacity: 0.75; position: fixed; top: 0; width: 100%;">'
		}

		// Calcular base GIF

		html = html
			+ '<div align="center" style="position: relative; top: 50%; width: 100%;">'
			+ '<img src="' + extranetURL("images/cargandoinforme.gif") + '">'
			+ '<br><span id="' + mensajeEsperaSpanID + '">'
			+ '&nbsp;</span>'
			+ '</div></div>';

		document.getElementById('showRelojFullscreen').innerHTML += html;

		relojImg = document.getElementById(relojImgID);
	}
	else {
		alert('ELSE');
		relojImg.style.display = visible ? "block" : "none";	
	}

	// Control mensaje
	var mensajeEspera = document.getElementById(mensajeEsperaSpanID);
	mensajeEsperaStr = mensajeEsperaStr != null ? mensajeEsperaStr : "Cargando datos...";
	if (tt_ie) {

		mensajeEspera.firstChild.data = mensajeEsperaStr;
	} else {
		mensajeEspera.firstChild.textContent = mensajeEsperaStr;
	}

	relojImg.style.display = visible ? "block" : "none";
}


/**
 * Objeto con metodos de utilidad para el tratamiento de fechas.
 * 
 * @author ATD0000
 */
window.DateUtils = new Object();

/**
 * Calcula la diferencia entre dos objetos de tipo {@link Date}. El orden de las fechas NO es tenido en cuenta, ya que
 * se devuelve la diferencia absoluta.
 * 
 * Ejemplos: <code>d1 = new Date(2011, 04, 19); d2 = new Date(2010, 04, 20);</code>
 * <code>DateUtils.diferenciaDates(d1, d1, "year") == 0</code>
 * <code>DateUtils.diferenciaDates(d1, d2, "year") == 0.9972602739726028</code>
 * <code>DateUtils.diferenciaDates(d2, d1, "year") == 0.9972602739726028</code>
 * <code>DateUtils.diferenciaDates(d1, d2, "month") == 11.967123287671233</code>
 * 
 * @param date1
 *            Primera {@link Date}
 * @param date2
 *            Segunda{@link Date}
 * @param componente
 *            Valores posibles: "year", "month" y "day".
 * @return Número real positivo o NaN en caso de error.
 */
DateUtils.diferenciaDates = function (date1, date2, componente) {

	try {

		var d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()).getTime();
		var d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()).getTime();
		var granularidad = 1000 * 60 * 60 * 24; // 1 dia en milisegundos

		switch (componente) {
		case "year": {
			granularidad *= 365;
			break;
		}
		case "month": {
			granularidad = (granularidad * 365) / 12.0;
			break;
		}
		case "day": {
			break;
		}
		default:
			throw new Error("componente");
		}

		return Math.abs((d1 - d2) / granularidad);
	} catch (e) {
		return NaN;
	}
};
