/* ------------------------------------------------------------------------------ */
/* Funciones de Ventana --------------------------------------------------------- */
/* ------------------------------------------------------------------------------ */

function showWin(FileName, wWidth, wHeight, wScroll)
{
 var nTop;
 var nLeft;
 
 nTop = (screen.height - wHeight) / 2
 nLeft = (screen.width - wWidth) / 2

 if (window.ventana && !(window.ventana.closed))
  window.ventana.close();
 
 ventana=window.open(FileName, "Ventana", "width=" + wWidth +
                     ",height=" + wHeight + ",top=" + nTop + ",left=" + nLeft +
                     ",scrollbars=" + wScroll );
}

function showDetalle(FileName, wWidth, wHeight, wScroll)
{
 var nTop;
 var nLeft;
 
 nTop = (screen.height - wHeight) / 2
 nLeft = (screen.width - wWidth) / 2
 
 ventana=window.open(FileName, "HelpWindow", "width=" + wWidth +
                     ",height=" + wHeight + ",top=" + nTop + ",left=" + nLeft +
                     ",scrollbars=" + wScroll );
}


/* ------------------------------------------------------------------------------ */
/* Funciones de Mensaje --------------------------------------------------------- */
/* ------------------------------------------------------------------------------ */

   function ingreso()
   {
   var a,b,strlength;
   a=document.emailForm.Mensaje.value;
  <!-- b=document.emailForm.EmailFrom.value;-->
  <!-- strlength= a.length + b.length;-->
   strlength= a.length;
   if (strlength > 120 ) {
   alert ("El mensaje ha superado los 120 caracteres!"); 
  <!-- document.emailForm.Mensaje.value=a.substring(0,120 - b.length);-->
   document.emailForm.Mensaje.value=a.substring(0,120);
   charleft = 0;
    }
    else {
   	   charleft = 120 - strlength}
	   document.emailForm.contador.value=charleft;
	   startTimer()
   }
  
    function ingresoform()
   {
   var a,b,strlength;
   a=document.emailForm.Mensaje.value;
  <!-- b=document.emailForm.EmailFrom.value;-->
  <!-- strlength= a.length + b.length;-->
   strlength= a.length;
   if (strlength > 120 ) {
   alert ("El mensaje ha superado los 120 caracteres!"); 
  <!-- document.emailForm.Mensaje.value=a.substring(0,120 - b.length);-->
   document.emailForm.Mensaje.value=a.substring(0,120);
   charleft = 0;
    }
    else {
 	   charleft = 120 - strlength}
	   document.emailForm.contador.value=charleft;
	   stopTimer()
   }

/* ========================================================= */  
  function startTimer()
  {
  	  running = true
	  now = new Date()
	  now = now.getTime()
	  endTime = now + (1000 * 0.1 * 1)
	  showCountDown()
  }

/* ========================================================= */  
  function showCountDown()
  {
	  var now = new Date()
	  now = now.getTime()
	  if (endTime - now <= 0) {
	  	  ingreso(document.emailForm.Mensaje.value)
	  } else {
		  var delta = new Date(endTime - now)
		  var theMin = delta.getMinutes()
		  var theSec = delta.getSeconds()
		  var theTime = theMin
		  theTime += ((theSec < 10) ? ":0" : ":") + theSec
		  if (running) {
			  timerID = setTimeout("showCountDown()",1000)
		  }
	  }
  }

/* ========================================================= */  
  function stopTimer()
  {
	  clearTimeout(timerID)
	  running = false
  } 


/* ------------------------------------------------------------------------------ */
/* Funciones de Validacion ------------------------------------------------------ */
/* ------------------------------------------------------------------------------ */

function validate(numero) {
    if (!numero) return false;
    var Chars = "0123456789";

    for (var i = 0; i < numero.length; i++) {
       if (Chars.indexOf(numero.charAt(i)) == -1)
          return false;
    }
    return true;
} 
