$(document).ready(function() {
	var checkUser = function (username) {
		var username = $('#username').val();
		var serviceName  = $('input[name=service]').val() 
		var myRand   = parseInt(Math.random()*99999999);

		var urand = Math.floor(Math.random()*100000);

		//remove all the class add the messagebox classes and start fading
		$("#"+serviceName).html('<img src="images/loading.gif?4">').fadeIn("slow");

		$("#response").html('').fadeOut("fast");

		$.post(
			"php/pars20.php",
			{user: username, service: serviceName, opID: myRand, rand: urand},
			function(data) {
				if(data) { //if username not avaiable
					//$("#"+serviceName).html('<img src="images/loading.gif">').fadeOut("slow");

		$("#"+serviceName).html('').fadeOut("fast");
		$("#response").html('').fadeIn("fast");


$("#response").fadeTo(900,0.1,function() {
//start fading the messagebox
//add message and change the class of the box and start fading
$(this).html(data).fadeTo(900,1);
});		
          		}
			}			
		)
	}
	$("#checkUser").click(checkUser);
});