function closeLoading(){

 	 
	
	var api = $("#loading").overlay();
	// call it's open() method		
	api.close();
}
	

   //post-submit callback 
  function signupShowResponse(responseText, statusText, xhr, $form)  { 
	  
	  
	  closeLoading();
	  
	  
//	          alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +  '\n\nThe output div should have already been updated with the responseText.'); 
       if(statusText == 'success'){
	       	var response = responseText.split("|");
	       	if(response[0] == 'ERROR'){
	       		alert(response[1]);
	       	} else if (response[0] == 'OK'){
	       		closeAllOverlays();
	       		//alert(response.length);
		       	 if(response.length == 2 )
                         {
                             $('#iframe_movistar').attr('src', response[1]);
                             $('#popup_movistar').overlay({
                                           mask: 	'#000',
                                           top:	"20%",
                                                speed:	200,
                                                oneInstance:  false,
                                            closeOnClick: true});


                                        var api = $("#popup_movistar").overlay();
                                        // call it's open() method		
                                        api.load();
                             
                             //window.location = response[1];
                         }
                         else
                         {

                                 $('#checkpin').overlay({
                                           mask: 	'#000',
                                           top:	"20%",
                                                speed:	200,
                                                oneInstance:  false,
                                            closeOnClick: true});


                                        var api = $("#checkpin").overlay();
                                        // call it's open() method		
                                        api.load();
                         }
		       	 
	       	}
       }
   } 
   
   
   
   function checkPinShowResponse(responseText, statusText, xhr, $form)  { 
	   
	   closeLoading();
	   	//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +  '\n\nThe output div should have already been updated with the responseText.'); 
       
       if(statusText == 'success'){
	       	var response = responseText.split("|");
	       	if(response[0] == 'ERROR'){
	       		alert(response[1]);
	       	} else if (response[0] == 'OK'){
	       		location.href=response[1];
	       	}
       }
   }    
   
   
   function loginShowResponse(responseText, statusText, xhr, $form)  { 
	   closeLoading();
	  //alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +  '\n\nThe output div should have already been updated with the responseText.'); 
      
      if(statusText == 'success'){
	       	var response = responseText.split("|");
	       	if(response[0] == 'ERROR'){
	       		alert(response[1]);
	       	} else if (response[0] == 'OK'){
	       		location.href=response[1];
	       	}
      }
  }    

   
   function showRequest(formData, jqForm, options) { 
	   
	   $('#loading').overlay({
		   //mask: 	'#000',
		   top:	"30%",
			speed:	200,
			close: 'x',
		    closeOnClick: true,
		    oneInstance:  false});
     	 
		
		var api = $("#loading").overlay();
		// call it's open() method		
		api.load();
	   
	
	    // here we could return false to prevent the form from being submitted; 
	    // returning anything other than false will allow the form submit to continue 
	    return true; 
	} 
   
   
   
	function  callAjax( div_id, _url, callback ){
	  var options = { 
        //target:        '#output1',   // target element(s) to be updated with server response 
	    beforeSubmit:  showRequest,  // pre-submit callback 
        success:       callback,  // post-submit callback 
        url:		   _url+'?rand='+Math.floor(Math.random()*1000000)}; 
	  

 
        $("#" + div_id + 'Form').ajaxForm(options); 
        return false; 
  }
   

   		
