function validMsg() {
	var frm = document.form1;	
	if( strEmpty(frm.fv_name.value) ) {
		alert("Please enter your name!");		
		frm.fv_name.focus();
		return false;
	}
	if( !isValidEmail(frm.fv_email.value) ) {
		alert("Please enter a valid email address!");		
		frm.fv_email.focus();
		return false;
	}
	if( frm.fv_topic.selectedIndex == 0 ) {
		alert("Please select a topic.");		
		frm.fv_topic.focus();
		return false;
	}
	if( strEmpty(frm.fv_msg.value) ) {
		alert("Please enter your message!");		
		frm.fv_msg.focus();
		return false;
	}
	return true;
}


function strEmpty( str ) {	
	if( str.length == 0 ) return true;		
	var trimstr = str.replace(/(^\s*)|(\s*$)/g, "");
	if( trimstr.length == 0 ) return true;	    
    return false;
}

function isValidEmail(s)
{   if (strEmpty(s)) return false;       
      
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
	
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
	
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
	
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}