function fnSetUserStatus(type) {    
  $.ajax({
    type: "POST",
    url: '/ajax/doit.htm',
    cache:false,
    success: function(page) {
      if (type == 1) {
        document.location.href = document.location.href;
      } else  {
        $("#app_store").empty().html(page);
        $("#app_store span").fadeIn("slow");
      }
    }
  });  
}

function fnSetUserBind(type, action) {
  if (confirm('Вы уверены?')) {
    $.ajax({
      type: "POST",
      url: '/ajax/dobind-'+type+'-'+action+'.htm',
      cache:false,
      success: function(page) {
        document.location.href = document.location.href;
      }
    });  
  }
}

  
/* Якоря */
jQuery.fn.anchorAnimate = function(settings) { 
  settings = jQuery.extend({
    speed : 1100
  }, settings);  
  
  return this.each(function(){
    var caller = this
    $(caller).click(function (event) {
      event.preventDefault();
      var locationHref = window.location.href;   
      var atr = $(caller).attr("href").split("#");      
      elementClick = "#"+ atr[1] +"";
      var destination = $(elementClick).offset().top;
      $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
        window.location.hash = elementClick;
      });      
      return false;
    })
  })
}  


function SetLoader(win_id) {
  $("#"+win_id+"").html($("#loader").html());
}
        
function fnOpenLink(div, link, sender, obj, funk) {
  SetLoader(div);  
  $.ajax({
    type: "POST",
    url: link,
    cache:false,
    success: function(page) {      
      $("#"+div+"").empty().html(page);
      if (funk) {
        eval(funk);
      }      
    }
  });
} 

function fnMasterReg(id) {
  SetLoader('fancy_content');    
  $.ajax({
    type: "POST",
    url: '/ajax/mregsave-'+id+'.htm',
    cache:false,
    success: function(page) {   
      $("#fancy_content").empty().html(page); 
      document.location.href = document.location.href;
    }
  }); 
}
