// ie check	
var isIE = false;
if (navigator.appName=="Microsoft Internet Explorer") {isIE=true;}
// content am start ausschalten

function content_startaus(){
	contentVisible = false;
	if (isIE == true) {$("#content_html").animate({ left: "-=1000" }, 0, "swing");} else {$("#content_html").fadeOut(0)};
	$("#content_bg").animate({ left: "-=1000" }, 0, "swing");
	$("#bContentFade").html("Text einblenden");
	$("#content_ui").addClass('uibuttonoverpic');
	$("#picture_ui").addClass('uibuttonoverpic');
	$("#picture_ui").css('visibility', 'visible');
	$(".customuilink").css('visibility', 'hidden');
	$("#content_ui").focus();
}


// document ready
$(document).ready(function(){

	var animSpeed = 500;
	
	// content on/off
	$("#bContentFade").click(function(event) {
		if (contentVisible == true){
			contentVisible = false;
			if (isIE == true) {$("#content_html").animate({ left: "-=1000" }, animSpeed, "swing");} else {$("#content_html").fadeOut("slow")};
			$("#content_bg").animate({ left: "-=1000" }, animSpeed, "swing");
			$("#bContentFade").html("Text einblenden");
			$("#content_ui").addClass('uibuttonoverpic');
			$("#picture_ui").addClass('uibuttonoverpic');
			$("#picture_ui").css('visibility', 'visible');
			$(".customuilink").css('visibility', 'hidden');
			$("#content_ui").focus();

		}
		else{
			contentVisible = true;
			if (isIE == true) {$("#content_html").animate({ left: "+=1000" }, animSpeed, "swing");} else {$("#content_html").fadeIn("slow")};
			$("#content_bg").animate({ left: "+=1000" }, animSpeed, "swing");
			$("#bContentFade").html("<b>Bilder zeigen</b>");
			$("#content_ui").removeClass('uibuttonoverpic');
			$("#picture_ui").removeClass('uibuttonoverpic');
			$("#picture_ui").css('visibility', 'hidden');
			$(".customuilink").css('visibility', 'visible');
			$("#content_ui").focus();

		}
		
	});
	
	// slideshow
	$(function() {
		$('#main_pic').cycle(
		{
			prev:	'#bPreviousPic',
			next:	'#bNextPic'
		});
	});
	
	if (contentVisible == false) { content_startaus(); }

});



// Soundmanager Init

soundManager.url = './scr';
soundManager.debugMode = false;
var mouseoverSound;
var bgSound;
var soundEnabled = true;

soundManager.onload = function() {
	bgSound = soundManager.createSound({id: 'bgSound', url: './snd/ansi004-artroom_mono_64k.mp3', volume: 50});
	mouseoverSound = soundManager.createSound({id: 'mouseoverSound', url: './snd/mouseover.mp3', volume: 50});
	if (getCookie("soundEnabled") == "false"){
		soundEnabled = false;
		$("#bScwitchSound").html("Sound ein");
	}
	if (bgSoundDisabled != "true") { playbgsound() };
}

soundManager.onerror = function() {
	soundEnabled = false;
	document.cookie="soundEnabled="+soundEnabled;
}


// soundmanager functions

function playbgsound(){
	if (soundEnabled == true && bgSoundDisabled != true){
		bgSound.play({onfinish: function() {this.play()}});
	}
}

function playmouseover(){
	if (soundEnabled == true){
		if (mouseoverSound != null) mouseoverSound.play();
	}
}

function switchSound(){
	soundEnabled = !soundEnabled;
	document.cookie="soundEnabled="+soundEnabled;
	if (soundEnabled == false)
	{
		soundManager.stopAll();
		$("#bScwitchSound").html("Sound ein");
	} 
	else 
	{
		playbgsound();
		$("#bScwitchSound").html("Sound aus");
	}
}

// Session Cookies 

function getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
