/* Javascript Document Ready */ 
	
	
  $(document).ready(function(){

	/* Elemente ausblenden */
	//$('[hide="true"]').hide();

	//Lightbox
	$('#bildgalerie_inner a').lightBox();
	$('.zoom').lightBox();
	$('#play').hide();

	$('.close').click(function(){
	
		$(this).parent('div:first').hide();
		
	});
	
	var config = {
		width:500
	};
 
	// Initialize the editor.
	// Callback function can be passed and executed after full instance creation.
	$('.editor').ckeditor(config);
	CKFinder.setupCKEditor( null, 'ckfinder/' ) ;

	$('div#bildlinks[hide="true"]').css("height","45px");
	$('div#bildlinks[hide="true"]').css("cursor","pointer");
	//$('div#bildlinks[hide="true"]').scrollTo('+=138px', 800);

	$('div#bildlinks[hide="true"]').click(function()
		{
	  		$(this).attr("hide", "false");
			$(this).css("cursor","default");
			$(this).css("height","312px");
		});
	
	$('[click=load]').live("click",function()
		{
			// alert ($(this).attr("goto"));
			if ($(this).attr("goto") != 3)
				$('#content').css("background-color","#006334");
			else
				$('#content').css("background-color","#fff");
	  		$.get('load.php', { id: $(this).attr("goto") }, function(data) {
 				 $('#loadContent').html(data);
			});
		});

	if ($('div.bildlink_item').attr('hide'))
	{							   
		$('div.bildlink_item[hide="true"]').css("height","45px");
		$('div.bildlink_item[hide="true"]').css("cursor","pointer");
		$('div#bildlinks').css("height","203px");
	//$('div#bildlinks[hide="true"]').scrollTo('+=138px', 800);
	}
	$('div.bildlink_item[hide="true"]').click(function()
		{
			$('div.bildlink_item[hide="true"]').css("cursor","default");
			$('div.bildlink_item[hide="true"]').css("height","154px");
			$('div.bildlink_item[hide="true"]').attr("hide", "false");
			$('div#bildlinks').css("height","312px");
		});


	$('.leftmenu_child').hide();
	ShowFormElement($("#inh_typ option:selected").val());
	
	if ($('#img_web').attr('action')==0)
		$('#img_web').hide();
	else
	{
		$('#img_upload').hide();
		$('#img_checkbox').hide();
	}
	initalizeValidationContactform();
	initalizeValidationGuestook();
	
	  $('#scroll_down').click(function()
		{
	  		$('#content').scrollTo('+=120px', 800);
		});
	  
	  $('#scroll_up').click(function()
		{
	  		$('#content').scrollTo('-=120px', 800);
		});
	  
	   $('#scroll_left').click(function()
		{
	  		$('#bildgalerie_inner').scrollTo('-=108px', 700);
		});
	  
	  $('#scroll_right').click(function()
		{
	  		$('#bildgalerie_inner').scrollTo('+=108px', 700);
		});
	
	  $('.leftmenu_item').click(function()
		{
			if ($(this).attr('open')==0)
			{
				$('#'+ $(this).attr('id') +'>div').slideDown();
				$('#arrow_'+ $(this).attr('id')).attr('src','img/buttons/arrow_down_w.gif');
				$(this).attr('open',1);
			}
			else
			{
				$('#'+ $(this).attr('id') +'>div').hide();
				$('#arrow_'+ $(this).attr('id')).attr('src','img/buttons/arrow_right_w.gif');
				$(this).attr('open',0)
			}
		});
	  
	   //Sound Manager Initialisieren
	  soundManager.url = 'swf';
	  soundManager.waitForWindowLoad = true;
	  soundManager.debugMode = false;
	  soundManager.debugFlash = false;
	  
	  //Sound Manager Starten
	  soundManager.onready(function(oStatus) {
		  if (oStatus.success) {
			
			soundManager.createSound({
			 id:'1',
			 url:'mp3/1.mp3'
			});
			soundManager.play('1',10);
		  }
		});
	  
	  	$('#play').click(function(){
			soundManager.play('1',10);
			$('#pause').show();	
			$('#play').hide();	
		});
		
		$('#pause').click(function(){
			soundManager.stopAll();
			$('#play').show();
			$('#pause').hide();				  
		});
	  
		$('#carousel').Carousel(
			{
				itemWidth: 150,
				itemHeight: 100,
				itemMinWidth: 150,
				items: 'a',
				reflections: 0.2,
				rotationSpeed: 2
			});
		
		$('#img_src_div').click(function()
		{
	  		if ($('#img_src:checked').val())
			{
				$('#img_src').attr('checked','');
				$('#img_upload').show();
				$('#img_web').hide();
			}
			else
			{
				$('#img_src').attr('checked','checked');
				$('#img_upload').hide();
				$('#img_web').show();
			}
		});
		
		$('#img_src').click(function()
		{
	  		if ($('#img_src:checked').val())
			{
				$('#img_upload').hide();
				$('#img_web').show();
			}
			else
			{
				$('#img_upload').show();
				$('#img_web').hide();
			}
		});
  });

  function ShowChildElement(elem)
    {
		$('#'+elem+'>div').show();
	}

  function ShowFormElement(elem)
	{
		$("div#artikelname").hide();
		$("div#artikeltext").hide();
		$("div#artikellink").hide();
		$("div#artikeltarget").hide();
		$("div#artikelnav_name").hide();
		$("div#artikelfrontpage").hide();
		
		switch (parseInt(elem)) {
			case 0:	$("div#artikelfrontpage").show();
					$("div#artikelposition").show();
					$("div#artikelnav_name").show();
					$("div#artikelname").show();
					$("div#artikeltext").show();
					$("div#artikeltarget").show();
					break;
			case 1:	$("div#artikelnav_name").show();
					$("div#artikelposition").show();
					break;
			case 2:	$("div#artikelnav_name").show();
					$("div#artikelposition").show();
					break;
			case 3:
					break;
			case 4: $("div#artikelnav_name").show();
					$("div#artikellink").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
			case 5: $("div#artikelfrontpage").show();
					$("div#artikelnav_name").show();
					$("div#artikelname").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
			case 7:	$("div#artikelfrontpage").show();
					$("div#artikelnav_name").show();
					$("div#artikelname").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
			case 8:	$("div#artikelfrontpage").show();
					$("div#artikelnav_name").show();
					$("div#artikelname").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
			case 9: $("div#artikelfrontpage").show();
					$("div#artikelnav_name").show();
					$("div#artikelname").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
			default:$("div#artikelfrontpage").show();
					$("div#artikelnav_name").show();
					$("div#artikeltarget").show();
					$("div#artikelposition").show();
					break;
		}
		
	}

  function deleteElement(datei)
  {
	var adress = "index.php?page=5&id=" + datei;
	var answer = confirm('Wollen Sie diesen Artikel wirklich entfernen?');
	if (answer)
		window.location = adress;
  }
  
  function deleteImage(datei,id)
  {
	var adress = "index.php?image=6&id=" + id + "&img_id=" + datei;
	var answer = confirm('Wollen Sie dieses Bild wirklich entfernen?');
	if (answer)
		window.location = adress;
  }
  
  function deleteGuestbook(datei,id)
  {
	var adress = "index.php?gbook=4&id=" + id + "&gbook_id=" + datei;
	var answer = confirm('Wollen Sie diesen Eintrag wirklich entfernen?');
	if (answer)
		window.location = adress;
  }
