﻿// JScript File

function GetValueFromRadioButton(element)
{
   var returnValue;
   var rbl = document.getElementById(element);
   var options = rbl.getElementsByTagName('input');
    
    for (var i=0; i < options.length; i++)
    {
        if (options[i].checked)
        {
         
            returnValue = options[i].value;
            break;
        }
    }

    return returnValue;
}

function fixMoney(fld,sep)
{ // monetary field check
  if(!fld.value.length||fld.disabled) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  if(typeof(sep)!='undefined') val= val.replace(new RegExp(sep,'g'),'');
  if(val.indexOf('$') == 0)
    val= parseFloat(val.substring(1,40));
  else
    val= parseFloat(val);
  if(isNaN(val))
  { // parse error 
   alert("El campo '" + fieldname(fld) +  "' debe ser un valor monetario.");
    return false;
  }
  var sign= ( val < 0 ? '-': '' );
  val= Number(Math.round(Math.abs(val)*100)).toString();
  while(val.length < 2) val= '0'+val;
  var len= val.length;
  val= sign + ( len == 2 ? '0' : val.substring(0,len-2) ) + '.' + val.substring(len-2,len+1);
  fld.value= val;
  return true;
}

function fixInt(fld,sep)
{ // integer check/complainer 
  if(!fld.value.length||fld.disabled) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  if(typeof(sep)!='undefined') val= val.replace(new RegExp(sep,'g'),'');
  val= parseInt(val);
  if(isNaN(val))
  { // parse error 
     alert("El campo '" + fieldname(fld) +  "' debe ser un valor numérico.");
    return false;
  }
  fld.value= val;
  return true;
}

function fieldname(fld)
{ // get the field label text or name
  if(fld.id && document.getElementsByTagName)
  {
    for(var i= 0, lbl= document.getElementsByTagName('LABEL'); i < lbl.length; i++)
      if(lbl[i].htmlFor==fld.id) return lbl[i].nodeValue||lbl[i].textContent||lbl[i].innerText;
    for(var i= 0, lbl= document.getElementsByTagName('label'); i < lbl.length; i++)
      if(lbl[i].htmlFor==fld.id) return lbl[i].nodeValue||lbl[i].textContent||lbl[i].innerText;
  }
  return fld.name;
}

function OpenBancaEnlinea()
{
  window.open('/BancaEnlinea','BancaEnLinea','width=850,height=600,scrollbars=yes,status=yes,resizable=yes,titlebar=yes,toolbar=no');
}

function SendToFriend(pageId)
{
     window.open('/utility/sendtofriend.aspx?p='+ pageId,'BancaEnLinea','width=540,height=550,scrollbars=yes,status=yes,resizable=yes,titlebar=yes,toolbar=no');
}
function OpPopup(image)
{
    window.open(image, 'MyPopUp', 'width=696,height=461,scrollbars=0,screenX=200,screenY=200,left=200,top=200,location=no,directories=no,menubar=no,toolbar=no');
}