var xPos;
var yPos;

function showToolTip(title,msg,evt){
    if (evt) {
        var url = evt.target;
    }
    else {
        evt = window.event;
        var url = evt.srcElement;
    }
    xPos = evt.clientX;
    yPos = evt.clientY;

   var toolTip = document.getElementById("toolTip");
   toolTip.innerHTML = "<h1>"+title+"</h1><p>"+msg+"</p>";
   toolTip.style.top = parseInt(yPos)+2 + "px";
   toolTip.style.left = parseInt(xPos)+2 + "px";
   toolTip.style.visibility = "visible";

}

function hideToolTip(){
   var toolTip = document.getElementById("toolTip");
   toolTip.style.visibility = "hidden";
}

/*function currencyFormat(fld, milSep, decSep, e, deci,cuantosd) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  if (deci==0)
  strCheck = '0123456789';
  else
  strCheck = '0123456789.';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;
  if (whichCode == 13) return true;
  if (whichCode == 37) return true;
  if (whichCode == 46)
  {
    if (fld.value.indexOf(".")!=-1)
    return false;
  }
  if (whichCode == 8 && whichCode == 46)
  {
    len = fld.value.length;
    if (len>cuantosd)
    {
      return false;
    }
    for(i = 0; i < len; i++)
    if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
    aux = '';
    for(; i < len; i++)
    if (strCheck.indexOf(fld.value.charAt(i))!=-1)
    aux += fld.value.charAt(i);

    aux += key;
    len = aux.length;
    if (len == 0) fld.value = '';
    if (len == 1) fld.value = '';
    if (len == 2) fld.value = '';
    aux2 = '';
    for (j = 0, i = len-1; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 -1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    return false;
  }
  key = String.fromCharCode(whichCode);
  if (strCheck.indexOf(key) == -1) return false;
  len = fld.value.length;
  if (len>cuantosd)
  {
    return false;
  }
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '';
  if (len == 2) fld.value = '';
  aux2 = '';
  for (j = 0, i = len-1; i >= 0; i--) {
    if (j == 3) {
      aux2 += milSep;
      j = 0;
    }
    aux2 += aux.charAt(i);
    j++;
  }
  fld.value = '';
  len2 = aux2.length;
  for (i = len2 -1; i >= 0; i--)
  fld.value += aux2.charAt(i);
  if (deci!=0)
  {
    if (fld.value > 999999999.99)
    {
      por = fld.value;
      fld.value = por.substring(0,por.length-1);
    }
  }
  return false;
}
*/


function vacios(no,niveles)
{

  for (i=1; i<=niveles; i++)
  {
    if (document.getElementById("nivel_"+i).value == '')
    {
    alert("Debe introducir un valor para el pago peri\u00f3dico "+i)
    return false;
    }
  }
  for (i=1; i<=niveles; i++)
  {
    if (document.getElementById("monto_del_nivel_"+i).value == '')
    {
    alert("Debe introducir un valor para el monto del pago peri\u00f3dico "+i)
    return false;
    }
  }
  ceros = 0;
  for (i=1; i<=no; i++)
  {
    if (document.getElementById("periodo_"+i).value == '0')
      ceros = ceros + parseFloat(document.getElementById("monto_del_periodo_"+i).value);

    if (document.getElementById("periodo_"+i).value == '')
    {
    alert("Debe introducir un valor para el periodo "+i)
    return false;
    }
  }
  document.getElementById("pcero").value = ceros;
//  document.getElementById("monto_del_periodo_1").value = parseFloat(document.getElementById("apertura").value)+ parseFloat(document.getElementById("monto_del_periodo_1").value);
//  alert("HOLA"+document.getElementById("monto_del_periodo_1").value);

  for (i=1; i<=no; i++)
  {
    if (document.getElementById("monto_del_periodo_"+i).value == '')
    {
    alert("Debe introducir un valor para el monto del periodo "+i)
    return false;
    }
  }
}

function limpia()
{
  document.getElementById("r3").disabled = false;
if (! (document.forms [0].iva [0].checked || document.forms [0].iva [1].checked ) ) {
alert ('Especifique si la información que ingresa incluye o no IVA');
return false;
}
}

function valida()
{
  alert("valorIVA");
  var elemento=document.getElementByName("iva");
  var valorIVA=elemento.value;
  alert("valorIVA");

}

function resta ()
{
  document.getElementById("r3").value = document.getElementById("r1").value - document.getElementById("r2").value;
}
function currencyFormat(fld, milSep, decSep, e, deci,cuantosd) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var whichCode = (window.Event) ? e.which : e.keyCode;
  if (whichCode == 13) return true;
  if (whichCode == 37) return true;
  if (whichCode == 46)
  {
    if (fld.value.indexOf(".")!=-1)
    return false;
    else
    return true;
  }
  if (whichCode<48 || whichCode>57)
  return false;
//  len = fld.value.length;
/*  if (len>cuantosd)
  {
    return false;
  }
  if (strCheck.indexOf(fld.value.charAt(i))==-1)
  {
    alert("false");
  return false

  }*/
}

