// event popins
var popinLoadingHTML = "";
function eventPopin(popinUrl) {
	centrePopin();
	if(popinLoadingHTML == "") {  // first time
		resizePopinOverlay();
		popinLoadingHTML = $('popin-content').innerHTML; 
	} else {
		$('popin-content').update(popinLoadingHTML);
	}
	new Ajax.Updater('popin-content',popinUrl,{asynchronous:true,evalScripts:true});
	Element.setStyle('popin-overlay',{display:'block'});
	Element.setStyle('popin',{display:'block'});
}
function closePopin() {
	Element.setStyle('popin-overlay',{display:'none'});
	Element.setStyle('popin',{display:'none'});
}
function centrePopin() {
	if(window.innerHeight) { // Firefox 
		popinLeft = window.innerWidth/2 - 150;
		popinTop = window.pageYOffset;
	} else if( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac
		popinLeft = document.body.scrollWidth/2 - 150;
		popinTop = document.documentElement.scrollTop;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		popinLeft = (document.body.offsetWidth + document.body.offsetLeft)/2 - 150;
		popinTop = document.body.scrollTop;
	}
	if(popinTop > 240) { popinTop += 20; } else { popinTop = 240; }
	Element.setStyle('popin',{left:popinLeft + 'px',top:popinTop + 'px'});
}
function resizePopinOverlay() {
	if( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = '100%';
		pageHeight = (window.innerHeight + window.scrollMaxY) + 'px';
	} else if( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac
		pageWidth = document.body.scrollWidth + 'px';
		pageHeight = document.body.scrollHeight + 'px';
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		pageWidth = (document.body.offsetWidth + document.body.offsetLeft) + 'px';
		pageHeight = (document.body.offsetHeight + document.body.offsetTop) + 'px';
	}
	Element.setStyle('popin-overlay',{width:pageWidth,height:pageHeight});
}
function showMoreEvents(id){
	Element.setStyle('more-link-'+id,{display:'none'});
	Element.setStyle('more-events-'+id,{display:'block'});
}
function showLessEvents(id){
	Element.setStyle('more-link-'+id,{display:'block'});
	Element.setStyle('more-events-'+id,{display:'none'});
}