function calculate(display_results)
{
    var total = 0;
    var shipping = 0;
    var form = document.form1;
    var size = document.form1.size.options[document.form1.size.selectedIndex].value;
    var quantity = document.form1.quantity.options[document.form1.quantity.selectedIndex].value;
    var what_to_do = document.form1.what_to_do.options[document.form1.what_to_do.selectedIndex].value;
    // var design_needed = document.form1.design_needed.options[document.form1.design_needed.selectedIndex].value;
    var require_direct_mail = document.form1.require_direct_mail.options[document.form1.require_direct_mail.selectedIndex].value;
    
    if (size == '')
    {
        alert('Please select postcard size');
        return false;
    }
    
    if ((size == '5.5x8' | size == '5.5x11' | size == '6x9'))
    {
        document.getElementById('class_postage_row').style.display = '';
        document.form1.class_postage.disabled = false;
    }
    else
    {
        document.getElementById('class_postage_row').style.display = 'none';
        document.form1.class_postage.disabled = true;
    }

    
    if (quantity == '')
    {
        alert('Please select postcard quantity');
        return false;
    }
    
    // if (design_needed == 'yes')
    // {
    //    total += 75;
    // }
    var size1 = new Array();    size1[1000] = 199;    size1[2000] = 252;    size1[3000] = 282;    size1[4000] = 312;    size1[5000] = 342;    size1[6000] = 372;    size1[7000] = 402;    size1[8000] = 432;    size1[9000] = 462;    size1[10000] = 492;    size1[15000] = 642;    size1[20000] = 792;
    var size2 = new Array();    size2[1000] = 199;    size2[2000] = 252;    size2[3000] = 282;    size2[4000] = 312;    size2[5000] = 342;    size2[6000] = 372;    size2[7000] = 402;    size2[8000] = 432;    size2[9000] = 462;    size2[10000] = 492;    size2[15000] = 642;    size2[20000] = 792;
    var size3 = new Array();    size3[1000] = 327;    size3[2000] = 432;    size3[3000] = 492;    size3[4000] = 552;    size3[5000] = 612;    size3[6000] = 672;    size3[7000] = 732;    size3[8000] = 792;    size3[9000] = 852;    size3[10000] = 912;    size3[15000] = 1212;    size3[20000] = 1512;
	var size4 = new Array();    size4[1000] = 327;    size4[2000] = 432;    size4[3000] = 492;    size4[4000] = 552;    size4[5000] = 612;    size4[6000] = 672;    size4[7000] = 732;    size4[8000] = 792;    size4[9000] = 852;    size4[10000] = 912;    size4[15000] = 1212;    size4[20000] = 1512;
	var size5 = new Array();    size5[1000] = 412;    size5[2000] = 552;    size5[3000] = 632;    size5[4000] = 712;    size5[5000] = 792;    size5[6000] = 872;    size5[7000] = 952;    size5[8000] = 1032;    size5[9000] = 1112;    size5[10000] = 1192;    size5[15000] = 1592;    size5[20000] = 1992;
    
	var shipping1 = new Array();
    shipping1[1000] = 18;
    shipping1[2000] = 18;
    shipping1[3000] = 18;
    shipping1[4000] = 18;
    shipping1[5000] = 18;
    shipping1[6000] = 18;
    shipping1[7000] = 18;
    shipping1[8000] = 18;
    shipping1[9000] = 18;
    shipping1[10000] = 18;
    shipping1[15000] = 18;
    shipping1[20000] = 18;
        
    var shipping2 = new Array();
    shipping2[1000] = 18;
    shipping2[2000] = 18;
    shipping2[3000] = 18;
    shipping2[4000] = 18;
    shipping2[5000] = 18;
    shipping2[6000] = 18;
    shipping2[7000] = 18;
    shipping2[8000] = 18;
    shipping2[9000] = 18;
    shipping2[10000] = 18;
    shipping2[15000] = 18;
    shipping2[20000] = 18;
    
    var shipping3 = new Array();
    shipping3[1000] = 18;
    shipping3[2000] = 18;
    shipping3[3000] = 18;
    shipping3[4000] = 18;
    shipping3[5000] = 18;
    shipping3[6000] = 18;
    shipping3[7000] = 18;
    shipping3[8000] = 18;
    shipping3[9000] = 18;
    shipping3[10000] = 18;
    shipping3[15000] = 18;
    shipping3[20000] = 18;
	
	var shipping4 = new Array();
    shipping4[1000] = 18;
    shipping4[2000] = 18;
    shipping4[3000] = 18;
    shipping4[4000] = 18;
    shipping4[5000] = 18;
    shipping4[6000] = 18;
    shipping4[7000] = 18;
    shipping4[8000] = 18;
    shipping4[9000] = 18;
    shipping4[10000] = 18;
    shipping4[15000] = 18;
    shipping4[20000] = 18;
	
	var shipping5 = new Array();
    shipping5[1000] = 18;
    shipping5[2000] = 18;
    shipping5[3000] = 18;
    shipping5[4000] = 18;
    shipping5[5000] = 18;
    shipping5[6000] = 18;
    shipping5[7000] = 18;
    shipping5[8000] = 18;
    shipping5[9000] = 18;
    shipping5[10000] = 18;
    shipping5[15000] = 18;
    shipping5[20000] = 18;

    switch (size)
    {
        case '4x6':
            total += size1[Math.abs(quantity)];
            
            if (require_direct_mail == 'no')
            {
                shipping == shipping1[Math.abs(quantity)];
            }
            break;
			
		case '4.25x6':
            total += size2[Math.abs(quantity)];
            
            if (require_direct_mail == 'no')
            {
                shipping == shipping1[Math.abs(quantity)];
            }
            break;
            
        case '5.5x8':
            total += size3[Math.abs(quantity)];
            
            if (require_direct_mail == 'no')
            {
                shipping == shipping2[Math.abs(quantity)];
            }
            break;
        
        case '6x9':
            total += size4[Math.abs(quantity)];
            
            if (require_direct_mail == 'no')
            {
                shipping == shipping3[Math.abs(quantity)];
            }
            break;
			
		case '5.5x11':
            total += size5[Math.abs(quantity)];
            
            if (require_direct_mail == 'no')
            {
                shipping == shipping3[Math.abs(quantity)];
            }
            break;
    }
    
    if (document.form1.how_many_addresses.disabled == false)
    {
        if (size == '4.25x6' | size == '4x6')
        {
            document.form1.class_postage.disabled = true;
            document.getElementById('class_postage_row').style.display = 'none';
            
            if (Math.abs(document.form1.how_many_addresses.value) != 0)
            {
                total += (Math.abs(document.form1.how_many_addresses.value) * 0.26);
            }
        }
        
        if (Math.abs(document.form1.quantity.options[document.form1.quantity.selectedIndex].value) < Math.abs(document.form1.how_many_addresses.value))
        {
            alert('Your mail list is to large please choose a quantity less than or equal to the # of cards you are printing.');
            return false;
        }
    }
    
    if (document.form1.class_postage.disabled == false)
    {
        if (document.form1.class_postage.options[document.form1.class_postage.selectedIndex].value == 'standard')
        {
// 0.251
            total += (0.26 * Math.abs(document.form1.how_many_addresses.value));
        }
        else if (document.form1.class_postage.options[document.form1.class_postage.selectedIndex].value == 'first_class')
        {
// 0.346
            total += (0.39 * Math.abs(document.form1.how_many_addresses.value));
        }
    }
    
    if (document.form1.require_direct_mail.options[document.form1.require_direct_mail.selectedIndex].value == 'yes' &
     (Math.abs(document.form1.how_many_addresses.value) < quantity))
    {
        var remaining = (quantity - Math.abs(document.form1.how_many_addresses.value));
        document.getElementById('what_to_do_row').style.display = '';
        document.getElementById('what_remaining').innerHTML = 'You have chosen to print ' + quantity + ' postcards but your mail list is only ' + Math.abs(document.form1.how_many_addresses.value) + '.  This leaves ' + remaining + ' postcards remaining<br><br>';
        document.form1.what_to_do.disabled = false;
    }
    else
    {
        document.getElementById('what_to_do_row').style.display = 'none';
    }
    
    if (what_to_do == 'ship_to_me' | what_to_do == 'discard' | what_to_do == '')
    {
        switch (size)
        {
            case '4x6':
                for (shipping_quantity in shipping1)
                {
                    if ((remaining - shipping_quantity) > 99999)
                    {
                        continue;
                    }
                    else
                    {
                        shipping += shipping1[shipping_quantity];
                        break;
                    }
                }
                break;
			case '4.25x6':
                for (shipping_quantity in shipping2)
                {
                    if ((remaining - shipping_quantity) > 99999)
                    {
                        continue;
                    }
                    else
                    {
                        shipping += shipping2[shipping_quantity];
                        break;
                    }
                }
                break;
            case '5.5x8':
                for (shipping_quantity in shipping3)
                {
                    if ((remaining - shipping_quantity) > 99999)
                    {
                        continue;
                    }
                    else
                    {
                        shipping += shipping3[shipping_quantity];
                        break;
                    }
                }
                break;
			case '6x9':
                for (shipping_quantity in shipping4)
                {
                    if ((remaining - shipping_quantity) > 99999)
                    {
                        continue;
                    }
                    else
                    {
                        shipping += shipping4[shipping_quantity];
                        break;
                    }
                }
                break;	
            
            case '5.5x11':
                for (shipping_quantity in shipping5)
                {
                    if ((remaining - shipping_quantity) > 99999)
                    {
                        continue;
                    }
                    else
                    {
                        shipping += shipping5[shipping_quantity];
                        break;
                    }
                }
                break;
        }
    }
    
    if (display_results)
    {
        document.getElementById('total').innerHTML = total.toFixed(2);
        document.getElementById('shipping').innerHTML = shipping.toFixed(2);
		
		/*added by niranjan ebpearls*/
		document.getElementById('total_hidden').value = total.toFixed(2);
        document.getElementById('shipping_hidden').value = shipping.toFixed(2);
		/*added by niranjan ebpearls*/
    }
}

function show_questions()
{
    var size = document.form1.size.options[document.form1.size.selectedIndex].value;
    
    if (document.form1.require_direct_mail.options[document.form1.require_direct_mail.selectedIndex].value == 'yes')
    {
        document.getElementById('what_to_do_row').style.display = '';
        document.form1.what_to_do.disabled = false;
        document.getElementById('how_many_rows').style.display = '';
        document.form1.how_many_addresses.disabled = false;
        document.getElementById('class_postage_row').style.display = '';
        document.form1.class_postage.disabled = false;
    }
    else
    {
        document.getElementById('what_to_do_row').style.display = 'none';
        document.form1.what_to_do.disabled = true;
        document.getElementById('how_many_rows').style.display = 'none';
        document.form1.how_many_addresses.disabled = true;
        document.getElementById('class_postage_row').style.display = 'none';
        document.form1.class_postage.disabled = true;
   }
}