﻿function onSearchBlur() {
    var objSearch = document.getElementById('qsQuery');
    var Empty = 'Từ khóa tìm kiếm';

    if (objSearch.value == '') objSearch.value = Empty;
}
function onSearchFocus() {
    var objSearch = document.getElementById('qsQuery');
    var Empty = 'Từ khóa tìm kiếm';

    if (objSearch.value == Empty) objSearch.value = '';
}
function doSearch() {
    var objSearch = document.getElementById('qsQuery');
    var Empty = 'Từ khóa tìm kiếm';

    if (objSearch.value.length > 1 && objSearch.value != Empty)
        window.location.href = '/tim-kiem/?q=' + encodeURI(objSearch.value);
}
function news_change(index) {
    document.getElementById("newstitle" + index).className = 'tincongnghe-active';
    document.getElementById("newslist" + index).style.display = '';
    for (var i = 1; i < 4; i++) {
        if (i != index) {
            document.getElementById("newstitle" + i).className = 'tincongnghe';
            document.getElementById("newslist" + i).style.display = 'none';
        }
    }
}
function submitForm(theform) {
    document.hlForm.contact_name.value = Trim(document.hlForm.contact_name.value);
    if (document.hlForm.contact_name.value == '') {
        alert('Bạn chua nhập tên');
        document.hlForm.contact_name.focus();
        return;
    }

    if ((SEmail = CheckEmailAddress(document.hlForm.contact_email.value)) == '') {
        alert('Email bạn nhập không đúng');
        document.hlForm.contact_email.focus();
        return;
    }

    document.hlForm.contact_email.value = SEmail;

    document.hlForm.contact_content.value = Trim(document.hlForm.contact_content.value);
    if (document.hlForm.contact_content.value == '') {
        alert('Bạn chưa nhập nội dung');
        document.hlForm.contact_content.focus();
        return;
    }

    var status = AjaxRequest.submit(
			document.hlForm
			, {
			    'onSuccess': function (req) {
			        alert(req.responseText);
			        ResetDefault();
			    }
				, 'onError': function (req) {
				    alert(req.responseText);
				}
			}
		);
    return status;
}

function ResetDefault() {
    document.hlForm.contact_name.value = '';
    document.hlForm.contact_email.value = '';
    document.hlForm.contact_title.value = '';
    document.hlForm.contact_content.value = '';

    document.hlForm.contact_address.value = '';
    document.hlForm.contact_tel.value = '';
}
