function isEmpty(text)
{
    if (text=="") {
        return true;
    }
    else
    {
        return false;
    }
}

function isValidEmail(str){
   var re = /^\w([-\.]?\w+)*\@\w([-\.]?\w+)*\.\w+$/;
   if (str.search(re) != -1)
      return true;
   else 
      return false;
} 

function checkJabberMessage()
{
	var jName, jEmail, jSubject, jMessage;
	jName = document.getElementById("name");
	jEmail = document.getElementById("email");
	jSubject = document.getElementById("subjectname");
	jMessage = document.getElementById("messagedraft");
	
    if(isEmpty(jName.value))
    {
        window.alert("Please fill in the Name field:");
		jName.focus();
    }
	else if(isEmpty(jEmail.value))
    {
        window.alert("Please fill in the Email field:");
				jEmail.focus();
    }
	else if (!isValidEmail(jEmail.value))
	{
        window.alert("Please fill in a valid email address:");
				jEmail.focus();
	}
    else if(isEmpty(jSubject.value))
    {
        window.alert("Please fill in the Subject field:");
				jSubject.focus();
    }
    else if(isEmpty(jMessage.value))
    {
        window.alert("Please fill in the Message field:");
				jMessage.focus();
    }
    else
    {
        document.getElementById("subject").value = jSubject.value;
		document.getElementById("to").value = "udig"+"@"+"amessage.info"
		document.getElementById("message").value = "[" + jName.value + " ("+ jEmail.value + ")" + "] says:\n"+ jMessage.value;
        document.getElementById("jabbermessage").submit();
    }
}

