include("../js/prototype_1.6.1.js");
include("../js/src/scriptaculous.js");
include("../js/src/builder.js");
include("../js/src/effects.js");

var currentId;

function CoverLayer(id,theme_id)
{
	Event.observe(window,"resize",function(event){resizeCover(currentId);})
	resizeCover(id);
	currentId = id;
	$('working_layer').hide();
	new Effect.Opacity('working_layer',{from: 0, to: 1, duration: 0.2,delay:0.3,queue:{ position: 'end',scope: 'cover'}});
	new Effect.Grow('workLayerContainer',{duration:1,delay:0.1,direction:'center',queue:{ position: 'front',scope: 'cover'}});
	new Effect.Grow('backgroundDiv_'+id,{duration:1,queue:{ position: 'front',scope: 'cover'}});
	var queue = Effect.Queues.get('cover');
	queue.each(function(effect) {effect.startOn;});
	window.setTimeout(function() {
		new Ajax.Updater('working_layer', '../activity/activity_list.php?',{ method: 'get',parameters:{id:theme_id},onSuccess:function(){$('working_layer').show();}});
	},2000);
}

function closeCurtain()
{
	new Effect.Opacity('working_layer',{from: 1, to: 0, duration: 0.1});
	Effect.Shrink('workLayerContainer');
	Effect.Shrink('backgroundDiv_'+currentId);
	$('workLayerContainer').hide();
	Element.stopObserving(window,'resize', function(event){resizeCover(currentId);});
	
	var queue = Effect.Queues.get('cover');
	queue.each(function(effect) { effect.cancel(); });
		
}

function resizeCover(id)
{
	if(id)
	{
		if($('body_cat_'+id).getWidth()>=$('main_cat_'+id).getWidth())
		{
			newWidth = $('body_cat_'+id).getWidth();
			newHeight = $('body_cat_'+id).getHeight();
		}
		else
		{
			newWidth = $('main_cat_'+id).getWidth();
			newHeight = $('body_cat_'+id).getHeight();
		}
		$('workLayerContainer').style.width = newWidth+"px";
		$('backgroundDiv_'+id).style.width = newWidth+"px";
		$('backgroundDiv_'+id).style.height = newHeight+"px";
	}
}
