/* <![CDATA[
	jquery tooltip plugin
	version 0.4.2 Moob
	Creates CSS styled tooltips in place of real ones...
	(Requires jQuery)
	*/
jQuery.fn.extend({
  tooltip: function() {
  var zis = this;
  var cssTip;
	return $(this).find("*[title]").hover(function(){	
								try {
									titleVal = this.title || this.titleVal;
									this.title = "";
									this.titleVal = titleVal;
									cssTip = document.createElement('span');
									cssTip.className="tooltip";
									if($(cssTip).css("position")!="absolute"){//if the tooltip isnt styled externally...
										$(cssTip).css({//...style it:
														'margin' : '0',
														'max-width' : '200px',
														'height' : 'auto',
														'background-color' : '#FFFFCC',
														'padding' : '2px 6px',
														'color' : '#000',
														'font-size' : '1em',
														'font-weight' : 'normal',
														'font-family' : '"Trebuchet MS", Tahoma, Verdana',
														'text-align' : 'left',
														'-moz-border-radius' : '6px',
														'-webkit-border-radius' : '6px',
														'border' : '1px solid #666'
													  });
									}
									$(cssTip).css({//forced defaults regardless of whether the css has been defined elsewhere:
													'display' : 'none',
													'position' : 'absolute',
													'z-index' : '999999999',
													'zoom' : '1',
													'opacity' : '0.0'
												});
									cssTip.innerHTML = titleVal.replace(/\n/g,"<br />");
									offset = $(zis).offset();
									ie = (navigator.appName=="Microsoft Internet Explorer");
									initialPause = ($(this).attr("href"))?50:($(this).attr("name"))?50:($(this).attr("src"))?1000:500; // < initial pause lenght dependant on element type
									$(cssTip).stop();
									$(cssTip).animate({opacity: 0.0}, initialPause);	// < do nothing but pause for a fraction
									$(zis).before(cssTip);								// < insert the element (was .prepend() but ie didnt like it)
									$(cssTip).animate({opacity: 0.8}, 400, 				// < fade in
													  							function(){$(cssTip).animate({opacity: 0.8}, (500 + (titleVal.length*30)), 							// < show and pause
																								function(){$(cssTip).animate({opacity: 0.0}, 400, 										// < fade out
																												function(){this.title=titleVal;$(cssTip).stop();$(cssTip).remove();} 	// < destroy
																								);}
																				);}
									);// < end fade in then out		
									$(this).mousemove(function(e){							// < set tip position at cursor
																$(cssTip).css({	'display' : 'block',
																				'position' : 'absolute',
																				'left' : e.pageX - offset.left +'px',
																				'top' :e.pageY+((ie)?18:0) +'px',
																				'margin-right' : 20-offset.left +'px' });
																});									
									$(this).click(function(){this.title=titleVal;$(cssTip).stop();$(cssTip).remove();});
									} catch(err) {
									return;
									}
								},function(){if(this.title==""){this.title=titleVal;};$(cssTip).stop();$(cssTip).remove();}// < callback destroys tip 
				);
  		}
	});

//useage: $(elem).tooltip()
$(document).ready(function(){$("#content").tooltip();}); // < call here applies tooltip to all pages on load
/* ]]> */