<!--
var limit = 480;

function charCounter(objName, objCounter) {
    var old = objCounter.value;
    objCounter.value = objName.value.length;
    if (objCounter.value > limit && old <= limit) {
        alert('Ban da nhap nhieu hon ' + limit + ' ky tu!');
        if (document.styleSheets) {
            objCounter.style.fontWeight = 'bold';
            objCounter.style.color = '#FF0000';
        }
    }
    else if (objCounter.value <= limit && old > limit
            && document.styleSheets) {
        objCounter.style.fontWeight = 'normal';
        objCounter.style.color = '#0000FF';
    }
}
//this function includes all necessary js files for the application
function include(file)
{

    var script = document.createElement('script');
    script.src = file;
    script.type = 'text/javascript';
    script.defer = true;

    document.getElementsByTagName('head').item(0).appendChild(script);

}

/* include any js files here */
include('js/common.js');

function checkLogin(objName)
{
    if (objName.username.value == "")
    {
        alert("Ban phai nhap vao ten dang nhap!");
        objName.username.focus();
        return false;
    }

    if (objName.password.value == "")
    {
        alert("Ban phai nhap vao mat khau!");
        objName.password.focus();
        return false;
    }
    return true;
}

function checkAddGroup(objName)
{
    if (objName.group_name.value == "")
    {
        alert("Ban phai nhap vao nhom nguoi su dung!");
        objName.group_name.focus();
        return false;
    }

    return true;
}

function checkAddCommandCode(objName)
{
    if (objName.keyword.value == "")
    {
        alert("Ban phai nhap vao keyword!");
        objName.keyword.focus();
        return false;
    }
    if (objName.command_code.value == "")
    {
        alert("Ban phai nhap vao command code!");
        objName.command_code.focus();
        return false;
    }
    return true;
}

function checkRegister(objName)
{
    if (objName.fullname.value == "")
    {
        alert("Ban phai nhap vao ho ten!");
        objName.fullname.focus();
        return false;
    }
    if (objName.username.value == "")
    {
        alert("Ban phai nhap vao dinh danh!");
        objName.username.focus();
        return false;
    }

    if (!checkPassword(objName))
    {
        return false;
    }
    return true;
}
function checkUpdateFilm(objName)
{
    if (objName.mt1.value == "")
    {
        alert("Ban can nhap MT1");
        objName.mt1.focus();
        return false;
    }
     if (objName.mt1.value.length >160 )
    {
        alert("Do dai MT1 toi da la 160");
        objName.mt1.focus();
        return false;
    }
    if (objName.mt2.value.length >160 )
    {
        alert("Do dai MT2 toi da la 160");
        objName.mt2.focus();
        return false;
    }

   
    return true;
}
function checkChangePassword(objName)
{
    if (confirm("Ban co thuc su muon doi mat khau khong?"))
    {
        if (!checkPassword(objName))
        {
            return false;
        }
        return true;
    }
    return false;
}

function checkPassword(objName)
{
    if (objName.password.value == "")
    {
        alert("Ban phai nhap vao mat khau!");
        objName.password.focus();
        return false;
    }

    if (objName.confirm_password.value == "")
    {
        alert("Ban phai nhap vao lai mat khau!");
        objName.confirm_password.focus();
        return false;
    }

    if (objName.password.value.length < 6)
    {
        alert("Mat khau phai it nhat 6 ky tu");
        objName.password.value = "";
        objName.confirm_password.value = "";
        objName.password.focus();
        return false;
    }
    if (objName.password.value != objName.confirm_password.value)
    {
        alert("Hai mat khau khong khop nhau");
        objName.password.value = "";
        objName.confirm_password.value = "";
        objName.password.focus();
        return false;
    }
    return true;
}


function setDisable(thisForm, thisMenu, thisText1, thisText2) {
    var textField1 = thisForm.elements[thisText1];
    var textField2 = thisForm.elements[thisText2];
    if (thisMenu.options[thisMenu.selectedIndex].value == "1") {
        textField2.value = "";
        textField2.disabled = true;
        textField1.disabled = false;
        textField1.focus();
    } else {
        textField1.value = "";
        textField1.disabled = true;
        textField2.disabled = false;
        textField2.focus();
    }
}

function bodyLoad() {
    document.frmLogin.username.focus();
}
//-->