$(document).ready(function(){
   
/*   	$(".link_option").click(function(e) {
			  $('#option').delay(0).animate({opacity:'1', width:'toggle'},600);
	         $('#option_area').delay(700).animate({opacity: "show"}, "slow");
		
		$(this).animate({backgroundColor: '#0cf'}, 'slow');
		}, function() {
			$('#option').delay(700).animate({opacity:'0', width:'toggle'},600);javascript:void(0);
	        $('#option_area').delay(0).clearQueue().delay(700).animate({opacity: "hide"}, "fast");
	});;*/
/*Preview
////////////////////////////////////////////////*/

var img_array	= $('#img_cache a'); //liest alle cach elemente in ein array
var img_count = img_array.length; //sagt wie viele keys sich im array verstecken
var i = 0;
var count_block_counter = img_count;
var hideside = -1000;


$("#presentation").click(function() {
	var html = '<div id="preview_container" style=" display:none; "><ul id="thumbs" style=" position:absolute; z-index:999; "> </ul><div id="preview_backward"><img style="left:8%; width:53px; margin-top:-27px; top:50%; position:absolute; opacity:0;" src="rs_matrix/templates/rBio/files/ico_backward.png"></div><div id="preview_forward"> <img style="right:8%; width:53px; margin-top:-27px; top:50%; position:absolute; opacity:0;" src="rs_matrix/templates/rBio/files/ico_forward.png"></div>';
		html += '<a style="float:right;" href="#" id="link_preview_close"><img src="rs_matrix/templates/rBio/files/ico_close_white.png" width="50" height="51" /></a>';
		html += '<a style="float:right;" href="#" id="link_preview_grid"><img src="rs_matrix/templates/rBio/files/ico_grid.png" width="51" height="51" /></a>';
		html += '</div>';
    $('body').append(html);
	//$(html).appendTo('body');
	$('#preview_forward').hover(function() {$(this).find('img').animate({opacity:'1'},200); }, function() {$(this).find('img').animate({opacity:'0'},200); });
	$('#preview_backward').hover(function() {$(this).find('img').animate({opacity:'1'},200); }, function() {$(this).find('img').animate({opacity:'0'},200); });
	jQuery.each(img_array, function(i) {
		//img_array[i]
		//hier ollte gechekt werden um was für einen datei typ es sich handelt
		//if(img_array[i])
		$("#preview_container #thumbs").append('<li class="count_block" alt="'+i+'" ><img style="height:100px;" src="'+img_array[i]+'"> </li>');
		
	});
	
	$("#preview_container #thumbs").prepend('<li class="count_block_counter"  style=" display:block; float:left; height:104px; width:104px; margin:50px; background:#0cf; color:#fff; font-size:400%;  line-height:100px; ">'+count_block_counter+'</li>');
	//alert(count_block_counter)
/*	$('.count_block_counter').hover( function() {
		var count_block= $('.count_block');
		jQuery.each(count_block, function(i) {
			$(this).delay(200*i).animate({opacity:'show'},700);
		});
	});*/
/*	$('.count_block').click(function() {
		//count_block_counter += -1;
		if($(this).attr('Class') != 'hide'){
			$(this).addClass('hide');
			$(this).animate({opacity:'hide', width:'hide'},200,function(){
					count_block_counter = count_block_counter-1
					$('.count_block_counter').text(count_block_counter);
					$('#preview_big_pic').attr('src', $(this).attr('src') );
					if(count_block_counter <= 0) $('.count_block_counter').css(({ backgroundColor: "#fd1756"}));
					
				
			});
		}
			
	});
	*/
	

	$('.count_block_counter').bind({
		'click': function() { $('#thumbs').animate({opacity:'hide'},200) },
		'mouseover': function() { $('.count_block_counter').animate({opacity:'0.8'},200); },
		'mouseout': function() { $('.count_block_counter').animate({opacity:'1.0'},200); }
	});
	//$('.count_block_counter').hover(function() {$(this).animate({opacity:'0.5'},200);},function(){$(this).animate({opacity:'1.0'},200);});
	
	$('.count_block').hover(function() {
		$(this).find('img').animate({opacity:'0.7'},200)
	}, function(){
		$(this).find('img').animate({opacity:'1.0'},200)
	});
	$('.count_block').click(function() {
		//count_block_counter += -1;
		if($(this).attr('Class') != 'hide'){
			$(this).addClass('hide');
			var read_number = $(this).attr('alt')
			$(this).find('img').animate({opacity:'0.5'},200,function(){
					$(this).animate({opacity:'1'},100)
					$('#preview_big_pic').attr('src', img_array[read_number]);
					i = read_number;
					$('#thumbs').animate({opacity:'hide'},700);
					$('#preview_big_pic').center_image();
					if(count_block_counter <= 0) $('.count_block_counter').css(({ backgroundColor: "#fd1756"}));
					
				
			});
		}
			
	});
	
	$('#link_preview_grid').bind({
		'mouseover': function() { $('#link_preview_grid').animate({opacity:'1.0'},200); },
		'mouseout': function() { $('#link_preview_grid').animate({opacity:'0.1'},200); }
	});
		
	//$('#link_preview_grid').hover(function() { $('#link_preview_grid').animate({opacity:'1.0'},300)  });
	$('#link_preview_grid').click(function() {
		$('#thumbs').animate({opacity:'show'},700, function(){
			var thumbs_img = $('#thumbs .count_block');
			jQuery.each(thumbs_img, function(i) {
				$(this).delay(i*100).animate({opacity:'show'},500);
			});
		});
		
	});
	
	
	//startet die anzeige effekte
	$('#main_table').css({ position: "absolute"}).animate({left: -1000, opacity:'hide'},700);
	$('#preview_container').delay(600).animate({opacity:'show', width:'toggle'},600);
	$('#link_preview_close').delay(1300).animate({opacity:'show'},700);

	
	if(img_count > 1) {
		 image_string1 = new Image();
		 image_string2 = new Image();
		 image_string3 = new Image();
		 
		 $(image_string2).attr('src', img_array[i]);
		 $(image_string3).attr('src', img_array[i+1]);
	
		 //alert(minus_margin_left)
		 //$('.popup').removeClass('active');
						//$(this).delay(5).addClass('active');
		 $(image_string2).attr('id', 'preview_big_pic');
		 $(image_string3).attr('class', 'hidden');
		 
		 
		 
		 if($('#preview_container').append(image_string2, image_string3)) {
			 $('#preview_big_pic').animate({opacity:'show'},700,function(){
				
				$(this).center_image();
			 
			 });
		 }

		 
		 var test1 = $(image_string2).innerWidth();
		 var test2 = $(image_string2).width();
		  $('#preview_container').append('<p style="color:#fff; position:absolute; bottom:10px; left:20px;"><b style="color:#f03;">Alpha Bereich:</b> Dieser Bereich befindet sich im Aufbau. v.0.2.3</p>');
		 //$('#preview_container').append(test1+'   '+ test2);
		
	 } else {
		$('#preview_container').append('No Images found<p style="color:#fff; position:absolute; bottom:10px; left:20px;"><b style="color:#f03;">Alpha Bereich:</b> Dieser Bereich befindet sich im Aufbau. v.0.2.3</p>');	 
	 };
	
	
	//alert(img_array[1]);
/*	$(img_array).each(function(index, value) {
	 var img = new Image();
	 $(img).load(function(){
		 $(this).css('display','none');
		 ('#preview_container').append(this);
		 $(this).fadeIn('slow',function(){
			LoadImage(index+1,max);
		  });
	 });
	});*/
	
	
});;

$.fn.center_image = function() {
	  if (this.innerWidth() == 0)
	  { 
	      var minus_margin_left = '466';
	      var minus_margin_top = '369.5';
	  }
	  else
	  {
	      var minus_margin_left = this.innerWidth()/2;
	      var minus_margin_top = this.innerHeight()/2;
	  }  
	  //alert('g');
	 // $('#preview_container').append('<span style="color:#af0">---'+minus_margin_left+'----'+test2+'--- </span>');
	 // $(this).css({marginLeft: -minus_margin_left, marginTop: -minus_margin_top});
	 
  	$(this).animate({marginLeft: -minus_margin_left, marginTop: -minus_margin_top},300);
	$(this).animate({opacity:'show'},300);

};

$.fn.bild_wechsel = function(calc){
	if(i <= 0) i = 0;
	if(calc == 'forward') {i = i*1+1; hideside = -1000;}
	else {i = i*1-1; hideside = 1000;}
	//alert(i);
/*	$('.hidden').animate({opacity:'toggle', width:'toÄ__###################ggle'},600, function(){
		$('.hidden').attr('id', ('preview_big_pic'));
		$('.hidden').removeClass();		
	//	alert('fuck');
	});
	 
	 
	 $(this).animate({opacity:'toggle', width:'toggle'},600);
	 $(this).attr('id', (' '));	
	 $(this).attr('class', ('hidden'));	
	 $(this).center_image();*/
	 //$("#preview_big_pic").clone().append("#preview_container");
	 $('#preview_big_pic').animate({opacity:'hide', marginLeft:hideside},400, function(){
		 /*
		 		//$('#preview_big_pic').remove();
		 // image_string2 = new Image();
		// $(this).delay(200).attr('src', img_array[i]);
  	     //$(this).delay(200).attr('id', 'preview_big_pic');
		 
		 */
		 //DER BEREICH SOLLTE ERST STARTEN WENN DAS IMMAGE GELADEN SIT, onload event oder so hin 
		 // evtl beim wechsel mit remove arbeiten damit der ie z.b. erkenntt das es sich um ein neues bild handelt
		 $(this).attr('src', img_array[i]);
		 $(this).center_image();
		 
	 });
	 
	 $('.hidden').attr('src', img_array[i+1]);
	  

};

$("#preview_big_pic").live('click',function() {$(this).bild_wechsel('forward');});
$("#preview_backward").live('click',function() {$(this).bild_wechsel('backward');});
$("#preview_forward").live('click',function() {$(this).bild_wechsel('forward');});

$("#preview_container #link_preview_close").live('click',function() {
	$('#preview_container').animate({opacity:'hide', width:'toggle'},600,function(){
		$('#preview_container').remove();
	});
	$('#main_table').css({ position: "absolute"}).css({left: 0},1000).delay(1400).animate({opacity:'show'},600);
	
	//$('#test').remove(); 
		
});;
	
/*Option
////////////////////////////////////////////////*/
$(".img_span").hover(function() {
	 $(this).find('.lights').delay(0).animate({opacity:'toggle', hight:'toggle'},600);
});
/*Option END
////////////////////////////////////////////////*/

/*Option
////////////////////////////////////////////////*/
var key_active = false;
$(".pic_shadow").hover(function() {
	$(this).find('#hidden_close_pic').delay(100).animate({opacity: "show"},300);
	//$(this).find('#hidden_close_pic').delay(100).animate({opacity: "1"},300);
	$(this).find('form').animate({opacity: "show"},300); 
 }, function() {
	$(this).find('form').animate({opacity: "hide"},200);
	$(this).find('#hidden_close_pic').animate({opacity: "hide"},300);
});;


/*Option
////////////////////////////////////////////////*/
	$(".link_option").click(function() {
			  $('#option').delay(0).animate({opacity:'1', width:'toggle'},600);
			  $('#option_2').delay(0).animate({opacity:'1', height:'toggle'},600);
	         $('#option_area').delay(1000).animate({opacity: "show"}, "slow");	
			 $('#option_area span').delay(2100).animate({opacity: "show"}, "slow");	
	});;
	
	$(".link_option_close").click(function() {
				$('#option').delay(200).animate({opacity:'0', opacity:'toggle'},600);
				$('#option_2').delay(200).animate({opacity:'0', opacity:'toggle'},600);
	        $('#option_area').delay(50).clearQueue().delay(700).animate({opacity: "hide"}, "fast");
			$('#option_area span').delay(0).clearQueue().delay(700).animate({opacity: "hide"}, "fast");
			
	});;
	/*
	$("#option").click(function() {
				$('#option').delay(200).animate({opacity:'0', width:'toggle'},500);
	        $('#option_area').delay(0).clearQueue().delay(700).animate({opacity: "hide"}, "fast");
	});;*/
	
/*Form
/////////////////////////////////////////////////*/

/*text_span
/////////////////////////////////////////////////

	$(".pic_frame").hover(function() {
		   $('.text_span').delay(0).animate({height:'toggle'},600);
	});;
	
	$(".link_option_close").click(function() {
			 $('.text_span').delay(0).animate({height:'toggle'},600);

			
	});;

/*text_span
/////////////////////////////////////////////////*/
	
	$("#open_contact_form").click(function() {
			$(this).next('.contact_form').animate({height: 'toggle'}, 'slow');

	}, function() {
		$(this).next('.contact_form').animate({height: 'toggle'}, 'slow');
	});;
	
	
	
	
	$(".example1").mouseover(function() {
	  $(this).next(".show_pics").animate({opacity:'toggle', height:'toggle'},400);
	  $(this).toggleClass("active");
	});;
	
	
	$(".show_pics").click(function() {
		$(this).next('.show_pics_main').animate({width: 'toggle'}, 'slow');
		
	}, function() {
		$(this).next('.show_pics_main').animate({width: 'toggle'}, 'slow');
	});;
	
	
	$(".gallery_color_hover li").hover(function() {
		var color = $(this).css('color');
		$(this).animate({backgroundColor: color, height: '35px'}, 'slow');
		//if variable damit mehr farben möglich sind evtl. rel="color"
		//$(this).animate({height: '30px'}, 'fast');
		
	}, function() {
		//$(this).animate({"background-position": "-=50px"}, "slow");
		$(this).animate({backgroundColor: '#000'}, 'slow');
		$(this).animate({height: '20px'}, 'slow');
	});;
	
	///////////////////
	
	
	$("#footer_menue li").hover(function() {
		$(this).find("> ul").animate({opacity: 'show', height: 'show', width: 'show'}, 'fast');
	}, function() {
		$(this).find("> ul").animate({opacity: 'hide', height: 'hide'}, 'fast');
	});;
	
	
	//manipulatet for the field class
/*	$('input[class="field"]').focus(function() {  
        $(this).removeClass("idleField").addClass("focusField");  
        if (this.value == this.defaultValue){  
            this.value = '';  
        }  
        if(this.value != this.defaultValue){  
            this.select();  
        }  
    });  
	$('input[type="text"]').blur(function() {  
        $(this).removeClass("focusField").addClass("idleField");  
        if ($.trim(this.value == '')){  
            this.value = (this.defaultValue ? this.defaultValue : '');  
        }  
    });
	
    $('input[class="field_pw"]').focus(function() {  
        $(this).removeClass("idleField").addClass("focusField");  
        if (this.value == this.defaultValue){
			this.type = 'password';
            this.value = '';  
        }  
        if(this.value != this.defaultValue){  in
		    this.type = 'password';
            this.select();  
        }  
    });*/
//focus input off   
   $(".slide li").hover(function() {
	  $(this).next(".slide-out").animate({opacity:'toggle', height:'toggle'},400);
	  $(this).toggleClass("active");
	});;
						   
	$(".main_menue_li_norm").click(function() {
	  $(this).next(".main_menue_li_sub").animate({opacity:'toggle', height:'toggle'},400);
	  $(this).toggleClass("active");
	});;
	
	

	$("a.btn-slide").click(function(){
	  $(".panel").slideToggle("slow");
	  $(this).toggleClass("active");
	});


$(".pane .delete").click(function(){
	  $(this).parents(".pane").animate({ opacity: "hide" }, "slow");
	});



//cookie test!!!!!!!!!!!!!!!!!!!!!!!

	
/*		//	$.cookie("inner_div_left_slider","closed");
	elem = $("#inner_div_left");
	if (elem.hasClass ("active")) {
	   // whatever
	   $.cookie("inner_div_left_slider","open")
		
	} else {
		$.cookie("inner_div_left_slider","closed");
	}
	//.$.cookie("inner_div_left_slider","open")
 var inner_div_left_slider = $.cookie('inner_div_left_slider');
    // Set the user's selection for the left column
    if (inner_div_left_slider == 'closed') {
        $('#inner_div_left').animate({opacity:'toggle', width:'toggle'},400);
		//$('#inner_div_left').css("visibility","hidden");
    };
*/

//cookie test!!!!!!!!!!!!!!!!!!!!!!!


$(".drop_down").click(function(){
	  $(this).next("span .drop_down2").animate({opacity:'toggle',height:'toggle'},400);
	  $(this).toggleClass("active");
	});;

$("#impressum").click(function() {
		$(this).find("span").animate({opacity: 'show'}, 'slow');
	}, function() {
		$(this).find("span").animate({opacity: 'hide'}, 'slow');
	
	});;




/* lässt das nächste object sliden
	$("a#animate").click().toggle(function(){
		$(this).animate({
			height: 'hide',
			opacity: 'hide'
		}, 'slow');
	}, function() {
		$(this).animate({
			height: 'show',
			opacity: 'show'
		}, 'slow');
	});
*/
	$(".g_span").click().toggle(function(){
		$("#hallo").animate({
			height: 'show',
			opacity: 'show'

		}, 'slow');
	}, function() {
		$("#hallo").animate({
			height: 'hide',
			opacity: 'hide'
		}, 'slow');
	});
	

	
	$("a.bug").click(function(){
		$("#bug_div").slideToggle("slow");
	  $(this).toggleClass("active");
	});
	
	
	
	
	//gallery slide menue
	$(".sub_menue_div li").hover(function() {
		$(this).find("div").animate({height: 'show',opacity: 'show'}, 'fast');
	}, function() {
		$(this).find("div").animate({height: 'hide',opacity: 'hide'}, 'fast');
	
	});;
	

	//$(".accordion h3:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});
	
	//visiblefunction
	$(".visibile div:not(:first)").hide();

	$(".visibile a").click(function(){
		$(this).next("div").slideToggle("fast")
		.siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("a").removeClass("active");
	});
	

	//for the hover infoboxes
	$(".infobox a").hover(function() {
		$(this).next("div").animate({opacity: "show"}, "slow");
	}, function() {
		$(this).next("div").animate({opacity: "hide"}, "slow");
	});;
	
	
	$(".g_span a").hover(function(e) {
			$(this).find("img").fadeTo("slow", 0.61);
			$(this).next("div").animate({opacity: "show"}, "fast");
			$(this).next("div").css({ position:"fixed",  top:e.clientY-50, left:e.clientX+20 });
    		
			$(this).mousemove(function(e){
	 				$(this).next("div").css({ top:e.clientY-50, left:e.clientX+20 });
    		});			
	}, function() {
			  $(this).next("div").animate({opacity: "hide"}, "fast");
			  $(this).find("img").fadeTo("slow", 1);
	});;
	
	//gallery hover, used by rightside pics
	$(".gallery_r a").hover(function(e) {
			$(this).find("img").fadeTo("slow", 0.61);
			$(this).next("div").animate({opacity: "show"}, "fast");
			$(this).next("div").css({ position:"fixed",  top:e.clientY-50, left:e.clientX-250 });
			$(this).mousemove(function(e){
	 				$(this).next("div").css({ position:"fixed",  top:e.clientY-50, left:e.clientX-250 });
    		});
			$(this).next("div").animate({opacity: "show"}, "fast");
	}, function() {
			  $(this).next("div").animate({opacity: "hide"}, "fast");
			  $(this).find("img").fadeTo("slow", 1);
	});;

///////make the above object transparent and on another visible
	$(".hover_text").hover(function() {
		 //$(this).html("<div id='bla'>sasssasasasss</div>");
		 $(this).find("img").fadeTo("slow", 0.23);
		 //$(this).find("div").slideToggle("slow")
		$(this).find("div").animate({opacity: "show"}, "slow"); 
	}, function() {
		$(this).find("img").fadeTo("slow", 1);
		//$(this).find("div").slideToggle("slow")
		$(this).find("div").animate({opacity: "hide"}, "slow");
	});;

//browsercheck
$("#browsercheck").prependTo("body");	
//#browsercheck:not(children)
$("#browsercheck").delay(2500).animate({opacity: "show"}, "slow")

$("#browsercheck").click(function() {
	$(this).find('div').animate({marginTop:-130}, "slow", function(){
		$("#browsercheck").delay(100).animate({opacity: "hide"}, "slow",function(){
			$(this).remove();	
		});	
	});
	
});

/*Tools
--------------------------------------------------------*/
	var tools_active = false;
	var tools = $('.tools li');
	var tools_last_active = '';
	
	jQuery.each(tools, function(i) {
		var original_text = $(this).text();
		switch ($(this).text()) {
			case 'C4D': var t_color = '#0cf'; 
						var content = 'Maxon <br /><b style="color:'+t_color+'">Cinema4D</b> <br /><br /><br /> Eine 3D-Grafik-Software der Firma Maxon zum Erstellen von 3D-Modellen, Texturen, Computergrafiken und Animationen.'; 
						 break;
			case 'AE': var t_color = '#74799a';
					   var content = 'Adobe<br /><b style="color:'+t_color+'">AfterEffects</b><br /><br /> <br />Eine Compositing- und Animationssoftware. Mit ihr lassen sich Filmaufnahmen mit computergenerierten Bildern und Effekten zusammenf&uuml;gen.'; 	
					   break;
			case 'Ps': var t_color = '#0b9bff';
					   var content = 'Adobe<br /><b style="color:'+t_color+'">Photoshop</b><br /><br /><br />Ein kommerzielles Bild- bearbeitungsprogramm. <br />Im Bereich der prof. Bildbearbeitung'; 
					   break;
			case 'Ilu':	var t_color = '#f60'; 
						var content = 'Adobe <br /><b style="color:'+t_color+'">Illustrator</b><br /><br /><br />Ein vektorbasiertes Grafik- und Zeichenprogramm.'; 
						break;
			case 'ID':	var t_color = '#ec1a80'; 
						var content = 'Adobe <br /><b style="color:'+t_color+'">InDesign</b><br /><br /><br />Ein vektorbasiertes Grafik- und Zeichenprogramm.'; 
						break;
			case 'Mocha':	var t_color = '#7e543a'; 
						var content = 'Adobe <br /><b style="color:'+t_color+'">Mocha</b><br /><br /><br />Ein Programm zum tracken von Bildpunkten.'; 
						break;
			case 'Pen':	var t_color = '#506572'; 
						var content = 'Hand <br /><b style="color:'+t_color+'">Stift</b><br /><br /><br />Ein altmodisches Gerät zum zeichnen.'; 
						break;
			case 'PHP':	var t_color = '#b6d837'; 
						var content = 'Code <br /><b style="color:'+t_color+'">Hypertext Preprocessor</b>';
						break; 
			case 'HTML': var t_color = '#171717'; 
						 var content = 'Code <br /><b style="color:'+t_color+'">Hypertext Markup Language</b>';
						 break;
			case 'CSS': var t_color = '#171717'; 
						var content = 'Code <br /><b style="color:'+t_color+'">Cascading Style Sheets</b><br /><br />CSS genannt, sind quasi eine deklarative Sprache für Stilvorlagen'; 
						break;
			case 'AS': var t_color = '#d02e38';
					   var content = 'Adobe<b style="color:'+t_color+'">ActionScript</b>'; 
					   break;
			default: var t_color = '#232323';
					 var content = $(this).text();  
					 break;
		}
		var parent_rel = $(this).parent().attr('rel');
		//$(this).append('<div style="position:absolute; margin:50px; z-index:997;" alt="'+content+'" >"'+content+'</div>');
		
		
		$(this).click(function() {
			if(tools_last_active != 'p'+i){
				if(tools_active == true){
					$('.tools_active_layer').delay(0).animate({opacity:'hide'},300,function(){
						$('.tools_active_layer').remove();
						tools_active = false;
						//if(tools_last_active != i){
							$('#'+parent_rel).delay(100).tools_active_layer_show(original_text, t_color, content);
							tools_last_active = 'p'+i;
						//}
					});
				} else { 
					$('#'+parent_rel).tools_active_layer_show(original_text, t_color, content);
					tools_last_active = 'p'+i;
				}
			} else {
				$('.tools_active_layer').delay(0).animate({opacity:'hide'},300,function(){
						$('.tools_active_layer').remove();
						tools_active = false;
						tools_last_active = '';
				});
			}
			
		});
		
		$.fn.tools_active_layer_show = function(original_text, t_color, content) {
				$(this).prepend('<div class="tools_active_layer" style="width:200px; height:auto; color:#fff; padding:10px; position:absolute; z-index:998;  bottom:20px; right:20px; background:#171717; font-family:calibri;">'
								   +'<span style="">'+original_text+'</span>'
								   +content
								   +'</div>'
								   +'<div class="tools_active_layer" style="position:absolute; display:none; height:100%; opacity:0.8; width:100%; z-index:997; background:'+t_color+';"></div>');
				$(this).find('div').animate({opacity: "show"});
				tools_active = true;
		}
	/*
		$(this).click(function() {
		$('#'+parent_rel).prepend('<div style="position:absolute; display:none; height:100%; opacity:0.5; width:100%; z-index:998; color:#fff; background:#ff6600;"><div style="width:100px; height:100px; position:absolute; bottom:20px; right:20px; background:#171717; ">'+content+'</div></div>');
		$('#'+parent_rel).find('div').animate({opacity: "show"});
		}, function() {
			$('#'+parent_rel).find('div').animate({opacity: "hide"},function(){
				$('#'+parent_rel).find('div').remove();	
		});
		
	});
	*/
	
	});
	
	//soll immmer aktualisiert werden. damit sich die main menue pos, automatisch aktualiesirt
	
	$(window).load(function () {
		$(this).select_menue_bullet();
		$(this).hide_content_parts();
		//alert();
	});
	//$('body').select_menue_bullet();
	$(document).scroll(function () { 
		$(this).select_menue_bullet();
   }); 
   
    //live(hide_content_parts());
    $(window).resize(function() {
		$(this).hide_content_parts();
	});
	
	$.fn.select_menue_bullet = function() {
		 var marker = $('#main_menue').offset().left;
		 //alert($('#main_menue').offset().left);
		 gallery_pos = $('#pics').offset();
		 wip_pos = $('#WIP').offset();
		 rStudio_pos = $('#rStudio').offset();
		 impressum_pos = $('#impressum').offset(); 
			  
			  
		 if (gallery_pos.left-400 <= marker && wip_pos.left-400 >= marker) {  $('#mm_gallery').addClass('active');}
		 else {  $('#mm_gallery').removeClass('active');};
		  
		 if (wip_pos.left-400 <= marker && rStudio_pos.left-400 >= marker) {  $('#mm_WIP').addClass('active');}
		 else { $('#mm_WIP').removeClass('active');};
		  
		 if (rStudio_pos.left-400 <= marker && impressum_pos.left-400 >= marker) { $('#mm_rStudio').addClass('active');}
		 else {  $('#mm_rStudio').removeClass('active');};
	}
	//alert(main_menue_pos.left+' '+impressum_pos.left)
	
	$('#new_menue').live('click',function() {
		$(this).find('ul').animate({height:'toggle', opacity:'toggle'});
		$('body').hide_content_parts();
	});
	
	$.fn.hide_content_parts = function() {
		$(this).dequeue();
		var bodywidth = $('body').innerWidth();
		var bodyheight = $('body').innerHeight();
		//$('#new_menue').unbind('click');
		//alert (bodywidth);
		var new_menue = '<div id="new_menue">Menue<br /><ul><li><a href="#pics">Gallery</a></li><li><a href="#WIP">W.I.P</a></li><li><a href="#rStudio">rStudio</a></li><li><a href="#impressum">Impressum</a></li></ul></div>'
		if($('#new_menue').length <= 0) $('body').prepend(new_menue);
		
		
		if(bodywidth <= 900 || bodyheight <= 645) {
			$('#main_menue, #menue_impress').animate({opacity: 'hide'},200);
			$('#new_menue').delay(400).animate({opacity: 'show'},400);
		} else {
			$('#new_menue').animate({opacity: 'hide'},200,function(){
				$('#main_menue, #menue_impress').animate({opacity: 'show'},400);
				//alert();
			//	$('#new_menue').animate({opacity: 'hide'},400,function(){
				$('#new_menue').remove();
			});
			//});
		}
		
		if(bodywidth <= 800) $('#left, #right').animate({opacity: 'hide'},400);
		else $('#left, #right').animate({opacity: 'show'},400);
		
	};

});
