
function AJ_C(destfield, ajaxpage, params, values, waittext) {
	
	        //Para ver si esta visible
	        var isVis = $(destfield).is(':visible');
		
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	    
			
		var ArrPar = params.split('~');
		var ArrVal = values.split('~');
			
		var strData ="";
		for (i=0; i<ArrPar.length; i++) 
		{
		    if (i==0)
		        {strData += ArrPar[i] + "=" + ArrVal[i]}
		    else
		        {strData += "&" + ArrPar[i] + "=" + ArrVal[i]}
		}
			
	
		if (!isVis && htmlContent == '')
		{
		$(destfield).html(waittext);
		$(destfield).toggle();
		// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
				, dataType:"html"
				, type: "POST"
				, cache: false
				, url: ajaxpage
				, data: strData
					
				// RESULT PARSE -------------------------------
				, success: function(html){$(destfield).html(html);}
				// RESULT PARSE -------------------------------
						
				});
			// AJAX ------------------------------------------------------------------------------			 

		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}

/****** Usar las funciones de aca para abajo.....********************/

function AJ_CG(destfield, ajaxpage, waittext) {
/** Hace get de una page sin parametros **/

	   //Para ver si esta visible
	    var isVis = $(destfield).is(':visible');
		
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	    
		
		if (!isVis && htmlContent == '')
		{
			$(destfield).html(waittext);
			$(destfield).toggle();
			// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
				, dataType:"html"
				, url: ajaxpage
				, cache: false
				, error: function() {$(destfield).html("Request could not be fulfilled.")}
				// RESULT PARSE -------------------------------
				, success: function(html){$(destfield).html(html);}
				// RESULT PARSE -------------------------------
				});
			// AJAX ------------------------------------------------------------------------------			 

		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}




function AJ_N(destfield, ajaxpage, params, values, waittext) {
/** Hace post de una page con 2 array uno con los nombres y otro con los valores de los params **/
	
	    //Para ver si esta visible
	    var isVis = $(destfield).is(':visible');
		
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	    
		if (htmlContent==null) {htmlContent=''};
				
		var strData ="";

		for (x in params)
		{
		if (x==0)
			{strData += params[x] + "=" + values[x]}
		else
			{strData += "&" + params[x] + "=" + values[x]}
		}

		if (!isVis && htmlContent == '')
		{
		
		$(destfield).html(waittext);
		$(destfield).toggle();
		// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
					, dataType:"html"
					, type: "POST"
					, cache: false
					, url: ajaxpage
					, data: strData
					, error: function() {$(destfield).html("Request could not be fulfilled.")}
					// RESULT PARSE -------------------------------
					, success: function(html){$(destfield).html(html);}
					// RESULT PARSE -------------------------------
						
				});
			// AJAX ------------------------------------------------------------------------------			 

		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}



function AJ_M(destfield, ajaxpage, params, waittext) {
/** Hace post de una page con objeto de pares  { nombre : valor, nombre: valor}  **/
	
	    //Para ver si esta visible
	    var isVis = $(destfield).is(':visible');
		
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	    
		if (htmlContent==null) {htmlContent=''};
				
		if (!isVis && htmlContent == '')
		{
		
		$(destfield).html(waittext);
		$(destfield).toggle();
		// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
					, dataType:"html"
					, type: "POST"
					, cache: false
					, url: ajaxpage
					, data:(params)
					, error: function() {$(destfield).html("Request could not be fulfilled.")}
					// RESULT PARSE -------------------------------
					, success: function(html){$(destfield).html(html);}
					// RESULT PARSE -------------------------------
						
				});
			// AJAX ------------------------------------------------------------------------------			 

		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}


function AJ_S(destfield, ajaxpage, params, waittext) {
/** Hace post de una page con los valores de form serializados en string  **/
	    //Para ver si esta visible
	    var isVis = $(destfield).is(':visible');
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	
		if (htmlContent==null) {htmlContent=''};
				
		if (!isVis && htmlContent == '')
		{
		
		$(destfield).html(waittext);
		$(destfield).toggle();
		// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
					, dataType:"html"
					, type: "POST"
					, cache: false
					, url: ajaxpage
					, data: params
					, error: function() {$(destfield).html("Request could not be fulfilled.")}
					// RESULT PARSE -------------------------------
					, success: function(html){$(destfield).html(html);}
					// RESULT PARSE -------------------------------
						
				});
			// AJAX ------------------------------------------------------------------------------			 

		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}


function AJ_S_NC(destfield, ajaxpage, params, waittext) {
/** Hace post de una page con los valores de form serializados en string  **/
	
	/*sin chequear que este lleno o que ya haya sido llamado.*/
		
		$(destfield).html(waittext);
		//$(destfield).toggle();
		// AJAX ------------------------------------------------------------------------------
			$.ajax({  asynch: false
					, dataType:"html"
					, type: "POST"
					, cache: false
					, url: ajaxpage
					, data: params
					, error: function() {$(destfield).html("Request could not be fulfilled.")}
					// RESULT PARSE -------------------------------
					, success: function(html){$(destfield).html(html);}
					// RESULT PARSE -------------------------------
				});
			// AJAX ------------------------------------------------------------------------------			 
	}
	
function AJ_F(destfield, sForm, waittext) {
/** Hace post de una page con el formualario x**/
	
	    //Para ver si esta visible
	    var isVis = $(destfield).is(':visible');
		//Para ver si ya fue llenado o no
		var htmlContent = $(destfield).html();	    
		if (htmlContent==null) {htmlContent=''};
		
		if (!isVis && htmlContent == '')
		{

			$(destfield).html(waittext);
			$(destfield).toggle();
		    
			var options = { // url: 			// override for form's 'action' attribute 
							// type: 			// 'get' or 'post', override for form's 'method' attribute 
							//beforeSubmit:  showRequest,  // pre-submit callback 
							success: function(html){//showResponse;			// post-submit callback 
													$(destfield).html(html);} 
							
							// pre-submit callback 
							,dataType: "html" // 'xml', 'script', or 'json' (expected server response type) 						
							// $.ajax options can be used here too, for example: 
							,asynch: false										
							,cache: false																	
							,error: function(){$(destfield).html("Request could not be fulfilled.")}	
							//,error: function(html){//showResponse;			// post-submit callback 
													//$(destfield).html(html);} 
							
						}; 
 
			// bind form using 'ajaxForm' 
			//alert("aca");
			$(sForm).ajaxSubmit(options); 
			return false;
		}//if (!isVis) 
		else
		{			
		$(destfield).toggle();
		}
	}
	
	
function AJ_F_car(destfield, sForm, waittext) {
/** Hace post de una page con el formualario x**/
			$(destfield).html(waittext);
			$(destfield).toggle();
			var options = { // url: 			// override for form's 'action' attribute 
							// type: 			// 'get' or 'post', override for form's 'method' attribute 
							//beforeSubmit:  showRequest,  // pre-submit callback 
							success: function(html){//showResponse;			// post-submit callback 
													$(destfield).html(html);} 
							
							// pre-submit callback 
							,dataType: "html" // 'xml', 'script', or 'json' (expected server response type) 						
							// $.ajax options can be used here too, for example: 
							,asynch: false										
							,cache: false																	
							,error: function(){$(destfield).html("Request could not be fulfilled.")}							
							
						}; 
 
			// bind form using 'ajaxForm' 
			//alert("aca");
			$(sForm).ajaxSubmit(options); 
			return false;
}

function showRequest(formData, jqForm, options) 
{ 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
	 
    alert('About to submit: \n\n' + queryString); 
     
    // 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; 
} 


// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
	
} 

