$(document).ready(function(){
  $("#overlay").height($("body").height());
  btnInit();
  $(".mitem").hover(function(){
    $(this).addClass("act");
  },function(){
    $(this).removeClass("act");
  });
  $("#pdelim").height($("#answ").height()-10);
  iload(['../img/btn_a.gif','../img/pbtn_a.gif','../img/close_a.gif']);
  $("#pbtn").hover(function(){
    $(this).css('background','url(\'../img/pbtn_a.gif\')');
    $(this).css('color','#fff');
  },function(){
    $(this).css('background','url(\'../img/pbtn.gif\')');
    $(this).css('color','#000');
  });  
  // Added by ARTFLAME {
  $("#redbox").hover(function(){
    $("#redbox h2").fadeOut('fast');
    $("#redbox div").fadeOut('fast');
    $("#redbox h2.read").fadeIn('fast');
    $("#redbox h2.write").fadeIn('fast');
  },function(){
    $("#redbox h2").fadeIn('fast');
    $("#redbox div").fadeIn('fast');
    $("#redbox h2.read").fadeOut('fast');
    $("#redbox h2.write").fadeOut('fast');
  });

  $("#redbox h2.read").hover(function(){
    $(this).css('text-decoration','underline');
  },function(){
    $(this).css('text-decoration','none');
  });
  $("#redbox h2.write").hover(function(){
    $(this).css('text-decoration','underline');
  },function(){
    $(this).css('text-decoration','none');
  });

  $("#redbox h2.write").click(function(){
    showModal('sign');
	void(0);
  });
  $("#redbox h2.read").click(function(){
    window.location.replace('/president/a6011145f334982de088f297d7c08b1b/');
	void(0);
  });
  
  
  // }
});
function btnInit(){
  $(".btn").hover(function(){
    $(this).css('background','url(\'../img/btn_a.gif\')');
    $(this).css('color','#fff');
  },function(){
    $(this).css('background','url(\'../img/btn.gif\')');
    $(this).css('color','#000');
  });
}
function showModal(s, i, l){
  $("#modal > :first").load('/modal.php',{act:s, id:i, link: l},function(){
    $("#modal").center();
    $("#modal").slideDown(500,function(){
      $("#overlay").height($("body").height());
    });
  });
  $("#overlay").css('display','block');
  $("#overlay").fadeTo(500,0.8);
  $("#ntv").css('visibility','hidden');
}
function closeModal(callback){
  $("#modal").slideUp(300,function(){
    $("#overlay").fadeTo(300,0,function(){
      $("#overlay").css('display','none');
      $("#ntv").css('visibility','visible');
      if (callback!=undefined) callback();
    });
    $("#modal > :first").html('');
  });
}
function poll() {
  a = $(":input").serializeArray();
  if (a.length == 3 && $.cookie('poll_' + a[1].value) != '1') {
    $.cookie('poll_' + a[1].value, '1', { expires: 1, path: '/'});
    $.post('/modal.php',a,function(data){
      $.cookie('poll_s_' + a[1].value, '1', { expires: 1, path: '/'});
      $("#answ").html(data);
      $("#pdelim").height($("#answ").height()-10);
    });
  } else if (a.length == 2) {
    alert('Выберите вариант');
  } else {
    alert('Вы уже голосовали');
  }
}
$.fn.center=function(){var w = $(window);this.css("position","absolute");this.css("top",(w.height()-this.height())/2+w.scrollTop() + "px");this.css("left",(w.width()-this.width())/2+w.scrollLeft() + "px");return this;}
function iload(img){$("body").append("<div id=\"preload\" style=\"display:none\"></div>");for (var i=0;i<img.length;i++) $("#preload").append("<img src=\""+img[i]+"\" />");}

function commentsForm(id, l) {
 showModal('comments_form', id, l);
}
