/*
*	Javascript Funktionen für NIGHTRAIN
*	Website Version 1.0
*	Mar 2010
*/
/* BACKEND CONTENT anzeigen und verbergen */
function show_content(divname) {
document.getElementById(divname).style.display = "block";
}

function hide_content(divname) {
document.getElementById(divname).style.display = "none";
}

/* Pop Up für Datenupload */
function upload_file(mode) {
var link;
if(mode == "new") {link = "http://www.nightrain-band.de/controller/upload.php";}
else {link = "http://www.nightrain-band.de/controller/renew.php";}

window.open(link,'Popup','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=375,height=125,left=100,top=300'); return false;
}

/* Webplayer */
function webplayer() {
window.open("http://www.nightrain-band.de/controller/webplayer.php",'Popup','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=375,height=135,left=700,top=200'); return false;
}

/* Formular absenden; BUGFIX jQuery RTE */
function sendform(name) {
//Name des Forms generieren
var form = name+"_form";

//Check ob Design oder HTML-Modus aktiviert ist
	//iframe ist nicht aktiv
	if(typeof document.getElementById(name+"_text_area").contentWindow == 'undefined') {
		document.getElementById("hidden_"+name+"_text_area").value = document.getElementById(name+"_text_area").value;
		document.getElementById(form).submit();
	} 
	//iframe ist aktiv
	else {
		value = document.getElementById(name+"_text_area").contentWindow.document.getElementsByTagName("body")[0].innerHTML;
		document.getElementById("hidden_"+name+"_text_area").value = value;
		document.getElementById(form).submit();
	}
}

/* Funktion zur Content-Anzeige im Bereich Media -> Music */
function show_music_content(name) {
 document.getElementById("tslc").style.display = "none";
 document.getElementById("bib").style.display = "none";
 document.getElementById("dod").style.display = "none";
 document.getElementById("other").style.display = "none";

 document.getElementById(name).style.display = "block";
}

function fixContentHeight() {
	$('#content').css('min-height', parseFloat( $('#sidebar_right').css('height') ) + 20 + 'px' );
}

$(document).ready(function() {
	fixContentHeight();

	$('.title_link[title=Show Tweets]').addClass('mandatory');
	
	$('.title_link').click(function() {
		$('.title_link').removeClass('mandatory');
		$(this).addClass('mandatory');
		
		if( this.getAttribute('title') == 'Show Tweets' ) {
			$('#twitter').css('display','block');
			$('#social_widgets').css('display','none');
		} else if( this.getAttribute('title') == 'Show FB Box' ) {
			$('#twitter').css('display','none');
			$('#social_widgets').html(' <iframe src=\"http://www.facebook.com/plugins/likebox.php?id=128754682595&amp;width=165&amp;connections=4&amp;stream=false&amp;header=true&amp;height=287\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:165px; height:287px; background:#fff; margin-top:10px;\" allowTransparency=\"false\"></iframe> ');
			$('#social_widgets').css('display','block');
		}
		
		fixContentHeight();
	});
	
	// FORUM: bandprobe rücksetzen
	$('#resetRehearsal').click(function() {
		var trigger = confirm('Sicher?');
		
		if(trigger == true) {
		$.ajax({
			url: 'controller/rehearsalDelete.php',
			dataType: 'html',
			success: function(data) {
				$("#content").load(location.href+" #content>*", function() {
					$('<span> - ' + data + '</span>').insertAfter('#resetRehearsal');
				});
			}
		});
		}
	});
	
	// FORUM: Zeige ungelesene
	$('#showUnread').click(function() {
		$.ajax({
			url: 'controller/view_unread.php',
			dataType: 'html',
			success: function(data) {
				$("#content").html(data);
			}
		});
	});
})
