﻿function getInformation(cls)
{
    var result = informations.GetInformation(cls).value;
    if(result.Code != -1)
    {
        alert(result.Message);
        return;
    }
    
    GetControl('divTitle').innerHTML = result.Pagination[0];
    GetControl('spanTitle').innerHTML = result.Pagination[0];
    GetControl('divInfo').innerHTML = result.Pagination[1];
    GetControl('divImage').innerHTML = result.Pagination[2];
}

// 添加留言
function addContact()
{
    var txtTitle = GetControl("txtTitle");
    if(!validateControl(txtTitle,'留言标题',true,2,50))
        return;
        
    var txtName = GetControl("txtName");
    if(!validateControl(txtName,'您的姓名',true,2,5))
        return;
    
    var txtCompany = GetControl("txtCompany");
    var txtAddress = GetControl("txtAddress");
    var txtTelephone = GetControl("txtTelephone");
    var txtFax = GetControl("txtFax");
    var txtMail = GetControl("txtMail");
    var txtInfo = GetControl("txtInfo");
    if(!validateControl(txtInfo,'留言内容',true,0,0))
        return;
    
    var result = informations.addContact(txtTitle.value,txtName.value,txtCompany.value,txtAddress.value,txtTelephone.value,txtFax.value,txtMail.value,txtInfo.value).value;
    if(result.Code != -1)
    {
        alert(result.Message);
        return;
    }
    else
    {
        alert('留言添加成功。');
        txtTitle.value = '';
        txtName.value = '';
        txtCompany.value = '';
        txtAddress.value = '';
        txtTelephone.value = '';
        txtFax.value = '';
        txtMail.value = '';
        txtInfo.value = '';
    }
}

function addLeaveword()
{
    var txtName = GetControl('txtName');
    if(!validateControl(txtName,'您的姓名',true,2,20))
        return;
        
    var txtInfo = GetControl('txtInfo');
    if(!validateControl(txtInfo,'留言内容',true,2,0))
        return;
        
    var result = informations.addLeaveword(txtName.value, txtInfo.value).value;
    if(result.Code != -1)
    {
        alert(result.Message);
        return;
    }
    
    txtName.value = '';
    txtInfo.value = '';
    alert('留言成功，骄阳非常感谢你对本站的关注！');
}