$(window).load(function() {
	$('#navigation ul.menu').supersubs({ 
			minWidth:    10,
			maxWidth:    30,
			extraWidth:  1     
		}).superfish({ speed: 'normal', delay: 0, animation: {opacity:'show',height:'show'}});
	Cufon.replace('ul.menu a, #frontpagewidgets h2, #intro, .post h1, .post h2, .post h3, .post h4, .post h5, .post h6, #right h2, a.button, a.more-link, .pagetitle h2, #footer h2, #relatedposts h3, li.share, #commentsarea h3, #authordesc h3', {
		hover: true
	});
	$(".postimage img").before("<span></span>");
	$(".nivoSlider a.nivo-imageLink").simpletooltip();
	$("#relatedposts a").simpletooltip();
	
	$('a[href$="top"]').click( function() {
		$.scrollTo( $('#header'), {speed:700} );
	});
	jQuery(".toggle_body").hide(); 

	jQuery("h4.toggle").toggle(function(){
		jQuery(this).addClass("toggle_active");
		}, function () {
		jQuery(this).removeClass("toggle_active");
	});
	
	jQuery("h4.toggle").click(function(){
		jQuery(this).next(".toggle_body").slideToggle();

	});
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'facebook',slideshow:5000});
});
(function($){ $.fn.simpletooltip = function(){
	return this.each(function() {
		var text = $(this).attr("title");
		$(this).attr("title", "");
		if(text != undefined) {
			$(this).hover(function(e){
				var tipX = e.pageX + 12;
				var tipY = e.pageY + 12;
				$(this).attr("title", ""); 
				$("body").append("<div id='simpleTooltip' style='position:absolute; z-index: 100; display: none;'>" + text + "</div>");
				if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
				else var tipWidth = $("#simpleTooltip").width()
				$("#simpleTooltip").width(tipWidth);
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			}, function(){
				$("#simpleTooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tipX = e.pageX - 0;
				var tipY = e.pageY - 40;
				var tipWidth = $("#simpleTooltip").outerWidth(true);
				var tipHeight = $("#simpleTooltip").outerHeight(true);
				if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
				if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			});
		}
	});
}})(jQuery);
