function formValidator(from,message)
{
    var kosong = "";

   if((!isEmpty(from)) || (!isEmpty(message)))
   {
    if(!isEmpty(from))
    {
        var kosong = "- From";
    }
    if(!isEmpty(message))
    {
        var kosong = kosong + "\n" + "- Message";
    }
       alert("Please fill in the following field(s): \n" + kosong);
       return false;
   }
   return true;
}

function formSubscriptionValidator(name,email)
{
    var kosong = "";

   if((!isEmpty(name)) || (!isEmpty(email)))
   {
    if(!isEmpty(name))
    {
        var kosong = "- Name";
    }
    if(!isEmpty(email))
    {
        var kosong = kosong + "\n" + "- Email Address";
    }
       alert("Please fill in the following field(s): \n" + kosong);
       return false;
   }

   if(!emailValidator(email, "Please enter a valid email address."))
   {
        return false;
   }
   return true;
}

function formEnquiryValidator(email,message)
{
    var kosong = "";

   if((!isEmpty(email)) || (!isEmpty(message)))
   {
    if(!isEmpty(email))
    {
        var kosong = "- Email";
    }
    if(!isEmpty(message))
    {
        var kosong = kosong + "\n" + "- Message";
    }
       alert("Please fill in the following field(s): \n" + kosong);
       return false;
   }

   if(!emailValidator(email, "Please enter a valid email address."))
   {
        return false;
   }
   return true;
}

function isEmpty(elem)
{
	if(elem.value.length == 0)
    {
        return false;
    }
    else
    {
	    return true;
    }
}

function emailValidator(elem, helperMsg)
{
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp))
    {
		return true;
	}
    else
    {
		alert(helperMsg);
		elem.focus();
		return false;
	}
}