function AJAXReplace(what, where, opt, callback)
{
				
	
				var mod = "#";
				
                //** only once show ajax content
                var a = 0;
				
				if(opt && opt['mod'])
					mod = opt['mod'];
				 
	             $(mod + where).fadeOut(200,
                 function()
                 {
                	 
                	if(opt && opt['relativeLoader'])                		
                	{
                		var style = "position:relative;";
                	}
                	else
                	{	            		            	 
		            	 //** loader prepare
		                	 var w = $(this).css("width");
		                	 w = w.substring(0, w.indexOf("px"));                	 
		                	 w = (w / 2) - 12;
		                	 w = Math.round(w);
		                	 
		                	 var h = $(this).css("height");
		                	 h = h.substring(0, h.indexOf("px"));                	 
		                	 h = (h / 2) - 12;
		                	 h = Math.round(h);
		                	 
		                	 var style = "position:absolute;";
		                	 
		                	 if(w > 0)
		                		 style = style + "padding-left: " + w + "px;";
		                	 else
		                		 style = style + "padding-left: 10px;";
		                	 
		                	 if(h > 0)
		                		 style = style + "padding-top: " + h + "px;";
		                	 else
		                		 style = style + "padding-top: 10px;";
	                	 //** END: loader prepare
                	}
                	 
                	var image = "i-loader0.gif";
	                if(opt && opt['image'])
	                	image = opt['image'];
	                
	                var a = 0;
                	
	                if(opt && opt['isLoader'] == false)
	                {

	                                     $.ajax({
	                                      url: what,
	                                      cache: false,
	                                      type: "POST",
	                                      data: "",
	                                      success: function(html)
	                                      {
 
	                                    	 	$(mod + where).fadeOut(400,
	                                            function()
	                                              {
	                                    	 		if(a < 1)
	    	                            	 		{
	                                    	 			
	                                    	 			$(mod + where).html(html).fadeIn(200);
	                                    	 			if(callback) callback(html); 
		                                    	 		a++;
		                                                
		                                    	 		return html;
	    	                            	 		}
	                                              });
	                      
	                                      }
	                                      
	                                     });
               	
                 	}
	                else
	                {
	                	htmlLoaderContent = '<img src="' + image + '" class="loader" style="' + style + '">';
	                	
                		
	                	$(this).hide().html(htmlLoaderContent).fadeIn(400,	                	
	                	function()
	                    {
	                                     $.ajax({
	                                      url: what,
	                                      cache: false,
	                                      type: "POST",
	                                      data: "",
	                                      success: function(html)
	                                      {
 
	                                    	 	$(mod + where).fadeOut(200,
	                                            function()
	                                              {
	                                    	 		if(a < 1)
	    	                            	 		{
	                                    	 			
	                                    	 			$(mod + where).html(html).fadeIn(200);
	                                    	 			if(callback) callback(html); 
		                                    	 		a++;
		                                                
		                                    	 		return html;
	    	                            	 		}
	                                              });
	                      
	                                      }
	                                      
	                                     });
	                    });	                	
	                
	                }	 
	                
	                
	                
	                	

                 
                 });

};

var ret = "";

function AJAXFormSubmit(what, where, opt, callback)
{
    //disableAllForms();
    
    if(opt != undefined && opt['preload'])
    {
    	
    	if($('#' + opt['preload']).attr('id'))
	    	$('#' + opt['preload']).fadeIn(400);
	    else
	    {
	    	$('#' + what).append('<div class="preload-layer ui-state-active ui-corner-all" id="' + opt['preload'] + '"></div>');
	    	$('#' + opt['preload']).fadeIn(400);	
	    }
    }
    else
    {
	    if($('#preloadLayer').attr('id'))
	    	$('#preloadLayer').fadeIn(400);
	    else
	    {
	    	$('#' + what).append('<div class="preload-layer ui-state-active ui-corner-all" id="preloadLayer"></div>');
	    	$('#preloadLayer').fadeIn(400);	
	    }    
    }
    


    
    
   

	var options = 
	{
		timeout: 30000,
        success: function(html)
        {                                            	          		    		 		
		    	$("#" + where).html(html);
		    	
		    	
		    	if(callback) callback(html);  	 		 		
		       
		    	//onEveryAjax();
		        //enableAllForms();
		        
		        $('#ajaxExecuteTime').remove();
		                    
		        if(opt != undefined && opt['preload'])
		        	$('#' + opt['preload']).fadeOut(200); 
		        else		        
		        	$('#preloadLayer').fadeOut(200);
        }      
	};
	

    if(opt != undefined && opt['clear'])
    	options['clearForm'] = opt['clear'];


    if(opt != undefined && opt['reset'])
    	options['resetForm'] = opt['reset'];

    
    
	$("#" + what).ajaxSubmit(options);

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000


        //$("#" + where).html('<img src="./img/main/loader.gif" class="'+ preloaderClass + '">');
        // inside event callbacks 'this' is the DOM element so we first
        // wrap it in a jQuery object and then invoke ajaxSubmit

       return false;

};








