﻿function TuningQuotation() {
}

TuningQuotation.prototype = {
    init: function() {
        this.project_man = $('.tuning .project_man');
        this.project_man.bind('click', this.update);
        
        this.timeframe = $('.tuning .timeframe');
        this.timeframe.bind('change', this.update);
        
        this.webpages = $('.tuning .pages');
        this.webpages.bind('change', this.update);
        
        this.update();
    },
    update: function() {
        var price = 0;

        // Project Managements
        var project_man_quotes = 0;
        var project_man_items = $('.tuning .project_man[@checked]');
        var project_man_prices = 250;
        if (project_man_items != 'undefined')
            project_man_items.each(function(i) {project_man_quotes += project_man_prices});
        else {
            alert('Invalid project_man type: ' + project_man_type);
        }
        
        // TimeFrame
        var timeframe_quote = 0;
        var timeframe_type = $('.tuning .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 = $('.tuning .pages').attr('value');
        var webpages_prices = {'Standard': 50, 'More': 150, 'More2': 300, 'Most': 450};
        if (webpages_prices[webpages_type] != 'undefined')
            webpages_quote = webpages_prices[webpages_type];
        else {
            alert('Invalid webpages type: ' + webpages_type);
        }
        
        price =  webpages_quote + project_man_quotes;
        
        price += (timeframe_quote/100)*price;
        $('#tuning_quote').html('$' + price);
        //console.log(price);
    }
}

var Tuning = new TuningQuotation();
Tuning.init();