function textCounter(field,maxlimit) {
    // text width//
    var fieldWidth = parseInt(field.offsetWidth);
    var charcnt = field.value.length;
    // trim the extra text
    if (charcnt > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    }
}

function right(e)
{
    if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
        return false;
    else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
    {
        alert("[ Warning !!!, you can't use right click ]");
        return false;
    }
    return true;
}

document.onmousedown = right;
document.onmouseup = right;

/*Begin open frame*/
function openNewWindow(url,w,h)
{
    var prop = "\"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10,top=10,width="+w+",height="+h+"\"";
    //alert(prop);
    window.open(url,"newwindow",prop);
}

function openNewFullWindow(url)
{
    window.open(url,"newfullwindow");
}
/*End open frame*/

function verifyFriedns()
{
    friendsName = document.all.friendsName.value;
    friendsEmailMsn = document.all.friendsEmailMsn.value;
    friendsDetail = document.all.friendsDetail.value;
    error="";
    
    if(friendsName == "")
    {
        error+="\n*- ชื่อ";
    }
    if(friendsEmailMsn == "")
    {
        error+="\n*- อีเมล";
    }
    if(friendsDetail == "")
    {
        error+="\n*- ข้อความแนะนำตัว";
    }
    if(error!="")
    {
        alert("ข้อมูลไม่ถูกต้อง"+error);
        return false;
    }
    return true;
}

function complete()
{
    alert('ข้อความของคุณถูกส่งแล้ว');
    closeWindow();
    return true;
}

function error()
{
    alert('ไม่สามารถส่งข้อความได้');
    closeWindow();
    return true;
}

function closeWindow()
{
    if (navigator.appName != "Microsoft Internet Explorer")
    { // เปิดโดย IE
        window.open('','_parent','');
        window.close();
    }else
    { // ไม่ใช่ IE
        window.opener=null;
        window.close();
    }
}

