$(function(){

	jQuery.fn.encHTML = function() { 
	  return this.each(function(){ 
		var me   = jQuery(this); 
		var html = me.html(); 
		me.html(html.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')); 
	  }); 
	}; 
	 
	jQuery.fn.decHTML = function() { 
	  return this.each(function(){ 
		var me   = jQuery(this); 
		var html = me.html(); 
		me.html(html.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')); 
	  }); 
	}; 
	 
	jQuery.fn.isEncHTML = function(str) { 
	  if(str.search(/&amp;/g) != -1 || str.search(/&lt;/g) != -1 || str.search(/&gt;/g) != -1) 
		return true; 
	  else 
		return false; 
	}; 
	 
	jQuery.fn.decHTMLifEnc = function(){ 
	  return this.each(function(){ 
		var me   = jQuery(this); 
		var html = me.html(); 
		if(jQuery.fn.isEncHTML(html)) 
		  me.html(html.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')); 
	  }); 
	};
	
	// Gallery Thumbnails
	
	/*$("div.scrollable").scrollable({ 
		size:1,
		items:'#thumbs', 
 		next:'a.next',
		prev:'a.prev',
		speed:700
	});*/
	$("div.scrollable2").scrollable({
		size:1,
		items:'#thumbs2', 
		next:'a.next2',
		prev:'a.prev2',
		clickable:false,
		loop: false,
		speed:700
	});
	
	// Lightbox
	/*
	$('.get_picture').livequery(function(){
		$('.get_picture').lightBox({
			imageLoading: '/js/images/ajax-loader.gif',
			imageBtnClose: '/js/images/close.png',
			imageBtnPrev: '/js/images/prev.png',
			imageBtnNext: '/js/images/next.png',
			containerBorderSize:5,
			containerResizeSpeed: 350
		});
	});*/
	
	// Paragraphen
	
	$("div.scrollable").livequery(function(){ 
		$("div.scrollable").scrollable({
			size:1,
			items:'.items', 
			next:'a.naechster_p',
			prev:'a.letzter_p',
			clickable:false,
			loop: true,
			speed:700
		}).mousewheel(700);
	});
	
	var zaehler = 1;
	
	$("a.naechster_p").click(function() {
	
		var titel, titel2;
		zaehler = zaehler + 1;
		titel = $("div#element_"+(zaehler-1)).children("h1").html();
		titel2 = $("div#element_"+(zaehler+1)).children("h1").html();
		
		if(titel2 == null) {
			titel2 = "N&auml;chste Seite";
		}

		$("a.letzter_p span").html(titel);
		$("a.naechster_p span").html(titel2);
		

	});
	
	$("a.letzter_p").click(function() {
	
		var titel, titel2;
		zaehler = zaehler - 1;
		titel = $("div#element_"+(zaehler-1)).children("h1").html();
		titel2 = $("div#element_"+(zaehler+1)).children("h1").html();

		if(titel2 == null) {
			titel2 = "N&auml;chste Seite";
		}

		$("a.letzter_p span").html(titel);
		$("a.naechster_p span").html(titel2);
		

	});

	
});
