/* Главная страница
----------------------------------------------- */
	/* -----------| Авторизация |----------- */  
		function setCookie(name, value, expire)
		{
				document.cookie = name + "=" + value + "; path=/; expires=" + expire;
		}
		
		function getCookie(name) {
		  var search = name + "=";
		  if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			if (offset != -1) {
			  offset += search.length;
			  end = document.cookie.indexOf(";", offset);
			  if (end == -1) end = document.cookie.length;
			  return unescape(document.cookie.substring(offset, end));
			}
		  }
		}
		
		var today = new Date();
		var expires = new Date(today.getTime() + (56 * 86400000));
		setCookie("chbx","guest",expires);
		
		if (document.cookie.indexOf('__utm') >= 0)
		{
				document.cookie = "__utma=0; path=/; domain=.liveinternet.ru; expires=Sat, 09 Dec 2000 21:00:00 GMT";
				document.cookie = "__utmb=0; path=/; domain=.liveinternet.ru; expires=Sat, 09 Dec 2000 21:00:00 GMT";
				document.cookie = "__utmc=0; path=/; domain=.liveinternet.ru; expires=Sat, 09 Dec 2000 21:00:00 GMT";
				document.cookie = "__utmz=0; path=/; domain=.liveinternet.ru; expires=Sat, 09 Dec 2000 21:00:00 GMT";
		}
		
		var username = getCookie("bbusername");
		var bbjurl = getCookie("jurl");
		var jurl = bbjurl;
		var bbuserid = getCookie("bbuserid");
		var userid = getCookie("bbuserid");
		var sstyle = getCookie("ucss");
		var sava = getCookie("ava");
		
		if (jurl!=null)
		{
				var domain = (jurl.indexOf('liveinternet.ru')==-1)?jurl:"http://www.liveinternet.ru/";
		}
		else
		{
				var domain ="http://www.liveinternet.ru/";
		}
		
		if ((bbjurl != null) && (bbjurl != ""))
		{
				var last=bbjurl;
		}
		else
		{
				if ((bbuserid != null) && (bbuserid != ""))
				{
						var last="/users/"+bbuserid;
			}
				else
				{
						var last="/users/"+username;
				}
		}
		
		if ((username != null)&&(username != "deleted")&&(username != ""))
		{
				var auth=1;
		}
		else
		{
				var auth=0;
		}  
		  
  
  /* -----------| Управление хоткеями |----------- */       
    /* - Инициализируем функцию управления - */
    function inithotkeys() 
    {
      document.onkeydown = register;
    }
    /* - Реакция клавиш на нажатие - */
    function register(e) 
    {
      if (!e) e = window.event;
      var k = e.keyCode;

      if (e.ctrlKey) 
      {
        if (k == 90) 
        {
          popopen('PopStat');
        }
        if (k == 88) 
        {
          popopen('PopDiary');
        }
        if (k == 67) 
        {
          popopen('PopMail');
        }       
      }
    }    
    
  /* -----------| Фокус на поле ввода, курсор в конце строкик |----------- */    
    function inputfocus ()
    {
      var inputname=document.getElementById('GlobalSrcFormRTxt'); 
      /* - Отбрасываем в конец строки в Ишаке - */
      if (inputname.selectionStart)
      {
        var end = inputname.value.length;
        inputname.setSelectionRange(end,end);
        inputname.focus();
      }
      /* - Отбрасываем в конец строки в Мозиллах - */
      if (inputname.createTextRange)
      {
        var r = inputname.createTextRange();
        r.collapse(false);
        r.select();
      }                
    }   

	/* -----------| Попапчики |----------- */      
		function popclose (popid)
		{	
			document.getElementById(popid).style.display='none';
		}
		
		function popopen(popid) 
		{
			if (popid=='PopStat')
			{
				popclose ('PopDiary');
				popclose ('PopMail');
			}
			if (popid=='PopDiary')
			{
				popclose ('PopStat');
				popclose ('PopMail')
			}
			if (popid=='PopMail')
			{
				popclose ('PopStat');
				popclose ('PopDiary');
			}
			
			document.getElementById(popid).style.display='block';
		}
