function isNetscape()
{
  isnetscape = false;
  if(navigator.appName.substring(0,8) == "Netscape" )
  {
    isnetscape = true;
  }
  return isnetscape;
}

function myDecodeURIComponent(textURIEncoded)
{
  value = textURIEncoded;
  try
  {
    value = decodeURIComponent(textURIEncoded);
  }
  catch(error)
  {
    value = textURIEncoded;
  }
  return value;
}

function LTrim(text)
{
  if(text == null || text.length == 0)
  {
    return "";      
  }      
  idx = 0;
  text = myDecodeURIComponent(text);
  while(text.charAt(idx) == ' ')
  {
    ++idx;
    if(idx >= text.length)
      break; 
  }
  if(idx < text.length)
  {
    return text.substring(idx);
  }
  else  
    return "";
}

function RTrim(text)
{
  if(text == null || text.length == 0)
  {
    return "";      
  }
  text = myDecodeURIComponent(text);
  idx = text.length - 1;
  while(text.charAt(idx) == ' ')
  {
    --idx;
    if(idx < 0)
      break;
  }
  if(idx >= 0)
  {
    return text.substring(0, (idx + 1));
  }    
  else  
    return "";
}

function Trim(text)
{
  testo = LTrim(text);
  testo = RTrim(testo);
  return testo;
}

function isEmpty(text)
{
  if(text == null)
  {
    return true;  
  }
  else
  {
    testo = Trim(text);
    if(testo.length == 0)
    {
      return true;
    }
    else
      return false;
  }
}

function rendiNumero(text)
{
  text = Trim(myDecodeURIComponent(text));
  if(text.indexOf(",") >= 0)
  {
    text = text.replace(".", "");
    text = text.replace(",", ".");
  }
  while((text.indexOf("0") == 0) && (text.length > 1) && ((text.indexOf(".") < 0) || (text.indexOf(".") > 1)))
  {
    text = text.substring(1);
  }
  return Trim(text);
}

function eNumero(text)
{
  text = myDecodeURIComponent(text);
  if(isEmpty(text))
  {
    return false;  
  }
  else
  {        
    testo = rendiNumero(text);
    ok = (!isNaN(testo));
    ok = (ok && isFinite(testo));  
    return ok;
  }
}

function openPopupAtPositionScrollbarNoResizable(iTop, iLeft, width, height, redirect) 
{
  innerITop = iTop;
  innerILeft = iLeft;  
  windowOuterHeight = window.outerHeight;
  windowOuterWidth = window.outerWidth;
  if(isEmpty(innerITop) || (!eNumero(innerITop)) || (parseInt('' + innerITop) < 0))
  {
    if(isEmpty(windowOuterHeight) || (!eNumero(windowOuterHeight)))
    {    
      windowOuterHeight = window.screen.height;
      if(isEmpty(windowOuterHeight) || (!eNumero(windowOuterHeight)))
      {      
        windowOuterHeight = height;
      }      
    }
    innerITop = Math.round((windowOuterHeight / 2) - (height / 2));
  }
  if(isEmpty(innerILeft) || (!eNumero(innerILeft)) || (parseInt('' + innerILeft) < 0))
  {
    if(isEmpty(windowOuterWidth) || (!eNumero(windowOuterWidth)))
    {      
      windowOuterWidth = window.screen.width;
      if(isEmpty(windowOuterWidth) || (!eNumero(windowOuterWidth)))
      {      
        windowOuterWidth = width;
      }
    }
    innerILeft = Math.round((windowOuterWidth / 2) - (width / 2));
  }

  var OpenWindow = redirect;
  var params = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ',height=' + height + ',top='+innerITop+',left='+innerILeft
  popup = window.open(OpenWindow, "Popup", params);
}
