function vote_sf_perform(idea_id, project_id, method) {
    var $post = $('#idea_' + idea_id);

    var $loader = $post.find('.loader-holder');
    $loader.show();

    $.ajax({
        url: '/vote/' + method,
        type: 'POST',
        dataType: 'json',
        data: {idea_id: idea_id, project_id: project_id},
        success: function(response) {
            if ('success' == response.outcome) {
                var selector = 'agree' == method ? 'li.agreed' : 'li.disagreed';
                $post.find('.vote-prompt-agree, .vote-prompt-disagree').hide();
                $post.find(selector).show();
                $post.find('.vote-wrapper').html(response.stats);
            } else alert(response.message);
            $loader.hide();
        }
    });
}

function vote_sf_cancel(idea_id, project_id) {
    var $post = $('#idea_' + idea_id);

    var $loader = $post.find('.loader-holder');
    $loader.show();

    $.ajax({
        url: '/vote/cancel',
        type: 'POST',
        dataType: 'json',
        data: {idea_id: idea_id, project_id: project_id},
        success: function(response) {
            $post.find('.vote-prompt-agree').show();
            if (voting_down_enabled) $post.find('.vote-prompt-disagree').show();
            $post.find('.agreed, .disagreed').hide();
            $post.find('.vote-wrapper').html(response.stats);
            $loader.hide();
        }
    });
}

$(function() {
    $('.vote-status').hover(
        function() {
            $(this).addClass('vote-status-hover');
        },
        function() {
            $(this).removeClass('vote-status-hover');
        }
    );
});

/* -------------------------------------------------------------------------- */


var qstop = 0;
var sq    = 0;
function include(filename)
{
	var head = document.getElementsByTagName('head')[0];

	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';

	head.appendChild(script)
}
include('/config.js');

if( typeof _DOMAIN == 'undefined' )
	var _DOMAIN = 'reformal.ru';

function ShowDelay(id, str, strb, block, hblock, wait_id, num, wmode) {
	sq = 1;
	num = (null != num) ? num : 0;
    if (str.length) {
        if (_v('search_reset')) {_v('search_reset').style.display = 'inline';}
    } else {
        if (_v('search_reset')) {_v('search_reset').style.display = 'none';}
    }
	setTimeout("Search('"+id+"', '"+str+"', '"+strb+"', '"+block+"', '"+hblock+"', '"+wait_id+"', '"+num+"', '"+wmode+"')", 500);
}
function ShowDelay2(id, str, strb, block, hblock, wait_id, num, wmode) {
	sq = 1;
	num = (null != num) ? num : 0;
	setTimeout("Search2('"+id+"', '"+str+"', '"+strb+"', '"+block+"', '"+hblock+"', '"+wait_id+"', '"+num+"', '"+wmode+"')", 500);
}

function Search(id, str, strb, block, hblock, wait_id, num, wmode) {
    if ( !qstop && _v(strb).value == str && sq ) {
        qstop = 1;
        sq    = 0;
        _v(wait_id).style.display = 'block';

        var req = new JsHttpRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                _v(hblock).style.display  = 'none';
                _v(block).innerHTML       =  req.responseJS.q;
                _v(block).style.display   = 'block';
                _v(wait_id).style.display = 'none';
                qstop = 0;
            }
        };
        num = (null != num) ? num : 0;
        req.open(null, siteAdr+'pajax.php', true);
        if (wmode>0) {
            req.send( {action: 'search', id: id, str: str, num: num, wmode: wmode} );
        } else {
            req.send( {action: 'search', id: id, str: str, num: num} );
        }
    }
}
function Search2(id, str, strb, block, hblock, wait_id, num, wmode) {   
    if ( !qstop && _v(strb).value == str && sq ) {
        qstop = 1;
        sq    = 0;
        _v(wait_id).style.display = 'block';

        var req = new JsHttpRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                _v(hblock).style.display  = 'none';
                _v(block).innerHTML       =  req.responseJS.q;
                _v(block).style.display   = 'block';
                _v(wait_id).style.display = 'none';
                qstop = 0;
            }
        };

        num = (null != num) ? num : 0;
        req.open(null, siteAdr+'pajax2.php', true);
	if (wmode>0) {
	    req.send( {action: 'search', id: id, str: str, num: num, wmode: wmode} );
	} else {
	    req.send( {action: 'search', id: id, str: str, num: num} );
	}
    }
}

function ShowLoad(t)
{
    if (_v('load'))
	{
	    _v('load').style.display = (t == 1) ? 'block' : 'none';
	}
}

//**************************************************************//
//           Top blocks 
//**************************************************************//
/** for ideas */
function ShowBlock( num, cur, id, block, wait, is_out )
{
    if (is_out) {
        _v(wait).style.display = 'block';
        _v('bl'+cur).className = '';
        _v('bl'+num).className = 'active';
    }
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            _v(block).innerHTML =  req.responseJS.q;
            _v(wait).style.display = 'none';

            if (0==num)
                _v('topc').innerHTML = req.responseJS.state;
            if (1==num)
                _v('newc').innerHTML = req.responseJS.state;
            if (2==num)
                _v('successc').innerHTML = req.responseJS.state;
            if (3==num)
                _v('allc').innerHTML = req.responseJS.state;
        }
    }
    var out = (null != is_out) ? 1 : 0;
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {
        action: 'getmainblock',
        id: id,
        num: num,
        out: out,
        show_idea: _v('show_idea').value,
        show_ques: _v('show_ques').value,
        show_error: _v('show_error').value,
        show_thanks: _v('show_thanks').value
    } );
}

/** for projects */
function ShowBlockP( num, cur, block, wait )
{
    _v(wait).style.display = 'block';
	_v('bl'+cur).className = '';  
    _v('bl'+num).className = 'active';
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            _v(block).innerHTML =  req.responseJS.q;
			_v(wait).style.display = 'none';
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {action: 'getmainprojblock', num: num} );   
}
//**************************************************************//
//           Vote 
//**************************************************************//
function Vote( id, block, sout, loginb , pid) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            _v(block).innerHTML =  req.responseJS.q;
            if (req.responseJS.eq) {
                alert(req.responseJS.eq);
            }
        }
    }
    
    sout = (null == sout || 0 == sout) ? 0 : sout;
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {action: 'vote', id: id, block: block, sout: sout, pid: pid} );
}
function Vote2( id, block, sout, loginb , pid) {   
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            _v(block).innerHTML =  req.responseJS.q;
            if (req.responseJS.eq) {
                alert(req.responseJS.eq);
            }
        }
    }

    sout = (null == sout || 0 == sout) ? 0 : sout;
    req.open(null, siteAdr+'pajax2.php', true);
    req.send( {action: 'vote', id: id, block: block, sout: sout, pid: pid} );
}



function CancelVote( id, block, sout, loginb , pid) {   
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            _v(block).innerHTML =  req.responseJS.q;
        }
    };

    sout = (null == sout || 0 == sout) ? 0 : sout;
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {action: 'cancelvote', id: id, block: block, sout: sout, pid: pid} );
}
function CancelVote2( id, block, sout, loginb , pid) {   
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
		    _v(block).innerHTML =  req.responseJS.q;
			if (null != loginb) {
			    //_v(loginb).style.display = 'block';
			}
        }
    }
	sout = (null == sout || 0 == sout) ? 0 : sout;
    req.open(null, siteAdr+'pajax2.php', true);
	req.send( {action: 'cancelvote', id: id, block: block, sout: sout, pid: pid} );
}

//**************************************************************//
//           Favorites
//**************************************************************//
function Fav( pid, id, block, wait ) {   
	_v(wait).style.display = 'block';
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
		    _v(block).innerHTML =  req.responseJS.q;
		    _v(wait).style.display = 'none';
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
	req.send( {action: 'fav', pid: pid, id: id, block: block} );
}

function CancelFav( pid, id, block, wait ) {   
	_v(wait).style.display = 'block';
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
		    _v(block).innerHTML =  req.responseJS.q;
		    _v(wait).style.display = 'none';
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
	req.send( {action: 'cancelfav', pid: pid, id: id, block: block} );
}

//**************************************************************//
//          Ban && Dublicate
//**************************************************************//
function SetModer( act, id, block ) {   
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4 && req.responseJS.q) {
		    _v(block).innerHTML =  req.responseJS.q;
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
	req.send( {action: act, id: id} );
}

function SetStatus( id, status, block, stsblock ) {  
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            status = status * 1;
            if (null !=  _v(stsblock)) {
                switch (status) {
			        case 1:_v(stsblock).className = 'status status4';_v('a'+stsblock).innerHTML = 'выполнено';break;
				    case 2:_v(stsblock).className = 'status status3';_v('a'+stsblock).innerHTML = 'запланировано';break;
				    case 3:_v(stsblock).className = 'status status2';_v('a'+stsblock).innerHTML = 'делается';break;
				    case 4:_v(stsblock).className = 'status status1';_v('a'+stsblock).innerHTML = 'отклонено';break;
			    }
            }			
            if (req.responseJS.q && 0 < req.responseJS.q) {
                var v = req.responseJS.q;
                _v(block+'_'+v).className = 'actv';
                _v(block+'_'+v).href  = 'javascript:SetStatus(\''+id+'\', \''+req.responseJS.q+'\', \'sta_'+id+'\', \'sts_'+id+'\')';
            }
            if (status) {
                _v(block+'_'+status).className = 'actm';
                _v(block+'_'+status).href  = 'javascript:void(0);';
            }
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {
        action: 'setstatus',
        id: id,
        status: status
    } );
}

function BanIp( pid, ip, login, block ) {   
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4 && req.responseJS.q) {
		    _v(block).innerHTML =  req.responseJS.q;
			//_v(block).className = (1 == req.responseJS.q) ? 'grey' : 'blue';
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
	req.send( {action: 'banip', pid: pid, ip: ip, login: login} );
}

function NoTop( id, block ) {   
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4 && req.responseJS.q) {
		    _v(block).innerHTML =  req.responseJS.q;
			_v(block).style.color = ('1' == req.responseJS.eq) ? '#105895' : '#A3A3A2';
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
	req.send( {action: 'notop', id: id} );
}

//**************************************************************//
//           Check Emails
//**************************************************************//
function CheckEmails(private_emails, res, what, actb) {
    if ( private_emails ) {
        _v(res).innerHTML = '';
        var req = new JsHttpRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if ( req.responseJS.q ) {
                    _v(res).innerHTML = req.responseJS.q;
                } 
				if (null != _v(actb)) {
				    _v( actb ).style.display =( req.responseJS.rq ) ? 'block' : 'none';
				}
            }
        }
        req.open(null, siteAdr+'ajax.php', true);
        req.send( {action: 'checkuserlist', private_emails: private_emails, what: what} );                  
    }
}

function DelProjUser( uid, pid, res ) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if ( req.responseJS.q ) {
                _v(res).innerHTML = req.responseJS.q;
            } 
        }
    }
    req.open(null, siteAdr+'ajax.php', true);
    req.send( {action: 'delprojuser', uid: uid, pid: pid} );                  
}

function GetWidget3( res, link, title, ltitle, color, bcolor, tcolor, align, cr, waction, lfont, lsize, project_title, domain, regime, vcolor, cmline,glcolor,tbcolor, w, h) 
{
    _v(res).innerHTML = '';

    title = strTruncate(title);
    
    p = "<script type=\"text/javascript\">\nreformal_wdg_w    = \""+w+"\";\nreformal_wdg_h    = \""+h+"\";\nreformal_wdg_domain    = \""+domain+"\";\nreformal_wdg_mode    = "+regime+";\nreformal_wdg_title   = \""+project_title+"\";\nreformal_wdg_ltitle  = \""+ltitle+"\";\nreformal_wdg_lfont   = \""+lfont+"\";\nreformal_wdg_lsize   = \""+lsize+"\";\nreformal_wdg_color   = \""+color+"\";\nreformal_wdg_bcolor  = \""+bcolor+"\";\nreformal_wdg_tcolor  = \""+tcolor+"\";\nreformal_wdg_align   = \""+align+"\";\nreformal_wdg_charset = \""+(cr==2?'utf-8':'windows-1251')+"\";\nreformal_wdg_waction = "+waction+";\nreformal_wdg_vcolor  = \""+vcolor+"\";\nreformal_wdg_cmline  = \""+cmline+"\";\nreformal_wdg_glcolor  = \""+glcolor+"\";\nreformal_wdg_tbcolor  = \""+tbcolor+"\";\n\n</script>\n";

	_v(res).value = p+"\n"+'<div class="poxupih_center"><script type="text/javascript" language="JavaScript" src="'+link + '?charset=' + (cr==2 ? 'utf-8' : 'windows-1251') + '"></script><div class="drsdtf">на платформе <a href="http://"'+_DOMAIN+'" target="_blank" title="Reformal.ru">Reformal.ru</a></div></div>';
}



function GetWidget( res, link, title, ltitle, color, bcolor, tcolor, align, cr, waction, lfont, lsize, project_title, domain, regime, vcolor, cmline,glcolor,tbcolor, ext_domain, img_url, ext_mode, our_img, dis, https) 
{
    //alert(img_url);
    ltitle = strTruncate(ltitle); 
    //ltitle = ltitle != '' ? ltitle : 'Оставьте отзыв'
	var ext_image_param = '';
	if (ext_mode==1 && jQuery.trim(ltitle)!='')
	{
		ext_image_param = ' \nreformal_wdg_bimage = "'+our_img+'";\n ';
	}else
	{
		ext_image_param = ' \nreformal_wdg_bimage = "'+img_url+'";\n ';
	}
		
	ps = "<script type=\"text/javascript\">\n"+(ext_domain?"reformal_wdg_vlink    = \""+ext_domain+"\";"+(https?"\nreformal_wdg_https=1;":"")+"\n":"")+"reformal_wdg_domain    = \""+domain+"\";\nreformal_wdg_mode    = "+regime+";\nreformal_wdg_title   = \""+project_title+"\";\nreformal_wdg_ltitle  = \""+ltitle+"\";\nreformal_wdg_lfont   = \""+lfont+"\";\nreformal_wdg_lsize   = \""+lsize+"\";\nreformal_wdg_color   = \""+color+"\";\nreformal_wdg_bcolor  = \""+bcolor+"\";\nreformal_wdg_tcolor  = \""+tcolor+"\";\nreformal_wdg_align   = \""+align+"\";\nreformal_wdg_charset = \""+(cr==2?'utf-8':'windows-1251')+"\";\nreformal_wdg_waction = "+waction+";\nreformal_wdg_vcolor  = \""+vcolor+"\";\nreformal_wdg_cmline  = \""+cmline+"\";\nreformal_wdg_glcolor  = \""+glcolor+"\";\nreformal_wdg_tbcolor  = \""+tbcolor+"\";\n"+ext_image_param+"\n</script>\n";

	_v(res).value = ps+"\n"+'<script type="text/javascript" language="JavaScript" src="'+link + '?charset=' + (cr==2 ? 'utf-8' : 'windows-1251') +'"></script><noscript><a href="http://'+domain+'.'+_DOMAIN+'">'+project_title+' feedback </a> <a href="http://'+_DOMAIN+'"><img src="http://'+_DOMAIN+'/i/logo.gif" /></a></noscript>';
  	
}


function GetWidgetAdi( res, link, title, ltitle, color, bcolor, tcolor, align, cr, waction, lfont, lsize, project_title, domain, regime, vcolor, cmline,glcolor,tbcolor, w, h, img_url, ext_mode, our_img, dis, aw4_tcolor, ext_domain, https) 
{
    _v(res).innerHTML = '';
    
    title = strTruncate(title);
    
	var ext_image_param = '';
	if (ext_mode==1 && jQuery.trim(ltitle)!='') 
	{
		ext_image_param = ' \nreformal_wdg_bimage = "'+our_img+'";\n ';
	}else
	{
		ext_image_param = ' \nreformal_wdg_bimage = "'+img_url+'";\n ';
	}	

	p = "<script type=\"text/javascript\">\n"+(ext_domain?"reformal_wdg_vlink    = \""+ext_domain+"\";"+(https?"\nreformal_wdg_https=1;":"")+"\n":"")+"reformal_wdg_w    = \""+w+"\";\nreformal_wdg_h    = \""+h+"\";\nreformal_wdg_domain    = \""+domain+"\";\nreformal_wdg_mode    = "+regime+";\nreformal_wdg_title   = \""+project_title+"\";\nreformal_wdg_ltitle  = \""+ltitle+"\";\nreformal_wdg_lfont   = \""+lfont+"\";\nreformal_wdg_lsize   = \""+lsize+"\";\nreformal_wdg_color   = \""+color+"\";\nreformal_wdg_bcolor  = \""+bcolor+"\";\nreformal_wdg_tcolor  = \""+tcolor+"\";\nreformal_wdg_align   = \""+align+"\";\nreformal_wdg_charset = \""+(cr==2?'utf-8':'windows-1251')+"\";\nreformal_wdg_waction = "+waction+";\nreformal_wdg_vcolor  = \""+vcolor+"\";\nreformal_wdg_cmline  = \""+cmline+"\";\nreformal_wdg_glcolor  = \""+glcolor+"\";\nreformal_wdg_tbcolor  = \""+tbcolor+"\";\nreformal_wdg_tcolor_aw4  = \""+aw4_tcolor+"\";\n"+ext_image_param+"\n</script>\n";

	_v(res).value = p+"\n"+'<script type="text/javascript" language="JavaScript" src="'+link + '?charset=' + (cr==2 ? 'utf-8' : 'windows-1251') +'"></script><noscript><a href="http://'+domain+'.'+_DOMAIN+'">'+project_title+' feedback</a> <a href="http://'+_DOMAIN+'">на платформе <img src="http://widget.'+_DOMAIN+'/i/reformal_ru.png" /></a></noscript>';
}


function strTruncate(str, length, etc, break_words, middle)
{
    str = (typeof(str) != 'undefined') ? String(str) : '';
    length = (typeof(length) != 'undefined') ? length : 80;
    etc = (typeof(etc) != 'undefined') ? etc : '...';
    break_words = (typeof(etc) != 'undefined') ? break_words : false;
    middle = (typeof(middle) != 'undefined') ? middle : false;

    if (length == 0) {
       return '';
    }
    
    if (str.length > length) {
        length -= etc.length;
        if (!break_words && !middle) {
            str = str.slice(0, length + 1).replace(/\s+?(\S+)?$/g, "");
        }
        
        if (!middle) {
            return str.slice(0, length) + etc;
        } else {
            return str.slice(0, parseInt(length / 2)) + etc + str.slice(-parseInt(length / 2));
        }
    } else {
        return str;
    }

}

function CheckDomain(err_id, iid1, iid2, domain, id) {
    var req = new JsHttpRequest();
    //_v( err_id ).style.display = 'none';
	
	req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.responseJS.q) {
                _v(iid1).style.display = (0 == req.responseJS.eq) ? 'none' : 'block';
                _v(iid2).style.display = (0 == req.responseJS.eq) ? 'block' : 'none';    
                _v(err_id).className   = (0 == req.responseJS.eq) ? 'red' : 'green';
			    _v( err_id ).innerHTML     = req.responseJS.q;
                _v( err_id ).style.display = 'block';
            }
        }
    }
    
    req.open(null, siteAdr + 'ajax.php', true);
    req.send( {action: "checkdomain", fm: {domain: domain, id: id}} );  
}

var cur_mnu = 0;
function ShowMenuTab( id ) {
    var oi = 0;
	if ( 0 < cur_mnu) {
	    _v('mnu_'+cur_mnu).style.display = 'none';
		oi = cur_mnu;
		cur_mnu = 0;
	}
	if ( id != oi ) {
        _v('mnu_'+id).style.display = 'block';
        cur_mnu = id;		
	}
}

function SHBl( id ) {
    _v( id ).style.display = ('none' == _v( id ).style.display) ? 'block' : 'none';
}

function Subm( id ) {
    _v( id ).submit();
}

function RegInlShb( num ) {
    if (inl_act == num) {
	    //return true;
	} else {
        _v('ib'+inl_act).className = '';
		_v('ib'+inl_act+'na').style.display = 'none';
		_v('ib'+inl_act+'a').style.display  = 'block';
		
		_v('ib'+num).className = 'active';
		_v('ib'+num+'na').style.display = 'block';
		_v('ib'+num+'a').style.display  = 'none';
        inl_act = num;  
        
        if (null != _v('no_registration'))
		{
		    _v('no_registration').style.display = (1 == num) ? 'block' : 'none';
        }
		
        if (null != _v('verify_auth')) 
        {
        	_v('verify_auth').style.display = (2 == num) ? 'block' : 'none';
        }
        
		if (null != _v('registration'))
		{
			_v('registration').style.display = (3 == num) ? 'block' : 'none';
		}

        if (null != _v('auth_janrain'))
		{
			_v('auth_janrain').style.display = (4 == num) ? 'block' : 'none';
		}
	}
}


function ChangeDis(id, dis) { 
    var req = new JsHttpRequest();
	req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.responseJS.q) {
                _v('dis_1').style.display = _v('dis_1').style.display == 'none' ? 'block' : 'none';
                _v('dis_2').style.display = _v('dis_2').style.display == 'none' ? 'block' : 'none';
            }
        }
    }
    
    req.open(null, siteAdr + 'ajax.php', true);
    req.send( {action: "changedisign", id: id, dis: dis} );  
}



function FilterAll()
{
        var img_dir = 'http://'+document.domain+'/i/ideacat/';
        _v('show_idea').value = 1;
        _v('fltr_idea').style.visibility = 'visible';
        _v('fltr_idea').src = img_dir+'cat_idea.gif';
        
        _v('show_ques').value = 1;
        _v('fltr_quest').style.visibility = 'visible';
        _v('fltr_quest').src = img_dir+'cat_quest.gif';

        _v('show_error').value = 1;
        _v('fltr_err').style.visibility = 'visible';
        _v('fltr_err').src = img_dir+'cat_bug.gif';
        
        _v('show_thanks').value = 1;
        _v('fltr_thank').style.visibility = 'visible';
        _v('fltr_thank').src = img_dir+'cat_thank.gif';
        
        _v('fltr_all').style.visibility = 'visible';
}
function SetFilters(filter)
{
    var img_dir = 'http://'+document.domain+'/i/ideacat/';

    if (filter == 'idea')
    {
        _v('show_idea').value = _v('show_idea').value==1 ? 0 : 1;
        //_v('fltr_idea').style.visibility = _v('fltr_idea').style.visibility=='hidden'?'visible':'hidden';
        _v('fltr_idea').src = _v('fltr_idea').src==img_dir+'cat_idea_gray.gif'?img_dir+'cat_idea.gif':img_dir+'cat_idea_gray.gif';
    }
    if (filter == 'ques')
    {
        _v('show_ques').value = _v('show_ques').value==1 ? 0 : 1;
        //_v('fltr_quest').style.visibility = _v('fltr_quest').style.visibility=='hidden'?'visible':'hidden';
        _v('fltr_quest').src = _v('fltr_quest').src==img_dir+'cat_quest_gray.gif'?img_dir+'cat_quest.gif':img_dir+'cat_quest_gray.gif';
    }
    if (filter == 'error')
    {
        _v('show_error').value = _v('show_error').value==1 ? 0 : 1;
        //_v('fltr_err').style.visibility = _v('fltr_err').style.visibility=='hidden'?'visible':'hidden';
        _v('fltr_err').src = _v('fltr_err').src==img_dir+'cat_bug_gray.gif'?img_dir+'cat_bug.gif':img_dir+'cat_bug_gray.gif';
    }
    if (filter == 'thanks')
    {
        _v('show_thanks').value = _v('show_thanks').value==1 ? 0 : 1;
        //_v('fltr_thank').style.visibility = _v('fltr_thank').style.visibility=='hidden'?'visible':'hidden';
        _v('fltr_thank').src = _v('fltr_thank').src==img_dir+'cat_thank_gray.gif'?img_dir+'cat_thank.gif':img_dir+'cat_thank_gray.gif';
    }

    if (_v('fltr_idea').style.visibility=='hidden'
        ||_v('fltr_quest').style.visibility=='hidden'
        ||_v('fltr_err').style.visibility=='hidden'
        ||_v('fltr_thank').style.visibility=='hidden'
        )
        {
            _v('fltr_all').style.visibility = 'hidden';
        }else _v('fltr_all').style.visibility = 'visible';

}

function ModerCat( id, cat, block, stsblock ) {
    var img_dir = 'http://'+document.domain+'/i/ideacat/';
   
    if (null !=  _v('idea_cat_'+id))
    {
         switch (cat) {
	           case 1:_v('idea_cat_'+id).src = img_dir+'idea.gif';break;
                   case 2:_v('idea_cat_'+id).src = img_dir+'quest.gif';break;
	           case 3:_v('idea_cat_'+id).src = img_dir+'bug.gif';break;
	           case 4:_v('idea_cat_'+id).src = img_dir+'thank.gif';break;
         }
    }
    
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            cat = cat * 1;
            if (null !=  _v(stsblock)) {
                switch (cat) {
			   case 1:_v(stsblock).className = 'h_idea';break;
			   case 2:_v(stsblock).className = 'h_quest';break;
			   case 3:_v(stsblock).className = 'h_bug';break;
			   case 4:_v(stsblock).className = 'h_thank';break;
                }
            }
            if (req.responseJS.q && 0 < req.responseJS.q) {
                var v = req.responseJS.q;
                _v(block+'_'+v).className = 'actv';
                _v(block+'_'+v).href  = 'javascript:ModerCat(\''+id+'\', \''+req.responseJS.q+'\', \'cat_'+id+'\', \'cat_'+id+'\')';
            }
            if (cat) {
                 _v(block+'_'+cat).className = 'actm';
                 _v(block+'_'+cat).href  = 'javascript:void(0);';			                    
            }
        }
    }
    req.open(null, siteAdr+'pajax.php', true);
    req.send( {
        action: 'setcat',
        id: id,
        cat: cat
    } );
}

