var e_popup = e_popup_data = vp_w = vp_h = blackout = null;
var e_popup_w = 800;
var e_popup_h = 500;
var e_popup_x = e_popup_y = e_popup_data_h = 0;
function init()
{
	// element assignment
	e_popup = $("event-info-popup");
	e_popup_data = $("event-info");
	blackout = $("blackout-box");
	e_handle = $("event-handle");

	// window size
	align();
	
	// styling
	e_popup.setStyle({width: e_popup_w + 'px', height: e_popup_h + 'px', left: e_popup_x + 'px', top: e_popup_y + 'px', display: 'none'});
	e_popup_data.setStyle({height: (e_popup_data_h - 10) + 'px'});
	
	// blackout box
	blackout.setStyle({position: "fixed", opacity: .5, zIndex: 99, top: 0, left: 0, width: "100%", height: "100%", backgroundColor: "#000000", display: "none"});
	
	// set draggable
	new Draggable(e_popup, {handle: 'event-handle', revert: true});
}

function align()
{
	vp_w = document.viewport.getWidth();
	vp_h = document.viewport.getHeight();
	e_popup_x = Math.ceil((vp_w / 2) - (e_popup_w / 2));
	e_popup_y = Math.ceil((vp_h / 2) - (e_popup_h / 2));
	e_popup_data_h = e_popup_h - (e_handle.getHeight());
	e_popup.setStyle({left: e_popup_x + 'px', top: e_popup_y + 'px'});
}

function hideEvent()
{
	new Effect.Fade(e_popup, {queue: "end", duration: .3});
	new Effect.Fade(blackout, {queue: "end", duration: .1, from: .5, to: 0});
}

function showEvent(id)
{
	new  Effect.Appear(blackout, {duration: .1, from: 0, to: .5});

	//$("event-page-link").writeAttribute("href", "http://www.thehubguide.com/event/"+id);
	new Ajax.Updater(e_popup_data, "/ajax/geteventinfo.php", 
	{
		method: "get",
		parameters: {id: id},
		evalScripts: true
	}
	);

	new Effect.Appear(e_popup, {duration: .3, from: 0.0, to: 1.0, queue: "end"});
	
}