if (document.compatMode == "BackCompat") {
document.write('<style type="text/css">'+
'#krible { width:1px; height:1px; position:absolute; bottom:0px; z-index:1000; display:block; overflow:hidden; }'+ // todo: change block to none
'body > div#krible { position: fixed; }'+
'.right { right:0px; }'+
'.left { left:0px; }'+
'</style>'+
'<!--[if IE]>'+
'<style type="text/css">'+
'div#krible.right {'+
'  position:absolute !important; right: auto; bottom: auto;'+
'  left: expression( ( 0 - krible.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + "px" );'+
'  top: expression( ( 0 - krible.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + "px" );'+
'}'+
'div#krible.left {'+
'  position:absolute !important; left:0px; bottom: auto;'+
'  top: expression( ( 0 - krible.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + "px" );'+
'}'+
'</style>'+
'<![endif]-->');
} else {
document.write('<style type="text/css">'+
'#krible { width:250px; height:370px; position:fixed; bottom:-400px; z-index:1000; display:block; }'+
'.right { right:0px; }'+
'.left { left:0px; }'+
'</style>');
}



var Krible = new Object();


function kribleDetectBrowser ()
{
	Krible.browser = (function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown'
	Krible.IE6 = /msie|MSIE 6/.test(navigator.userAgent);
}


function kribleGetMessage(event) 
{
	kribleOnOff(event.data);
	return;
}


function kribleOnOff(call) {  
    // проверяем вызов для модных браузеров
    try {
        if (call.indexOf('krible') > -1)  Krible.callStr = call;
        } catch (e) {
        Krible.callStr = null;
    }


    // проверяем вызов для старых браузеров
    try {
        if (!Krible.callStr && location.hash.indexOf('krible') > -1) Krible.callStr = location.hash;
        } catch (e) {
         Krible.callStr = null;    
    }


    // парсим строку и определяем тип вызова
    if (Krible.callStr) {
        if (Krible.callStr == 'kribleOn' || Krible.callStr == '#kribleOn') { Krible.call = 'on' }
        if (Krible.callStr == 'kribleOff' || Krible.callStr == '#kribleOff') { Krible.call = 'off' }
        if (Krible.callStr == 'kribleBar' || Krible.callStr == '#kribleBar') { Krible.call = 'bar' }
    }
    
    
  if (Krible.call == 'on') {
        Krible.windowChat.style.width = "250px";
        Krible.windowChat.style.height = "370px";
        Krible.windowChat.style.bottom = "0px";
  } 
  
  if (Krible.call == 'bar') {
        Krible.windowChat.style.width = "250px";
        Krible.windowChat.style.height = "30px";
        Krible.windowChat.style.bottom = "0px";
  }
  
  if (Krible.call == 'off') {
        Krible.windowChat.style.width = "0px";
        Krible.windowChat.style.height = "0px";
        Krible.windowChat.style.bottom = "-400px";
  }
}



if (window.addEventListener) 
{
	if (typeof window.postMessage != 'undefined') 
	{
		window.addEventListener("message", kribleGetMessage, false);
	}
}

if (window.attachEvent)
{
	if (typeof window.postMessage != 'undefined') 
	{
		window.attachEvent('onmessage', kribleGetMessage);
	}
}


try {
	kriblePosition;
} catch (e) {  kriblePosition = 'right'; }


document.write('<div id="krible" class="'+ kriblePosition +'"><iframe name="kribleChat" src="' +
		'http://chat.krible.ru/arena/'+ kribleCode.substr(0,2) +'/'+ kribleCode +'/index.html?'+
		'url=' + escape(document.URL) +
		'&domain=' + escape(document.domain) +
		'&code=' + kribleCode +
		'&bot=general' +
	'" width="250" height="370" scrolling="no" frameborder="0" allowtransparency="true"></iframe></div>');


kribleDetectBrowser();

Krible.windowChat = document.getElementById('krible');


if (typeof window.postMessage == 'undefined') {
	var kribleCallID = setInterval("kribleOnOff()", 1000);
}

kribleOnOff('kribleOff');

