function showLoginRevendedores ( title )
{

	var dialog = $('<div style="display:hidden" id="newDialog"></div>').appendTo('body');

	$("#newDialog").html("<image src='../img/progressAnimation.gif'/>");
				
	$("#newDialog").dialog({ 
		bgiframe: true,
		buttons: { "Cancelar": function() { $(this).dialog("close"); }, 
			   "Login": function() { login_agencia(); $(this).dialog("close");}
			 },
		modal: true,
		/*show: 'scale', //Allowed Values: 'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'.
		hide: 'scale', //Allowed Values: 'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'.*/
		title: "" + title,
		height: 277,
		width: 577,
		close: function() {
			//$(this).dialog("close");
			//$("#newDialog").dialog("destroy");
			$("#newDialog").remove();
		},
		dialogClass: "loginRevendedores"
	});
	

	//load Password Reset Form
	//the AJAX request
	$.ajax({
		   type: "GET",
		   url: "../formAgencyLogin.html",
		   success: function( msg ) {
		
				if ( msg != '' ) {
	
					$("#newDialog").html( msg );
					
				}	   	   
	
		   }
	});
	
}


function login_agencia ( )
{
	
	var user = $("#user").val();
	var pass = $("#pass").val();
	
	//the AJAX Login request
	$.ajax({
		   type: "POST",
		   url: "../ajaxLoginAgencia.php",
		   data: "user=" + user + "&pass=" + pass,
		   success: function( msg ) {
												
				if ( msg != '' ) {
					
					arrResponse = msg.split('|||');
					
					if ( arrResponse[0] == 'error' ) {// on error
						alert ( arrResponse[1] );
					} else { 
						if ( arrResponse[1] == "" || arrResponse[1] == "undefined") {
							window.location.reload(false);
						} else {
							window.location = arrResponse[1];
						}
					}
											
				}    	   
	
		   }
	});
	
}
