(function($){$.fn.findandfilter=function(selector){var ret=this.filter(selector).add(this.find(selector));ret.prevObject=ret.prevObject.prevObject;return ret};$.fn.parsecss=function(callback,parseAttributes){var parse=function(str){$.parsecss(str,callback)};this.findandfilter("style").each(function(){parse(this.innerHTML)}).end().findandfilter("link[type=text/css]").each(function(){if(!this.disabled&&!/\w+:/.test($(this).attr("href"))&&$.parsecss.mediumApplies(this.media)){$.get(this.href,parse)}}).end();if(parseAttributes){$.get(location.pathname+location.search,"text",function(HTMLtext){callback(styleAttributes(HTMLtext))})}return this};$.parsecss=function(str,callback){var ret={};str=munge(str).replace(/@(([^;`]|`[^b]|`b[^%])*(`b%)?);?/g,function(s,rule){processAtRule($.trim(rule),callback);return""});$.each(str.split("`b%"),function(i,css){css=css.split("%b`");if(css.length<2){return}css[0]=restore(css[0]);ret[css[0]]=$.extend(ret[css[0]]||{},parsedeclarations(css[1]))});callback(ret)};$.parsecss.mediumApplies=(window.media&&window.media.query)||function(str){if(!str){return true}if(str in media){return media[str]}var style=$('<style media="'+str+'">body {position: relative; z-index: 1;}</style>').appendTo("head");return media[str]=[$("body").css("z-index")==1,style.remove()][0]};$.parsecss.isValidSelector=function(str){var s=$("<style>"+str+"{}</style>").appendTo("head")[0];return[s.styleSheet?!/UNKNOWN/i.test(s.styleSheet.cssText):!!s.sheet.cssRules.length,$(s).remove()][0]};$.parsecss.parseArguments=function(str){if(!str){return[]}var ret=[];$.each(munge(str,true).split(/\s+/),function(i,a){var a=restore(a);try{ret.push(eval("("+a+")"))}catch(err){ret.push(a)}});return ret};$.parsecss.jquery=function(css){for(var selector in css){for(var property in css[selector]){var match=/^-jquery(-(.*))?/.exec(property);if(!match){continue}var value=munge(css[selector][property]).split("!");var which=match[2];dojQuery(selector,which,restore(value[0]),restore(value[1]))}}};$.parsecss.styleAttributes=styleAttributes;var media={};var munged={};function parsedeclarations(index){var str=munged[index].replace(/(?:^\s*[{'"]\s*)|(?:\s*([^\\])[}'"]\s*$)/g,"$1");str=munge(str);var parsed={};$.each(str.split(";"),function(i,decl){decl=decl.split(":");if(decl.length<2){return}parsed[restore(decl[0])]=restore(decl[1])});return parsed}var REbraces=/{[^{}]*}/;var REfull=/\[[^\[\]]*\]|{[^{}]*}|\([^()]*\)|function(\s+\w+)?(\s*%b`\d+`b%){2}/;var REatcomment=/\/\*@((?:[^\*]|\*[^\/])*)\*\//g;var REcomment_string=/(?:\/\*(?:[^\*]|\*[^\/])*\*\/)|(\\.|"(?:[^\\\"]|\\.|\\\n)*"|'(?:[^\\\']|\\.|\\\n)*')/g;var REmunged=/%\w`(\d+)`\w%/;var uid=0;function munge(str,full){str=str.replace(REatcomment,"$1").replace(REcomment_string,function(s,string){if(!string){return""}var replacement="%s`"+(++uid)+"`s%";munged[uid]=string.replace(/^\\/,"");return replacement});var RE=full?REfull:REbraces;while(match=RE.exec(str)){replacement="%b`"+(++uid)+"`b%";munged[uid]=match[0];str=str.replace(RE,replacement)}return str}function restore(str){if(str===undefined){return str}while(match=REmunged.exec(str)){str=str.replace(REmunged,munged[match[1]])}return $.trim(str)}function processAtRule(rule,callback){var split=rule.split(/\s+/);var type=split.shift();if(type=="media"){var css=restore(split.pop()).slice(1,-1);if($.parsecss.mediumApplies(split.join(" "))){$.parsecss(css,callback)}}else{if(type="import"){var url=restore(split.shift());if($.parsecss.mediumApplies(split.join(" "))){url=url.replace(/^url\(|\)$/gi,"").replace(/^["']|["']$/g,"");$.get(url,function(str){$.parsecss(str,callback)})}}}}function dojQuery(selector,which,value,value2){if(value2===undefined||!$.livequery){if(!which){$(selector).each(Function(value))}else{if(/^(show|hide)$/.test(which)){showhide(which,$.parsecss.parseArguments(value),selector)}else{if($.fn[which]){$.fn[which].apply($(selector),$.parsecss.parseArguments(value))}}}}else{if(!which){var fn=Function(value);var fn2=value2?Function(value2):undefined}else{if(/^(show|hide)$/.test(which)){fn=showhide(which,$.parsecss.parseArguments(value));fn2=value2?showhide(which,$.parsecss.parseArguments(value2)):undefined}else{if($.fn[which]){value=$.parsecss.parseArguments(value);var plugin=$.fn[which];fn=function(){plugin.apply($(this),value)};fn2=value2?function(){plugin.apply($(this),$.parsecss.parseArguments(value2))}:undefined}}}(new $.livequery(selector,document,undefined,fn,fn2)).run()}}var _show={show:$.fn.show,hide:$.fn.hide};$.each(["show","hide"],function(){var which=this,show=_show[which];$.fn[which]=function(){if(arguments.length>0){return show.apply(this,arguments)}return this.each(function(){var fn=$.data(this,which),$this=$(this);if(fn){$.removeData(this,which);fn.call($this);$this.queue(function(){$this.data(which,fn).dequeue()})}else{show.call($this)}})}});function showhide(which,args,selector){var name=args[0];if($.fn[name]){args.shift();var fn=$.fn[name]}else{if($.effects&&$.effects[name]){if(typeof args[1]!="object"){args.splice(1,0,{})}fn=_show[which]}else{fn=_show[which]}}$(selector||this).data(which,function(){fn.apply(this,args)})}var RESGMLcomment=/<!--([^-]|-[^-])*-->/g;var REnotATag=/(>)[^<]*/g;var REtag=/<(\w+)([^>]*)>/g;function styleAttributes(HTMLtext){var ret={},style,tags={};HTMLtext=HTMLtext.replace(RESGMLcomment,"").replace(REnotATag,"$1");munge(HTMLtext).replace(REtag,function(s,tag,attrs){tag=tag.toLowerCase();if(tags[tag]){++tags[tag]}else{tags[tag]=1}if(style=/\sstyle\s*=\s*%s`(\d+)`s%/i.exec(attrs)){var id=/id\s*=\s*(\S+)/i.exec(attrs);if(id){id="#"+restore(id[1]).replace(/^['"]|['"]$/g,"")}else{id=tag+":eq("+(tags[tag]-1)+")"}ret[id]=parsedeclarations(style[1])}});return ret}})(jQuery);
