function check()
{
	var first = document.getElementById('first');
	var last = document.getElementById('last');
	var company = document.getElementById('company');
	var email = document.getElementById('email');
	var form = document.getElementById('requestForm');

	if (isNotEmpty(first) && isNotEmpty(last) && isNotEmpty(company) && isEMailAddr(email))
	{
		return true;
	}
	else return false;
}

// validates that the entry is formatted as an email address
function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Verify the email address format.");
        return false;
    } else {
        return true;
    }
}

// validates that the field value string has one or more characters in it
function isNotEmpty(elem) {
    var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        alert("Please fill in the required field.");
        return false;
    } else {
        return true;
    }
}

function validateLogin (obj)
{
	if (obj.account_id.value=='') { obj.account_id.focus(); return false; }
	if (obj.user_login.value=='') { obj.user_login.focus(); return false; }
	if (obj.user_password.value=='') { obj.user_password.focus(); return false; }
	obj.action='http://demo.aceremoteproject.com/'+obj.account_id.value+'/';
	return true;
}

function toggle_block (id)
{
	obj=document.getElementById(id);
	if (obj)
	{
		obj.style.display=(obj.style.display=='none')? 'block': 'none';
	}
}
