//JQUERY
$(document).ready(function(){
	
	var open = '-10px';
	var closed = '-280px';
	var vis = '0px';
	var unvis = '-40px';
	
	//init
	$('#backend').css({'left' : closed});
	$('#menu').css({'left' : closed});
	$('#navicaller').css({'left' : vis});
	$('#admincaller').css({'left' : vis});
	
	
	$('#navicaller').mouseenter(function(e){
	 	$('#menu').stop().animate({left: open}, 'fast');
		$('#backend').stop().animate({left: closed}, 'fast');
		$('#navicaller').stop().animate({left: unvis}, 'fast');
		$('#admincaller').stop().animate({left: unvis}, 'fast');
	});
	$('#menu').live('mouseleave', function() {
		$('#menu').stop().animate({left: closed}, 'fast');
		$('#navicaller').stop().animate({left: vis}, 'fast');
		$('#admincaller').stop().animate({left: vis}, 'fast');
		$('.sbox input').blur();//blur inputfield if not visible
	});
	
	$('#admincaller').mouseenter(function(e){
	 	$('#backend').stop().animate({left: open}, 'fast');
		$('#menu').stop().animate({left: closed}, 'fast');
		$('#navicaller').stop().animate({left: unvis}, 'fast');
		$('#admincaller').stop().animate({left: unvis}, 'fast');
	});
	$('#backend').live('mouseleave', function() {
		$('#backend').stop().animate({left: closed}, 'fast');
		$('#navicaller').stop().animate({left: vis}, 'fast');
		$('#admincaller').stop().animate({left: vis}, 'fast');
		$('.sbox input').blur();//blur inputfield if not visible
	});
	
	//Search
	//set color of "Suche..."
	$('.sbox input').css({'color':'#333'})
	$(".s").focus(function () {
		//Input Value
		if ($(this).val() == 'Suche...') {$(this).val('');}
		//set color of "Suche..."
		$('.sbox input').css({'color':'#000'})
	});
	$(".s").blur(function (evt) {
		//Input Value
		if ($(this).val() == '') {$(this).val('Suche...');}
		if($("#s").val() == 'Suche...') {
		//set color of "Suche..."
		$('.sbox input').css({'color':'#333'})
	}
	});
	
	/*
	// last-comment should have id of last-comment
	*/
	$('#comments .commentEntry:last').attr('id', 'last-comment')
	
	//Contentarea Linkstyles for Images
	$(function() {
		$("a img").each(function() {
			$(this).parent().addClass("image");			
		});
	});
	
	//No Image-Border for imgs smaller than 50px
	$(".entry-content img").each(function() {     
		if ($(this).width() < 50) {
			$(this).css({'margin' :'0' , 'border' :'none'})
		}        
	});    
 
	//Contentarea Linkstyles for Anchors
	$(function() {
		$('.entry-content a').each(function() {
			if ($(this).attr('name')) {
				$(this).addClass("image");
			}
		});
	});
	
	//Sociable Linkstyles	
	$(".sociable a").hover(
	  function () {
	    $(this).children("img").css({'opacity' : '1'});
	  },
	  function () {
	    $(this).children("img").css({'opacity' : '0.4'});
	  }
	);
	
	//Hide Typekit Badge
	$('.typekit-badge, #tkloadsht0kxh, #typekit-badge-sht0kxh').hide(); //Hide Typekit Badge
	
	//Disable Textselection
	$(function(){
		$.extend($.fn.disableTextSelect = function() {
			return this.each(function(){
				if($.browser.mozilla){ //Firefox
					$(this).css('MozUserSelect','none');
				}else if($.browser.msie){ //IE
					$(this).bind('selectstart',function(){return false;});
				}else{ //Opera, etc.
					$(this).mousedown(function(){return false;});
				}
			});
		});
		$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
	});
	
	//Hide Show Toplink
	$('.toplink').hide();
	$(window).scroll(function(){    
	    var scrolltop = $(this).scrollTop();
	    if(scrolltop != 0) {
	        $('.toplink').show('fast');
	    } else {
			$('.toplink').hide('fast');
		}
	});
	
	$('#print').click(function() {
		window.print();
	});
	
	$('#print, #emaillink, #rss').css({opacity:'0.5', cursor: 'pointer'})
	$("#print, #emaillink, #rss").hover(
	  function () {
	    $(this).stop().animate({opacity: '1'}, 'fast');
	  },
	  function () {
	    $(this).stop().animate({opacity: '0.5'}, 'fast');
	  }
	);
	
	
	/*
	// LAYER
	*/
	
	/*	
	if($.cookie('opt_visible') != 'true'){ //wenn kein Cookie existiert
		$('#layer').show();
		$('#coreContent, #footer, #navicaller, #coreContent, #navicaller, #footer').hide();
    }else{ 
        $('#layer').hide();
		$('#coreContent, #footer, #navicaller, #coreContent, #navicaller, #footer').show();
    }
	
	$('#layer #closebox').click(function() {
		$('#layer').hide('slow');
		$('#coreContent, #footer, #navicaller, #coreContent, #navicaller, #footer').show();
		$.cookie('opt_visible', 'true', { path: '/', expiresAt: new Date(new Date().getTime()+3600000) });
	});
	*/
	
});
