/**
 * @author      Andre Berg
 *              
 * @copyright   2009 Berg Media. All rights reserved.
 *              
 * @license     Licensed under the Apache License, Version 2.0 (the "License");
 *              you may not use this file except in compliance with the License.
 *              You may obtain a copy of the License at
 *              
 *              http://www.apache.org/licenses/LICENSE-2.0
 *              
 *              Unless required by applicable law or agreed to in writing, software
 *              distributed under the License is distributed on an "AS IS" BASIS,
 *              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *              See the License for the specific language governing permissions and
 *              limitations under the License.
 *              
 * @requires    jQuery 1.3+
 *                                                                                                                 
 * @info        FlexiTip v0.7
 * 
 *              Creates a simple yet elegant tooltip for targeted objects.                                                  
 *              The tip can be fixed or floating (following the mouse).
 *              Unlike most other tips, targeting works on the complete wrapped
 *              jQuery set and it also returns it like every jQuery plugin that
 *              is chainable. In an earlier version the plugin would only target
 *              elements with a specific class, but using the wrapped set means
 *              you can use the full arsenal of jQuery to make a selection and
 *              then apply the tip to this group.                                                   
 *                                                                                                                 
 *              As a special feature, the tooltip, when in fixed mode, accounts                                                 
 *              for the case when the user resizes the window and re-calculates                                             
 *              the position of the target element.                                                                         
 *                                                                                                                 
 *              You can either provide styling rules via a class or you can pass it 
 *              as inline JSON (as needed for $.css(properties)). For this style                                           
 *              you don't need to specify 'position: absolute' and 'z-index' because                                        
 *              this will be set for you. More specifically, the z-index will be 200 and
 *              'display' will be set to 'block'.                                                       
 *                                                                                                                 
 *              At the very least however I recommend to add a 'display: none'                                              
 *              property to the class, so that, in the sense of 'graceful degradation',                                     
 *              the tooltip will be hidden and the browser help tip for the element's title                                         
 *              will appear if JavaScript is disabled.
 *              
 *              If you use this plugin on your own site, please give credit where
 *              credit is due!
 */
;(function($){var name="FlexiTip";var version="v0.7";var consoleGroup=name+' '+version+' Debug';var DEBUG=false;var beingShown=false,shown=false;var delayTimer=null;$.fn.flexitip=function(options){var opts=$.extend({},$.fn.flexitip.defaults,options);return this.each(function(i){var $trigger=$(this);var o=(typeof $.metadata!=='undefined')?$.extend({},opts,$trigger.data()):opts;var e=$.fn.flexitip.events;var p=$.fn.flexitip.properties;var tipTargetClass=o.targetclass;var tipStyle=o.style;var tipSpeed=o.speed;var tipHideDelay=o.hidedelay;var tipShowDelay=o.showdelay;var tipEasing=o.easing;var tipOpacity=o.opacity;var tipOffsetX=o.offsetX;var tipOffsetY=o.offsetY;var tipFixed=o.fixed;var tipSource=o.textsrc;var tipText;var tipEasingIn;var tipEasingOut;var hiSensitivity=o.sensitivity;var hiInterval=o.interval;var hiTimeout=o.timeout;if(typeof tipStyle==='string'&&tipStyle.charAt(0)==="."){tipStyle=tipStyle.substring(1,tipStyle.length);}if(tipTargetClass.charAt(0)!=="."){tipTargetClass="."+tipTargetClass;}if(/^easeInOut/.test(tipEasing)){if((typeof $.easing.jswing!=='function')&&typeof console.debug==='function'){var warning='Warning: A transition function has been specified'+'that by its name looks like it needs the jQuery easing plugin '+'but the plugin seems to be missing.';console.debug(warning);}var easingName=tipEasing.match(/^easeInOut(\w+)$/)[1];tipEasingIn="easeIn"+easingName;tipEasingOut="easeOut"+easingName;}else{tipEasingIn=tipEasing;tipEasingOut=tipEasing;}var triggerX=$trigger.position().left;var triggerY=$trigger.position().top;var minOpacity=0;var maxOpacity=tipOpacity;if(tipSource===null||typeof tipSource==='undefined'){tipSource='title';}tipText=e.onpreparingtext.apply($trigger,[tipSource]);if(typeof tipText==='undefined'||!tipText||tipText.toString()==="undefined"){return false;}else{p.savedText=tipText;}var tipID='flexitip'+i;$('<div class="'+tipStyle+'" id='+tipID+'>'+tipText+'<\/div>').insertAfter($trigger);var $tip=$('#'+tipID);if(typeof tipStyle==='object'){$tip.css(tipStyle);}function handleMouseOver(evt){if(delayTimer){clearTimeout(delayTimer);}delayTimer=setTimeout(function(){clearTimeout(delayTimer);if(beingShown||shown){return;}else{beingShown=true;e.onbeingshown.call($trigger);$tip.css({opacity:minOpacity,position:"absolute",zIndex:200,display:'block'}).animate({opacity:maxOpacity},tipSpeed,tipEasingIn,function(){beingShown=false;shown=true;});}},tipShowDelay);}function handleMouseOut(evt){if(delayTimer){clearTimeout(delayTimer);}delayTimer=setTimeout(function(){clearTimeout(delayTimer);$tip.animate({opacity:minOpacity},tipSpeed,tipEasingOut,function(){});e.onbeinghidden.call($trigger);shown=false;},tipHideDelay);}if(typeof $.fn.hoverIntent==='function'){$([$trigger,$tip]).each(function(){$(this).hoverIntent({sensitivity:hiSensitivity,interval:hiInterval,over:handleMouseOver,timeout:hiTimeout,out:handleMouseOut});});}else{$([$trigger,$tip]).each(function(){$(this).hover(handleMouseOver,handleMouseOut);});}if(!tipFixed){$trigger.mousemove(function(evt){$tip.css({left:evt.pageX+tipOffsetX,top:evt.pageY+tipOffsetY});});}else{$tip.css({left:triggerX+tipOffsetX,top:triggerY+tipOffsetY});$(window).resize(function(){$([$trigger,$tip]).each(function(){$(this).css({left:$trigger.offset().left+tipOffsetX,top:$trigger.offset().top+tipOffsetY});});});}});};$.fn.flexitip.defaults={targetclass:'.tooltip',style:'.flexitip',textsrc:'longdesc',speed:400,hidedelay:300,showdelay:300,easing:'swing',opacity:0.8,offsetX:15,offsetY:15,fixed:true,sensitivity:7,interval:100,timeout:0};$.fn.flexitip.properties={savedText:null};$.fn.flexitip.events={onpreparingtext:function(srcname){return this.attr(srcname);},onbeingshown:function(){},onbeinghidden:function(){}};})(jQuery);