function popup_Fade(type)
{
	var blocdestination = $('form_' + type);
	if(blocdestination && blocdestination.className.indexOf("adm_popup")>-1)
		new Effect.Fade(blocdestination,{duration:0.5});
}

function popup_Appear(type)
{
	var blocdestination = $('form_' + type);
	if(blocdestination)
		blocdestination.style.display="block";
}

function popup_Strech(type)
{
	var popup = $('adm_popup_' + type);
	var popup_bg = $('form_' + type);

	bDim = document.body.getDimensions();
	ovpDim = document.viewport.getDimensions();
	pDim = popup.getDimensions();
	
	if(pDim.height>=bDim.height && pDim.height>=ovpDim.height)
		popup_bg.style.height = pDim.height + "px";
	else
	{
		if(bDim.height>ovpDim.height)
			popup_bg.style.height = bDim.height + "px";
		else
			popup_bg.style.height = ovpDim.height + "px";
	}
}

function popup_Draggable(type)
{
	var popup_header_id = 'adm_popup_draggable_' + type;
	var form_ctn = $('adm_popup_' + type);
	if(form_ctn)
		new Draggable(form_ctn, {handle: popup_header_id });
}

function popup_Center(type)
{
	var form_ctn = $('adm_popup_' + type);
	var ovp = document.viewport.getDimensions();
	var dim = form_ctn.getDimensions();
	form_ctn.style.top="20px";
	scroll(0,0);
}

var myrules = {
	/****************Calendar********************/
	'.adm_popup_form' : function(popup){
		var type = popup.id.replace("adm_popup_","");
		popup_Appear(type);
		popup_Strech(type);
		popup_Draggable(type);
		popup_Center(type);
	}
};
/**********************************************/
// Enregistrement des regles definies ci dessus dans Behaviour
Behaviour.register(myrules);
