﻿
var sc_label_type = "4x6";
function set_sc_label_type(sc_lblType) 
{
    if      (sc_lblType == '2x2') { sc_label_type = '2x2'; }
    else if (sc_lblType == '2x3') { sc_label_type = '2x3'; }
    else if (sc_lblType == '2x4') { sc_label_type = '2x4'; }
    else if (sc_lblType == '2x5') { sc_label_type = '2x5'; }
    else if (sc_lblType == '3x3') { sc_label_type = '3x3'; }
    else if (sc_lblType == '3x4.5') { sc_label_type = '3x4.5'; }
    else if (sc_lblType == '3x6') { sc_label_type = '3x6'; }
    else if (sc_lblType == '3x7.5') { sc_label_type = '3x7.5'; }
    else if (sc_lblType == '4x4') { sc_label_type = '4x4'; }
    else if (sc_lblType == '4x6') { sc_label_type = '4x6'; }
    else if (sc_lblType == '4x8') { sc_label_type = '4x8'; }
    else if (sc_lblType == '4x10') { sc_label_type = '4x10'; }
    else if (sc_lblType == '6x6') { sc_label_type = '6x6'; }
    else if (sc_lblType == '6x9') { sc_label_type = '6x9'; }
    else if (sc_lblType == '6x12') { sc_label_type = '6x12'; }
    else if (sc_lblType == '6x15') { sc_label_type = '6x15'; }
    else if (sc_lblType == '7x7') { sc_label_type = '7x7'; }
    else if (sc_lblType == '7x10.5') { sc_label_type = '7x10.5'; }
    else if (sc_lblType == '7x14') { sc_label_type = '7x14'; }
    else if (sc_lblType == '7x17.5') { sc_label_type = '7x17.5'; }
    else if (sc_lblType == '8x8') { sc_label_type = '8x8'; }
    else if (sc_lblType == '8x12') { sc_label_type = '8x12'; }
    else if (sc_lblType == '8x16') { sc_label_type = '8x16'; }
    else if (sc_lblType == '8x20') { sc_label_type = '8x20'; }
    else if (sc_lblType == '9x9') { sc_label_type = '9x9'; }
    else if (sc_lblType == '9x13.5') { sc_label_type = '9x13.5'; }
    else if (sc_lblType == '9x18') { sc_label_type = '9x18'; }
    else if (sc_lblType == '9x22.5') { sc_label_type = '9x22.5'; }
}

var p = 0.0;
var q = 1.0;
var t = 0.0;
var actual_price = 0.0;
var setP = 0.0;
var sc_p = "";

percent = 1.0;
var sc_q = "";
var sc_t = "";

function update_SC() 
{
    sc_p = document.getElementById('SC_Price');
    sc_q = document.getElementById('SC_Qty');
    sc_t = document.getElementById('SC_Total');
    input_qty = document.getElementById('SetQuantity').value;
    q = parseFloat(input_qty);
    
    if (isNaN(q) == true) {q = 0.0;}

    if (sc_label_type == '2x2') { setP = 15.47; }
    if (sc_label_type == '2x3') { setP = 15.70; }
    if (sc_label_type == '2x4') { setP = 15.93; }
    if (sc_label_type == '2x5') { setP = 16.16; }
    if (sc_label_type == '3x3') { setP = 20.31; }
    if (sc_label_type == '3x4.5') { setP = 20.52; }
    if (sc_label_type == '3x6') { setP = 20.62; }
    if (sc_label_type == '3x7.5') { setP = 21.83; }
    if (sc_label_type == '4x4') { setP = 20.55; }
    if (sc_label_type == '4x6') { setP = 20.83; }
    if (sc_label_type == '4x8') { setP = 21.11; }
    if (sc_label_type == '4x10') { setP = 21.39; }
    if (sc_label_type == '6x6') { setP = 21.25; }
    if (sc_label_type == '6x9') { setP = 21.87; }
    if (sc_label_type == '6x12') { setP = 22.50; }
    if (sc_label_type == '6x15') { setP = 23.12; }
    if (sc_label_type == '7x7') { setP = 20.60; }
    if (sc_label_type == '7x10.5') { setP = 20.86; }
    if (sc_label_type == '7x14') { setP = 21.20; }
    if (sc_label_type == '7x17.5') { setP = 21.55; }
    if (sc_label_type == '8x8') { setP = 20.79; }
    if (sc_label_type == '8x12') { setP = 21.18; }
    if (sc_label_type == '8x16') { setP = 21.57; }
    if (sc_label_type == '8x20') { setP = 21.97; }
    if (sc_label_type == '9x9') { setP = 21.18; }
    if (sc_label_type == '9x13.5') { setP = 21.83; }
    if (sc_label_type == '9x18') { setP = 22.35; }
    if (sc_label_type == '9x22.5') { setP = 22.88; }
    
    //Set the Qty Discount
    if (q > 0 && q <= 5) 
    {
        percent = 1.0;//set percent
        
        actual_price = setP * percent;
        p = setP;
        t = p * q * percent;

        sc_p.innerHTML = formatCurrency(actual_price);
        sc_q.innerHTML = q;
        sc_t.innerHTML = formatCurrency(t);
        //updateImageCard();

    } else if (q >= 6 && q <= 10) 
    {
        percent = 0.38; //set percent
        actual_price = setP * percent;
        p = setP;
        t = p * q * percent;

        sc_p.innerHTML = formatCurrency(actual_price);
        sc_q.innerHTML = q;
        sc_t.innerHTML = formatCurrency(t);
        //updateImageCard();

    } else if (q >= 11 && q <= 25) 
    {
        percent = 0.34; //set percent
        actual_price = setP * percent;
        p = setP;
        t = p * q * percent;

        sc_p.innerHTML = formatCurrency(actual_price);
        sc_q.innerHTML = q;
        sc_t.innerHTML = formatCurrency(t);
        //updateImageCard();

    } else if (q >= 26) 
    {
        actual_price = setP * percent;
        p = setP;
        t = p * q * percent;

        sc_p.innerHTML = formatCurrency(actual_price);
        sc_q.innerHTML = q;
        sc_t.innerHTML = "Please call for pricing: <b>1-800-778-5572</b>"; //formatCurrency(t);
        //updateImageCard();
        
    } else {
    percent = 1.0;
    actual_price = setP * percent;
    p = setP;
    t = p * q * percent;

    sc_p.innerHTML = formatCurrency(actual_price);
    sc_q.innerHTML = q;
    sc_t.innerHTML = formatCurrency(t); //formatCurrency(t);
    //updateImageCard();
    }
}

function formatCurrency(num) 
{
    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num))
        num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
        num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
    return (((sign) ? '' : '-') + '$' + num + '.' + cents);
}


