//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
$(document).ready(function(){
	var u_name = null;
	$("#login_form").submit(function(){
		console.log($('#username').val(),$('#password').val())
		//check the username exists or not from ajax
		$.post("/mug/ajax_login.php",{
			user_name:$('#username').val(),
			password:$('#password').val(),
			rand:Math.random() 
		} ,function(data) {
			  if(data!='no'){
				// if on submit review page
				if($("#login_form").attr("name") == "submitreview"){
					console.log('heck yeah');
					location.reload(true);
				}else{
					$('#dialog').jqmHide();
					location.reload(true);
				}
			  }else{
		  		console.log("login data = "+data);
	          }				
        });
 		return false; //not to post the  form physically
	});
});