function writeMenu() {
    if (User && User.loggedIn) {
        document.write(header_logged_in);
    } else {
        document.write(header_logged_out);
    }
}

function writeFooter() {
    if (User && User.loggedIn) {
        document.write(footer_logged_in);
    } else {
        document.write(footer_logged_out);
    }
}

function wholeSalePrice() {
    if (User && User.loggedIn) {
        if (wsp) {
            wsp = parseFloat(wsp);
            basePrice = wsp;
	    /*
            if (baseDiscount != 'undefined') {
                discount = (Discount.amount + baseDiscount) * .01;
            }
            else {
                discount = (Discount.amount) * .01;
            }

            discountAmount = Math.round((basePrice * discount)*100)/100;

            finalPrice = (basePrice - discountAmount);
            finalPrice = Math.round(finalPrice * 100)/100; 
            discount = Math.round(discount * 100)/100;
	    */

            document.write('<div id="wholesale-price">Your Cost: $' + basePrice.toFixed(2) + '</div>');
            //document.write('<input id="discountHidden" type="hidden" name="Wholesale Discount" value="(-$' + discountAmount + ')"/>'); 
        }
            
        
    } else {
        $('.map-label').html('Retail Price: ');
    }
}

function optionChanged(select) {
    var value = select.options[select.selectedIndex].value;
    var optionPrice = value.match(/([0-9]+\.[0-9]+)/);
    if (optionPrice == null)
        optionPrice = 0;

    optionPrice = parseFloat(optionPrice);
    wsp = parseFloat(wsp);
    basePrice = wsp  + optionPrice;

    if (baseDiscount != 'undefined') {
        discount = (Discount.amount + baseDiscount) * .01;
    }
    else {
        discount = (Discount.amount) * .01;
    }

    discountAmount = Math.round((basePrice * discount)*100)/100;

    finalPrice = (basePrice - discountAmount);
    finalPrice = Math.round(finalPrice * 100)/100; 
    discount = Math.round(discount * 100)/100;

    $('#map-price-holder').html('$' + basePrice);
    $('#wholesale-price').html('Your Cost: $' + finalPrice);
    $('#discountHidden').val('(-$' + discountAmount + ')');

}

function quickOrderWholesale(wsp, optionstr, index) {
    if (User && User.loggedIn) {
        
        var optionPrice = optionstr.match(/([0-9]+\.[0-9]+)/);



        wsp = parseFloat(wsp);

        if (optionPrice == null)
            optionPrice = 0;

        optionPrice = parseFloat(optionPrice);
        basePrice = wsp + optionPrice;
        
        discount = (Discount.amount) * .01;

        discountAmount = Math.round(basePrice * discount * 100)/100;
        finalPrice = (basePrice - discountAmount);
        finalPrice = Math.round(finalPrice * 100) / 100;

        discount = Math.round(discount * 100) / 100;

        document.write('<div>Your Cost: $' + finalPrice + '</div>');
        document.write('<input type="hidden" name="vwattr' + index + '_Wholesale Discount" value="(-$' + discountAmount + ')"/>');

    }
}

function showButton() {
    if ((User && User.loggedIn) || retailAllowed) {
        document.write('<input type="image" src="/lib/yhst-16750746105545/addtocart.jpg" />');    
    } else {
        document.write('<a href="store-locator.html"><img src="/lib/yhst-16750746105545/retailer-button.gif" /></a>');
    }
}

