AW.Pages.ContactUs = {};

AW.Pages.ContactUs.index = {
    load: function load() {
        var _this     = this;
        
        // "Inquiry About" values mapped to event methods
        this.values = {
            'WTKT: Technical Question': 'showTech',
            'WTKT: Billing Question': 'showBilling',
            'WTKT: Cancellation - Include Login & Password': 'showCancel',
            'CTKT: Technical Question': 'showTech',
            'CTKT: Billing Question': 'showBilling',
            'CTKT: Cancellation - Include Login & Password': 'showCancel'
        };
        
        // "Question Type" values mapped to event methods
        this.types = {
            'Getting Started': 'showStart',
            'Messages': 'showMessages',
            'Web Form': 'showWebforms',
            'Other': 'hideTechMeta'
        };
        
        this.about    = $('#about');
        this.meta     = $('#inquiry-meta');
        this.hold     = this.meta.find('#hold-package');
        this.tech     = this.meta.find('#technical-meta');
        this.type     = this.tech.find('#question-type');
        this.start    = this.meta.find('#getting-started-meta');
        this.messages = this.meta.find('#messages-meta');
        this.webform  = this.meta.find('#web-form-meta');
        this.billing  = this.meta.find('#billing-meta');
        this.cancel   = this.meta.find('#cancellation-meta');
        
        this.about.bind('change', function(event) {
            if (typeof _this[_this.values[this.value]] == 'function') {
                _this[_this.values[this.value]].call(_this);
                if (_this.values[this.value] == 'showCancel') {
                    _this.cancelQuestion();
                } else {
                    _this.normalQuestion();
                }
                
            } else {
                _this.hideAll();
                _this.normalQuestion();
            }
        });
        
        this.type.bind('change', function(event) {
            if (typeof _this[_this.types[this.value]] == 'function') {
                _this[_this.types[this.value]].call(_this);
            } else {
                _this.hideTechMeta();
            }
        });
        
        this.hideNonTech = function hideNonTech() {
            this.hold.hide();
            this.billing.hide();
            this.cancel.hide();
        };
        
        this.hideTech = function hideTech() {
            this.tech.hide();
            this.hideTechMeta();
        };
        
        this.hideTechMeta = function hideTechMeta() {
            this.start.hide();
            this.messages.hide();
            this.webform.hide();
        };
        
        this.hideAll = function hideAll() {
            this.hideNonTech();
            this.hideTech();
        };
        
        this.showTech = function showTech() {
            this.hideAll();
            this.tech.show();
        };
        
        this.showBilling = function showBilling() {
            this.hideAll();
            this.billing.show();
        };
        
        this.showCancel = function showCancel() {
            this.hideAll();
            this.hold.show();
            this.cancel.show();
        };
        
        this.cancelQuestion = function switchQuestion() {
            $('#question-label').html("Would you mind telling us why you're " +
                "canceling?")
        };
        
        this.normalQuestion = function switchQuestion() {
            $('#question-label').text("Question/Comment/Feedback:")
        };
        
        this.showStart = function showStart() {
            this.hideTechMeta();
            this.start.show();
        };
        
        this.showMessages = function showMessages() {
            this.hideTechMeta();
            this.messages.show();
        };
        
        this.showWebforms = function showWebforms() {
            this.hideTechMeta();
            this.webform.show();
        };
        
        this.hideAll();
    }
}