﻿/**
    Add date: 02-07-2009
*/

var contact;

window.addEvent('domready', function() {
    contact = function()
    {
        var values = $H({
            action: 'Contact', 
            txtfullname: $('txtfullname').get('value'),
            txtaddress: $('txtaddress').get('value'),
            txtphone: $('txtphone').get('value'),
            txtfax: $('txtfax').get('value'),
            txtemail: $('txtemail').get('value'),
            txtcontent: $('txtcontent').get('value')            
        }).toQueryString();
        
        var req = new Request({
            method: 'post', 
            async: false,
            url: 'API/ServiceHandler.ashx',
            onSuccess: function(error) {                
                if(error == 0) 
                {
                    alert("Thông tin của bạn đã được gởi.");
                }
                else if(error == 1)
                {
                    alert("Vui lòng nhập thông tin tên cá nhân/ công ty");
                }                
                else if(error == 2)
                {
                    alert("Vui lòng nhập thông tin email");
                }
                else if(error == 3)
                {
                    alert("Vui lòng nhập thông tin liên hệ");
                }
                else
                {
                    alert("Lỗi hệ thống");
                }
            }.bind(this)
        }).send(values); 
    }
}); 
