﻿function SeoQuotation() {
}

SeoQuotation.prototype = {
    init: function() {
        this.project_man = $('.seo .project_man');
        this.project_man.bind('click', this.update);
        
        this.timeframe = $('.seo .timeframe');
        this.timeframe.bind('change', this.update);
        
        this.webpages = $('.seo .pages');
        this.webpages.bind('change', this.update);
        
        this.maintenance = $('.seo .maintenance');
        this.maintenance.bind('change', this.update);
        
        this.update();
    },
    update: function() {
        var price = 0;
        
        // Project Managements
        var project_man_quotes = 0;
        var project_man_items = $('.seo .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 = $('.seo .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 = $('.seo .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 = $('.seo .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 = project_man_quotes + webpages_quote + maintenance_quote;
        
        price += (timeframe_quote/100)*price;
        $('#seo_quote').html('$' + price);
        //console.log(price);
    }
}

var Seo = new SeoQuotation();
Seo.init();