// JavaScript Document


function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function isEmail(val) {
	var regexpEmail = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
	return regexpEmail.test(val);
}

function submitComment() {
	$("comment").value = trim($F("comment"));
        if($F("comment") == '') {
                alert("Please enter your comment");
                $("comment").select();
                return;
	}else {
		new Ajax.Request('rl/comments_post.php', {method:'post', postBody:Form.serialize("comments_form"), evalScripts:true, 
			onComplete:function(r){
				alert(r.responseText);
				if (r.responseText.indexOf("posted") != -1)
					$('cmtClose').lbox.deactivate();
			}
		});
	}
}

function sendPM() {
	$("message").value = trim($F("message"));
	$("uname").value = trim($F("uname"));

	if($F("uname") == '') {
		alert("Please enter an username");
		$("uname").select()
	}
        else if($F("message") == '') {
                alert("Please enter your message");
                $("message").select();
                return;
	}else {
		new Ajax.Request('private-messages.php', {method:'post', postBody:Form.serialize("pm_form"), evalScripts:true, 
			onComplete:function(r){
				alert(r.responseText);
				if (r.responseText.indexOf('successfully') != -1)
					$('cmtClose').lbox.deactivate();
			}
		});
	}
}

function blink(obj) {
	if(obj.value == '') {
		//obj.value = ' ';
		obj.select();
	}
}

