$(document).ready(function() { 
						   
	$('#question').focus(function() {
		if ($('#question').val() == "Enter your question here...")
			$('#question').val('');
    })
	
	$('#question').blur(function() {
		if ($('#question').val() == "")
			$('#question').val('Enter your question here...');
    })
						   
	$('form#askExpertForm').submit(function() {
		
		$errors = new Array();
											 
		if ($('#question').val() == "") 
			$errors.push("Please enter your question before submit form!");
			
		if ($('#question').val() == "Enter your question here...") 
			$errors.push("Please enter your question before submit form!");
			
		if ($errors.length > 0) {
			$msg = "<ul>";
			for($x = 0; $x < $errors.length; $x++) {
				$msg += "<li>" + $errors[$x] + "</li>";
			}
			$msg += "</ul>";
			
			$.jGrowl('<div style="height: 10px"></div><div class="errors">'+$msg + "</div>", {
				theme: 	'error',
				header: 'ERROR',
				life:	5000,
				sticky: false
			});	
			
		} else {
			
			$.ajax({
				type: "POST",
				url: baseUrl + "/expert/sendquestion",
				data: "question="+ $('#question').val(),
				success: function(del) {
					switch(del) {
						case "QUESTION_EMPTY" :
							$.jGrowl('<div style="height: 10px"></div>Please enter your question before submit form!', {
								theme: 	'error',
								header: 'ERROR',
								life:	5000,
								sticky: false
							});	
							break;
						case "FAILURE" :
							$.jGrowl('<div style="height: 10px"></div>There occured an error sending your question!', {
								theme: 	'error',
								header: 'ERROR',
								life:	5000,
								sticky: false
							});	
							break;
						case "SUCCESS" :
							changeLocation('/messages/exthankyou');
					}
				}, 
				error : function(del) {
					alert("Error posting data!");
				}

			});

			
		}
		
		return false;
		
	});

});