﻿function LogoQuotation() {
}

LogoQuotation.prototype = {
    init: function() {
        this.revisions = $('.logo .revisions');
        this.revisions.bind('change', this.update);
        
        this.concepts = $('.logo .concepts');
        this.concepts.bind('change', this.update);
        
        this.trademarks = $('.logo .trademarks');
        this.trademarks.bind('click', this.update);
        
        this.timeframe = $('.logo .timeframe');
        this.timeframe.bind('change', this.update);
        
        this.businesscard = $('.logo .businesscard');
        this.businesscard.bind('change', this.update);
        
        this.update();
    },
    update: function() {
        var price = 0;
        
        // Revisions
        var revisions_quote = 0;
        var revisions_type = $('.logo .revisions').attr('value');
        var revisions_prices = {'Standard': 25, 'More': 75, 'Most': 125};
        if (revisions_prices[revisions_type] != 'undefined')
            revisions_quote = revisions_prices[revisions_type];
        else {
            alert('Invalid revisions type: ' + revisions_type);
        }
        
        // Concepts
        var concepts_quote = 0;
        var concepts_type = $('.logo .concepts').attr('value');
        var concepts_prices = {'Standard': 50, 'More': 100, 'Most': 150};
        if (concepts_prices[concepts_type] != 'undefined')
            concepts_quote = concepts_prices[concepts_type];
        else {
            alert('Invalid concepts type: ' + concepts_type);
        }
        
        // Trademarks
        var trademarks_quote = 0;
        var trademarks_type = $('.logo .trademarks[@checked]').attr('value');
        var trademarks_prices = {'Optional': 0, 'Trademark Yes': 350};
        if (trademarks_prices[trademarks_type] != 'undefined')
            trademarks_quote = trademarks_prices[trademarks_type];
        else {
            alert('Invalid trademarks type: ' + trademarks_type);
        }
        
        // Hosting
        // no hosting feature for Logo
        
        // TimeFrame
        var timeframe_quote = 0;
        var timeframe_type = $('.logo .timeframe').attr('value');
        var timeframe_prices = {'Standard': 0, 'Quick': 75, 'Quicker': 150, 'Quickest': 250};
        if (timeframe_prices[timeframe_type] != 'undefined')
            timeframe_quote = timeframe_prices[timeframe_type];
        else {
            alert('Invalid timeframe type: ' + timeframe_type);
        }
        
        // Business Card
        var businesscard_quote = 0;
        var businesscard_type = $('.logo .businesscard').attr('value');
        var businesscard_prices = {'Optional': 0, 'Design': 150, '1000': 300, '2000': 400, '5000': 500};
        if (businesscard_prices[businesscard_type] != 'undefined')
            businesscard_quote = businesscard_prices[businesscard_type];
        else {
            alert('Invalid businesscard type: ' + businesscard_type);
        }
        
        price = revisions_quote + concepts_quote + trademarks_quote + businesscard_quote;
        
        price += (timeframe_quote/100)*price;
        $('#logo_quote').html('$' + price);
        //console.log(price);
    }
}

var Logo = new LogoQuotation();
Logo.init();