	var projekte = 1;
	var durchgang = 0;
	var display_id = 1;
	var middle = 3;
	var lr_id =

$(document).ready(function() {

  $("#sub-image-txt").css('opacity', '0.7');
	images = new Array();
	$.getJSON("http://"+location.host+"/index.php?id="+pageId+"&ajax="+projectId,
     function(data){

			$.each(data.items, function(i,item){



				try{
					$.preloadImages("uploads/tx_imxprojekte/"+item.inactive);
				}
				catch(e){

				}

				images[projekte] = new Array();
				images[projekte]["active"] = item.active;
				images[projekte]["inactive"] = item.inactive;
				images[projekte]["lightbox"]  = item.lightbox;
				images[projekte]["image"] = item.image;
				images[projekte]["subtext"] = item.subtext;


				if(projekte != 1){
					$("#imxprojekte_stripes_"+projekte).css({'opacity': '0.3', 'background-color': '#000000'});
				}



				projekte = projekte + 1;



		});


   });


   $("#go_left img").hide();

	var content_hoehe = viewport_height - 243 - 362 - 20;

	if($("#imxprojekte_basket").height() > content_hoehe){
		content_hoehe = $("#imxprojekte_basket").height();
		content_hoehe = content_hoehe + 20;
	}

	$("#imxprojekte_single_content").css('height', content_hoehe);

});




$(window).resize(function(){
	/**
		Berechne die Höhe von der Textbox
		Viewport Höhe - Höhe Header - Großes Bild - Padding 20px
	**/

	viewport_height = window.innerHeight;
	if(typeof viewport_height == "undefined"){
			viewport_height = document.documentElement.clientHeight;
	}
	var content_hoehe = viewport_height - 243 - 362 - 20;

	if($("#imxprojekte_basket").height() > content_hoehe){
		content_hoehe = $("#imxprojekte_basket").height();
		content_hoehe = content_hoehe + 20;

	}

	$("#imxprojekte_single_content").css('height', content_hoehe);

});


jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}


function active(id){
	if(id != display_id){

		$("#imxprojekte_stripes_"+id).css({'opacity': '1', 'background-color': '#000000'});
	}
}

function inactive(id){
	if(id == display_id){

	}
	else {

		$("#imxprojekte_stripes_"+id).css({'opacity': '0.3', 'background-color': '#000000'});
	}

}

function display(id){




	checkLightbox(id);

	checkImageText(id);

	if(id != display_id){
	  debog(images[id]);
	  if(images[id]['subtext'] != '') {
	    $("#sub-image-txt").html(images[id]['subtext']);
	    $("#sub-image-txt").show();
	  } else {
	     $("#sub-image-txt").css('display', 'none');
	  }
		$("#imxprojekte_single_image_big").attr("src", "uploads/tx_imxprojekte/"+images[id]["image"]);
		$("#imxprojekte_stripes_"+display_id).css({'opacity': '0.3', 'background-color': '#000000'});
		$("#imxprojekte_stripes_"+id).css({'opacity': '1', 'background-color': '#000000'});
		display_id = id;
	}

	durchgang++;

}


function caroussel(dir){

	if(dir == 'goRight'){
		if(middle+3 < projekte){
			hide(middle-2);
			show(middle+3);
			middle = middle+1;
			if(durchgang == 0){
				$("#go_left img").show();
			}
		}
	}
	else {
		if(middle-3 > 0){
			hide(middle+2);
			show(middle-3);
			middle = middle - 1;
		}
	}

	if(middle+2 == projekte-1){
		$("#go_right img").hide();
		$("#go_left img").show();
	}

	if(middle-2 == 1){
		$("#go_left img").hide();
		$("#go_right img").show();
	}

	if(middle+2 < projekte-1){
		$("#go_right img").show();
	}

	if(middle-2 > 1){
		$("go_left img").show();
	}
}

function hide(id){



	$("#imxprojekte_stripes_"+(id)).hide("");

}

function show(id){
	$("#imxprojekte_stripes_"+(id)).show("");
}

function checkLightbox(id){
	if(images[id]["lightbox"] != ""){
		$("#imxprojekte_single_lightboxlink_img").show();
		$("#imxprojekte_single_lightboxlink_img").attr('href', 'uploads/tx_imxprojekte/'+images[id]["lightbox"]);
	}else {
		$("#imxprojekte_single_lightboxlink_img").hide();
	}

}

function checkImageText(id){
	if(images[id]["text"] != ""){
		$("#imxprojekte_single_content").html(images[id]["text"])

	}
}
function makeItActive(what){

	if(what == 'goRight'){
		$("#go_right_image").attr('src', 'typo3conf/ext/imx_projekte/design/img/pfeil_rechts_h.gif');
	}
	else{
		$("#go_left_image").attr('src', 'typo3conf/ext/imx_projekte/design/img/pfeil_links_h.gif');
	}

}

function makeItInActive(what){

	if(what == 'goLeft'){
		$("#go_left_image").attr('src', 'typo3conf/ext/imx_projekte/design/img/pfeil_links.gif');
	}
	else {
		$("#go_right_image").attr('src', 'typo3conf/ext/imx_projekte/design/img/pfeil_rechts.gif');
	}

}


function lbactive(){
	$("#lightbox_bild").attr('src', 'typo3conf/ext/imx_projekte/design/img/lupe_h.gif');
}

function lbinactive(){
	$("#lightbox_bild").attr('src', 'typo3conf/ext/imx_projekte/design/img/lupe.gif');
}


$(function() {
	$('#imxprojekte_single_lightboxlink a').lightBox(
	  {
	    fixedNavigation:true
	  }
	);
});


function debog($obj) {
	if (window.console && window.console.log) window.console.log($obj);
}
