/**
*
*	simpleTooltip jQuery plugin, by Marius ILIE
*	visit http://dev.mariusilie.net for details
*
**/
(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;
				var tipY = e.pageY-8;
				$(this).attr("title", ""); 
				$("body").append("<div id='simpleTooltip' style='position: absolute; z-index: 100; display: none;'><span>" + text + "</span></div>");
				if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
				else var tipWidth = $("#simpleTooltip").width()
				$("#simpleTooltip").width(tipWidth);
				$("#simpleTooltip").css("left", tipX).css("top", tipY-$("#simpleTooltip").height()).fadeIn("medium");
			}, function(){
				$("#simpleTooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tipX = e.pageX;
				var tipY = e.pageY-8;
				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-$("#simpleTooltip").height()).fadeIn("medium");
			});
		}
	});
}})(jQuery);

/*
 * jQuery Dolore Wizard
 * Copyright (c) 2009  Oliver Astrologo
 * Dual licensed under MIT and GPL.
 * @author  Oliver Astrologo
 * @version 1.0
 */
var tabsController;
jQuery(function(){  	
	// console.log("JS LOADED");	
	tabsController = jQuery("#dolore-wizard-tabs").tabs({ fx: { opacity: 'toggle',width: 'toggle' }});		
	jQuery('#dolore-wizard-punti li a').simpletooltip();	
	jQuery('#dolore-wizard-punti li').hide();
	jQuery('#dolore-wizard-punti li:first').fadeIn({speed: 100,queue: "pallette", preDelay: 100});	
	jQuery('#dolore-wizard-punti li').not(":first").each(function(i, e){$(e).fadeIn({duration: 100,queue: "pallette"});});		
 	jQuery.fxqueue("pallette").start();
	jQuery('#patologie-comuni li a').click(function(){apriTab(jQuery(this));return false;})
});

function apriTab(t){
	var elementId = t.attr('href').replace('#punto-',''); 
	//console.log(elementId);
	
	 tabsController.tabs('select', elementId-1); // switch to third tab

	//jQuery('#dolore-wizard-tabs div.ui-tabs-panel').hide();
	//jQuery(elementId).fadeIn();		
}


