var hints;
var help_flag=0;
var questions_flag=1;
var comment_hover=0;
var bookmarks_show=false;
var count_groups=0;
var screenW;
var screenH;

function fillLinks(){if($.browser.msie) $("div.link").hover(function(){$(this).addClass("jshover")},function(){$(this).removeClass("jshover")}); else fixOpera();}// прописываем действия при наведении на закладку
function fillComments(){$("div.link").hover(function(){$(this).find('.info .comments').hover(function(){if (hints=='on') $(this).parent('.contain').css("z-index",98).find('.show_comment_popup').show();},function(){});},function(){$(this).find('.info .contain').css("z-index",1).find('.show_comment_popup').hide();});}
function fillUserlist(){if($.browser.msie) $("div.ulhovered div.user").hover(function(){$(this).addClass("uhover")},function(){$(this).removeClass("uhover")})}// прописываем действия при наведении на иконку юзера (только для IE)
function checkHeader(){if ($.cookie('header')=='compact') {$('#header').hide();$('#header-up').hide();$('#header-down').show();$('#cabinet-btn').show();}}// проверяем header
function checkHints(){if ($.cookie('hints')==null) hints='on'; else hints=$.cookie('hints'); if (hints=='off') $('#promts').addClass('promts_off'); else $('#promts').removeClass('promts_off');}// проверяем статус всплывающих комментариев
function countOrange(){var firstrun_count=0;firstrun_count=parseInt($.cookie('firstrun_count'));if (!firstrun_count) firstrun_count=1; else if (firstrun_count>1) $.cookie('firstrun', 'hidden'); else firstrun_count+=1;$.cookie('firstrun_count', firstrun_count);}// проверяем и прячем оранжевую плашку после 2 переходов
function reloadPage(){$('body').css("display","inline").css("display","block");}// чтобы не пёрло браузеры при изменении контента


$(document).ready(function(){
checkHeader();
if ($.cookie('firstrun')=='hidden') $('#firstrun').hide(); else countOrange();
if ($.cookie('notice')=='hidden') $('#notice').hide();
if ($.cookie('messages')=='hidden') $('#messages').hide();
if ($.cookie('yandexdirect')=='hidden') $('#yandexdirect').hide();
checkHints();
countOrange();
reloadPage();
});

function toggleHint(current){if ($('#promts').is(".promts_off")) {$('#promts').removeClass('promts_off');$.cookie('hints','on');hints='on';} else {$('#promts').addClass('promts_off');$.cookie('hints','off');hints='off';}return false;}// переключатель подсказок
function headerUp(){$.cookie('header','compact');$('#header').hide();$("#cabinet-btn").show();$('#header-down').show();return false;}// прячем header
function headerDown(){$.cookie('header',null);$('#header').show();$("#cabinet-btn").hide();$('#header-down').hide();return false;}// показываем header

function getResolution() {if (self.screen) {screenW=document.body.clientWidth;screenH=document.documentElement.clientHeight;}else if(self.java){var jkit = java.awt.Toolkit.getDefaultToolkit();var scrsize = jkit.getScreenSize();screenW = scrsize.width;screenH= scrsize.height;}}
function hidePopups(){$('#login').hide();$('#feedback').hide();};// прячем формы
function showPopup(name,noReset){$('#'+name).show();if(!noReset)$('#'+name+' form')[0].reset();return false;};// показываем попап
function showCenter(name,pTop,pLeft){getResolution();var vTop=screenH/2+pTop;var vLeft=screenW/2+pLeft;$('#'+name).css({top:vTop,left:vLeft}).show();}// показываем попап в центре экрана
function hidePopup(name){$('#'+name).hide();return false;}// прячем попап
function hidePanel(name){$.cookie(name,'hidden');$('#'+name).hide(reloadPage());return false;}// прячем панель
function fixOpera(){if($.browser.opera){$('head').append("<link rel='stylesheet' href='css/opera.css' type='text/css' media='all'/>");$('.link div.contain .block').wrap('<div class="contain2"></div>');$('.link div.contain .show_comment_popup').wrap('<div class="contain2"></div>');reloadPage();}}
function setZ(current,num){$(current).parents('.contain').css("z-index",num);};
function actionsZ(current,num){$(current).parents('li').css("z-index",num).parents('.actions').css("z-index",num);};

function showWriteComment () {$('#link_write_comment').show(reloadPage());formFocus ('link_write_comment');$('#link_show_comment').hide();return false;}// показываем "добавить комментарий"
function hideWriteComment () {$('#link_write_comment').hide(reloadPage());$('#link_show_comment').show();return false;}

function showFull (current) {$(current).parent().hide().parent().find('.full').css('display','inline');return false;}


function formFocus (name, idname) {
if (!idname) $('#'+name+' input:text')[0].focus();
else $('#'+idname)[0].focus();
}
