var bFormDirty = new Boolean(false);

/** Öppnar URL:en loc i nytt fönster med bredden w och höjdebn h. Sätt scrollbars
    och resizable = 1 om detta önskas*/
function showPopupWin(loc, caption, w, h, resizable, scrollbars, left, top)
{
  if (left == 0)
    left = (parseInt(screen.width/2) - w/2);
  if (top == 0)
    top = (parseInt(screen.height/2) - h/2);
  return window.open(loc, caption, "toolbar=no,scrollbars=" + scrollbars + 
                     ",width=" + w + 
                     ",height=" + h + 
                     ",left=" + left +
                     ",top=" + top +
                     ",resizable=" + resizable);
}


/** Kollar om data i formuläret är ändrat, returnerar då true*/
function isFormDirty(frm)
{
var obj;
var i;

  for (i = frm.elements.length-1; i>=0; i--)
  {
    obj = frm.elements[i];
    if (obj.type == "text")
    {
      if (obj.defaultValue != obj.value)
        return true;
    }
  }
  return false;
}


function checkForm()
{
  if (isFormDirty(frmDetail) || (bFormDirty==true))
  {
    if (confirm("You have made changes.\nClick on 'Cancel' to cancel close") == true)
      return true;
    else
      return false;
  }
  else
    return true;
}
