$(document).ready(function(){

//focus^basic script input by Sam Dunn:: thanks from rStudio!
   /* $('input[type="text"]').addClass("idleField");  
    $('input[type="text"]').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 : '');  
        }  
    });
	*/
	
	
	$(".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');
	});;
	
	
	
	//this part needs the jquerys color plugin
	$("#main_menue li").hover(function() {
		$(this).animate({backgroundColor: '#ff00aa'}, 'slow');
		
	}, function() {
		//$(this).animate({"background-position": "-=50px"}, "slow");
		$(this).animate({backgroundColor: '#c6c6c6'}, 'fast');
	});;
	
	$(".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){  
		    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!!!!!!!!!!!!!!!!!!!!!!!
$("#inner_div_left_slider").click(function(){
	  $("#inner_div_left").animate({opacity:'toggle', width:'toggle'},400);
	  
	  $("#inner_div_left").toggleClass("active");
	});;	
	
/*		//	$.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!!!!!!!!!!!!!!!!!!!!!!!



$("#absolute_div_right_slider").click(function(){
	  $("#absolute_div_right").animate({opacity:'toggle', width:'toggle'},400);
	  $(this).toggleClass("active");
	});;

$("#absolute_div_top_slider").click(function(){
	  $("#absolute_div_top").animate({height:'toggle'},400);
	  $(this).toggleClass("active");
	});;

$(".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');
	
	});;

$(".dir_system_pic").hover(function(e) {
		
		$(this).find("span").slideToggle("fast");
		//$(this).find("span").animate({ opacity: "show" }, "slow");
		$(this).toggleClass("active");
	
	});

$(".dir_system_pic li").hover(function(e) {
		
		$(this).find("textarea").animate({opacity:'toggle', width:'toggle'},100);
		//$(this).find("span").animate({ opacity: "show" }, "slow");
		$(this).toggleClass("textarea");
	
	});



/* 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");
	});;
	

});

/////////////////////////////////////BB code/////////////////////////////////
  var idTextfeld    = 'eingabe';       // ID der <textarea>

  var rangeIE = null;

  function insertProperty(prop,val)
  {
    insertText('[' + prop + '=' + val + ']', '[\/' + prop + ']');
  }

  // IE/Gecko-Weiche zum Einfügen von Text ins Textfeld
  function insertText(vor, nach)
  {
     var textfeld = document.getElementById(idTextfeld);
     textfeld.focus();                                         // falls Cursor außerhalb war

     if(typeof document.selection != 'undefined')              // für IE, auch Opera
     {
       insertIE(textfeld, vor, nach);
     }
     else if (typeof textfeld.selectionStart != 'undefined')   // Geckos (FF)
     {
       insertGecko(textfeld, vor, nach);
     }
  }

  // Im "textfeld" Portionen "vor" und "nach" einfügen (IE)
  function insertIE(textfeld, vor, nach)
  {
     if(!rangeIE) rangeIE = document.selection.createRange();

     // nichts weiter tun, falls wir nicht im Textfeld sind
     if(rangeIE.parentElement().id != idTextfeld) { rangeIE = null; return; }

     var alterText = rangeIE.text;

     // Auswahl um BBC ergänzen
     rangeIE.text = vor + alterText + nach;

     // Cursor neu setzen (wie SelfHTML)
     if (alterText.length == 0)
       rangeIE.move('character', -nach.length);
     else
       rangeIE.moveStart('character', rangeIE.text.length);
     
     rangeIE.select();
     rangeIE = null;
  }

  // Im "textfeld" Portionen "vor" und "nach" einfügen (Geckos)
  function insertGecko(textfeld, vor, nach)
  {
     von = textfeld.selectionStart;
     bis = textfeld.selectionEnd;

     // Text zerlegen
     anfang = textfeld.value.slice(0,   von);
     mitte  = textfeld.value.slice(von, bis);
     ende   = textfeld.value.slice(bis);        // der Rest des Strings

     // BBC einfügen und ins Textfeld schreiben
     textfeld.value = anfang + vor + mitte + nach + ende;

     // Cursor neu setzen
     if(bis - von == 0)
     {
       textfeld.selectionStart = von + vor.length;
       textfeld.selectionEnd   = textfeld.selectionStart;
     }
     else
     {
       textfeld.selectionEnd   = bis + vor.length + nach.length;
       textfeld.selectionStart = textfeld.selectionEnd;
     }
  };
///////////////////////////////////BB code ende///////////////////////////////
