
$(document).ready(function(){

  var allowSend = 1;

  $("#nav > li").hover(
    function(){$(this).addClass("jshover")},
    function(){$(this).removeClass("jshover")}
  );

  if($("a.commentsA").length > 0)
    $("p.serv_info").hide();

  $("div.date").append("<img height=\"9\" width=\"9\" title=\"Сегодня\" alt=\"Сегодня\" src=\"/images/date.gif\"/>&nbsp;<span id='curDate'></span>, <img height=\"9\" width=\"9\" title=\"Время\" alt=\"Время\" src=\"/images/time.gif\"/>&nbsp;<span id=\"curTime\"></span>");
  getCurTime();

 /////////////////////////////////////
 // Rating functions
 /////////////////////////////////////

  var curObj;

  $(".ratingForm .star-rating").click(function(){
    var newRating = $(this).parents(".ratingForm").children(".star-rating-control").children(".star-rating-on").length;
    $(this).parents(".ratingForm").children("input[name='f_rateCount']").attr("value",newRating);
    $(this).parents(".ratingForm").submit();
  });

  $(".ratingForm").submit(function(){
    if($(this).children("input[name=f_rateSent]").val() == 0) {
      vurObj = $(this);
      $(this).ajaxSubmit(setRateOptions);
    }
    return false;
  });

  // options
  var setRateOptions = { 
    target: "",
    beforeSubmit: showRequest,
    success: showResponse,
    timeout: 3000
  };

  // Actions before sending form
  function showRequest(formData, jqForm, options) { 
//    var queryString = $.param(formData); 
//    alert('Вот что мы передаем: \n\n' + queryString); 
    vurObj.children(".rateSend").show();
    return true; 
  } 

  // Callback function
  function showResponse(responseText, statusText)  {
    // submit of loaded form for a form turned back from a server
    var input_file = responseText.substring(responseText.indexOf("<!--BEGIN CONTENT-->"),responseText.indexOf("<!--END CONTENT-->"));
//    alert(input_file);
    vurObj.children(".thanks").fadeIn("slow");
    vurObj.children(".tech").html(input_file);
    vurObj.children(".rateSend").hide();
    vurObj.children("input:radio").each(function(){
      $(this).attr("disable","disabled");
    });
    vurObj.children("input[name=f_rateSent]").val("1");
  }

/*

  // Скрываем комменты, если есть ссылка на них
  // И не скрываем, если есть #comment
  if($("div.comment > h2 > a").length > 0 && window.location.hash!="#comments")
    $("div.comment > div").hide();

  $("a.toComments").click(function(){
    $("div.comment > div:hidden").toggle("slow");
    return true;
  });

  $("div.comment > h2 > a").click(function(){
    $("div.comment > div").toggle("slow");
    return false;
  });

*/
/*
  $("div.comment > h2 > a").click(function(){
    if($("div.comment_list").html() == "")
    {
      $("div.loading").fadeIn("slow");
      $("div.comment_list").hide();
      var ajURL = $(this).attr("href").substr(0,$(this).attr("href").indexOf("#"))+"&a=1";
      $("div.comment_list").load(ajURL+" div.comment_list","",function(data){ 
        $("div.loading").fadeOut("slow",function(){
          alert(data);
          $("a.commentsA").click(function(){
            eval("$('a.commentsA').attr('onclick')");
          });
          $("div.comment_list").slideDown("slow");
        });  
      });
    }
    return false;
  });
*/

  // Скрываем сеансы на другие дни
  $("#otherDays").hide();
  $(".otherDaysLinkShow").show();

  $(".otherDaysLinkShow").click(function(){
    $("#otherDays").slideDown();
    $(".otherDaysLinkShow").hide();
    $(".otherDaysLinkClose").show();
  });

  $(".otherDaysLinkClose").click(function(){
    $("#otherDays").slideUp();
    $(".otherDaysLinkClose").hide();
    $(".otherDaysLinkShow").show();
  });

  $("p.hdr3.catalog:first").addClass("firstH3");
  $("p.hdr3.catalog").prev("span.catalog").each(function(){
    var thisText = $(this).html();
    $(this).html(thisText.substring(0,thisText.length-1)+".");
  });
//  $("span.catalog").each(function(){
//  if($(this).next())
//  });

// end of document.ready
});

var months = new Array("января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря");
var days = new Array("воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота");

function getCurTime()
{
  var curTime = new Date();
  var timeString = curTime.getHours();
  (curTime.getSeconds()%2!= 0 ? timeString += ":" : timeString += "<span style='visibility:hidden;'>:</span>");
  (curTime.getMinutes().toLocaleString().indexOf(",")!= -1 ? curTimeMinutes = curTime.getMinutes().toLocaleString().substr(0,curTime.getMinutes().toLocaleString().indexOf(",")) : curTimeMinutes = curTime.getMinutes().toLocaleString());
  (curTimeMinutes.length != 2 ? timeString += "0"+curTimeMinutes : timeString += +curTimeMinutes);

  var dateString = curTime.getDate()+" "+months[curTime.getMonth()]+", "+days[curTime.getDay()];

  $("#curDate").html(dateString);
  $("#curTime").html(timeString); //+":"+curTime.getSeconds()
  setTimeout("getCurTime()",1000);
}
