    var message      
  var fieldtofocus
 
function pnr(textfield, ctrl) {
    //alert (textfield.value);
    if(ctrl==1 && (textfield.value.length != 10 || isNaN(textfield.value))) {
      //alert("felaktigt personnummer")
      return false;
    }
    var sum = 0
    for(i=0;i<9;i++) {        // Multiplicera siffrorna var och en växelvis med 2 och 1
      var n = textfield.value.substr(i,1)
      var m = 2 - (i % 2)
      // lägg ihop produkterna, 10-talen läggs till som ental
      sum += (m * n) % 10 + parseInt((m * n) / 10)
    }
    // checksiffran är 10 - entalet i summan
    if(ctrl==1) {
      if(textfield.value.substr(9,1) != (10 - (sum % 10))) {
         //                          alert("Checksiffran är felaktig")
         return false;
      }
    }
    else {
      textfield.value = textfield.value.substr(0,9) + (10 - (sum % 10))
    }
    return true;
}
 
function isFormReady(form)
{
  var passed = true;
  fieldtofocus = "";
  message ="Fyll i alla fält som markerats med en *: \n";

  if (form.invContactNM.value == "")
  {
    message += "- - Namn \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.invContactNM}
  }
  
  if (form.invAdd1.value == "")
  {
    message += "- - Adress \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.invAdd1}
  }

  if (form.invZip.value == "")
  {
    message += "- - Postnummer \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.invZip}
  }

  if (form.invCity.value == "")
  {
    message += "- - Ort \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.invCity}
  }  


  if (form.invEmail.value == "")
  {
    message += "- - E-post \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.invEmail}
  }  
  

/* Remmad 050715 av WAt pga problem enligt mail från Fredrik
  if (!form.AcceptPUL.checked)
  {
    message += "- -  Bekräfta att du läst köpvillkoren\n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.AcceptPUL}
  }
*/

  
/*  if (form.retail.checked) {
    if (form.retailtext.value == "") {
      pnr (form.retailtext, 1);
      message += "- - Organisationsnummer \n";
      passed = false;
    } else {
      if (!(pnr (form.retailtext, 1))) {
         message += "- - Organisationsnummer Ej godkänt\n";
         passed = false;
      }
    }
  }

  if (form.student.checked) {
    if (form.studenttext.value == "") {
      message += "- - Ange skola/födelseår \n";
      passed = false;
      if (fieldtofocus == "")  {fieldtofocus = form.studenttext};
    }
  } 

  if (form.shipCompanyNM.value == "")
  {
    message += "- - Företag \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipCompanyNM}
  }

  if (form.shipContactNM.value == "")
  {
    message += "- - Namn \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipContactNM}
  }


  if (form.shipZip.value == "")
  {
    message += "- - Postnummer \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipZip}
  }


  if (form.shipCity.value == "")
  {
    message += "- - Ort \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipCity}
  }
  if (form.shipEMail.value =="")
  {
    message += "- - E-post \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipEMail}
  }
  
  if (form.shipPhone.value == "")
  {
    message += "- - Telefon \n";
    passed = false;
    if (fieldtofocus == "")  {fieldtofocus = form.shipPhone}
  }
*/
  
  if (passed == false)
  {
    fixFieldInfo(message, fieldtofocus); 
    return passed;
  }
  else
  {
    form.submit();
    return true;
  }
}

function isFormReady2(form){
    form.submit();
    return true;
}

function fixFieldInfo(message, fieldtofocus) {
  alert(message);
  fieldtofocus.focus();
}


function openInfo(document)
{
  var myWindow=window.open(document, "Information", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=447,height=600");
  // Can't set focus here because it doesn't always work
  // The focus is handled by the page itself
}
  
function chkQty( qtyNew, qtyOrg, qtyWhse)
{
  if (qtyNew.value != qtyOrg){
    if (qtyNew.value > qtyWhse){
      alert('Det finns endast ' + qtyWhse + ' kvar i lager.');    
      qtyNew.value = qtyOrg;
      qtyNew.focus();
    } 
    else {
      if (window.confirm('Vill du uppdatera antal?')){
        document.frm_basket.submit();
      }
      else{
        qtyNew.value = qtyOrg;
        qtyNew.focus();  
      }
    }
  }
}

function reloadParent()
{
  parent_win = window.opener;
  parent_win.location.href = '<?php echo $HTTP_SESSION_VARS["SessionVar"][$Path]["app"]["shopMore"] ?>'; //'http://www.sos.se/plus/skrift.htm';
  parent_win.focus();
}

function openInfo(document)
{
  var myWindow=window.open(document, "Information", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=447,height=600");
  // Can't set focus here because it doesn't always work
  // The focus is handled by the page itself
}