/*
 * JXtension - A Sufficient JavaScript Library
 * http://jxtension.gotochriswest.com/
 *
 * Copyright (c) 2009 Christopher West
 * Dual licensed under the MIT and GPL licenses.
 * 
 * Version: 1.0 - Full
 * Revised: December 20, 2009
 */
var JXtension={creator:"Chris West",version:"1.0 (Full)",toString:function(){return"JXtension version "+this.version+" was created by "+this.creator+"."},select:function(f){var g=[];if(typeof f=="string"){var f=f.trim().replace(/\s+/g," ");f=f.replace(/ ?> ?/g," >");f=f.replace(/@(\w+)\b/,"[name=$1]");f=f.replace(/\[(\!)?(\w+)\]/g,"[$2$1=*]");f=f.replace(/(\(.+?\)|\[.+?\])/g,function(i){return i.replace(/,/g,";").replace(/\s+/g,"")});f=f.replace(/\:(TEXT|FILE|RADIO|CHECKBOX|BUTTON|SUBMIT|RESET|PASSWORD|IMAGE)/ig,function(i){return"[type="+i.substring(1).toLowerCase()+"]"});var e=f.split(/ ?, ?/g);var k=arguments.length==1?[document.documentElement]:parseArray(arguments[1]);for(var h,a,b,c=0,d=e.length;c<d;c++){e[c]=e[c].split(" ");a=e[c].length;e[c][-1]=k;for(b=0;b<a;b++){if(h=(e[c][b].charAt(0)==">")){e[c][b]=e[c][b].substring(1)}if(/^#/.test(e[c][b])){e[c][b]=JXtension.getByID(e[c][b].substring(1),e[c][b-1])}else{if(/^\w/.test(e[c][b])){e[c][b]=JXtension.getByTag(e[c][b],e[c][b-1],h)}else{e[c][b]=JXtension.getByOther(e[c][b],e[c][b-1],h)}}if(e[c][b][0]==undefined){e[c][b]=[]}}if(a>0){g=g.concat(e[c][b-1])}}}else{g=parseArray(f)}g=g.uniquify();g.execute=function(i){if(typeof i=="string"){if(!/^on/i.test(i)){i="on"+i}(function(j){j[i]()}).map(this)}else{(function(j){i.apply(j,[])}).map(this)}return this};g.setHTML=function(i){(function(o){var l=/^(INPUT|TEXTAREA)$/i.test(o.nodeName)?"value":"innerHTML";if(!o[l]){o[l]=""}var j,n="",r=0,m=0,q=i.indicesOf("$(this)");if(q){for(;m<q.length;m++){j=q[m];if(j>0&&i.charAt(j-1)=="\\"){n+=i.substring(r,j-1)+i.substring(j,j+7)}else{n+=i.substring(r,j)+o[l]}r=j+7}}n+=i.substring(r,i.length);o[l]=n}).map(this);return this};g.setText=function(i){(function(j){if(/^(INPUT|TEXTAREA)$/i.test(j.nodeName)){$(j).setHTML(i+"")}else{$(j).setHTML((i+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))}}).map(this);return this};g.getText=function(i){var j=(function(l){if(/^(INPUT|TEXTAREA)$/i.test(l.nodeName)){return l.value}else{if(l.innerText){return l.innerText}else{return l.textContent}}}).map(this);if(i!=undefined){return j[i]}return j};g.get=function(l,i){var j=(function(m){return m[l]}).map(this);if(i!=undefined){return j[i]}return j};g.setCSS=function(i,j){i=i.replace(/(-\w)/g,function(l){return l.charAt(1).toUpperCase()});(function(m){try{m.style[i]=j+""}catch(l){}}).map(this);return this};g.getCSS=function(l,i){l=l.replace(/(-\w)/g,function(m){return m.charAt(1).toUpperCase()});var j=(function(m){return m.style[l]}).map(this);if(i!=undefined){return j[i]}return j};g.set=function(i,j){(function(m){try{m[i]=j}catch(l){}}).map(this);return this};g.getElement=function(i){return this[i]};g.slice=function(n,l){if(n==null){n=0}if(l==null){l=this.length}var j=[];for(var m=n;m<l;m++){j.push(this[m])}return $(j)};g.bind=function(i,j){return this.set(/^on/.test(i)?i:"on"+i,j)};g.filter=function(){var q=0,m=[];if(typeof arguments[0]=="function"){for(var s=arguments[0];q<this.length;q++){if(s.apply(this[q],parseArray(arguments[1]))){m.push(this[q])}}}else{if(/^(DESCENDANT|ANCESTOR|PARENT|CHILD) ?OF$/i.test(arguments[0])){var u,t,o,n,l=RegExp.$1.toUpperCase();var r=parseArray(arguments[1]);for(;q<this.length;q++){n=true;for(o=0;o<r.length&&n;o++){u=r[o];t=this[q];if(l=="ANCESTOR"||l=="PARENT"){t=u;u=this[q]}if(l=="ANCESTOR"||l=="DESCENDANT"){if(this[q].contains){n=u.contains(t)}else{n=(u.compareDocumentPosition(t)&16)>0}}else{n=u.parentNode==t}}if(n){m.push(this[q])}}}}return $(m)};g.remove=function(){(function(i){if(p=i.parentNode){p.removeNode(i)}}).map(this);return this};g.bindOnce=function(i,j){return this.bind(i,j.concat(function(){$(this).unbind(i)}))};g.unbind=function(i){if(!/^on/.test(i)){i="on"+i}(function(j){j[i]=function(){}}).map(this);return this};g.bindHover=function(l,m,j,i){this.bind("mouseover",l).bind("mouseout",m);if(j){this.execute(function(){this.onmouseout()})}if(i){this.bindFocus(l,m)}return this};g.bindFocus=function(i,j,m,l){this.bind("onfocus",i).bind("onblur",j);if(m){this.execute(function(){this.onblur()})}if(l){this.bindHover(i,j)}return this};g.hide=function(){return $(this).setCSS("display","none")};g.show=function(){return $(this).setCSS("display","")};g.addClass=function(i){(function(j){if(j.className!=undefined&&j.className.length>0){j.className+=" "+i}else{j.className=i}}).map(this);return this};g.removeClass=function(i){(function(l){if(l.className!=undefined){var m=l.className.trim().split(" ");var j=m.indexOf(i);if(j>=0){m.splice(j,1)+'"'}l.className=m.join(" ")}}).map(this);return this};g.setClass=function(i){return this.set("className",i)};return g},filter:function(x,o){var s,t,r,n,w=o.match(/\.\w+/g);if(w==undefined){w=[]}else{w=w.join(",").replace(/\./g,"").split(",");for(s=0,t=w.length;s<t;s++){w[s]=new RegExp("\\b"+w[s]+"\\b")}}n=w.length;var f=o.match(/\[.+?\!?=(\*|\w+(\\\[\w*\\\])*)?\]/g);if(f==undefined){f=[]}else{for(s=0,t=f.length;s<t;s++){f[s]=f[s].match(/\[(.+?)(\!?)=(\*|\w+(\\\[\w*\\\])*|)\]/).splice(1,3);f[s][0]=f[s][0].replace(/^class$/,"className")}}var b=f.length;var a,l=[];for(s=0,t=x.length;s<t;s++){a=true;for(r=0;a&&r<n;r++){a=w[r].test(x[s].className)}for(r=0;a&&r<b;r++){if(f[r][2]=="*"){a=((x[s][f[r][0]]!=null)==(f[r][1]==""))}else{a=((x[s][f[r][0]]==f[r][2])==(f[r][1]==""))}}if(!a){l.push(x.splice(s,1)[0]);s--;t--}}var c=o.match(/:element\((.+?)\)/i);if(c!=undefined&&x.length>0){c=c[1].replace(/(^|;)first(;|$)/i,"$11$2");var e=/\beven\b/i.test(c);var d=/\bodd\b/i.test(c);var u,v=/(^|;)last(;|$)/i.test(c);c=c.split(";");var h=c.length;var q,g=x;var m=g[0].parentNode;x=[];t=g.length;do{r=1;for(s=0;s<t;s++){if(g[s].parentNode==m){if((e&&r%2==0)||(d&&r%2==1)){q=-1}else{for(q=0;q<h;q++){if(parseInt(c[q])==r){break}else{if(/\b(\d+):(\d+)\b/.test(c[q])){if(parseInt(RegExp.$1)<=r&&r<=parseInt(RegExp.$2)){break}}else{if(/\b(\d+):(last)\b/i.test(c[q])){if(parseInt(RegExp.$1)<=r){break}}}}}}if(q<h){x.push(g.splice(s,1)[0]);u=-1}else{if(v){u=l.length}l.push(g.splice(s,1)[0])}s--;t--;r++}}if(u>-1&&v){x.push(l.splice(u,1)[0])}if(t>0){m=g[0].parentNode}else{m=undefined}}while(m!=undefined)}return[x,l]},getByID:function(f,d){var e=document.getElementById(f.replace(/^.+?#(\w+).+$/,"$1"));if(e==undefined){return[]}for(var c,b=0,a=d.length;b<a;b++){for(c=e.parentNode;c;c=c.parentNode){if(c==d[b]){return JXtension.filter([e],f)[0]}}}return[]},getByOther:function(g,b,h){var c,d,a=[],k=[];for(var e=0,f=b.length;e<f;e++){if(b[e].childNodes!=undefined){for(d=0,c=b[e].childNodes.length;d<c;d++){a.push(b[e].childNodes[d])}}}a=JXtension.filter(a,g);if(h){k=a[1]}else{k=a[0].concat(a[1])}a=a[0];if(k.length==0){return a}return a.concat(JXtension.getByOther(g,k,h))},getByTag:function(b,c,m){var l=b;b=b.replace(/^(\w+).*$/,"$1").toUpperCase();var a=[];var k=document.getElementsByTagName(b);for(var f=0,h=k.length;f<h;f++){a.push(k[f])}k=[];a=JXtension.filter(a,l)[0];var g,e,d=c.length;for(var f=0,h=a.length;f<h;f++){for(e=0;e<d;e++){for(g=a[f].parentNode;g!=undefined;g=g.parentNode){if(g==c[e]){k.push(a[f]);e=d;break}else{if(m&&JXtension.filter([g],l)[0].length==1){e=d;break}}}}}return k}};var $=function(){return JXtension.select.apply(this,arguments)};function xor(b,a){return !!(b^a)}function parseArray(c){if(c==undefined){return[]}if(c instanceof Array){return c}if(c.callee==undefined){return[c]}var b=[],a=0;for(;a<c.length;a++){b.push(c[a])}return b}Array.prototype.toString=function(c){var a="";for(var b=0;b<this.length;b++){a+=","+(this[b] instanceof Array?this[b].toString(c):this[b].toString())}if(this.length>0){a=a.substring(1)}if(arguments[0]){return"["+a+"]"}return a};Array.prototype.equals=function(b){if(!(b instanceof Array)||this.length!=b.length){return false}for(var c=0,a=this.length;c<a;c++){if(this[c] instanceof Array){if(!this[c].equals(b[c])){return false}}else{if(b[c] instanceof Array){if(!b[c].equals(this[c])){return false}}else{if(this[c]!=b[c]){return false}}}}return true};Array.prototype.uniquify=function(){var a,b=0,c=this.clone();for(;b<c.length;b++){for(a=b+1;a<c.length;a++){if(c[b].equals?c[b].equals(c[a]):(c[a].equals?c[a].equals(c[b]):c[b]==c[a])){c.splice(a--,1)}}}return c};Array.prototype.clone=function(d){var c=[];for(var b=0,a=this.length;b<a;b++){if(d&&this[b] instanceof Array){c.push(this[b].clone(true))}else{c.push(this[b])}}return c};Array.prototype.subtract=function(c){if(!(c instanceof Array)){return[]}var a,b=0,e=[],d=[];for(;b<this.length;b++){for(a=0;a<c.length;a++){if(d[a]!=true&&(c[a].equals?c[a].equals(this[b]):(this[b].equals?this[b].equals(c[a]):c[a]==this[b]))){d[a]=true;break}}if(a==c.length){e.push(this[b])}}return e};Array.prototype.intersect=function(a){if(!(a instanceof Array)){return[]}return this.subtract(this.subtract(a))};Array.prototype.union=function(c){if(!(c instanceof Array)){return[]}var b=c.subtract(this);return this.concat(b)};Array.prototype.indicesOf=function(c){var d=[];for(var b=0,a=this.length;b<a;b++){if(this[b].equals?this[b].equals(c):this[b]==c){d.push(b)}}return d};Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b].equals?this[b].equals(c):this[b]==c){return b}}return -1};Function.prototype.concat=function(a,b){var c=this;return function(){var d=c.apply(this,arguments=parseArray(arguments));if(b!=undefined){arguments[b]=d}return a.apply(this,arguments)}};Function.prototype.map=function(d){d=parseArray(d);var c=[];for(var b=0,a=d.length;b<a;b++){c.push(this.apply(this,parseArray(d[b])))}return c};var $_GET={};if(self.location.search.length>0){(function(d){var b,c,e=d.split("=");b=unescape(e[0]);c=unescape(e[1]);if($_GET[b]){($_GET[b]=parseArray($_GET[b])).push(c)}else{$_GET[b]=c}}).map(self.location.search.substring(1).split("&"))}var Color=function(){this.setColor.apply(this,arguments)};Color.prototype.setColor=function(){if(arguments.length==1){if(/^#?(([\dA-F]{3}){1,2})$/i.test(arguments[0]+"")){var a=RegExp.$1;if(a.length==3){a=a.replace(/(.)/g,"$1$1")}this.red=parseInt(a.substring(0,2),16);this.green=parseInt(a.substring(2,4),16);this.blue=parseInt(a.substring(4,6),16)}else{if(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(arguments[0]+"")){this.setColor.apply(this,[RegExp.$1,RegExp.$2,RegExp.$3])}}}else{if(arguments.length==3){this.red=Math.max(Math.min(Math.round(arguments[0]),255),0);this.green=Math.max(Math.min(Math.round(arguments[1]),255),0);this.blue=Math.max(Math.min(Math.round(arguments[2]),255),0)}}if(isNaN(this.red)){this.red=0}if(isNaN(this.green)){this.green=0}if(isNaN(this.blue)){this.blue=0}};Color.prototype.getHexCode=function(){var a=[this.red.toString(16),this.green.toString(16),this.blue.toString(16)].join(",").replace(/\b([\da-f])\b/gi,"0$1");return"#"+a.toUpperCase().replace(/,/g,"")};Color.prototype.combine=function(e,f){f=new Number(f);if(isNaN(f)){f=50}var g=Math.max(Math.min(f,100),0)/100;var a=1-g;var b=[[this.red,e.red]];b.push([this.green,e.green]);b.push([this.blue,e.blue]);for(var d=0;d<3;d++){b[d]=b[d][0]*a+b[d][1]*g}var c=new Color();c.setColor.apply(c,b);return c};Color.prototype.toString=Color.prototype.getHexCode;Color.prototype.getSafeColor=function(){var a=this.getLuminance()<128?255:0;return new Color(a,a,a)};Color.prototype.getLuminance=function(){return 0.3*this.red+0.6*this.green+0.1*this.blue};Color.prototype.toGrayscale=function(){var a=Math.round(this.getLuminance());return new Color(a,a,a)};Color.prototype.getOpposite=function(){with(this){return new Color(255-red,255-green,255-blue)}};Color.prototype.getLighter=function(a){return this.combine(new Color(255,255,255),a?a:30)};Color.prototype.getDarker=function(a){return this.combine(new Color(0,0,0),a?a:30)};if(!String.prototype.replace$){String.prototype.replace$=String.prototype.replace}String.prototype.replace=function(f,d,a,h){if(h==undefined){h=0}var g=this.substring(0,h);var c=this.substring(h);if(f instanceof RegExp){return g+c.replace$(f,d)}if(a==undefined){a=1}var e=f.length;for(var b=0;b!=a&&(index=c.indexOf(f))>=0;b++){g+=c.substring(0,index)+d;c=c.substring(index+e)}return g+c};if(!String.prototype.indexOf$){String.prototype.indexOf$=String.prototype.indexOf}String.prototype.indexOf=function(c,d){if(d==undefined){d=0}var a=this.length;var b=this.substring(d).indexOf$(c);if(b==-1||d>a){return -1}return d+b};String.prototype.indicesOf=function(c,e){if(e==undefined){e=0}var d=[];var a=this.indexOf$(c,e);var b=c.length;while(a>=0){e=a+b;d.push(a);a=this.indexOf(c,e)}return d};String.prototype.reverse=function(){return this.split("").reverse().join("")};String.prototype.toProperCase=function(){return this.replace(/(^|[^\w'-])\w/g,function(a){return a.toUpperCase()})};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.remove=function(b,a){return this.substring(0,b?b:0)+this.substring(a!=undefined?a:this.length)};