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