function crearCristal(doc,principal){
  if(!doc.body) return;
  var div = doc.createElement("DIV"); 
  div.id = 'cristal'; 
  div.style.cursor='wait';
  div.style.width='100%';
  div.style.height='100%';
  div.style.top='0';
  div.style.left='0';
  div.style.position='absolute';
  div.style.visibility='hidden';
  div.style.zIndex = 99999;
  if(principal){
    div.innerHTML = '<table style="width:100%; height:500px"><tr><td align="center" valign="middle">'+
    '<table style="width:200px;height:50px;">'+
    '<tr> '+
    '  <td valign="middle">'+
    '    <table width="200px" height="50px" cellpadding="0px" cellspacing="0px" border="0px">'+
    '      <tr> '+
    '        <td width="200px" bgcolor="#e6e6e6" height="50px">'+
    '          <table width="200px" height="50px" cellpadding="1px" cellspacing="0px" border="0px" bgcolor="#666666">'+
    '            <tr> '+
    '              <td class="VentanaInterior">'+
    '                <table width="200px" height="50px" class="Font11px" border="0px" bgcolor="#e6e6e6">'+
    '                  <tr> '+
    '                    <td colspan="3" height="30px" align="center" valign="middle" '+
    '                      class="Font10pxB">'+
    '                        Procesando... espere por favor.'+
    '                    </td>'+
    '                  </tr>'+
    '                  <tr> '+
    '                    <td width="10px" height="6px"></td>'+
    '                    <td width="180px" height="6px" align="center" valign="middle">'+
	'						<img src="'+contexto+'/images/cargando.gif" class="relieve" width="175px"></td>'+
    '                    <td width="10px" height="6px"></td>'+
    '                  </tr>'+
    '                  <tr> '+
    '                    <td bgcolor="#e6e6e6" colspan="3" height="2px"></td>'+
    '                  </tr>'+
    '                </table>'+
    '              </td>'+
    '            </tr>'+
    '          </table>'+
    '        </td>'+
    '      </tr>'+
    '      <tr> '+
    '        <td colspan="2" height="1px">'+
    '          <table cellpadding="0px" cellspacing="0px" border="0px">'+
    '            <tr> '+
    '              <td width="1px" height="1px" bgcolor="#B0BDCD"></td>'+
    '              <td width="200px" height="1px" bgcolor="#393939"></td>'+
    '            </tr>'+
    '          </table>'+
    '        </td>'+
    '      </tr>'+
    '    </table>'+
    '  </td>'+
    '</tr>'+
    '</table>'+
    '</tr></table>';
  }else{
    div.innerHTML = '<table width="100%" height="100%"><tr><td>&nbsp;</tr></table>';
  }
  doc.body.appendChild(div);
  return div;
}

function muestraReloj(){	
  displayReloj(top,true);
}

function ocultaReloj(){
  displayReloj(top,false);
}

function displayReloj(parentFrame,reloj){
    /*// ESTE FRAME ESTA EN UNA PESTAŅA DE CONSULTAS DE PADRON Y FALLA AL SITUAR EL FOCO
		// POR ESO ME LO SALTO
		if(parentFrame.name=="resultado") return;*/
		var actual = parentFrame.frames;
		if(!actual.document.body) return;
		var elt = actual.document.getElementById("cristal");
		if(!elt){
/*			var principal = false;
			if(actual.name=="mainFrame"){
				principal = true;
			}*/
			elt = crearCristal(actual.document,true);
		}
		if(elt){
			elt.style.visibility = ((reloj)?"visible":"hidden");
			elt.style.zIndex = ((reloj)?99999:0);
			elt.style.cursor = ((reloj)?'wait':'auto');
			if(reloj && document.all) elt.focus();
		}
}

function configReloj(marco){
  initReloj(marco);
  ocultaReloj();
}

function initReloj(marco){
 
  var elt = marco.document.getElementById("cristal");
  if(elt){
    elt.style.visibility = "hidden";
    elt.style.zIndex = 0;
  }
  
  for(var i=0;i < marco.document.forms.length; i++){
    if(!marco.document.forms[i].oldSubmit){
		
      marco.document.forms[i].oldSubmit = marco.document.forms[i].submit;
      marco.document.forms[i].submit = function(){
        top.muestraReloj();
		this.oldSubmit();
      };
    }
  }
}
