$(document).ready(function(){

//Superfish menu
$("ul.sf-menu").supersubs().superfish(
{
            delay:       1000,                            // one second delay on mouseout
            animation:   {opacity:'show'},  // fade-in and slide-down animation
            speed:       'normal',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: false                            // disable drop shadows
        }
);

//Toggle functions
$(".hide-excerpt").click(function (event) {
	event.preventDefault();
      $(this).parents(".excerpt").hide("normal");
    });

 $(".view-excerpt").toggle(
                    function(){
      			 $(this).parents(".headline").next(".excerpt").hide("normal");
                    }, function() {
      			 $(this).parents(".headline").next(".excerpt").show("normal");
                    });

 $("#toggle-all").toggle(
                    function(){
                         $(".excerpt").hide('slow');
			 $("#toggle").attr("class","show-all");
                    }, function() {
                         $(".excerpt").show('slow');
			 $("#toggle").attr("class","hide-all");
                    });
                    
       $(".rss").hover(function(){
       		$(this).animate({ "bottom": "0"}, 166);
    	}, function(){
    			$(this).animate({ "bottom": "-12"}, 166);
    	});
    	
    	$("a#totop").click(function(){
    		$("html").animate({scrollTop:0},"slow");
    		return false;
    	});

 });

$.fn.extend({
    insertAtCaret: function(myValue){
    		if (document.selection) {
        this.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
        this.focus();
    		}
      else if (this.selectionStart || this.selectionStart == '0') {
        var startPos = this.selectionStart;
        var endPos = this.selectionEnd;
        var scrollTop = this.scrollTop;
        this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
        this.focus();
        this.selectionStart = startPos + myValue.length;
        this.selectionEnd = startPos + myValue.length;
        this.scrollTop = scrollTop;
      } else {
        this.value += myValue;
        this.focus();
      }
    }
})


