var wnd,txt;
onerror=function(){return(true)};
try {
	if (self.parent.frames.length!=0) self.parent.location = document.location;
} catch(exp) {}

function setCookie(name, value, expires, path, domain, secure)
{
    if (!name || !value) return false;
    if (!path) path = '/';

	var str = name + '=' + encodeURIComponent(value);

	if (expires) str += '; expires=' + expires.toGMTString();
	if (path)    str += '; path=' + path;
	if (domain)  str += '; domain=' + domain;
	if (secure)  str += '; secure';

	document.cookie = str;
	return true;
}

function getCookie(name)
{
	var pattern = "(?:; )?" + name + "=([^;]*);?";
	var regexp  = new RegExp(pattern);

	if (regexp.test(document.cookie))
	return decodeURIComponent(RegExp["$1"]);

	return false;
}

function deleteCookie(name, path, domain)
{
	setCookie(name, null, new Date(0), path, domain);
	return true;
}

function paste()
{
    if (wnd.document.getElementById("target"))
        wnd.document.getElementById("target").innerHTML=txt;
    else
        setTimeout('paste()',100);
}

function ipaste()
{
    if(wnd.document.getElementById("target"))
    {
        wnd.moveTo(0,0);
        wnd.resizeTo(screen.availWidth,screen.availHeight);
        wnd.document.getElementById("target").src=txt;
        wnd.document.getElementById("target").alt="";
        wnd.document.getElementById("target").title="Закрыть окно";
    }
    else
        setTimeout('ipaste()',100);
}

function printme(postid)
{
    txt=document.getElementById(postid).innerHTML;
    wnd=eval('win'+'dow.o'+'pen'+'("print.html","_blank")');
    setTimeout('paste()',500);
}

function showme(lnk)
{
    txt=lnk.href;
    wnd=eval('win'+'dow.o'+'pen'+'("show.html","_blank")');
    setTimeout('ipaste()',500);
}

function dropShadow()
{
    var st=document.createElement("link");
    st.setAttribute("rel","StyleSheet");
    st.setAttribute("href","../shadow.css");
    document.body.appendChild(st);
}

function initShowBox()
{
    var anchors=document.getElementsByTagName('a');
    for(var i=0;i<anchors.length;i++)
    {
        var anchor=anchors[i];
        var relAttribute=String(anchor.getAttribute('rel'));
        if(anchor.getAttribute('href')&&(relAttribute.toLowerCase().match('show')))
        anchor.onclick=function(){showme(this);return false;}
    }
    var img=new Image();
    img.src='../img/wait.gif';
    setTimeout('dropShadow()',50);
}

function cl(link)
{
    img=new Image();
    img.src='http://www.liveinternet.ru/click?*'+link;
}

function finderror()
{
    alert("На сайте работает система Orphus (www.orphus.ru)\n\nВыделите орфографическую ошибку мышью и нажмите Ctrl+Enter. \n\nСделаем язык чище!");
}

function toggle_cmt()
{
    var div_comm = document.getElementById('comments_tabs');
    if (div_comm.style.display == 'none')
    {
        setCookie('hide_comments', '0');
        div_comm.style.display = 'block';
    }
    else
    {
        setCookie('hide_comments', '1');
        div_comm.style.display = 'none';
    }
}

function toggle_tab(tab)
{
    var tab_1 = document.getElementById('comment-tabs-1');
    var tab_2 = document.getElementById('comment-tabs-2');

    var pane_1 = document.getElementById('comment-pane-1');
    var pane_2 = document.getElementById('comment-pane-2');

    tab_1.className = (tab == '1')? 'current' : '';
    tab_2.className = (tab == '2')? 'current' : '';

    pane_1.style.display = (tab == '1')? 'block' : 'none';
    pane_2.style.display = (tab == '2')? 'block' : 'none';

    setCookie('tabs_comments', tab);
    return false;	
}

function _init_scripts()
{
   window.fbAsyncInit = function() 
   {
	try {
  		FB.init({appId:'176575759081109', status:true, cookie:true, xfbml:true});
	} 
	catch(exp) {};
   };
   window.vkAsyncInit = function() 
   {
	try {
	  	VK.init({apiId:2146094, onlyWidgets: true}); VK.Widgets.Comments("vk_comments", {limit: 15, attach: false}); VK.Widgets.Like("vk_like", {type: "mini"});
	} 
	catch(exp) {};
   };
   try {
	   var head = document.getElementsByTagName('head');
	   if (head)
	   {
		   var ey = document.createElement('script'); ey.type = "text/javascript"; ey.async = true;
		   ey.src = document.location.protocol + '//yandex.st/share/share.js';
		   head[0].appendChild(ey);
	   }
   } 
   catch(exp) {};
   try {
	   var fb_root = document.getElementById('fb-root');
	   if (fb_root)
	   {
		   var ef = document.createElement('script'); ef.type = "text/javascript"; ef.async = true;
		   ef.src = document.location.protocol + '//connect.facebook.net/ru_RU/all.js';
		   fb_root.appendChild(ef);
	
		   var ev = document.createElement('script'); ev.type = "text/javascript"; ev.async = true;
		   ev.src = document.location.protocol + '//userapi.com/js/api/openapi.js';
		   fb_root.appendChild(ev);
	   }
   } 
   catch(exp) {};
}

function liru()
{
   try {
	document.write("<a href='http://www.liveinternet.ru/click' target=_blank><img src='http://counter.yadro.ru/hit?t26.11;r" + escape(document.referrer) + ((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' border=0 width=88 height=15 alt='' title='LiveInternet: показано число посетителей за сегодня'><\/a>");
   } 
   catch(exp) {};
}

function init_scripts(){}

if (window.attachEvent)      window.attachEvent("onload", function(){_init_scripts()});
if (window.addEventListener) window.addEventListener("load", function(){_init_scripts()}, true);

