var sonarValue = 0;
var dlpValue = 0;
var lpcValue = 0;
var moValue = 0;
var moaValue = 0;
var geoValue = 0;
var wfoValue = 0;
var hostValue = 0;
var factor = 1;
var timer = 1;

var sonarListPrice = 0;
var sonarPrice = 0;
var dlpListPrice = 0;
var dlpPrice = 0;
var lcoListPrice = 0;
var lcoPrice = 0;
var moListPrice = 0;
var moPrice = 0;
var moaListPrice = 0;
var moaPrice = 0;
var geoListPrice = 0;
var geoPrice = 0;
var wfoListPrice = 0;
var wfoPrice = 0;

var sonarHostPrice = 0;
var dlpHostPrice = 0;
var lcoHostPrice = 0;
var moHostPrice = 0;
var moaHostPrice = 0;
var geoHostPrice = 0;
var wfoHostPrice = 0;

var sonarSelfListPrice = 0;
var sonarSelfPrice = 0;
var dlpListSelfPrice = 0;
var dlpSelfPrice = 0;

var lcoListSelfPrice = 0;
var lcoSelfPrice = 0;
var moListSelfPrice = 0;
var moSelfPrice = 0;
var moaListSelfPrice = 0;
var moaSelfPrice = 0;
var geoListSelfPrice = 0;
var geoSelfPrice = 0;
var wfoListSelfPrice = 0;
var wfoSelfPrice = 0;

var serverSetupPrice = 0;

var sonarUnit = 0;
var dlpUnit = 0;
var lcoUnit = 0;
var moUnit = 0;
var moaUnit = 0;
var geoUnit = 0;
var wfoUnit = 0;

// Start quantity discount price
var quantity4DiscountSonar = 0;
var quantity100DiscountSonar = 0;
var quantity4Discountdlp = 0;
var quantity100Discountdlp = 0;

var quantity4Discountlco = 0;
var quantity100Discountlco = 0;

var quantity4Discountmo = 0;
var quantity100Discountmo = 0;

var quantity4Discountmoa = 0;
var quantity100Discountmoa = 0;


var quantity4Discountgeo = 0;
var quantity100Discountgeo = 0;

var quantity4Discountwfo = 0;
var quantity100Discountwfo = 0;

var quantitySelf4DiscountSonar = 0;
var quantitySelf100DiscountSonar = 0;
var quantitySelf4Discountdlp = 0;
var quantitySelf100Discountdlp = 0;

var quantitySelf4Discountlco = 0;
var quantitySelf100Discountlco = 0;

var quantitySelf4Discountmo = 0;
var quantitySelf100Discountmo = 0;

var quantitySelf4Discountmoa = 0;
var quantitySelf100Discountmoa = 0;

var quantitySelf4Discountgeo = 0;
var quantitySelf100Discountgeo = 0;

var quantitySelf4Discountwfo = 0;
var quantitySelf100Discountwfo = 0;
// End quantity discount price

// Start terms
var term1 = 0;
var term2 = 0;
var term3 = 0;
var term4 = 0;
// End terms


// Start Support Fee
var support = 0;
var supportValue = 0;
// End Support Fee

// Start Discount Flag
var discountApplied = "";
// End Discount Flag

// Start Original Price
var sonarOriginalPrice = 0;
var dlpOriginalPrice = 0;
var lcoOriginalPrice = 0;
var moOriginalPrice = 0;
var moaOriginalPrice = 0;
var geoOriginalPrice = 0;
var wfoOriginalPrice = 0;
// End Original Price

// Start Quantity range to use discount code
var quantityRangeLow = 0;
var quantityRangeHigh = 0;
// End Quantity range to use discount code

$(InitIgcart);

function InitIgcart(){      
    
    sonarListPrice = parseFloat(document.getElementById("Hidden5").value).toFixed(2);   
    sonarPrice = parseFloat(document.getElementById("Hidden6").value).toFixed(2);   
    dlpListPrice = parseFloat(document.getElementById("Hidden7").value).toFixed(2);   
    dlpPrice = parseFloat(document.getElementById("Hidden8").value).toFixed(2);   
    lcoListPrice = parseFloat(document.getElementById("Hidden9").value).toFixed(2);
    lcoPrice = parseFloat(document.getElementById("Hidden10").value).toFixed(2);
    //moListPrice = parseFloat(document.getElementById("Hidden61").value).toFixed(2);
    moPrice = parseFloat(document.getElementById("Hidden62").value).toFixed(2);
    //moaListPrice = parseFloat(document.getElementById("Hidden81").value).toFixed(2);
    moaPrice = parseFloat(document.getElementById("Hidden82").value).toFixed(2);
    geoListPrice = parseFloat(document.getElementById("Hidden71").value).toFixed(2);
    geoPrice = parseFloat(document.getElementById("Hidden72").value).toFixed(2);   
    wfoListPrice = parseFloat(document.getElementById("Hidden11").value).toFixed(2);   
    wfoPrice = parseFloat(document.getElementById("Hidden12").value).toFixed(2); 
    
    sonarHostPrice = parseFloat(document.getElementById("Hidden1").value).toFixed(2);   
    dlpHostPrice = parseFloat(document.getElementById("Hidden2").value).toFixed(2);
    lcoHostPrice = parseFloat(document.getElementById("Hidden3").value).toFixed(2);
    moHostPrice = parseFloat(document.getElementById("Hidden63").value).toFixed(2);
    moaHostPrice = parseFloat(document.getElementById("Hidden83").value).toFixed(2);
    geoHostPrice = parseFloat(document.getElementById("Hidden75").value).toFixed(2);   
    wfoHostPrice = parseFloat(document.getElementById("Hidden4").value).toFixed(2);
        
    sonarSelfListPrice = parseFloat(document.getElementById("Hidden13").value).toFixed(2); 
    sonarSelfPrice = parseFloat(document.getElementById("Hidden14").value).toFixed(2);   
    dlpListSelfPrice = parseFloat(document.getElementById("Hidden15").value).toFixed(2);   
    dlpSelfPrice = parseFloat(document.getElementById("Hidden16").value).toFixed(2);   
    lcoListSelfPrice = parseFloat(document.getElementById("Hidden17").value).toFixed(2);
    lcoSelfPrice = parseFloat(document.getElementById("Hidden18").value).toFixed(2);
    moListSelfPrice = parseFloat(document.getElementById("Hidden64").value).toFixed(2);
    moSelfPrice = parseFloat(document.getElementById("Hidden65").value).toFixed(2);
    moaListSelfPrice = parseFloat(document.getElementById("Hidden84").value).toFixed(2);
    moaSelfPrice = parseFloat(document.getElementById("Hidden85").value).toFixed(2);
    geoListSelfPrice = parseFloat(document.getElementById("Hidden73").value).toFixed(2);
    geoSelfPrice = parseFloat(document.getElementById("Hidden74").value).toFixed(2);   
    wfoListSelfPrice = parseFloat(document.getElementById("Hidden19").value).toFixed(2);   
    wfoSelfPrice = parseFloat(document.getElementById("Hidden20").value).toFixed(2);      
    
    term1 = (parseFloat(100-document.getElementById("Hidden41").value)/100).toFixed(2);
    term2 = (parseFloat(100-document.getElementById("Hidden42").value)/100).toFixed(2);
    term3 = (parseFloat(100-document.getElementById("Hidden43").value)/100).toFixed(2);
    term4 = (parseFloat(100-document.getElementById("Hidden44").value)/100).toFixed(2);
    support = (parseFloat(document.getElementById("Hidden45").value)).toFixed(2);
    
    document.getElementById("term1").innerHTML = "<input type='radio' name='license_term' value='1' class='radio_align' checked onclick='CalculateSubtotal(this.value);'/>&nbsp;1 year";
    document.getElementById("term2").innerHTML = "<input type='radio' name='license_term' value='2' class='radio_align' onclick='CalculateSubtotal(this.value);'/>&nbsp;2 years - " + document.getElementById("Hidden42").value + "% Discount";
    document.getElementById("term3").innerHTML = "<input type='radio' name='license_term' value='3' class='radio_align' onclick='CalculateSubtotal(this.value);'/>&nbsp;3 years - " + document.getElementById("Hidden43").value + "% Discount";
    document.getElementById("term4").innerHTML = "<input type='radio' name='license_term' value='5' class='radio_align' onclick='CalculateSubtotal(this.value);'/>&nbsp;5 years - " + document.getElementById("Hidden44").value + "% Discount";
    document.getElementById("supportfee").innerHTML = document.getElementById("Hidden46").value + ":";
    
    serverSetupPrice = parseFloat(document.getElementById("Hidden21").value).toFixed(2);     
    
    discountApplied = document.getElementById("Hidden22").value;  
    sonarOriginalPrice = parseFloat(document.getElementById("Hidden47").value).toFixed(2);  
    dlpOriginalPrice = parseFloat(document.getElementById("Hidden48").value).toFixed(2);
    lcoOriginalPrice = parseFloat(document.getElementById("Hidden49").value).toFixed(2);
    moOriginalPrice = parseFloat(document.getElementById("Hidden66").value).toFixed(2);
    moaOriginalPrice = parseFloat(document.getElementById("Hidden86").value).toFixed(2);
    geoOriginalPrice = parseFloat(document.getElementById("Hidden78").value).toFixed(2);  
    wfoOriginalPrice = parseFloat(document.getElementById("Hidden50").value).toFixed(2);  
    
    quantityRangeLow = document.getElementById("quantityRangeLow").value;  
    quantityRangeHigh = document.getElementById("quantityRangeHigh").value;  
    
    updateListPrice();                  
    getQuantityDiscountPrice();             
    CalculateSonar();
    CalculateDLP();
    CalculateLPC();
    CalculateMobile();
    CalculateMobileAndroid();
    CalculateGeolocate();
    CalculateWFO();                       
}

function getQuantityDiscountPrice(){
     quantity4DiscountSonar = parseFloat(document.getElementById("Hidden37").value).toFixed(2);
     quantity100DiscountSonar = parseFloat(document.getElementById("Hidden38").value).toFixed(2);
     quantity4Discountdlp = parseFloat(document.getElementById("Hidden31").value).toFixed(2);
     quantity100Discountdlp = parseFloat(document.getElementById("Hidden32").value).toFixed(2);

     quantity4Discountlco = parseFloat(document.getElementById("Hidden39").value).toFixed(2);
     quantity100Discountlco = parseFloat(document.getElementById("Hidden40").value).toFixed(2);

     quantity4Discountmo = parseFloat(document.getElementById("Hidden67").value).toFixed(2);
     quantity100Discountmo = parseFloat(document.getElementById("Hidden68").value).toFixed(2);

     quantity4Discountmoa = parseFloat(document.getElementById("Hidden87").value).toFixed(2);
     quantity100Discountmoa = parseFloat(document.getElementById("Hidden88").value).toFixed(2);

     quantity4Discountgeo = parseFloat(document.getElementById("Hidden76").value).toFixed(2);
     quantity100Discountgeo = parseFloat(document.getElementById("Hidden77").value).toFixed(2);

     quantity4Discountwfo = parseFloat(document.getElementById("Hidden25").value).toFixed(2);
     quantity100Discountwfo = parseFloat(document.getElementById("Hidden26").value).toFixed(2);

     quantitySelf4DiscountSonar = parseFloat(document.getElementById("Hidden35").value).toFixed(2);
     quantitySelf100DiscountSonar = parseFloat(document.getElementById("Hidden36").value).toFixed(2);
     quantitySelf4Discountdlp = parseFloat(document.getElementById("Hidden33").value).toFixed(2);
     quantitySelf100Discountdlp = parseFloat(document.getElementById("Hidden34").value).toFixed(2);

     quantitySelf4Discountlco = parseFloat(document.getElementById("Hidden29").value).toFixed(2);
     quantitySelf100Discountlco = parseFloat(document.getElementById("Hidden30").value).toFixed(2);

     quantitySelf4Discountmo = parseFloat(document.getElementById("Hidden69").value).toFixed(2);
     quantitySelf100Discountmo = parseFloat(document.getElementById("Hidden70").value).toFixed(2);

     quantitySelf4Discountmoa = parseFloat(document.getElementById("Hidden89").value).toFixed(2);
     quantitySelf100Discountmoa = parseFloat(document.getElementById("Hidden90").value).toFixed(2);

     quantitySelf4Discountgeo = parseFloat(document.getElementById("Hidden79").value).toFixed(2);
     quantitySelf100Discountgeo = parseFloat(document.getElementById("Hidden80").value).toFixed(2);

     quantitySelf4Discountwfo = parseFloat(document.getElementById("Hidden27").value).toFixed(2);
     quantitySelf100Discountwfo = parseFloat(document.getElementById("Hidden28").value).toFixed(2);
}

function updateListPrice(){
    if(document.getElementById("atiHostTrue").checked){
        
        sonarUnit = sonarPrice;
        dlpUnit = dlpPrice;
        lcoUnit = lcoPrice;
        moUnit = moPrice;
        moaUnit = moaPrice;
        geoUnit = geoPrice;
        wfoUnit = wfoPrice;
    }   
    else{
        sonarUnit = sonarSelfPrice;
        dlpUnit = dlpSelfPrice;
        lcoUnit = lcoSelfPrice;
        moUnit = moSelfPrice;
        moaUnit = moSelfPrice;
        geoUnit = geoSelfPrice;
        wfoUnit = wfoSelfPrice;
    }
    
    document.getElementById("mcBlistPrice").innerHTML = "Enter Qty";
    document.getElementById("mcBPrice").innerHTML = "Enter Qty";
    document.getElementById("dlpBListPrice").innerHTML = "Enter Qty";
    document.getElementById("dlpBPrice").innerHTML = "Enter Qty";
    document.getElementById("lcoListPrice").innerHTML = "Enter Qty";
    document.getElementById("lcoPrice").innerHTML = "Enter Qty";
    //document.getElementById("moListPrice").innerHTML = "Enter Qty";
    document.getElementById("moPrice").innerHTML = "Enter Qty";
    //document.getElementById("moaListPrice").innerHTML = "Enter Qty";
    document.getElementById("moaPrice").innerHTML = "Enter Qty";
    document.getElementById("geoListPrice").innerHTML = "Enter Qty";
    document.getElementById("geoPrice").innerHTML = "Enter Qty";
    document.getElementById("wfoListPrice").innerHTML = "Enter Qty";
    document.getElementById("wfoPrice").innerHTML = "Enter Qty";
    
}

function updateUnitPrice(){
    if(discountApplied == "Applied"){
    
        if(parseFloat(document.getElementById("sonarQty").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("sonarQty").value) >= parseFloat(quantityRangeLow)){ 
            sonarPrice = parseFloat(document.getElementById("Hidden6").value).toFixed(2); 
            sonarSelfPrice = parseFloat(document.getElementById("Hidden14").value).toFixed(2);  
        }
        else{
            sonarPrice = sonarOriginalPrice; 
            sonarSelfPrice = sonarOriginalPrice;
        }
        
        if(parseFloat(document.getElementById("dlpB").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("dlpB").value) >= parseFloat(quantityRangeLow)){ 
            dlpPrice = parseFloat(document.getElementById("Hidden8").value).toFixed(2);  
            dlpSelfPrice = parseFloat(document.getElementById("Hidden16").value).toFixed(2); 
        }
        else{
            dlpPrice = dlpOriginalPrice; 
            dlpSelfPrice = dlpOriginalPrice;
        }
        
        if(parseFloat(document.getElementById("lco").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("lco").value) >= parseFloat(quantityRangeLow)){ 
            lcoPrice = parseFloat(document.getElementById("Hidden10").value).toFixed(2); 
            lcoSelfPrice = parseFloat(document.getElementById("Hidden18").value).toFixed(2);  
        }
        else{
            lcoPrice = lcoOriginalPrice; 
            lcoSelfPrice = lcoOriginalPrice;
        }

        if (parseFloat(document.getElementById("mo").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("mo").value) >= parseFloat(quantityRangeLow)) {
            moPrice = parseFloat(document.getElementById("Hidden62").value).toFixed(2);
            moSelfPrice = parseFloat(document.getElementById("Hidden65").value).toFixed(2);
        }
        else {
            moPrice = moOriginalPrice;
            moSelfPrice = moOriginalPrice;
        }

        if (parseFloat(document.getElementById("moa").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("moa").value) >= parseFloat(quantityRangeLow)) {
            moaPrice = parseFloat(document.getElementById("Hidden82").value).toFixed(2);
            moaSelfPrice = parseFloat(document.getElementById("Hidden85").value).toFixed(2);
        }
        else {
            moaPrice = moaOriginalPrice;
            moaSelfPrice = moaOriginalPrice;
        }

        if (parseFloat(document.getElementById("geo").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("geo").value) >= parseFloat(quantityRangeLow)) {
            geoPrice = parseFloat(document.getElementById("Hidden72").value).toFixed(2);
            geoSelfPrice = parseFloat(document.getElementById("Hidden74").value).toFixed(2);
        }
        else {
            geoPrice = geoOriginalPrice;
            geoSelfPrice = geoOriginalPrice;
        }

        if(parseFloat(document.getElementById("wfo").value) <= parseFloat(quantityRangeHigh)
            && parseFloat(document.getElementById("wfo").value) >= parseFloat(quantityRangeLow)){ 
            wfoPrice = parseFloat(document.getElementById("Hidden12").value).toFixed(2); 
            wfoSelfPrice = parseFloat(document.getElementById("Hidden20").value).toFixed(2);  
        }
        else{
            wfoPrice = wfoOriginalPrice; 
            wfoSelfPrice = wfoOriginalPrice;
        }
    }

    if(document.getElementById("atiHostTrue").checked){  
        if(document.getElementById("sonarQty").value <10){
            sonarUnit = sonarPrice;
        }
        else if(document.getElementById("sonarQty").value >= 10 && document.getElementById("sonarQty").value <25){
            sonarUnit = sonarPrice - quantity4DiscountSonar;
        }
        else{
            sonarUnit = sonarPrice - quantity100DiscountSonar;
        }
        
        if(document.getElementById("dlpB").value < 10){
            dlpUnit = dlpPrice;
        }
        else if(document.getElementById("dlpB").value >= 10 && document.getElementById("dlpB").value <25){
            dlpUnit = dlpPrice - quantity4Discountdlp;
        }
        else{
            dlpUnit = dlpPrice - quantity100Discountdlp;
        }
        if(document.getElementById("lco").value < 10){
          
            lcoUnit = lcoPrice;
        }
        else if(document.getElementById("lco").value >= 10 && document.getElementById("lco").value <25){

            lcoUnit = lcoPrice - quantity4Discountlco;
        }
        else{

            lcoUnit = lcoPrice - quantity100Discountlco;
        }
        if (document.getElementById("mo").value < 10) {

            moUnit = moPrice;
        }
        else if (document.getElementById("mo").value >= 10 && document.getElementById("mo").value < 25) {

            moUnit = moPrice - quantity4Discountmo;
        }
        else {

            moUnit = moPrice - quantity100Discountmo;
        }

        if (document.getElementById("moa").value < 10) {

            moaUnit = moaPrice;
        }
        else if (document.getElementById("moa").value >= 10 && document.getElementById("moa").value < 25) {

            moaUnit = moaPrice - quantity4Discountmoa;
        }
        else {

            moaUnit = moaPrice - quantity100Discountmoa;
        }

        if (document.getElementById("geo").value < 10) {

            geoUnit = geoPrice;
        }
        else if (document.getElementById("geo").value >= 10 && document.getElementById("geo").value < 25) {

            geoUnit = geoPrice - quantity4Discountgeo;
        }
        else {

            geoUnit = geoPrice - quantity100Discountgeo;
        }

        if(document.getElementById("wfo").value < 10){
            wfoUnit = wfoPrice;
        }
        else if(document.getElementById("wfo").value >= 10 && document.getElementById("wfo").value <25){
            wfoUnit = wfoPrice - quantity4Discountwfo;
        }
        else{
            wfoUnit = wfoPrice - quantity100Discountwfo;
        }
    }   
    else{
        if(document.getElementById("sonarQty").value <10){
            sonarUnit = sonarSelfPrice;
        }
        else if(document.getElementById("sonarQty").value >= 10 && document.getElementById("sonarQty").value <25){
            sonarUnit = sonarSelfPrice - quantitySelf4DiscountSonar;
        }
        else{
            sonarUnit = sonarSelfPrice - quantitySelf100DiscountSonar;
        }
        if(document.getElementById("dlpB").value < 10){
            dlpUnit = dlpSelfPrice;
        }
        else if(document.getElementById("dlpB").value >= 10 && document.getElementById("dlpB").value <25){
            dlpUnit = dlpSelfPrice - quantitySelf4Discountdlp;
        }
        else{
            dlpUnit = dlpSelfPrice - quantitySelf100Discountdlp;
        }
        if(document.getElementById("lco").value < 10){
            lcoUnit = lcoSelfPrice;
        }
        else if(document.getElementById("lco").value >= 10 && document.getElementById("lco").value <25){
            lcoUnit = lcoSelfPrice - quantitySelf4Discountlco;
        }
        else{
            lcoUnit = lcoSelfPrice - quantitySelf100Discountlco;
        }
        if (document.getElementById("mo").value < 10) {
            moUnit = moSelfPrice;
        }
        else if (document.getElementById("mo").value >= 10 && document.getElementById("mo").value < 25) {
            moUnit = moSelfPrice - quantitySelf4Discountmo;
        }
        else {
            moUnit = moSelfPrice - quantitySelf100Discountmo;
        }
        if (document.getElementById("moa").value < 10) {
            moaUnit = moaSelfPrice;
        }
        else if (document.getElementById("moa").value >= 10 && document.getElementById("moa").value < 25) {
            moaUnit = moaSelfPrice - quantitySelf4Discountmoa;
        }
        else {
            moaUnit = moaSelfPrice - quantitySelf100Discountmoa;
        }
        if (document.getElementById("geo").value < 10) {
            geoUnit = geoSelfPrice;
        }
        else if (document.getElementById("geo").value >= 10 && document.getElementById("geo").value < 25) {
            geoUnit = geoSelfPrice - quantitySelf4Discountgeo;
        }
        else {
            geoUnit = geoSelfPrice - quantitySelf100Discountgeo;
        }
        if(document.getElementById("wfo").value < 10){
            wfoUnit = wfoSelfPrice;
        }
        else if(document.getElementById("wfo").value >= 10 && document.getElementById("wfo").value <25){
            wfoUnit = wfoSelfPrice - quantitySelf4Discountwfo;
        }
        else{
            wfoUnit = wfoSelfPrice - quantitySelf100Discountwfo;
        }
    }
    sonarUnit = parseFloat(sonarUnit).toFixed(2);
    dlpUnit = parseFloat(dlpUnit).toFixed(2);
    lcoUnit = parseFloat(lcoUnit).toFixed(2);
    moUnit = parseFloat(moUnit).toFixed(2);
    moaUnit = parseFloat(moaUnit).toFixed(2);
    geoUnit = parseFloat(geoUnit).toFixed(2);
    wfoUnit = parseFloat(wfoUnit).toFixed(2);
}

function updatesupportValue(){
    supportValue = ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor * support);
}

function CalculateSonar(){
    if(document.getElementById("sonarQty").value <= 0 || isNaN(document.getElementById("sonarQty").value)){
        document.getElementById("sonarQty").value = "0";
        document.getElementById("mcBPrice").innerHTML = "Enter Qty";
    }
    else{
        updateUnitPrice();
   //     alert(sonarUnit);
        document.getElementById("mcBPrice").innerHTML = "$"+ sonarUnit;
    }
    sonarValue = document.getElementById("sonarQty").value * sonarUnit;
    UpdateHost();
 //   AJAXRequest('mcB');
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
    }  
    document.getElementById("calcSonar").innerHTML = "$" + (sonarValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateDLP(){

    if(document.getElementById("dlpB").value <= 0 || isNaN(document.getElementById("dlpB").value) ){
        document.getElementById("dlpB").value = "0";
        document.getElementById("dlpBPrice").innerHTML = "Enter Qty";
    }
    else{
        updateUnitPrice();
        document.getElementById("dlpBPrice").innerHTML = "$"+ dlpUnit;
    }
    dlpValue = document.getElementById("dlpB").value * dlpUnit;
    
    UpdateHost();
 //   AJAXRequest('dlpB');
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
    }  
    document.getElementById("calcDLP").innerHTML = "$" + (dlpValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateLPC(){
    if(document.getElementById("lco").value <= 0 || isNaN(document.getElementById("lco").value) ){
        document.getElementById("lco").value = "0";
        document.getElementById("lcoPrice").innerHTML = "Enter Qty";
    }
    else{
        updateUnitPrice();
        document.getElementById("lcoPrice").innerHTML = "$"+ lcoUnit;
    }
    lpcValue = document.getElementById("lco").value * lcoUnit;
 
    UpdateHost();
 //   AJAXRequest('lco');
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
    }  
    document.getElementById("calcLPC").innerHTML = "$" + (lpcValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateMobile() {
    if (document.getElementById("mo").value <= 0 || isNaN(document.getElementById("mo").value)) {
        document.getElementById("mo").value = "0";
        document.getElementById("moPrice").innerHTML = "Enter Qty";
    }
    else {
        updateUnitPrice();
        document.getElementById("moPrice").innerHTML = "$" + moUnit;
    }
    moValue = document.getElementById("mo").value * moUnit;

    UpdateHost();
    //   AJAXRequest('mo');
    if (!document.getElementById("atiHostTrue").checked) {
        hostValue = parseFloat(serverSetupPrice);
    }
    document.getElementById("calcMO").innerHTML = "$" + (moValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateMobileAndroid() {
    if (document.getElementById("moa").value <= 0 || isNaN(document.getElementById("moa").value)) {
        document.getElementById("moa").value = "0";
        document.getElementById("moaPrice").innerHTML = "Enter Qty";
    }
    else {
        updateUnitPrice();
        document.getElementById("moaPrice").innerHTML = "$" + moaUnit;
    }
    moaValue = document.getElementById("moa").value * moaUnit;

    UpdateHost();
    //   AJAXRequest('moa');
    if (!document.getElementById("atiHostTrue").checked) {
        hostValue = parseFloat(serverSetupPrice);
    }
    document.getElementById("calcMOA").innerHTML = "$" + (moaValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateGeolocate() {
    if (document.getElementById("geo").value <= 0 || isNaN(document.getElementById("geo").value)) {
        document.getElementById("geo").value = "0";
        document.getElementById("geoPrice").innerHTML = "Enter Qty";
    }
    else {
        updateUnitPrice();
        document.getElementById("geoPrice").innerHTML = "$" + geoUnit;
    }
    geoValue = document.getElementById("geo").value * geoUnit;

    UpdateHost();
    //   AJAXRequest('geo');
    if (!document.getElementById("atiHostTrue").checked) {
        hostValue = parseFloat(serverSetupPrice);
    }
    document.getElementById("calcGEO").innerHTML = "$" + (geoValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateWFO(){
    if(document.getElementById("wfo").value <= 0 || isNaN(document.getElementById("wfo").value) ){
        document.getElementById("wfo").value = "0";
        document.getElementById("wfoPrice").innerHTML = "Enter Qty";
    }
    else{
        updateUnitPrice();
        document.getElementById("wfoPrice").innerHTML = "$"+ wfoUnit;
    }
    wfoValue = document.getElementById("wfo").value * wfoUnit;
    
    UpdateHost();
 //   AJAXRequest('wfo');
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
    }  
    document.getElementById("calcWFO").innerHTML = "$" + (wfoValue).toFixed(2);
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();    
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function CalculateSubtotal(total){
    timer = total;
    switch(timer){
        case "1":
            factor = term1;
            break;
        case "2":
            factor = term2;
            break;
        case "3":
            factor = term3;
            break;
        case "5":
            factor = term4;
            break;
    };
    
    UpdateHost();
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
     }
    document.getElementById("totalValue").innerHTML = "$" + ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}


function CalculateHost(value){

    updateListPrice();
    CalculateSonar();
    CalculateDLP();
    CalculateLPC();
    CalculateWFO();
    
    UpdateHost();
    if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
    }  
    
    document.getElementById("selectedDiv").innerHTML = "$" + (hostValue).toFixed(2);
    updatesupportValue();
    document.getElementById("supportValue").innerHTML = "$" + (supportValue).toFixed(2);
    document.getElementById("wholeTotal").innerHTML = "$" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue + supportValue)).toFixed(2);
}

function UpdateHost(){

    var subtotal = ((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor).toFixed(2);
   // updateHostingValue();
    var tmpHost = ((parseFloat(document.getElementById("Hidden1").value)*document.getElementById("sonarQty").value
                 + parseFloat(document.getElementById("Hidden2").value)*document.getElementById("dlpB").value
                    + parseFloat(document.getElementById("Hidden3").value) * document.getElementById("lco").value
                        + parseFloat(document.getElementById("Hidden63").value) * document.getElementById("mo").value
                            + parseFloat(document.getElementById("Hidden83").value) * document.getElementById("moa").value
                                //+ parseFloat(document.getElementById("Hidden75").value) * document.getElementById("geo").value
                                    + parseFloat(document.getElementById("Hidden4").value)*document.getElementById("wfo").value)* timer).toFixed(2);
    if( subtotal >= 5000 )
    {
        document.getElementById("radioButtonTrue").disabled = false;
        document.getElementById("selfhostingText").style.color = "Black";
        document.getElementById("comparePriceATI").innerHTML = "$" + tmpHost;
        document.getElementById("comparePriceSelf").innerHTML = "$" + parseFloat(serverSetupPrice).toFixed(2);
    }
    else
    {
        document.getElementById("radioButtonTrue").disabled = true;
        document.getElementById("atiHostTrue").checked = true;
        document.getElementById("selfhostingText").style.color = "Gray";
        document.getElementById("atihostingText").style.color = "Black";
        document.getElementById("comparePriceATI").innerHTML = "";
        document.getElementById("comparePriceSelf").innerHTML = "";
    }
    

    updateHostingValue();
}

function updateHostingValue(){
    
     hostValue = (parseFloat(document.getElementById("Hidden1").value)*document.getElementById("sonarQty").value
                 + parseFloat(document.getElementById("Hidden2").value)*document.getElementById("dlpB").value
                    + parseFloat(document.getElementById("Hidden3").value) * document.getElementById("lco").value
                        + parseFloat(document.getElementById("Hidden63").value) * document.getElementById("mo").value
                            + parseFloat(document.getElementById("Hidden83").value) * document.getElementById("moa").value
                              //  + parseFloat(document.getElementById("Hidden75").value) * document.getElementById("geo").value
                                    + parseFloat(document.getElementById("Hidden4").value)*document.getElementById("wfo").value)* timer;
     
     if(!document.getElementById("atiHostTrue").checked){
        hostValue = parseFloat(serverSetupPrice);
     }     
     document.getElementById("selectedDiv").innerHTML = "$"+(hostValue).toFixed(2);
}

function setAction()
{
    var percentageDiscount = ((100-parseFloat(document.getElementById("Hidden24").value))/100.0).toFixed(2);
    var pricediscount = parseFloat(document.getElementById("Hidden23").value).toFixed(2);

    if(document.getElementById("atiHostTrue").checked){
        document.getElementById("form1").action = "/ProductCart/pc/sessionbuilder.asp?sonarID=204&datalockID=205&laptopID=149&wfoID=212&moID=260&moaID=289&geoID=296&serverFee=0&sonarPrice=$" + (sonarValue * timer * factor).toFixed(2) + "&dlpPrice=$" + (dlpValue * timer * factor).toFixed(2) + "&lpcPrice=$" + (lpcValue * timer * factor).toFixed(2) + "&moPrice=$" + (moValue * timer * factor).toFixed(2) + "&moaPrice=$" + (moaValue * timer * factor).toFixed(2) + "&geoPrice=$" + (geoValue * timer * factor).toFixed(2) + "&wfoPrice=$" + (wfoValue * timer * factor).toFixed(2) + "&supportfee=" + (supportValue).toFixed(2) + "&totalPrice=" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue)).toFixed(2) + "&termFactor=" + factor;
    }
    else {
        document.getElementById("form1").action = "/ProductCart/pc/sessionbuilder.asp?sonarID=84&datalockID=206&laptopID=144&wfoID=211&moID=329&moaID=286&geoID=328&serverFee=180&sonarPrice=$" + (sonarValue * timer * factor).toFixed(2) + "&dlpPrice=$" + (dlpValue * timer * factor).toFixed(2) + "&lpcPrice=$" + (lpcValue * timer * factor).toFixed(2) + "&moPrice=$" + (moValue * timer * factor).toFixed(2) + "&moaPrice=$" + (moaValue * timer * factor).toFixed(2) + "&geoPrice=$" + (geoValue * timer * factor).toFixed(2) + "&wfoPrice=$" + (wfoValue * timer * factor).toFixed(2) + "&supportfee=" + (supportValue).toFixed(2) + "&totalPrice=" + (((sonarValue + dlpValue + lpcValue + moValue + moaValue + geoValue + wfoValue) * timer * factor + hostValue)).toFixed(2) + "&termFactor=" + factor;
    }
}

