var pricelist_driveencryption = new Array(29.95, 24.95, 19.95, 16.95, 13.95, 2890, 2099, 1674657);
var countlist_driveencryption = new Array(1, 9, 19, 199, 9999);
var pricelist_all2pdf = 	new Array(24.95, 21.95, 19.95, 16.95, 13.95, 499, 1599, 1671031);
var countlist_all2pdf = 	new Array(1, 9, 19, 199, 9999);
var pricelist_docconv_ce = 	new Array(29.95, 26.95, 23.95, 20.95, 17.95, 599, 1699, 1671032);
var countlist_docconv_ce = 	new Array(1, 9, 19, 199, 9999);
var pricelist_docconv_pro = 	new Array(39.95, 34.95, 29.95, 24.95, 19.95, 699, 1899, 1671033);
var countlist_docconv_pro = 	new Array(1, 9, 19, 199, 9999);
var pricelist_docconv_x = 	new Array(89.95, 79.95, 69.95, 59.95, 49.95, 1499, 2999, 1671034);
var countlist_docconv_x = 	new Array(1, 9, 19, 199, 9999);
var pricelist_splbatconv = 	new Array(298.95, 259.95, 219.95, 189.95, 159.95, 1999, 2999, 1915748);
var countlist_splbatconv = 	new Array(1, 9, 19, 199, 9999);
var pricelist_httpsnifferce = 	new Array(19.95, 15.95, 12.95, 9.95, 7.95, 1690);
var countlist_httpsnifferce = 	new Array(1, 9, 49, 199, 9999);

var pricelist_virprt_emf = 	new Array(899, 299, 95);
var pricelist_virprt_pdf = 	new Array(1699, 299, 95, 195);
var pricelist_virprt_image = 	new Array(1599, 299, 95);
var pricelist_virprt_spl = 	new Array(2499, 299, 95);


Number.prototype.toFixed=function(len)
{
    var add = 0;
    var s,temp;
    var s1 = this + "";
    var start = s1.indexOf(".");
    if (-1 == start) return this;
    if(s1.substr(start+len+1,1)>=5)add=1;
    var temp = Math.pow(10,len);
    s = Math.floor(this * temp) + add;
    return s/temp;
}

function checknum(p)
{
var iLoop, iCount, digit;
if (p == "0")
{
  alert ("The order quantity cannot be less than 1");
  return false;
}
iCount = p.length;
for(iLoop=0; iLoop<iCount; iLoop++)
{
  digit = p.charAt(iLoop);
  if ((digit < "0") || (digit > "9"))
  {
    alert ("Please enter numerical value");
    return false;
  }
}
return true;
}

function ShowPrice(productname, pricecount, count)
{
var countlist, pricelist;	
var iLoop, iCount, paytotal;

switch(productname)
{
case "Drive Encryption":
  pricelist = pricelist_driveencryption;
  countlist = countlist_driveencryption;
  break;
case "ActMask SPL Batch Converter":
  pricelist = pricelist_splbatconv;
  countlist = countlist_splbatconv;
  break;  
case "ActMask HTTP Sniffer CE":
  pricelist = pricelist_httpsnifferce;
  countlist = countlist_httpsnifferce;
  break; 
case "ActMask ALL2PDF PDF Creator":
  pricelist = pricelist_all2pdf;
  countlist = countlist_all2pdf;
  break;
case "ActMask Document Converter CE":
  pricelist = pricelist_docconv_ce;
  countlist = countlist_docconv_ce;
  break;
case "ActMask Document Converter Pro":
  pricelist = pricelist_docconv_pro;
  countlist = countlist_docconv_pro;
  break;
case "ActMask Document Converter X":
  pricelist = pricelist_docconv_x;
  countlist = countlist_docconv_x;
  break;
default:
  return false;
}

if ('site' == pricecount)
{
  paytotal = pricelist[5];
  paytotal = paytotal.toFixed(2);
  document.write('$' + paytotal);
  return true;
}
else if ('msite' == pricecount)
{
  paytotal = pricelist[6];
  paytotal = paytotal.toFixed(2);
  document.write('$' + paytotal);
  return true;
}

iCount = countlist.length;
//alert(iCount);
for(iLoop=0; iLoop<iCount; iLoop++)
{
  if (pricecount <= countlist[iLoop])
  {
    paytotal = pricelist[iLoop] * 100 * count / 100;
    paytotal = paytotal.toFixed(3);
    document.write('$' + paytotal);

    return true;
  }
}
return false;
}

function Buy(useCC, formObj, productname, count)
{
var countlist, pricelist;
var iLoop, iCount, paytotal;

switch(productname)
{
case "Drive Encryption":
  pricelist = pricelist_driveencryption;
  countlist = countlist_driveencryption;
  break;
case "ActMask SPL Batch Converter":
  pricelist = pricelist_splbatconv;
  countlist = countlist_splbatconv;
  break;  
case "ActMask HTTP Sniffer CE":
  pricelist = pricelist_httpsnifferce;
  countlist = countlist_httpsnifferce;
  break; 
case "ActMask ALL2PDF PDF Creator":
  pricelist = pricelist_all2pdf;
  countlist = countlist_all2pdf;
  break;
case "ActMask Document Converter CE":
  pricelist = pricelist_docconv_ce;
  countlist = countlist_docconv_ce;
  break;
case "ActMask Document Converter Pro":
  pricelist = pricelist_docconv_pro;
  countlist = countlist_docconv_pro;
  break;
case "ActMask Document Converter X":
  pricelist = pricelist_docconv_x;
  countlist = countlist_docconv_x;
  break;
default:
  alert('Error:' + productname);
  return false;
}

if ('site' == count)
{
  paytotal = pricelist[5];
  if (!useCC)
  {
    	formObj.item_name.value = productname + " | Single Site License";
    	formObj.item_number.value = count;
    	formObj.amount.value = paytotal;
  }
  else
  {
    formObj.overridePrice.value = paytotal;
  }
  //alert(productname + '\r\n' + pricelist[5] + ' * ' + count + " = " + paytotal);
  return true;
}
else if ('msite' == count)
{
  paytotal = pricelist[6];
  if (!useCC)
  {
    	formObj.item_name.value = productname + " | Multi Site License";
    	formObj.item_number.value = count;
    	formObj.amount.value = paytotal;
  }
  else
  {
    formObj.overridePrice.value = paytotal;
  }
  //alert(productname + '\r\n' + pricelist[6] + ' * ' + count + " = " + paytotal);
  return true;
}

iCount = countlist.length;
//alert(iCount);
for(iLoop=0; iLoop<iCount; iLoop++)
{
  if (count <= countlist[iLoop])
  {
    paytotal = pricelist[iLoop] * 100 * count / 100;
    paytotal = paytotal.toFixed(2);
    
    if (!useCC)
    {
    	formObj.item_name.value = productname + " | " + count + " Computer(s) License";
    	formObj.item_number.value = count;
    	formObj.amount.value = paytotal;
    	//alert(formObj.item_name.value + '\r\n' + pricelist[iLoop] + ' * ' + count + " = " + paytotal);
    }
    else
    {
      formObj.overridePrice.value = paytotal;
    }

    //alert(productname + '\r\n' + pricelist[iLoop] + ' * ' + count + " = " + paytotal);

    return true;
  }
}
return false;
}

function BuyOption(productname)
{
var pricelist, iLoop, iMax, objoption, paytotal, item;

switch(productname)
{
case "ActMask EMF Virtual Printer SDK":
  pricelist = pricelist_virprt_emf;
  break;
case "ActMask PDF Virtual Printer SDK":
  pricelist = pricelist_virprt_pdf;
  break;
case "ActMask Image Virtual Printer SDK":
  pricelist = pricelist_virprt_image;
  break;
case "ActMask SPL Virtual Printer SDK":
  pricelist = pricelist_virprt_spl;
  break;
default:
  alert('Error:' + productname);
  return false;
}

paytotal = pricelist[0];
iMax = pricelist.length;
item = productname + " | Option:";

for(iLoop=1; iLoop<iMax; iLoop++)
{
  objoption = eval("checkbox" + iLoop);
  if (objoption.checked)
  {
    paytotal = paytotal + pricelist[iLoop];
    item = item + iLoop + "|";
  }
}
paytotal = paytotal.toFixed(2);
form_CC_1.overridePrice.value = paytotal;

//form_PP_1.item_name.value = item;
//form_PP_1.amount.value = paytotal;
//alert("ItemName: " + item + " " + paytotal);

return true;
}

function CalcPrice()
{
var objName, fPrice, fAmount, iLoop, iLoop1, iGroups, iCheckBoxs, iListBoxs, iIndex, szTxt, szComment;

fAmount = 0;
szComment = "";

iGroups = groups.value;
//alert ("Group:" + iGroups);

for(iLoop=0; iLoop<iGroups; iLoop++)
{
  iCheckBoxs = 0;
  iListBoxs = 0;

  objName = "checkboxItems_" + iLoop;
  objoption = eval(objName);
  if (objoption)
    iCheckBoxs = objoption.value;
    
  objName = "listboxItems_" + iLoop;
  objoption = eval(objName);
  if (objoption)
    iListBoxs = objoption.value;
  if ((0 == iCheckBoxs) && (0 == iListBoxs) )
    continue;
    
  //alert("checkboxItems_" + iLoop + ": " + iCheckBoxs + "\r\nlistboxItems_" + iLoop + ": " + iListBoxs);
  szComment = szComment + "|" + iLoop + ":";
  for(iLoop1=0; iLoop1<iCheckBoxs; iLoop1++)
  {
    szTxt = "";
      
    objName = "checkbox" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    if (!objoption.checked)
      continue;

    fPrice = parseFloat(objoption.value).toFixed(3);
    fAmount += fPrice;
        
    objName = "checkboxTxt" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    szTxt = objoption.value;
    szComment = szComment + szTxt + ",";
    //alert("fPrice: " + fPrice + "\r\nszTxt: " + szTxt);
  }

  for(iLoop1=0; iLoop1<iListBoxs; iLoop1++)
  {
    szTxt = "";
      
    objName = "listbox" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    iIndex = objoption.selectedIndex;
    fPrice = parseFloat(objoption.options[iIndex].value).toFixed(3);
    if (0.1 > fPrice)
      continue;
    fAmount += fPrice;
        
    objName = "checkboxTxt" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    szTxt = objoption.value;
    szComment = szComment + szTxt + "(" + iIndex + "),";
    //alert("fPrice: " + fPrice + "\r\nszTxt: " + szTxt);
  } 
}
/*
if (form_Pay.support[0].checked)
{
  fPrice = 0;
  szComment = szComment + "|S:1";
}
else if (form_Pay.support[1].checked)
{
  fPrice = fAmount * 0.3;
  fAmount += fPrice.toFixed(3);
  szComment = szComment + "|S:2";
}
*/

if (form_Pay.support[0].checked)
{
  fPrice = 0;
  szComment = szComment + "|S:0";
}
else if (form_Pay.support[1].checked)
{
  fPrice = fAmount * 0.15;
  fAmount += fPrice.toFixed(3);
  szComment = szComment + "|S:1";
}
else if (form_Pay.support[2].checked)
{
  fPrice = fAmount * 0.3;
  fAmount += fPrice.toFixed(3);
  szComment = szComment + "|S:2";
}

form_Pay.amountTxt.value = "$" + fAmount;
window.status = "Amount:$" + fAmount + " Options:" + szComment;

fAmount -= discount.value;
form_CC.overridePrice.value = fAmount.toFixed(2);
form_CC.custom1.value = szComment;

form_PP.amount.value = fAmount.toFixed(2);
form_PP.item_number.value = szComment;

return true;
}


function Buy_AdvNew()
{
CalcPrice();
if (form_Pay.paytype[0].checked)
{
  //alert ("CC Amount:" + fAmount + " Comment:" + szComment);
  form_CC.submit(); 
}
else if (form_Pay.paytype[1].checked)
{
  //alert ("PP Amount:" + fAmount + " Comment:" + szComment);	
  form_PP.submit(); 
}
return true;
}
function Buy_AdvNew_Discount()
{
CalcPrice_Discount();
if (form_Pay.paytype[0].checked)
{
  //alert ("CC Amount:" + fAmount + " Comment:" + szComment);
  form_CC.submit(); 
}
else if (form_Pay.paytype[1].checked)
{
  //alert ("PP Amount:" + fAmount + " Comment:" + szComment);	
  form_PP.submit(); 
}
return true;
}

function Buy_Adv()
{
var objName, fPrice, fAmount, iLoop, iMaxCheckBox, iMaxListBox, szComment;

iMaxCheckBox = checkbox_Items.value;
iMaxListBox = listbox_Items.value;
//alert ("Count:" + iMaxCheckBox + " " + iMaxListBox);

fAmount = 0;
szComment = "";

for(iLoop=0; iLoop<iMaxCheckBox; iLoop++)
{
  objName = "checkbox" + iLoop;
  //alert (objName);
  objoption = eval(objName);
  if (objoption && objoption.checked)
  {
  	//alert (objName);
	fPrice = parseFloat(objoption.value);
	if (fPrice > 0.1)
	{
      fAmount = fAmount + fPrice;
      szComment = szComment + "C" + iLoop + ":$" + fPrice.toFixed(0) + "|";
	  //alert ("CheckBox" + iLoop + " SubPrice: $" + fPrice);
	}
  }
}
//alert ('Amount: $' + fAmount);	
for(iLoop=0; iLoop<iMaxListBox; iLoop++)
{
  objName = "listbox" + iLoop;
  objoption = eval(objName);
  if (objoption)
  {
    //alert (objName);
	fPrice = parseFloat(objoption.options[objoption.selectedIndex].value);
	if (fPrice > 0.1)
	{
      fAmount = fAmount + fPrice;
      szComment = szComment + "L" + iLoop + ":" + objoption.selectedIndex + "-$" + fPrice.toFixed(0) + "|";
      //alert ("ListBox" + iLoop + " SubPrice: $" + fPrice);
	}
  }
}
//alert ("Amount:" + fAmount + " Comment:" + szComment);
switch(support.selectedIndex)
{
case 0:
  fPrice = 0;
  break;
case 1:
  fPrice = fAmount * 0.15;
  break;
case 2:
  fPrice = fAmount * 0.3;
  break;
}

fAmount = fAmount * dis.value;
if (fPrice > 0.1)
{
  //fAmount += fPrice;
  fAmount += fPrice;
  szComment = szComment + "S:" + support.selectedIndex + "-$" + fPrice.toFixed(2);
}

//alert ("Amount:" + fAmount + " Comment:" + szComment);
form_CC.overridePrice.value = fAmount.toFixed(2);
form_CC.custom1.value = szComment;
form_PP.amount.value = fAmount.toFixed(2);
//alert ('Amount: $' + fAmount);

if (form_Pay.paytype[0].checked)
	form_CC.submit(); 
if (form_Pay.paytype[1].checked)
	form_PP.submit(); 

return true;
}

function CalcPrice_Upgrade()
{
var objName, fPrice, fAmount, iLoop, iLoop1, iGroups, iCheckBoxs, iListBoxs, iIndex, szTxt, szComment;

fAmount = 0;
szComment = "";

iGroups = groups.value;
//alert ("Group:" + iGroups);

for(iLoop=0; iLoop<iGroups; iLoop++)
{
  iCheckBoxs = 0;
  iListBoxs = 0;

  objName = "checkboxItems_" + iLoop;
  objoption = eval(objName);
  if (objoption)
    iCheckBoxs = objoption.value;
    
  objName = "listboxItems_" + iLoop;
  objoption = eval(objName);
  if (objoption)
    iListBoxs = objoption.value;
  if ((0 == iCheckBoxs) && (0 == iListBoxs) )
    continue;
    
  //alert("checkboxItems_" + iLoop + ": " + iCheckBoxs + "\r\nlistboxItems_" + iLoop + ": " + iListBoxs);
  szComment = szComment + "|" + iLoop + ":";
  for(iLoop1=0; iLoop1<iCheckBoxs; iLoop1++)
  {
    szTxt = "";
      
    objName = "checkbox" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    if (!objoption.checked)
      continue;

    fPrice = parseFloat(objoption.value).toFixed(3);
    fAmount += fPrice;
        
    objName = "checkboxTxt" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    szTxt = objoption.value;
    szComment = szComment + szTxt + ",";
    //alert("fPrice: " + fPrice + "\r\nszTxt: " + szTxt);
  }

  for(iLoop1=0; iLoop1<iListBoxs; iLoop1++)
  {
    szTxt = "";
      
    objName = "listbox" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    iIndex = objoption.selectedIndex;
    fPrice = parseFloat(objoption.options[iIndex].value).toFixed(3);
    if (0.1 > fPrice)
      continue;
    fAmount += fPrice;
        
    objName = "checkboxTxt" + iLoop + "_" + iLoop1;
    objoption = eval(objName);
    if (!objoption)
      break;
      
    szTxt = objoption.value;
    szComment = szComment + szTxt + "(" + iIndex + "),";
    //alert("fPrice: " + fPrice + "\r\nszTxt: " + szTxt);
  } 
}

if (form_Pay.support[0].checked)
{
  fPrice = parseFloat(form_Pay.TxtSupport_0.value).toFixed(3);
  fAmount += fPrice;
  szComment = szComment + "|FreeSupport:"+fPrice;
}
else if (form_Pay.support[1].checked)
{
  fPrice = parseFloat(form_Pay.TxtSupport_1.value).toFixed(3);
  fAmount += fPrice;
  szComment = szComment + "|AnnualSubscription:"+fPrice;
}

form_Pay.amountTxt.value = "$" + fAmount;
window.status = "Amount:$" + fAmount + " Options:" + szComment;

form_CC.overridePrice.value = fAmount.toFixed(2);
form_CC.custom1.value = szComment;

form_PP.amount.value = fAmount.toFixed(2);
form_PP.item_number.value = szComment;

return true;
}