﻿/// <reference path="ext.js" />

ContactView = function() {

}

ContactView.prototype = {
    init: function() {
        Ext.fly('btnContact').on('click', this.submit, this);
    },

    submit: function() {
        var prms = {
            contact: true,
            name: document.getElementById('name').value,
            busname: document.getElementById('busname').value,
            email: document.getElementById('email').value,
            phone: document.getElementById('phone').value,
            website: document.getElementById('website').value,
            comments: document.getElementById('comments').value
        };
        this.hideContact();
        Ext.Ajax.request({
            url: 'ContactUs.aspx',
            params: prms,
            callback: this.hideLoading,
            scope: this
        });
    },

    hideContact: function() {
        Ext.fly('contact').slideOut('t', { duration: 0.5, callback: this.showLoading, scope: this, remove: true });
    },

    showLoading: function() {
        Ext.fly('loading').slideIn('t', { duration: 0.5 });
        //this.hideLoading.defer(4000, this);
    },

    hideLoading: function() {
        Ext.fly('loading').slideOut('t', { duration: 0.5, callback: this.showSuccess, scope: this, remove: true });
    },

    showSuccess: function() {
        Ext.fly('success').slideIn('t', { duration: 0.5 });
    }
}

Ext.onReady(function() {
    var cv = new ContactView();
    cv.init();
});
