<!-- plugins changelog block -->

<script type="text/javascript">//<![CDATA[
var actions_locked = false;
var plugin_is_installing_phrase = '{$lang.plugin_is_installing}';
var plugin_is_updating_phrase = '{$lang.plugin_is_updating}';
var plugin_obj = false;
var plugin_install_notice = "{$lang.remote_plugin_install_notice}";
var plugin_connect_phrase = "{$lang.remote_progress_connect}";
var plugin_installing_phrase = "{$lang.remote_progress_installing}";
var plugin_updating_phrase = "{$lang.remote_progress_updating}";

var plugin_update_notice = "{$lang.remote_plugin_update_notice}";
var plugin_update_backingup = "{$lang.remote_progress_backingup}";
{literal}

var rlPluginRemoteInstall = function(){
	// install links handler
	$('div.changelog_install div.navbar a').click(function(){
		if ( !actions_locked )
		{
			plugin_obj = this;
			rlConfirm(plugin_install_notice, 'startInstallation');
		}
	});
	
	// update links handler
	$('div.changelog_update a').click(function(){
		if ( !actions_locked )
		{
			plugin_obj = this;
			rlConfirm(plugin_update_notice, 'startUpdating');
		}
	});
};

var startInstallation = function(){
	actions_locked = true;
	
	hideNotices();
	
	var key = $(plugin_obj).attr('name');
	var area = $(plugin_obj).parent().parent().parent().parent().parent().parent().parent();
	var name = $(area).find('a:first').html();
	var id = $(area).attr('id');
	var height = $(area).height();
	var width = $(area).width();
	
	/* set fixed height for main container */
	$(area).height($(area).height());
	
	/* prepare HTML DOM */
	var html = ' \
	<div style="height: '+ height +'px;width: '+ width +'px;position: absolute;margin: 0;padding: 0;" class="hide grey_area" id="'+ id +'_tmp"> \
		<div style="padding: 10px;"> \
			<div class="dark_12"><b>'+ name +'</b> '+ plugin_is_installing_phrase +'</div> \
			<div class="progress static" style="padding: 5px 0 0;"></div> \
		</div> \
	</div>';
	
	/* show progress bar */
	$(area).append(html);
	$(area).find('.changelog_item').css({width: $(area).find('.changelog_item').width(), position: 'absolute'}).fadeOut();
	$(area).find('.changelog_item').next().fadeIn('normal', function(){
		$(area).find('.changelog_item').css('position', 'relative');
		$(this).css({position: 'relative', width: 'auto'});
		$(this).find('.progress').html(plugin_connect_phrase);
		xajax_remoteInstall(key);
	});
};

var startUpdating = function(){
	actions_locked = true;
	
	hideNotices();
	
	var key = $(plugin_obj).attr('name');
	var area = $(plugin_obj).parent().parent().parent().parent().parent().parent().parent();
	var name = $(area).find('a:first').html();
	var id = $(area).attr('id');
	var height = $(area).height();
	var width = $(area).width();
	
	/* set fixed height for main container */
	$(area).height($(area).height());
	
	/* prepare HTML DOM */
	var html = ' \
	<div style="height: '+ height +'px;width: '+ width +'px;position: absolute;margin: 0;padding: 0;" class="hide grey_area" id="'+ id +'_tmp"> \
		<div style="padding: 10px;"> \
			<div class="dark_12"><b>'+ name +'</b> '+ plugin_is_updating_phrase +'</div> \
			<div class="progress static" style="padding: 5px 0 0;"></div> \
		</div> \
	</div>';
	
	/* show progress bar */
	$(area).append(html);
	$(area).find('.changelog_item').css({width: $(area).find('.changelog_item').width(), position: 'absolute'}).fadeOut();
	$(area).find('.changelog_item').next().fadeIn('normal', function(){
		$(area).find('.changelog_item').css('position', 'relative');
		$(this).css({position: 'relative', width: 'auto'});
		$(this).find('.progress').html(plugin_update_backingup);
		xajax_remoteUpdate(key);
	});
};

var continueInstallation = function(key){
	var area = $('div.changelog_item a[name='+ key +']').parent().parent().parent().parent().parent().parent().parent();
	$(area).find('div.progress').html(plugin_installing_phrase);
	
	xajax_install(key, 'true');
};

var continueUpdating = function(key){
	var area = $('div.changelog_item a[name='+ key +']').parent().parent().parent().parent().parent().parent().parent();
	$(area).find('div.progress').html(plugin_updating_phrase);
	
	xajax_update(key, 'true');
};

var hideProgressBar = function(){
	var area = $(plugin_obj).parent().parent().parent().parent().parent().parent().parent();
	
	/* hide progress bar */
	$(area).find('.changelog_item').next().fadeOut('normal', function(){
		$(area).find('.changelog_item').css({width: 'auto'}).fadeIn('normal', function(){
			$(this).css('position', 'relative');
		});
	});
	
	actions_locked = false;
};

var ab_plugins_log_load = false;

$(document).ready(function(){
	var load = false;
	var key = 'plugins_log';
	var func = 'xajax_getPluginsLog()';
	
	if ( $('.block div[lang='+key+']').is(':visible') )
	{
		eval(func);
	}
	else
	{
		$('.block div[lang='+key+']').prev().find('div.collapse').click(function(){
			if ( !load )
			{
				eval(func);
				load = true;
			}
		});
	}

	$('input#apsblock\\\:'+key).click(function(){
		if ( !load && $(this).attr('checked') && $('.block div[lang='+key+']').is(':visible') )
		{
			eval(func);
			load = true;
		}
	});
});

{/literal}
//]]>
</script>

<!-- plugins changelog block end -->