﻿// JScript File
    // 1-1
    //        (
    //            first 1 - license option
    //            second 1 - no of DS[Data Source] (0-none)
    //        )
    var priceList = new Array();
    //workstation 
    //0 DataSource
    priceList["1-0"]= new Array();
    priceList["1-0"]["list_price"] = "$0";
    priceList["1-0"]["pay_price"] = "$0";
    priceList["1-0"]["save"] = "0%";
    //one DataSource 
    priceList["1-1"]= new Array();
    priceList["1-1"]["list_price"] = "$1,300";
    priceList["1-1"]["pay_price"] = "$995";
    priceList["1-1"]["save"] = "23.46%";
    //two DS
    priceList["1-2"]= new Array();
    priceList["1-2"]["list_price"] = "$2,600";
    priceList["1-2"]["pay_price"] = "$1,990";
    priceList["1-2"]["save"] = "23.46%";
    //three DS
    priceList["1-3"]= new Array();
    priceList["1-3"]["list_price"] = "$3,900";
    priceList["1-3"]["pay_price"] = "$2,985";
    priceList["1-3"]["save"] = "23.46%";
    //four DS
    priceList["1-4"]= new Array();
    priceList["1-4"]["list_price"] = "$5,200";
    priceList["1-4"]["pay_price"] =  "$3,980";
    priceList["1-4"]["save"] = "23.46%";
   //five DS
    priceList["1-5"]= new Array();
    priceList["1-5"]["list_price"] = "$6,500";
    priceList["1-5"]["pay_price"] =  "$4,975";
    priceList["1-5"]["save"] = "23.46%";
    //six DS
    priceList["1-6"]= new Array();
    priceList["1-6"]["list_price"] = "$7,800";
    priceList["1-6"]["pay_price"] =  "$5,970";
    priceList["1-6"]["save"] = "23.46%";

//    //bundle
//    priceList["1-6"]= new Array();
//    priceList["1-6"]["list_price"] = "$3,600";
//    priceList["1-6"]["pay_price"] =  "$2,495";
//    priceList["1-6"]["save"] = "30.69%";

 
    //server license 
     //0 DataSource
    priceList["2-0"]= new Array();
    priceList["2-0"]["list_price"] = "$0";
    priceList["2-0"]["pay_price"] = "$0";
    priceList["2-0"]["save"] = "0%";
       //one DataSource 
    priceList["2-1"]= new Array();
    priceList["2-1"]["list_price"] = "$5,000";
    priceList["2-1"]["pay_price"] = "$4,500";
    priceList["2-1"]["save"] = "10.00%";
    //two DS
    priceList["2-2"]= new Array();
    priceList["2-2"]["list_price"] = "$10,000";
    priceList["2-2"]["pay_price"] = "$9,000";
    priceList["2-2"]["save"] = "10.00%";
    //three DS
    priceList["2-3"]= new Array();
    priceList["2-3"]["list_price"] = "$15,000";
    priceList["2-3"]["pay_price"] = "$13,500";
    priceList["2-3"]["save"] = "10.00%";
    //four DS
    priceList["2-4"]= new Array();
    priceList["2-4"]["list_price"] = "$20,000";
    priceList["2-4"]["pay_price"] =  "$18,000";
    priceList["2-4"]["save"] = "10.00%";
    //five DS
    priceList["2-5"]= new Array();
    priceList["2-5"]["list_price"] = "$25,000";
    priceList["2-5"]["pay_price"] =  "$22,500";
    priceList["2-5"]["save"] = "10.00%";
        //Packages
    priceList["2-6"]= new Array();
    priceList["2-6"]["list_price"] = "$12,000";
    priceList["2-6"]["pay_price"] =  "$8,995";
    priceList["2-6"]["save"] = "25.04%";
    
    function SelectDS(thisObj) {
        var license = 1; //default as workstation
        var selected_db_no = 1; //default as 1 db
        var prefix = thisObj.id.substr(0,2);
        
        if (prefix == "sl")
            license = 2;
         var checkedDSCollection =  getCheckedDBCollection(["ws_edifact", "ws_x12", "ws_iata", "ws_eancom", "ws_flat", "ws_hl7"]);
         
         if (license == 2)
            checkedDSCollection =  getCheckedDBCollection(["sl_edifact", "sl_x12", "sl_iata", "sl_eancom", "sl_flat"]);
           if (license == 1) {
                document.getElementById("ws_ds_checked_length").value = checkedDSCollection.length;           
                document.getElementById("ws_ds_checked_list").value = retrieveCollectionList(checkedDSCollection); 
           
            }
          else {
                document.getElementById("sl_ds_checked_length").value = checkedDSCollection.length;
                document.getElementById("sl_ds_checked_list").value = retrieveCollectionList(checkedDSCollection); 
            }
            

         if (checkedDSCollection.length > 0) {
            document.getElementById(prefix + "_warning").innerHTML = "";
            }
         var package_key; 
         if (checkedDSCollection.length >= 3) {
            package_key = eval(license) + "-" + "6";
           // document.getElementById(prefix + "_warning").innerHTML = "You can purchase Bundle/Package for only " + priceList[package_key]["pay_price"];
         }
        // else
           // document.getElementById(prefix + "_warning").innerHTML = "";
          
          
          
         resetPrice(prefix, license, checkedDSCollection.length);
    
    }
         
      
      function retrieveCollectionList(checkedDSCollection) {
        var thisList = "";
        for (var thisObj in checkedDSCollection)
            thisList = thisList + "," + document.getElementById(checkedDSCollection[thisObj]).value;
        return(thisList.substr(1, thisList.length-1));
      }
      
      
      function getCheckedDBCollection(collectionList) {
           var dsCheckedCollection = new Array();
           for (var thisIndex in collectionList) 
               if (document.getElementById(collectionList[thisIndex]).checked)
                   dsCheckedCollection.push(collectionList[thisIndex]);
            return(dsCheckedCollection);
      }
      
      function resetPrice(prefix, license, dsCheckedNo) {
        var key = license + "-" + dsCheckedNo;
        document.getElementById(prefix + "_list_price").innerHTML = priceList[key]["list_price"];
        document.getElementById(prefix + "_save").innerHTML = priceList[key]["save"];
        document.getElementById(prefix + "_pay_price").innerHTML = priceList[key]["pay_price"];
        
      }
      
      function SelectCPU(thisObj) {
      
        if (thisObj.value == 2) 
            alert("For orders of more than 3 CPU licenses, please contact our Enterprise Sales Team at (800) 477-6473 (Ext. 4488) or (781) 280-4488.");
            thisObj.selectedIndex = 0;
      }
      
      
        // Retrieve the value of the cookie with the specified name.
        function GetCookie(sName)
        {
          // cookies are separated by semicolons
          var aCookie = document.cookie.split("; ");
          for (var i=0; i < aCookie.length; i++)
          {
            // a name/value pair (a crumb) is separated by an equal sign
            var aCrumb = aCookie[i].split("=");
            if (sName == aCrumb[0]) 
              return unescape(aCrumb[1]);
          }

          // a cookie with the requested name does not exist
          return null;
        }
        
        function validate() {
            var eventSourceID = document.getElementById("eventSourceID").value;
            if (eventSourceID == "") return(false);
            
            var prefix = eventSourceID.substr(0,2);
            var license = 1; //default as workstation
     
        
            if (prefix == "sl")
                license = 2;
            var checkedDSCollection =  getCheckedDBCollection(["ws_edifact", "ws_x12", "ws_iata", "ws_eancom", "ws_flat", "ws_hl7"]);
         
            if (license == 2)
                checkedDSCollection =  getCheckedDBCollection(["sl_edifact", "sl_x12", "sl_iata", "sl_eancom", "sl_flat"]);
          
            if (checkedDSCollection.length >= 1) 
                return(true);
            else 
            {
                document.getElementById(prefix + "_warning").innerHTML = "Choose one or more XML Converters to add to your cart.";
                return(false);
            }
           
        }
        
        function setEventID(thisObj) {
            document.getElementById("eventSourceID").value = thisObj.name;
        }