﻿function controlDIV(name)
{
	document.getElementById("ul1").style.display="none";
	document.getElementById("ul2").style.display="none";
	document.getElementById("ul3").style.display="none";
	if(name!="")
	{
		document.getElementById(name).style.display="block";
	}
}

function checkEmail(str) 
{
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
        return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false
    }

    if (str.indexOf(at,(lat+1))!=-1){
        return false
    }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false
    }

    if (str.indexOf(dot,(lat+2))==-1){
        return false
    }

    if (str.indexOf(" ")!=-1){
        return false
    }
    return true					
}

function check_faqs_vn()
{
    if (document.aspnetForm._ctl0_ContentPlaceHolder1_txtFullname.value=='')
	{
	    alert('Bạn cần nhập họ và tên!');
	    document.aspnetForm._ctl0_ContentPlaceHolder1_txtFullname.focus();
	    return false;
	}
	
	if (document.aspnetForm._ctl0_ContentPlaceHolder1_txtEmail.value=='')
	{
	    alert('Bạn cần nhập địa chỉ email!');
	    document.aspnetForm._ctl0_ContentPlaceHolder1_txtEmail.focus();
	    return false;
	}
	else	
	    if(checkEmail(document.aspnetForm._ctl0_ContentPlaceHolder1_txtEmail.value)==false)
	    {
	        alert('Sai địa chỉ email!');
	        document.aspnetForm._ctl0_ContentPlaceHolder1_txtEmail.focus();
	        return false;
        }
    
    if (document.aspnetForm._ctl0_ContentPlaceHolder1_txtContent.value=='')
	{
	    alert('Bạn cần nhập nội dung câu hỏi!');
	    document.aspnetForm._ctl0_ContentPlaceHolder1_txtContent.focus();
	    return false;
	} 
	
	if (document.aspnetForm._ctl0_ContentPlaceHolder1_txtCode.value=='')
	{
	    alert('Bạn cần nhập mã bảo mật!');
	    document.aspnetForm._ctl0_ContentPlaceHolder1_txtCode.focus();
	    return false;
	}   
    return true;
}
