/*

  karba.js                May 19, 2008

  Copyright (c) 2007-2008 Scandinavian Digital Systems AB

  Developed by Anders Danielsson, http://www.digsys.se/

*/

function DisableAllForms()
{
  for (var n=0; n<document.forms.length; n++)
  {
    for (var m=0; m<document.forms[n].elements.length; m++)
    {
      document.forms[n].elements[m].disabled=true;
    }
  }
}

var Submitted=false;

function OnSubmitForm()
{
/*
  The form submit() method cannot be used when the button's name=value must be submitted.
  The ONSUBMIT function must return true to send the button's name=value pair.
*/
  if (Submitted) return false;
  Submitted=true;
  setTimeout("DisableAllForms()",500);
  return true;
}

function CookieSet(name,value,months)
/*
  If Months = 0 then the cookie is trashed when the user closes the browser.
  If Months = -1 then the cookie is trashed immediately.
*/
{
  var expires;

  if (months!=0)
  {
    var date = new Date();
    date.setMonth(date.getMonth()+months);
    expires=";expires="+date.toGMTString();
  }
  else
    expires="";
  document.cookie=name+"="+value+expires+";path=/";
}

function CookieGet(name)
{
  var nameEQ = name+"=";
  var a = document.cookie.split(';');
  var s;
  var n;

  for (n=0; n<a.length; n++)
  {
    s=a[n];
    while (s.length>1 && s.charAt(0)==' ') { s=s.substr(1); }
    if (s.indexOf(nameEQ)==0)
    {
      s=s.substring(nameEQ.length,s.length);
      if (s.length==0) return null;
      return  s;
    }
  }
  return null;
}

function onload_main()
{
  var s = CookieGet("karbalogin");
  if (s)
  {
    var a = s.split(',');
    document.login.uid.value=a[0];
    document.login.pwd.value=a[1];
    document.login.login.focus();
  }
  else
    document.login.uid.focus();
}


