window.addEvent('domready', function() {
	//create our Accordion instance
	initializeAccordion();
});

function initializeAccordion() {
	var myAccordion = new Accordion($('accordion'), 'h2.toggler', 'div.element', {
		opacity: false,
		show: 0
	});
}

function showLoading() {
	var thisAccordion = document.getElementById('accordion');
	var screen = document.createElement('div');
	screen.style.position='absolute';
	screen.style.top = 0;
	screen.style.left =  0;
	screen.style.zIndex=1;
	screen.style.backgroundColor="#000000";
	if(thisAccordion.offsetHeight<130) {
		screen.style.height = "130px";
	} else{
		screen.style.height = thisAccordion.offsetHeight+"px";
	}
	screen.style.width = thisAccordion.offsetWidth+"px";
	screen.style.opacity = .8;
	screen.style.filter = "alpha(opacity=80)";
	var myImage = new Image();
	myImage.src = basePath+themePath+"/img/loader.gif";
	myImage.style.position="absolute";
	myImage.style.top= "50px";
	myImage.style.left= "110px";
	screen.appendChild(myImage);
	thisAccordion.appendChild(screen);
}

function showMultimediaLoading() {
	$('mediascreen').style.height = $('multimedia').offsetHeight+"px";
	$('mediascreen').style.width = $('multimedia').offsetWidth+"px";
	$('mediascreen').style.backgroundColor = "#000000";
	$('mediascreen').style.opacity = .8;
	$('mediascreen').style.filter = "alpha(opacity=80)";
	$('mediascreen').style.display= "block";
}

function setAccordion(data) {
	$('accordion').innerHTML = data;
	initializeAccordion();
}

function setMultimedia(data) {
	if(data=="home") {
		$('mediaBox').style.display = "block";
		$('contentBox').style.display = "none";
	} else {
		$('mediaBox').style.display = "none";
		$('contentBox').style.display = "block";
		$('contentBox').innerHTML = data;
	}
	$('mediascreen').style.display= "none";
}

/*var setAccordion = function() {
	var myAccordion = new Accordion($('accordion'), 'div.toggler', 'div.element', {
		opacity: false,
		display: initialDisplay,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#fff');
			toggler.setStyle('font-weight', 'bold');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#ccc');
			toggler.setStyle('font-weight', 'normal');
		},
		itemsOpen : [1]
	});
};*/

function setContent() {
  hideCalendar();
  showLoading();
  showMultimediaLoading();
  $j.get('?q=get/accordion/'+this.id,null,setAccordion);
  $j.get('?q=get/multimedia/'+this.id,null,setMultimedia);
}


function doNothing() {

}
