$(function()
{
  $("img.loader").bind("ajaxStart", function() { $(this).show(); }).bind("ajaxStop", function() { $(this).hide(); });
  if ($.hasFlashPlayer) {
    var params = { wmode: "transparent", allowFullScreen: false, quality: "high", bgcolor: "#f9f7f6" };
    $("div.logo").flash({
      swf: host + "/design/logo.swf",
      width: 246, height: 78, params: params
    });
    $("div.index-flash > div").flash({
      swf: host + "/design/flash.swf",
      width: "100%", height: 373, params: params
    });
    $("div.custom-rt").flash({
      swf: host + "/design/custom_rt.swf",
      width: 198, height: 231, params: params
    });
    $(window).bind("load, resize", function()
    {
      var width = $("html").innerWidth();
      if (width < 980) $("div.custom-rt").hide(); else $("div.custom-rt").show();
    });
  }
  $("div.dropdown").bind("click", function()
  {
    $(this).children("div.list").slideToggle(250);
  });
  $("div.dropdown > div.list > div").each(function()
  {
    $(this).hover(function() { $(this).addClass("over") }, function() { $(this).removeClass("over") });
    $(this).bind("click", function()
    {
      $(this).parent().parent().children("div.label").text($(this).text());
      var id = $(this).attr("id").substr(1);
      var newDate = new Date;
      $.get("xml/tariff.jsx", {"id": id, "no_cache": newDate.getTime()}, function(json)
      {
        for (var key in json) $("#"+key).html(json[key]);
      }, "json");
    });
  });
  $("#lang_"+lang).replaceWith("<span>"+$("#lang_"+lang).html()+"</span>");
  $("div.topmenu > a, div.quickmenu > a").each(function()
  {
    if ($(this).attr("href") == window.location.href) {
      var html = $(this).html().replace("off.gif", "on.gif");
      $(this).replaceWith("<span>"+html+"</span>");
    }
  });
});
