/**
* var string holds the active id 
*/
var sActiveId;
/**
* var string holds the active link element
*/
var sActiveLinkEl;

/**
* shows an element, hides an active one
*
*/	
function showItems(sId, oEl)
{
	//if active element and active element is not the same as the required one, hide it!
	if(sActiveId && (sId == sActiveId))
	{
		hideActive();
	}
	else
	{
		if(sActiveId)
		{
			hideActive();
		}
		
		$(sId).removeClassName('hide');
		$(sId).style.display = 'none';
		new Effect.BlindDown(sId);	
		oEl.removeClassName('arrow_gray_right');
	
		sActiveId = sId;	
		sActiveLinkEl = oEl;
	}
}

function hideActive()
{
	new Effect.BlindUp(sActiveId);
	sActiveLinkEl.addClassName('arrow_gray_right');
	sActiveId = null;
	sActiveLinkEl = null;
}
/* End of shows an element, hides an active one */

/**
 * For choice information (with id's poll, populair and newest)
 */
var sChosenElId = '';

function pollVote()
{
	var oFormID = $("pollform");
	if ( oFormID )
	{
		for (var x=0; oFormID.elements[x]; x++ ) 
		{
			var check = oFormID.elements[x].checked; 
			if(check)
			{
				var iVoteID = x + 1;
			}
		}
	}
    
    if(iVoteID) 
    {
		new Ajax.Updater(
			/*id of div where html is going to be showed*/
			'poll', 
			
			/*URI of request*/
			'/home/poll/' + iVoteID,
			{ 
				method: 'get'
			}
		);
	}				
}

function saveChoiceId(sElId)
{
	var oAjax = new Ajax.Request('/output/json?function=saveChoiceId&chosen=' + sElId,
	{
		method: 'get',
		onSuccess: function(transport, oJson)
		{
		  	/* Do nothing */
		}
	});
}

function showTabInfo(sElId, sDefaultId)
{	
	if(!sElId || sElId == '')
	{
		sElId = sDefaultId;
	}
	
	var oEl2Show = $(sElId);
	var oTab2Show = $('tab_'+sElId);
	
	if(oEl2Show && (sElId != sChosenElId))
	{
		var oCurActiveEl = $(sChosenElId);
		if(oCurActiveEl)
		{
			oCurActiveEl.style.display = 'none';
		}
		
		var oCurActiveTab = $('tab_'+sChosenElId);
		if(oCurActiveTab)
		{
			oCurActiveTab.removeClassName('active');
		}
		
		sChosenElId = sElId;
		oEl2Show.style.display = 'block';
		
		if(oTab2Show)
		{
			if(!oTab2Show.hasClassName('active'))
			{
				oTab2Show.addClassName('active');
			}
			saveChoiceId(sElId);
		}
	}
}
/* End of choice information (with id's poll, populair and newest) */

