/**
 * uses prototype.js
 *
 * -> more information on http://www.prototypejs.org/api/
 */

// add the event for switching from open to closed to all sectionFrame6 elements
function commentsInit(event) {
	commentsElements = $$('div.tx-comments-comment-form .guestbookFormEntry');
	
	for(var i=0; i < commentsElements.length; i++) {
		try {
			Event.observe(commentsElements[i], 'click', commentsSwitch);
			
		}catch(e) {
			commentsElements[i].onclick = commentsSwitch;
		}
	}
}

// switch the clicked element and close all others
function commentsSwitch(event) {
	try {
		commentsElements = $$('div.tx-comments-comment-form .guestbookFormEntry');
		for(var i=0; i < commentsElements.length; i++) {
			Element.addClassName(commentsElements[i], 'closed');
		}
		openCommentsElements = $$('div.tx-comments-comment-form .commentForm');
		for(var i=0; i < openCommentsElements.length; i++) {
			Element.removeClassName(openCommentsElements[i], 'closed');
		}
	}catch(e) {}
}

// remove startpage categories 
function removeStartPageCategory() {
	newsHeaders = $$('.newsHeader');
	if(newsHeaders.length > 0) {
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace(", Starseite 1", "");
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace(", Starseite 2", "");
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace(", Starseite 3", "");
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace("Starseite 1, ", "");
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace("Starseite 2, ", "");
		newsHeaders[0].innerHTML = newsHeaders[0].innerHTML.replace("Starseite 3, ", "");
	}
}

// rund news fix
document.observe('dom:loaded', removeStartPageCategory);

// run faqInit as soon as the page is ready
document.observe('dom:loaded', commentsInit);


