/**
 * HoverAttribute jQuery plugin v1.0.5
 * by Alexander Wallin (http://www.afekenholm.se).
 * 
 * parseUri() method by Steven Levithan (http://blog.stevenlevithan.com/).
 * 
 * This plugin allows you to make (link-)elements more dynamic by making an attribute
 * of that element show up on hovering. This is mainly intended for <a> tags residing
 * within full-width elements, such as headings or list entries.
 * 
 * For comments, discussion, propsals and/or development; please visit
 * http://www.afekenholm.se/hoverattribute-jquery-plugin or send a mail to
 * contact@afekenholm.se.
 * 
 * @author: Alexander Wallin (http://www.afekenholm.se)
 * @version: 1.0.5
 * @url: http://www.afekenholm.se/hoverattribute-jquery-plugin
 */
(function($){$.hoverAttribute=function(el,options){var base=this;base.options=$.extend({},$.hoverAttribute.defaults,options);base.$el=$(el);base.el=el;base.$el.$parent=base.$el.parent();base.$el.initWidth=base.$el.width();base.$el.initHeight=base.$el.height();var elText=base.$el.html(),attrValue=base.$el.attr(base.options.attribute);base.init=function(){if(base.options.attribute=="href")base.buildNiceHref();base.buildContent();base.setupHovering();};base.buildNiceHref=function(){if(base.options.removeProtocol)attrValue=attrValue.replace("http://","");if(base.options.removeWWW)attrValue=attrValue.replace("www.","");if(base.options.wrapLink!="none"){var doWrapping=true,wrapLength=base.options.wrapLength;if(wrapLength=="auto")wrapLength=elText.length-3;else if(wrapLength=="none"||wrapLength<=0)doWrapping=false;if(doWrapping&&attrValue.length>wrapLength+3){var wrapLink=base.options.wrapLink;if(wrapLink=="after"){attrValue=attrValue.substr(0,wrapLength)+"...";}else if(wrapLink=="before"){var numChars=attrValue.length,wrapStart=numChars-wrapLength;attrValue="..."+attrValue.substr(wrapStart,numChars-1);}else if(wrapLink=="middle"){var hrefStart=attrValue.substr(0,Math.floor(attrValue.length/2)),hrefEnd=attrValue.substr(hrefStart.length,attrValue.length);hrefStart=hrefStart.substr(0,Math.floor(wrapLength/2));hrefEnd=hrefEnd.substr(hrefEnd.length-Math.ceil(wrapLength/2),hrefEnd.length);attrValue=hrefStart+"..."+hrefEnd;}}}if(base.options.highlightURLPart!="none"){var hrefParts=parseUri(attrValue),partName=base.options.highlightURLPart;base.highlightPart=function(str){attrValue=attrValue.replace(str,"<span class='hoverattribute-highlight'>"+str+"</span>");};if(partName=="lastURIPart"){var path=hrefParts.path,lastPart=path.match(/[a-zA-Z0-9-_]+\/?$/i);base.highlightPart(lastPart);}else if(hrefParts[partName]!=undefined&&hrefParts[partName]!=""){base.highlightPart(hrefParts[partName]);}else{}}}
base.buildContent=function(){base.$el.css({'display':'block','position':'relative','width':base.$el.initWidth+'px','height':base.$el.height()+'px','overflow':'hidden'}).html("<span class='hoverattribute-title'>"+elText+"</span>").append("<span class='hoverattribute-attr'></span>");$(".hoverattribute-title",base.$el).css($.extend({},$.hoverAttribute.spanCSSDefaults,$.hoverAttribute.spanCSSVisible));$(".hoverattribute-attr",base.$el).css($.extend({},$.hoverAttribute.spanCSSDefaults,$.hoverAttribute.spanCSSHidden)).css({'width':'auto','height':base.$el.initHeight+'px'}).html(attrValue);};base.setupHovering=function(){var animTime=base.options.animationTime*1000,animEase=base.options.animationEase;base.$el.bind('mouseover',function(){if(base.options.cssSettings.canExpandToFullWidth){$(this).css('width',base.$el.$parent.width()+'px');}$(".hoverattribute-title",this).stop().animate($.hoverAttribute.spanCSSHidden,animTime,animEase);$(".hoverattribute-attr",this).stop().animate($.hoverAttribute.spanCSSVisible,animTime,animEase);}).bind('mouseout',function(){var $thisEl=$(this);$(".hoverattribute-title",this).stop().animate($.hoverAttribute.spanCSSVisible,animTime,animEase);$(".hoverattribute-attr",this).stop().animate($.hoverAttribute.spanCSSHidden,animTime,animEase,function(){$thisEl.css('width',base.$el.initWidth+'px');});});};base.init();};$.hoverAttribute.defaults={attribute:"href",animationTime:0.3,animationEase:"swing",removeProtocol:false,removeWWW:false,wrapLink:"after",wrapLength:60,highlightURLPart:"domain",cssSettings:{canExpandToFullWidth:true}};$.hoverAttribute.spanCSSDefaults={'display':'block','position':'absolute','top':'0','overflow':'hidden','width':'auto'};$.hoverAttribute.spanCSSVisible={'left':'0','opacity':'1'};$.hoverAttribute.spanCSSHidden={'left':'-10px','opacity':'0'};$.fn.hoverAttribute=function(options){return this.each(function(i){new $.hoverAttribute(this,options);});};})(jQuery);

/* parseUri JS v0.1, by Steven Levithan (http://blog.stevenlevithan.com/)
Splits any well-formed URI into the following parts (all are optional):
----------------------
• source (since the exec() method returns backreference 0 [i.e., the entire match] as key 0, we might as well use it)
• protocol (scheme)
• authority (includes both the domain and port)
    • domain (part of the authority; can be an IP address)
    • port (part of the authority)
• path (includes both the directory path and filename)
    • directoryPath (part of the path; supports directories with periods, and without a trailing backslash)
    • fileName (part of the path)
• query (does not include the leading question mark)
• anchor (fragment)
*/
function parseUri(sourceUri){var uriPartNames=["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];var uriParts=new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);var uri={};for(var i=0;i<10;i++){uri[uriPartNames[i]]=(uriParts[i] ? uriParts[i]:"");}if(uri.directoryPath.length>0){uri.directoryPath=uri.directoryPath.replace(/\/?$/,"/");}return uri;}
