function showLoginBox(phoneNumber, redirectUrl,inButtons){
	var defaultPhone = phoneNumber ? phoneNumber : '';
		$("#jquery_box").html("<center>"
									+ "<label for='tel'>"+labelTel+"</label>" 
										+ "<br/><input type='text' id='tel' value='"+defaultPhone+"' />"
									+ "<br/><br/><label for='password'>"+labelPassword+"</label>" 
										+ "<br/><input type='password' id='password' value='' />"
								+"</center>");
		var buttonsArray = inButtons ? inButtons : {};
		buttonsArray['Ok'] = function() 
		{
			$.post("/ajax/login.php", {'tel' : $('#tel').val(), 'password' : $('#password').val() },
			function(data)
			{
				manageLoginData(data,redirectUrl ? redirectUrl : false);
			}
			,"json");
		};
		$("#jquery_box").dialog(
							{
								buttons: buttonsArray,
								position: 'center',
								title: titleLoginBox,
								//height: "280",
								stack: false,
								width:"350",
								resizable: false,
								 close: function(event, ui) {$(this).dialog("destroy"); }
							}
		);
}

function manageLoginData(data,redir){
	if(data.valid){
		redirect = redir ? redir : data.redirect;
		$('#jquery_box').dialog("destroy");
		if(data.message){
			$("#jquery_dialog").html(+data.message);
			$("#jquery_dialog").dialog(
					{
						buttons: {'Ok' : function(){
							if(redirect)
								window.location = redirect;
							else
								window.location.reload();
						}},
						position: 'center',
						title: titleLoginBox,
						height: "280",
						stack: false,
						resizable: false,
						close: function(event, ui) {
							if(redirect)
								window.location = redirect;
							else
								window.location.reload();
						}
					}
			);
		}
		else{
			window.location = redirect;
		}
	}
	else{
		$("#jquery_dialog").html("<div class='msg_alert'>"+data.message+"</div>").dialog(
				{
					buttons: {'Ok' : function(event, ui) { $(this).dialog('destroy'); }},
					position: 'center',
					title: titleLoginBox,
					height: "280",
					stack: false,
					resizable: false,
					close: function(event, ui) { $(this).dialog('destroy'); }
				}
		);
	}
}

(function($){  
	$.fn.showLockBack = function(){
		$('#lockBack').height($(document).height()).css('opacity','0.5').show();
	}
	

})(jQuery); 
(function($){  
	$.fn.hideLockBack = function(){
		$('#lockBack').hide();
	}
})(jQuery); 