function isEmpty(s)
      { return ((s == null) || (s.length == 0)) }

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function enable_disable()
{
	//if(!document.form_signup.chk_agree.checked)
		document.form_signup.btn_submit.disabled=false;
	//else
	//	document.form_signup.btn_submit.enabled=false;
}

function validate_signup()
{
	if(isEmpty(document.form_signup.inp_id.value))
	{
		alert("Please input User ID for registration");
		return false;
	}
	if(isEmpty(document.form_signup.inp_pass1.value))
	{
		alert("Please specify the password");
		return false;
	}
	if(isEmpty(document.form_signup.inp_pass2.value))
	{
		alert("Please reenter the password");
		return false;
	}
	if(isEmpty(document.form_signup.inp_email.value))
	{
		alert("Please provide you valid email");
		return false;
	}
	if(!isEmail(document.form_signup.inp_email.value))
	{
		alert("Please provide a valid email address");
		return false;
	}
	if(document.form_signup.inp_pass1.value!=document.form_signup.inp_pass2.value)
	{
		alert("The two passwords you provided did not match");
		return false;
	}
	if(!document.form_signup.chk_agree.checked)
	{
		alert("You must accept the terms and conditions before continuing registration");
		return false;
	}
	return true;
}

function validate_contactus()
{
	if(isEmpty(document.form_contact.inp_name.value))
	{
		alert("Please specify your name");
		return false;
	}
	if(isEmpty(document.form_contact.inp_email.value))
	{
		alert("Please specify your email");
		return false;
	}
	if(isEmpty(document.form_contact.inp_country.value))
	{
		alert("Please specify your country");
		return false;
	}
	if(isEmpty(document.form_contact.inp_comments.value))
	{
		alert("Comments should not be empty");
		return false;
	}
	if(!isEmail(document.form_contact.inp_email.value))
	{
		alert("Please provide a valid email address");
		return false;
	}

	return true;
}