﻿//svc.js

function AttachnLicEvent()
{
  if (!document.getElementById) return;
  
  oLic = document.getElementById("NumLicense");
   
  if (oLic.attachEvent)
      oLic.attachEvent("onchange", NumLic_OnChange);
  else
      oLic.addEventListener("change", NumLic_OnChange, false);
      
  oEdition = document.getElementById("Edition");
   
  if (oEdition.attachEvent)
      oEdition.attachEvent("onchange", NumLic_OnChange);
  else
      oEdition.addEventListener("change", NumLic_OnChange, false);

}

function NumLic_OnChange() {
   //mywin = window.open("images/ss_01.png","Test","toolbar=no,scrollbars=no,resizable=no,width=100,height=100");
   //return mywin;
   if (!document.getElementById) return;
   
   var punit_ent = 99.00;
   var punit_pro = 9.00;
   var punit_ps = 59.00;
   
   oLic = document.getElementById("NumLicense");
   oAmt = document.getElementById("Amount");
   oEdt = document.getElementById("Edition");
   
   if(oLic.value == "")
   {
      return;
   }
   
   vLic = parseInt(oLic.value);
   
   var vEdt = oEdt.value;
   
   if(vEdt.toString() == "")
    vEdt = "Professional";
   
   vAmt = 0;
    if(vEdt.toString() == "Enterprise")
    {
        if (vLic <= 5)
            vAmt = punit_ent * vLic;
        else if (vLic <= 10)
            vAmt = punit_ent * vLic * 0.85;
        else if (vLic <= 50)
            vAmt = punit_ent * vLic * 0.75;
        else
            vAmt = punit_ent * vLic * 0.65;
    }
    else if(vEdt.toString() == "Professional")
    {
        /*if (vLic <= 5)
            vAmt = punit_pro * vLic;
        else if (vLic <= 10)
            vAmt = punit_pro * vLic * 0.85;
        else if (vLic <= 50)
            vAmt = punit_pro * vLic * 0.75;
        else
            vAmt = punit_pro * vLic * 0.65;
        */         
        vAmt = punit_pro * vLic;

    }
    else
    {
        vAmt = punit_pro * vLic;
    }
   
   var stmp = "";
   var ntmp = 0;
   vAmt = vAmt * 100.0;
   stmp = vAmt;
   ntmp = parseInt(stmp);
   vAmt = ntmp / 100.0;
   
   oAmt.value = vAmt;
}





