﻿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 = '';
}

function vip_next_back() {
    if (run_next_mode) vip_next();
    else vip_back();
}
function vip_back() {
    run_next_mode = false;
    index--;
    if (index < 0) index = maxindex;
    vip_change();
}
function vip_next() {
    run_next_mode = true;
    index++;
    if (index > maxindex) index = 0;
    vip_change();
}
function vip_change() {
    var list_video = document.getElementById("list_vip");

    sLink = '/Tools/SlideShowXML.aspx?p=' + index;
    AjaxRequest.get(
		{
		    'url': sLink
		, 'onSuccess': function (req) {
		    if (req.responseXML.getElementsByTagName('Item').length > 0) {
		        var sHtml = '';
		        for (var i = 0; i < req.responseXML.getElementsByTagName('Item').length; i++) {
		            with (req.responseXML.getElementsByTagName('Item').item(i)) {
		                var file = getNodeValue(getElementsByTagName('File'));
		                
		                sHtml+='<img style="margin-right: 6px;" src="' + file + '" onclick="viewImgFull(this.src);" width="80" border="0" height="60">';
		            }
		        }
                list_video.innerHTML = sHtml;
		    }
		}
		, 'onError': function (req) { }
		}
	)
}
function checkdomain() {
    window.location.href = '/kiem-tra-ten-mien/?n=' + document.getElementById('txtDomain').value + '&e=' + document.getElementById('txtExt').value;
}
