﻿function FlashQuotation() {
}

FlashQuotation.prototype = {
    init: function() {
        this.revisions = $('.flash .revisions');
        this.revisions.bind('change', this.update);
        
        this.concepts = $('.flash .concepts');
        this.concepts.bind('change', this.update);
        
        this.trademarks = $('.flash .trademarks');
        this.trademarks.bind('click', this.update);
        
        this.trademarks = $('.flash .hosting');
        this.trademarks.bind('click', this.update);
        
        this.timeframe = $('.flash .timeframe');
        this.timeframe.bind('change', this.update);
        
        this.webpage = $('.flash .pages');
        this.webpage.bind('change', this.update);
        
        this.maintenance = $('.flash .maintenance');
        this.maintenance.bind('change', this.update);
        
        this.update();
    },
    update: function() {
        var price = 0;
        
        // Revisions
        var revisions_quote = 0;
        var revisions_type = $('.flash .revisions').attr('value');
        var revisions_prices = {'Standard': 175, 'More': 350, 'Most': 500};
        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 = $('.flash .concepts').attr('value');
        var concepts_prices = {'Standard': 225, 'More': 450, 'Most': 750};
        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 = $('.flash .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
        var hosting_quote = 0;
        var hosting_type = $('.flash .hosting[@checked]').attr('value');
        var hosting_prices = {'Optional': 0, 'Hosting Yes': 10};
        if (hosting_prices[hosting_type] != 'undefined')
            hosting_quote = hosting_prices[hosting_type];
        else {
            alert('Invalid hosting type: ' + hosting_type);
        }
        
        // TimeFrame
        var timeframe_quote = 0;
        var timeframe_type = $('.flash .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);
        }
        
        // Website
        var webpages_quote = 0;
        var webpages_type = $('.flash .pages').attr('value');
        var webpages_prices = {'Standard': 100, 'More': 200, 'More2': 350, 'Most': 500};
        if (webpages_prices[webpages_type] != 'undefined')
            webpages_quote = webpages_prices[webpages_type];
        else {
            alert('Invalid webpages type: ' + webpages_type);
        }
        
        // Maintenance
        var maintenance_quote = 0;
        var maintenance_type = $('.flash .maintenance').attr('value');
        var maintenance_prices = {'Optional': 0, '2Year': 300, '6Year': 800, '12Year': 1500, '24Year': 2800};
        if (maintenance_prices[maintenance_type] != 'undefined')
            maintenance_quote = maintenance_prices[maintenance_type];
        else {
            alert('Invalid maintenance type: ' + maintenance_type);
        }
        
        price = revisions_quote + concepts_quote + trademarks_quote + maintenance_quote + webpages_quote + hosting_quote;
        
        price += (timeframe_quote/100)*price;
        $('#flash_quote').html('$' + price);
        //console.log(price);
    }
}

var Flash = new FlashQuotation();
Flash.init();