/*
 * href.locationpatch 0.1
 * Copyright (c) 2007 PeriCHR (www.PeriCHR.org)
 * Code Page: http://code.google.com/p/perichr-js-href/
 * Date: 2008-01-23 14:30:00 +0800
*/
(function(){var g=function(e){e.split={search:'&',hash:'&'};e.equal={search:'=',hash:'='};e.xsearch=e.search.split('?')[1]||'';e.xhash=e.hash.split('#')[1]||'';var f={};f.object=function(a){var b=e[a+'Arg']()||[];retval={};for(var i=0;i<b.length;i++){if(-1==b[i].indexOf(e.equal[a])){retval[b[i]]=''}else{retval[b[i].substr(0,b[i].indexOf(e.equal[a]))]=b[i].substr(b[i].indexOf(e.equal[a])+1,b[i].length)}};return retval};f.arg=function(a,b){var c=e['x'+a].split(e.split[a])||[];var d=[];for(var i=0;i<c.length;i++){c[i]=c[i].replace(/(^\s*)|(\s*$)/g,"");if(''==c[i]||0==c[i].indexOf(e.equal[a]))continue;if(''!=c[i].split(e.equal[a])[0]){d.push(c[i])}};if(undefined!=b&&NaN!=parseInt(b)){return d[parseInt(b)]||''}else{return d}};f.name=function(a,b){var c=e[a+'Arg']();var d=[];for(var i=0;i<c.length;i++){d.push(c[i].split(e.equal[a])[0])};if(undefined!=b&&NaN!=parseInt(b)){return d[parseInt(b)]||''}else{return d}};f.value=function(a,b){var c=e[a+'Arg']();var d=[];for(var i=0;i<c.length;i++){if(-1==c[i].indexOf(e.equal[a])){d.push('')}else{d.push(c[i].substr(c[i].indexOf(e.equal[a])+1,c[i].length))}};if('number'==typeof b){return c[b]||''}else if('string'==typeof b){return e[a+'Obj']()[b]||''}else{return d}};e.searchObj=function(a){return f.object('search')};e.hashObj=function(a){return f.object('hash')};e.searchArg=function(a){return f.arg('search',a)};e.hashArg=function(a){return f.arg('hash',a)};e.searchName=function(a){return f.name('search',a)};e.hashName=function(a){return f.name('hash',a)};e.searchValue=function(a){return f.value('search',a)};e.hashValue=function(a){return f.value('hash',a)}};if(!window.perichr){window.perichr={}}if(!window.perichr.fn){window.perichr.fn={}}if(!window.perichr.fn.locationpatch){window.perichr.fn.locationpatch=g}if(!window.locationpatch){window.locationpatch=g}g(window.location);g(window.top.location);g(window.parent.location);g(window.self.location);g(window.document.location)})();
