getJSON.cache = {};
function getJSON( config, success ) {
	config.cache = config.cache || false;
	if(config.params) {
		var params = [];
		for( key in config.params ) {
			params.push([key,'=',encodeURIComponent(config.params[key])].join(''));
		}
		config.params = params.join('&');
	} else {
		config.params = null;
	}
	var that = this;
	if( config.cache === false || typeof getJSON.cache[config.url + config.params] == 'undefined') {
		var a = new XHConn();
		a.connect( config.url, config.method, config.params, function ( response ) {
			try {
				success( getJSON.cache[config.url + config.params] = eval('(' + response.responseText + ')') );
			} catch ( error ) { ; }
		} );
	} else {
		success( getJSON.cache[config.url + config.params] );
	}
}
/*  Cookes */ 
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; domain=."+domain+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
/* end Cookes */ 

/* CANSEL BUBLe */
function stopB(e){
    if(!e)e=window.event;
    e.cancelBubble=true;
}

function send(id) {
    new ajax("/send/", {postBody: "a=" + id, onComplete: function (res) {} });
    return false;
}

function sendComplain( table_id, usernick ) {
	if(confirm('Вы уверенны, что хотите сообщить администрации сайта о том, что пользователь "' + usernick + '" нарушает Правила комментирования и размещения контента?')){new ajax("/exec/complain.php", {postBody: "table_id=" + table_id + "&item_id=" + comment_itemID + "&tablename=" + comment_tablename, onComplete: function (res) {_('complain_link_'+table_id).style.display='none';_('complain_margin_'+table_id).style.display='none';alert('Спасибо за сотрудничество!'+"\n"+'Сообщение о нарушении было отправлено и будет рассмотрено администрацией в ближайшее время');}});}
    return false;
}

function _(e) {
    return document.getElementById(e) ? document.getElementById(e) : false;
}

function getClientHeight(block_id) { return _(block_id).clientHeight; }

function truncate_ul_block( div_id, ul_id, height ) {

    if (!height) height = 0;

    var ul         = _(div_id);
    var ul_height  = getClientHeight(div_id) + height;

    var div_height = getClientHeight(ul_id);

    if (parseInt(ul.getElementsByTagName('li').length) != 0 )
    {
        while (ul_height > div_height)
        {
            var ddos = parseInt(ul.getElementsByTagName('li').length) - 1;

            if (ddos > 0 )
            {
                _(div_id).removeChild(_(div_id).getElementsByTagName('li')[ddos]);
                ul_height  = getClientHeight(div_id) + height;
                div_height = getClientHeight(ul_id);
            }
        }
    }
}

function truncate_text(h_title, h_news, height, detail_id){

    String.prototype.cut = function()
                                    {
                                        return this.substring(0, this.lastIndexOf(" "));
                                    };

    if (!height) height = 125;

    title = getClientHeight(h_title);
    news  = getClientHeight(h_news);
    str   = _(h_news).innerHTML;

    while( (title + news) > height )
    {
        str = str.cut();
        _(h_news).innerHTML = str + "...";
        title = getClientHeight(h_title);
        news  = getClientHeight(h_news);

        if (str.length == 0)
        { 
            str = "";
            _(h_news).innerHTML = str;
            break;
        }
    }
    
    if(_(detail_id))
        _(h_news).innerHTML = _(h_news).innerHTML + ' ' + _(detail_id).innerHTML;
    
}

function VotePoll ( config ) {
	var knopka	= _(config.knopka)	|| null;
	var forma	= _(config.forma) 	|| null;
	var sloy	= _(config.sloy) 	|| null;
	if( knopka !== null ) { knopka.onclick = function () {
		var send = { option : null, pollID : config.pollID, sended : 1 };
		var radios = forma.getElementsByTagName('input');
		for( key in radios ) {
			if( radios[key].className == 'inp_radio vmid' && radios[key].checked == true ) {
				send.option = radios[key].value;
			}
		}
		getJSON({
			method	: 'POST',
			params	: send,
			url		: '/ajax/' + langAlias + '/votes'
		}, function ( res ){
			sloy.innerHTML = res.Results;
		});
		return false;
	}}
}

ffvinc.counter = 0;
ffvinc.classNames = new Array('1.0', '1.2');

function ffvinc($)
{
	 _('0097f').style.fontSize = (function(){
		return function ()
		{
			if ($ == "+")
			{
				ffvinc.counter++
				if ( ffvinc.counter < ffvinc.classNames.length)
				{
					_("fav").className = "plus_font_disabled";
					_("minus").className = "minus_font";
					return ffvinc.classNames[ffvinc.counter]
				}
				else
				{
					ffvinc.counter = ffvinc.classNames.length - 1;
					return ffvinc.classNames[ffvinc.counter]
				}
			}
			
			if ($ == "-")
			{
				ffvinc.counter--
				if ( ffvinc.counter > 0 )
				{
					return ffvinc.classNames[ffvinc.counter]
				}
				else
				{
					_("fav").className = "plus_font";
					_("minus").className = "minus_font_disabled";
					ffvinc.counter = 0;
					return ffvinc.classNames[ffvinc.counter]
				}
			}
		}();
	})() + "em";
}

function hide_div(id)
{
	document.getElementById(id).style.display = 'none';
}