function CopyToShip(){
    if (document.getElementById('SameShip').checked==true){
        document.getElementById('SName').value=document.getElementById('Name').value ;
        document.getElementById('SCompany').value=document.getElementById('Company').value ;
        document.getElementById('SAddress').value=document.getElementById('Address').value ;
        document.getElementById('SCity').value=document.getElementById('City').value;
        document.getElementById('SState').value=document.getElementById('State').value;
        document.getElementById('SZip').value=document.getElementById('Zip').value;
    }
    return true;
}

function UpdateCopyToShip(){
    if (document.getElementById('SName').value==document.getElementById('Name').value && document.getElementById('SCompany').value==document.getElementById('Company').value  && document.getElementById('SAddress').value==document.getElementById('Address').value  && document.getElementById('SCity').value==document.getElementById('City').value && document.getElementById('SState').value==document.getElementById('State').value && document.getElementById('SZip').value==document.getElementById('Zip').value){
        document.getElementById('SameShip').checked=true;
    }else{
        document.getElementById('SameShip').checked=false;
    }
    return true;
}


function GetQuote(){
    // need this to run after the calendar :(
    RushCheck();

    var Shipping = 0;
    var subTotal = 0;
    var rushTotal = 0;
    var Total = 0;
    var qty = 0;
    var tempPrice = 0;
    var tempShipping = 0;
    var tempQty = 0;
    
    var ProdTot = new Array(13);
      
    for (i=4; i<=12; i++){
        ProdTot[i] = 0;
        qty = document.getElementById('Prod'+i+'_qty').value;
        tempPrice=0;
        if (i==4 || i==5 || i==8 || i==9 || i==11 || i==12){
            if (qty<5){
                qty=0;
                document.getElementById('Prod'+i+'_qty').value=0;
            }
            if (qty<250){
                document.getElementById('Prod'+i+'_colors').value='none';
            }
            if (qty>=125000){
                qty=0;
                document.getElementById('Prod'+i+'_msg').innerHTML='<font size=-1><b>CALL! 1.888.372.1999</b></font>';
            }
        }else{
            if (qty<1){
                qty=0;
                document.getElementById('Prod'+i+'_qty').value=0;
            }
        }
        if (qty > 0){
            switch(i){
                 case 4:
                    //Child Fingerprint Kit
                    if(qty>=5 && qty<=249){
                        tempPrice=0.98;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=0.91;
                        Shipping = Shipping + 17;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=0.79;
                        Shipping = Shipping + 22;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=0.71;
                        Shipping = Shipping + 27;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=0.63;
                        Shipping = Shipping + 39;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=0.56;
                        Shipping = Shipping + 69;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=0.46;
                        Shipping = Shipping + 131;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=0.40;
                        Shipping = Shipping + 259;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.32;
                        Shipping = Shipping + 485;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.29;
                        Shipping = Shipping + 970;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }
                    
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    }
                                     
                    ProdTot[i] = tempPrice * qty;
                    break;
                case 5:
                    //Choice Kit
                    if(qty>=5 && qty<=249){
                        tempPrice=1.16;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=1.09;
                        Shipping = Shipping + 21;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=0.93;
                        Shipping = Shipping + 29;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=0.81;
                        Shipping = Shipping + 41;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=0.72;
                        Shipping = Shipping + 53;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=0.64;
                        Shipping = Shipping + 87;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=0.56;
                        Shipping = Shipping + 166;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=0.48;
                        Shipping = Shipping + 312;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.39;
                        Shipping = Shipping + 497;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.33;
                        Shipping = Shipping + 970;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }         
                    
                                       
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    } 
                             
                    ProdTot[i] = tempPrice * qty;
                    break;
                case 6:
                    //Cotton Swabs
                    if (document.getElementById('Prod'+i+'_unit').value == 'box'){
                        ProdTot[i] = 10 * qty;
                        Shipping = Shipping + (4 * qty);
                        if (qty >= 10){
                            document.getElementById('Prod'+i+'_msg').innerHTML='<font size=-2>You should consider purchasing by the case!</case>';
                        }
                        tempPrice = 10;
                    }else if (document.getElementById('Prod'+i+'_unit').value == 'case'){
                        ProdTot[i] = 80 * qty;
                        Shipping = Shipping + (22 * qty);
                        document.getElementById('Prod'+i+'_msg').innerHTML='';
                        tempPrice = 80;
                    }

                    break;
                case 7:
                    //DNA Card
                    
                    if (document.getElementById('Prod'+i+'_unit').value == 'pack'){
                        //Packs
                        tempPrice = 60.00;
                        Shipping = 2.95 * qty;
                        //alert('Packs!');
                    }else {
                        //Cases
                        tempPrice = 810.00;
                        Shipping = 22 * qty;
                        //alert('Cases!');
                    }         
                    
                    ProdTot[i] = tempPrice * qty;
                
                    //Shipping = Shipping + 0.00;
                    break;
                case 8:
                    //Genetikid DNA kit
                    if(qty>=5 && qty<=249){
                        tempPrice=1.74;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=1.67;
                        Shipping = Shipping + 29;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=1.52;
                        Shipping = Shipping + 42;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=1.39;
                        Shipping = Shipping + 56;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=1.27;
                        Shipping = Shipping + 68;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=1.18;
                        Shipping = Shipping + 119;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=1.08;
                        Shipping = Shipping + 197;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=0.98;
                        Shipping = Shipping + 349;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.89;
                        Shipping = Shipping + 592;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.78;
                        Shipping = Shipping + 970;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }         
                    
                                       
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    } 
                             
                    ProdTot[i] = tempPrice * qty;
                    Shipping = Shipping + 0;
                    break;
                case 9:
                    //IDComplete
                    if(qty>=5 && qty<=249){
                        tempPrice=2.17;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=2.10;
                        Shipping = Shipping + 34;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=1.88;
                        Shipping = Shipping + 47;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=1.69;
                        Shipping = Shipping + 61;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=1.51;
                        Shipping = Shipping + 74;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=1.37;
                        Shipping = Shipping + 129;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=1.25;
                        Shipping = Shipping + 215;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=1.13;
                        Shipping = Shipping + 382;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.96;
                        Shipping = Shipping + 619;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.90;
                        Shipping = Shipping + 1110;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }         
                    
                                       
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    } 
                             
                    ProdTot[i] = tempPrice * qty;
                    break;
                case 10:
                    //InkStrips
                    document.getElementById('Prod'+i+'_msg').innerHTML='';
                    if (document.getElementById('Prod'+i+'_unit').value == 'pack'){
                        if (qty>=12){
                            document.getElementById('Prod'+i+'_unit').value = 'case';
                            tempQty = (qty/12) + 0;
                            qty=Math.ceil(tempQty);
                            document.getElementById('Prod'+i+'_qty').value = qty;
                            document.getElementById('Prod'+i+'_msg').innerHTML='<font size=-2>Your order has been converted from packs into cases.</font>';
                        }else{

                            if(qty>=1 && qty<=3){
                                tempPrice=35;
                                tempShipping =  2.95;
                            }else if(qty>=4 && qty<=5){
                                tempPrice=30;
                                tempShipping =  2.55;
                            }else if(qty>=6 && qty<=7){
                                tempPrice=26;
                                tempShipping =  1.95;
                            }else if(qty>=8 && qty<=9){
                                tempPrice=23;
                                tempShipping =  1.65;
                            }else if(qty>=10 && qty<=11){
                                tempPrice=21;
                                tempShipping =  1.35;
                            }else {
                                //too many
                            }     
                        }
                    }
                    
                    if (document.getElementById('Prod'+i+'_unit').value == 'case'){
                       if(qty>=1 && qty<=5){
                            tempPrice=240;
                            tempShipping =  9.95;
                        }else if(qty>=6 && qty<=10){
                            tempPrice=230;
                            tempShipping =  7.95;
                        }else if(qty>=11 && qty<=15){
                            tempPrice=215;
                            tempShipping =  5.95;
                        }else if(qty>=16 && qty<=20){
                            tempPrice=205;
                            tempShipping =  4.95;
                        }else if(qty>=21 && qty<=50){
                            tempPrice=196;
                            tempShipping =  3.95;
                        }else if(qty>=51 && qty<=99){
                            tempPrice=193;
                            tempShipping =  2.95;
                        }else if(qty>=100){
                            tempPrice=191;
                            tempShipping =  1.95;                        }     
                    }
                    ProdTot[i] = tempPrice * qty;
                    Shipping = Shipping + (tempShipping * qty);
                    break;
                case 11:
                    //SHIELD kit
                    if(qty>=5 && qty<=249){
                        tempPrice=1.05;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=0.98;
                        Shipping = Shipping + 21;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=0.92;
                        Shipping = Shipping + 29;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=0.86;
                        Shipping = Shipping + 41;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=0.80;
                        Shipping = Shipping + 53;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=0.74;
                        Shipping = Shipping + 87;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=0.68;
                        Shipping = Shipping + 166;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=0.62;
                        Shipping = Shipping + 312;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.56;
                        Shipping = Shipping + 497;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.50;
                        Shipping = Shipping + 970;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }         
                    
                                       
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    } 
                             
                    ProdTot[i] = tempPrice * qty;
                    break;
                case 12:
                    //WHALE kit
                    if(qty>=5 && qty<=249){
                        tempPrice=1.05;
                        Shipping = Shipping + 0;
                    }else if(qty>=250 && qty<=599){
                        tempPrice=0.98;
                        Shipping = Shipping + 21;
                    }else if(qty>=600 && qty<=1199){
                        tempPrice=0.92;
                        Shipping = Shipping + 29;
                    }else if(qty>=1200 && qty<=1999){
                        tempPrice=0.86;
                        Shipping = Shipping + 41;
                    }else if(qty>=2000 && qty<=4999){
                        tempPrice=0.80;
                        Shipping = Shipping + 53;
                    }else if(qty>=5000 && qty<=9999){
                        tempPrice=0.74;
                        Shipping = Shipping + 87;
                    }else if(qty>=10000 && qty<=24999){
                        tempPrice=0.68;
                        Shipping = Shipping + 166;
                    }else if(qty>=25000 && qty<=49999){
                        tempPrice=0.62;
                        Shipping = Shipping + 312;
                    }else if(qty>=50000 && qty<=74999){
                        tempPrice=0.56;
                        Shipping = Shipping + 497;
                    }else if(qty>=75000 && qty<=124999){
                        tempPrice=0.50;
                        Shipping = Shipping + 970;
                    }else if(qty>=125000){
                        //too many
                    }else {
                        //too few
                    }         
                    
                                       
                    switch(document.getElementById('Prod'+i+'_colors').value){
                        case 'B&W':
                            tempPrice = tempPrice + 0;
                            break;
                        case '1 Color':
                            tempPrice = tempPrice + 0.10;
                            break;                        
                        case '2 Colors':
                            tempPrice = tempPrice + 0.20;
                            break;                        
                        case '3 Colors':
                            tempPrice = tempPrice + 0.30;
                            break;
                        case '4 Colors':
                            tempPrice = tempPrice + 0.40;
                            break;
                        default:
                            //error
                            break; 
                    } 
                             
                    ProdTot[i] = tempPrice * qty;
                    break;
                default:
                    //error
                    document.getElementById('Prod'+i+'_qty').value = 0;
                    ProdTot[i] = 0;
                    break;
            }
            if (i!=7 && i!=10 && i!=6){
                document.getElementById('Prod'+i+'_UnitPrice').innerHTML = '$' + tempPrice.toFixed(2) + '&nbsp;ea';
            }else{
                document.getElementById('Prod'+i+'_UnitPrice').innerHTML = '$' + tempPrice.toFixed(2) + '&nbsp;/&nbsp;' + document.getElementById('Prod'+i+'_unit').value;
            }
            document.getElementById('Prod'+i+'_PerUnitPrice').value = tempPrice.toFixed(2);
        }else{
            //to assure no errors
            /**if (qty>=125000){
                //keep qty
            }else{
                document.getElementById('Prod'+i+'_qty').value = 0;
            }**/
        }
    }
    
    if(document.getElementById('Artwork').value=='New Artwork - $40.00 setup fee') {
        subTotal=subTotal + 40;
        document.getElementById('CameraReady_price').innerHTML= '$40.00';
        document.getElementById('CameraReady_price2').innerHTML= '$40.00';
        //document.getElementById('CameraReady_msg').innerHTML= '<font size=-2>A one time charge is being added for the artwork.</font>'; // as it is not camera ready.  If no logo is being added to any of the products, or if your logo is camera ready, please select "Yes" above.';
    }else{
        subTotal=subTotal + 0;
        document.getElementById('CameraReady_price').innerHTML= '$0.00';
        document.getElementById('CameraReady_price2').innerHTML= '&nbsp;';
        //document.getElementById('CameraReady_msg').innerHTML= '<font size=-2>&nbsp;</font>';
    }


    //Calculate stuff here
    for (i=4; i<=12; i++){
        subTotal = subTotal + ProdTot[i];
        if (i==4 || i==5 || i==8 || i==9 || i==11 || i==12){
            if (document.getElementById('Prod'+i+'_qty').value >= 250 && document.getElementById('Prod'+i+'_colors').value != 'none' && document.getElementById('DeadlineY').checked == true){
                rushTotal = rushTotal + ProdTot[i];
            }
        }
    }
    
    if (getRushCheck()==true){
        rushTotal = rushTotal * 0.05
        document.getElementById('Rush_total').innerHTML= '$' + rushTotal.toFixed(2);  
        document.getElementById('Rush_totalamt').value= '$' + rushTotal.toFixed(2);  
        document.getElementById('Rush_totalY').value= 'YES';  
        subTotal = subTotal + rushTotal
    }else{
        document.getElementById('Rush_total').innerHTML= '$0.00';  
        document.getElementById('Rush_totalamt').value= '&nbsp;';  
        document.getElementById('Rush_totalY').value= 'NO';  
        
    }    
    
    Total = subTotal + Shipping;
    
    document.getElementById('subTotal').innerHTML= '$' + subTotal.toFixed(2);
    document.getElementById('Shipping').innerHTML= '$' + Shipping.toFixed(2);
    document.getElementById('Total').innerHTML= '$' + Total.toFixed(2);
    
    document.getElementById('ShippingTotal').value=Shipping.toFixed(2);
    document.getElementById('GrandSubTotal').value=subTotal.toFixed(2);
    document.getElementById('GrandTotal').value=Total.toFixed(2);
    


    for (i=4; i<=12; i++){
        if (ProdTot[i] == 0){
            document.getElementById('Prod'+i).innerHTML= '&nbsp;';
        }else{
            document.getElementById('Prod'+i).innerHTML= '$' + ProdTot[i].toFixed(2);
        }
        document.getElementById('Prod'+i+'_Total').value=ProdTot[i].toFixed(2);
    }
}

function ClearDivs(){
    document.getElementById('Shipping').innerHTML= '&nbsp;';
    document.getElementById('Total').innerHTML= '&nbsp;';
    document.getElementById('subTotal').innerHTML= '&nbsp;';
    document.getElementById('CameraReady_price').innerHTML= '&nbsp;';
    document.getElementById('CameraReady_price2').innerHTML= '&nbsp;';

    for (i=4; i<=12; i++){
        document.getElementById('Prod'+i).innerHTML= '&nbsp;';
        document.getElementById('Prod'+i+'_UnitPrice').innerHTML= '&nbsp;';
    }
}

function Print(){
    //send email
    //alert('Here I will recalculate the cost before sending to a printable page!\nWe will add the bottom text to the printerfriendly page only!\nGoing there will send an email!!');
    GetQuote();
    document.getElementById('Date1').disabled = false; //need to send date
}
