function toggle_search_result_class(id)
{
	$$('#media_navigator .search_results_selected').each(function(item)
	{
		item.className = 'search_results';
	});

	if ($('search_results_' + id))
		$('search_results_' + id).className = 'search_results_selected';
}

function starVoteEngine(i) {
	var star = null;
	
	for (var j = 1; j <= 5; j++)
	{
		star = $('star_' +  j);
		if(star){
			if(j <= i){
				star.setStyle({ backgroundPosition : '1px 0'});
			}
			else {
				star.setStyle({ backgroundPosition : '-28px 0'});
			}	
		}
	}
}

function vote_done(){
	$('vote_stars').stopObserving('mouseout');

	$('vote_msg').show();
	$('vote_content').hide();
	
	setTimeout(function(){
		$('vote_msg').hide();
		$('vote_content').show();
	},3000);
}



function show_blogit(){
	$('blog_it').stopObserving('click');
	$('blog_it_content').setStyle({display: 'block'});
	$('blog_it_close').observe('click',hide_blogit);
	$('blog_it_area').observe('click',function(){
		$('blog_it_area').select();
	});
}

function hide_blogit(){
	$('blog_it_close').stopObserving('click');
	$('blog_it_area').stopObserving('click');
	$('blog_it_content').setStyle({display: 'none'});
	$('blog_it').observe('click',show_blogit);
}


function refresh_media(internal_uri_detail, internal_uri_comment, media_id){
	if (executing_ajax == false) {
		executing_ajax = true;
		refresh_media_detail('media_details_content', internal_uri_detail, media_id, arguments[3] || {});
		refresh_media_comments('comment_list', 'media_datas', internal_uri_comment, media_id, arguments[4] || {});
	}
}

function refresh_media_detail(update,internal_uri,media_id){
	var options = Object.extend({
			asynchronous: true,
			evalScripts: true,
			onComplete: function(request, json){
				hide_media_waiter();
				executing_ajax = false;
			},
			method: 'get'
		}, arguments[3] || {});
	
	show_media_waiter();
	new Ajax.Updater(update, internal_uri, options);
}


function refresh_media_comments(update_list, update_add, internal_uri, media_id){
	var options = Object.extend({
			asynchronous: true,
			evalScripts: true,
			onComplete: function(request, json){
			},
			method: 'post'
		}, arguments[4] || {});
	
	new Ajax.Updater(update_list, internal_uri.replace('add','list') + '/config_name/eztv/media_id/' + media_id, options);
	new Ajax.Updater(update_add, internal_uri + '/config_name/eztv/media_id/' + media_id, options);
}



function show_media_waiter(){
	$('media_details_content').setOpacity(0.5);
	$('media_details_content').addClassName('waiter');
}

function hide_media_waiter(){
	$('media_details_content').setOpacity(1);
	$('media_details_content').removeClassName('waiter');
}

