function showBalloon(id)
{
	document.getElementById(id).style.display = "block";
}

function hideBalloon(id)
{
	document.getElementById(id).style.display = "none";
}

function showBalloon_fix(obj, id)
{
	var window_width = window.innerWidth ? window.innerWidth : document.body.offsetWidth; 

	if(window_width < obj.offsetLeft + 251)
	{
		document.getElementById(id).className = "balloon balloon_right";
	}
	document.getElementById(id).style.display = "block";
}

function showStat(id)
{
	hideAllStatObject();
	
	showBalloon('stat_' + id);
	document.getElementById('stat_btn_'+id).className = 'active';
}

function hideAllStatObject()
{
	for(i=0; document.getElementById('stat_'+i) != undefined; i++) {
		document.getElementById('stat_'+i).style.display = 'none';
		document.getElementById('stat_btn_'+i).className = '';
	}
}

function getOpinion(id, action) 
{
	if(!id || !action)
		return;
	
	
		
    var req = new JsHttpRequest();
    req.caching = false;
    req.onreadystatechange = function() 
    {
        if (req.readyState == 4) 
        {
        	/**/
        	if(req.responseText)
        		alert(req.responseText);
        	/**/
        	
        	if(req.responseJS.full_text) {
        		document.getElementById('opinion_content_full').innerHTML  = req.responseJS.full_text;
        		document.getElementById('etc').style.display = '';
        	} else {
        		document.getElementById('opinion_content_full').innerHTML = '';
        		document.getElementById('etc').style.display = 'none';
        	}
        	
        	document.getElementById('opinion_content').innerHTML = req.responseJS.text;
        	document.getElementById('opinion_owner').innerHTML = req.responseJS.owner;
        	document.getElementById('arrow_left').href = "javascript: getOpinion("+req.responseJS.id+",'back')";
        	document.getElementById('arrow_right').href = "javascript: getOpinion("+req.responseJS.id+",'next')";
        }
    }
    req.open(null, '/opinions/other', true);
    req.send( { current_id: id, action: action } );

}

