function AJAXReplace(what, where, opt)
{
				
	
				var mod = "#";
				
                //** only once show ajax content
                var a = 0;
				
				if(opt && opt['mod'])
					mod = opt['mod'];
				 
	             $(mod + where).fadeOut(400,
                 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-loader.gif";
	                if(opt && opt['image'])
	                	image = opt['image'];
	                
	                var a = 0;
	                	 
	                //$(this).hide().html('<img src="' + image + '" class="loader" style="' + style + '">').fadeIn(10,
	                $(this).hide().html('').fadeIn(10,	
                		function()
	                    {
	                                     $.ajax({
	                                      url: what,
	                                      cache: false,
	                                      type: "POST",
	                                      data: "isAjax=1",
	                                      success: function(html)
	                                      {
 
	                                    	 	$(mod + where).fadeOut(400,
	                                            function()
	                                              {
	                                    	 		if(a < 1)
	    	                            	 		{
		                                    	 		$(mod + where).html(html).fadeIn(400);
		                                    	 		a++;
		                                                //onEveryAjax();	    	                            	 			
	    	                            	 		}
	                                              });
	                      
	                                      }
	                                      
	                                     });
	                    });
                 
                 });

};

function AJAXFormSubmit(what, where, callback)
{
         //if(preloaderClass == undefined) preloaderClass = "preloader";
         //document.getElementById(where).innerHTML = '<img src="./img/main/loader.gif" class="'+ preloaderClass + '">';
         //return HTML_AJAX.formSubmit(what, where);
     
     var options = {
        success: function(html)
          {                           
                
    	       
    	 $("#" + where).fadeOut(400,
                function()
                {
    		 		if(callback) callback();      
   		    		 
    		 		$(this).html(html).fadeIn(600);

                   // onEveryAjax();

                });
          }
        };

//      if(whatwhere == "what")
//      {
//        $("#" + what).ajaxSubmit(options).html('<img src="./img/main/loader.gif" class="'+ preloaderClass + '">');
//      };

       $("#" + what).ajaxSubmit(options);
     
     //document.getElementById(where).innerHTML = '<img src="./img/main/loader.gif" class="'+ preloaderClass + '">';
       //$("#" + where).html('<img src="./img/main/loader.gif" class="'+ preloaderClass + '">');
       //$("#" + what).fadeOut(400,
      // function()
       //{
              //$("#loaderLayer").css("visibility", "visible").fadeIn(400,
              //function()
              //{
                //$("#" + what).ajaxSubmit(options);
                //onEveryAjax();
              //});
       
       
       //});

        // 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;
};






