//accordion
jQuery(document).ready(function(){
	regKreisraeteAccordion();
	//register xajax loading
	xajax.callback.global.onRequest = function() { showPageLoader() };
	xajax.callback.global.onComplete = function() { hidePageLoader() };
	xajax.callback.global.onFailure = function() { errorPageLoader(); };
});

function regKreisraeteAccordion() {
	$('#kreisraete .kreisrat .title').click(function() {
		$(this).next().toggle('slow');
		return false;
	}).next().hide();
}

var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	

		$(this.parent).append(modal);

		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
	}
};

function showPageLoader() {
	modalWindow.windowId = "Loading";
	modalWindow.width = 480;
	modalWindow.height = 405;
	modalWindow.content = '<div id="loader_frame_image"><h3>Bitte haben Sie einen Moment Geduld, die Daten werden geladen.</h3><br /><br /><img src="typo3conf/ext/sic_kreisrat/templates/gfx/ajax-loader.gif" /></div>';
	modalWindow.open();
};

function hidePageLoader() {
	modalWindow.close();
}

function errorPageLoader() {
	hidePageLoader();
	alert("Beim Ausführung ist ein Fehler aufgetreten, bitte versuchen Sie es später nocheimal.");
}



function styleSwitcher($paraDivID) {
	var e=document.getElementById($paraDivID);
	if(!e)return true;
	if(e.style.backgroundColor=="") {
	e.style.backgroundColor="#4273AE"
	e.style.color = "#FFFFFF"
	
	} else {
		e.style.backgroundColor=""
		e.style.color = ""
	}



 return true;
}
