/*
 * URL Utils - v0.95 - 4/9/2009
 * http://benalman.com/
 * 
 * Copyright (c) 2009 "Cowboy" Ben Alman
 * Licensed under the MIT license
 * http://benalman.com/about/license/
 */
(function($){var b,C={},g=Array.prototype.slice,k=document.location,n,y,B,f,p,d,a,e="urlInternal",v="urlExternal",i="queryString",o="fragment",j="passQueryString",t="passFragment",c="fragmentChange",q,E;function u(F){return typeof F==="string"}function x(F){return typeof F==="object"}function z(){var F=g.call(arguments),G=F.shift();return function(){return G.apply(this,F.concat(g.call(arguments)))}}function h(){return k.href.replace(/^[^#]*#?/,"")}$.urlTagAttrList=n=function(F){return $.extend(C,F)};n({a:"href",img:"src",form:"action",base:"href",script:"src",iframe:"src",link:"href"});function m(F){var G=F.nodeName;return G?C[G.toLowerCase()]:""}$.urlInternalHost=y=function(H){H=H?"(?:"+H+"\\.)?":"";var G=new RegExp("^"+H+"(.*)","i"),F="^"+k.protocol+"//"+k.hostname.replace(G,H+"$1")+(k.port?":"+k.port:"")+"/";return B(F)};$.urlInternalRegExp=B=function(F){if(F){b=u(F)?new RegExp(F,"i"):F}return b};y("www");$.isUrlInternal=f=function(F){if(!F){return undefined}if(/^(?:#|javascript:|mailto:|news:|tel:|im:)/i.test(F)){return undefined}if(b.test(F)){return true}if(!/^[^:]+:\/\//.test(F)){return true}if(!/^https?:\/\//.test(F)){return undefined}return false};$.isUrlExternal=p=function(F){var G=f(F);return typeof G==="boolean"?!G:G};d=function(G,F){return this.filter(":"+G+(F?"("+F+")":""))};$.fn[e]=z(d,e);$.fn[v]=z(d,v);a=function(J,I,H,G){var F=G[3]||m(I);return F?!!J($(I).attr(F)):false};$.expr[":"][e]=z(a,f);$.expr[":"][v]=z(a,p);function A(H,I,G,F){var J;if(u(G)||x(G)){return D(I,G,F,H)}else{if(x(I)){return $.param(I)}else{if(u(I)){return w(I,G,H)}else{J=H?h():k.search;return w(J,I,H)}}}}$[i]=z(A,0);$[o]=z(A,1);function l(){var F,J,I,H=g.call(arguments),G=H.shift();if(u(H[1])||x(H[1])){F=H.shift()}J=H.shift();I=H.shift();return this.each(function(){var K=F||m(this),L=K&&$(this).attr(K)||"";L=A(G,L,J,I);$(this).attr(K,L)})}$.fn[i]=z(l,0);$.fn[o]=z(l,1);function s(){var H=g.call(arguments),G=H.shift(),F=H.shift(),I=A(G);if($.isFunction(H[0])){I=H.shift()(I)}else{if($.isArray(H[0])){$.each(H.shift(),function(K,J){delete I[J]})}}return A(G,F,I,H.shift())}$[j]=z(s,0);$[t]=z(s,1);function r(){var F,H=g.call(arguments),G=H.shift();if(u(H[0])){F=H.shift()}return this.each(function(){var I=F||m(this),J=I&&$(this).attr(I)||"";J=s.apply(this,[G,J].concat(H));$(this).attr(I,J)})}$.fn[j]=z(r,0);$.fn[t]=z(r,1);function w(K,J,G){var F,M,I,L={},H={"null":null,"true":true,"false":false},N=G?/^.*[#]/:/^.*[?]|#.*$/g;K=K.replace(N,"").replace(/\+/g," ").split("&");while(K.length){F=K.shift().split("=");M=decodeURIComponent(F[0]);if(F.length===2){I=decodeURIComponent(F[1]);if(J){if(I&&!isNaN(I)){I=Number(I)}else{if(I==="undefined"){I=undefined}else{if(H[I]!==undefined){I=H[I]}}}}if($.isArray(L[M])){L[M].push(I)}else{if(L[M]!==undefined){L[M]=[L[M],I]}else{L[M]=I}}}else{if(M){L[M]=J?undefined:""}}}return L}function D(F,H,K,G){var L,N=G?/^([^#]*)[#]?(.*)$/:/^([^#?]*)[?]?([^#]*)(#?.*)/,J=F.match(N),M=w(J[2],0,G),I=J[3]||"";if(u(H)){H=w(H,0,G)}if(K===2){L=H}else{if(K===1){L=$.extend({},H,M)}else{L=$.extend({},M,H)}}L=$.param(L);return J[1]+(G?"#":L?"?":"")+L+I}$.setFragment=function(F){var G=x(F)?A(true,F):(F||"").replace(/^#/,"");k.href=k.href.replace(/#.*$/,"")+"#"+G};$[c]=function(F){if(F===true){F=100}if(q){clearTimeout(q);q=null}if(typeof F==="number"){E=h();(function(){var G,H=h();if(H!=E){E=H;G=$.Event(c);G.fragment=H;$(document).trigger(G)}q=setTimeout(arguments.callee,F<0?0:F)})()}}})(jQuery);