
var glock=function(){var that={};that.emptyFunction=function(){};that.idfu=function(x){return x;};that.isElement=function(object){return object&&object.nodeType==1;};that.isArray=function(object){return object!=null&&typeof object=="object"&&'splice'in object&&'join'in object;};that.isFunction=function(object){return typeof object=="function";};that.isString=function(object){return typeof object=="string";};that.isNumber=function(object){return typeof object=="number";};that.isHash=function(object){return object!=null&&typeof object=="object"&&'_gHash'in object;};that.isDef=function(object){return typeof object!=="undefined";};that.isUndefined=function(object){return typeof object=="undefined";};that.isObject=function(object){return(typeof object).toLowerCase()=="object";};that.xS=function(string){if(string===String.prototype){glock.extObj(String.prototype,glock.string);}else{string=new String(string);glock.extObj(string,glock.string);}
return string;}
that.xF=function(func){glock.extObj(func,glock.efunction);return func;}
that.xW=function(string){if(!glock.isString(string))return[];string=glock.xS(string).strip();return string?glock.xA(string.split(/\s+/)):glock.xA([]);};that.xH=function(object){return glock.hash(object);}
that.ScriptFragment='<script[^>]*>([\\S\\s]*?)<\/script>';that.JSONFilter=/^\/\*-secure-([\s\S]*)\*\/\s*$/;that.object=function(o,ext){var obj=that.isFunction(o)?o():o;function F(){}
F.prototype=obj;if(typeof ext!=='undefined'){glock.extObj(F.prototype,ext);}
return new F();}
that.x=function(element){if(that.isString(element)){element=document.getElementById(element);}
if((glock.extElement)&&(that.isObject(element))){element=glock.extElement(element);}
return element;}
that.xx=function(){return glock.Selector.findChildElements(document,glock.xA(arguments));};return that;}();glock.nodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};glock.env={ie:/MSIE/i.test(navigator.userAgent),ie6:/^[^(]*?\([^(]*?MSIE 6/i.test(navigator.userAgent),ie7:/^[^(]*?\([^(]*?MSIE 7/i.test(navigator.userAgent),ie8:/^[^(]*?\([^(]*?MSIE 8/i.test(navigator.userAgent),firefox:/Firefox/i.test(navigator.userAgent),opera:/Opera/i.test(navigator.userAgent),webkit:/Webkit/i.test(navigator.userAgent),gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1,mobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};glock.browserFeatures={XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:(function(){if(window.HTMLElement&&window.HTMLElement.prototype)
return true;if(window.Element&&window.Element.prototype)
return true;})(),SpecificElementExtensions:(function(){if(typeof window.HTMLDivElement!=='undefined')
return true;var div=document.createElement('div');if(div['__proto__']&&div['__proto__']!==document.createElement('form')['__proto__']){return true;}
return false;})()};if(glock.browserFeatures.XPath){glock._getElementsByXPath=function(expression,parentElement){var results=[];var query=document.evaluate(expression,glock.x(parentElement)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,length=query.snapshotLength;i<length;i++)
results.push(glock.extElement(query.snapshotItem(i)));return results;};}
glock.extObj=function(destination,source){if(destination&&source){for(var property in source){destination[property]=source[property];}}
return destination;};glock.obj={toJSON:function(object){var type=typeof object;switch(type){case'undefined':case'function':case'unknown':return;case'boolean':return object.toString();}
if(object===null)return'null';if(object.toJSON)return object.toJSON();if(glock.isElement(object))return;var results=[];for(var property in object){var value=glock.obj.toJSON(object[property]);if(!glock.isUndefined(value))
results.push(property.toJSON()+': '+value);}
return'{'+results.join(', ')+'}';},toQueryString:function(object){return glock.xH(object).toQueryString();},toHTML:function(object){return object&&object.toHTML?object.toHTML():glock.string.interpret(object);},keys:function(object){var keys=glock.xA([]);for(var property in object)
keys.push(property);return keys;},values:function(object){var values=[];for(var property in object)
values.push(object[property]);return values;},clone:function(object){return glock.extObj({},object);},isElement:function(object){return object&&object.nodeType==1;},isArray:function(object){return object!=null&&typeof object=="object"&&'splice'in object&&'join'in object;},isHash:function(object){return object instanceof glock.hash;},isFunction:function(object){return typeof object=="function";},isString:function(object){return typeof object=="string";},isNumber:function(object){return typeof object=="number";},isUndefined:function(object){return typeof object=="undefined";}};glock.string={};glock.extObj(glock.string,{interpret:function(value){return value==null?'':String(value);},specialChar:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','\\':'\\\\'}});glock.string={grep:function(pattern,replacement){var result=glock.xS(''),source=this,match;prepareReplacement=function(replacement){if(glock.isFunction(replacement))return replacement;var template=new glock.Template(replacement);return function(match){return template.evaluate(match)};};replacement=prepareReplacement(replacement);while(source.length>0){match=source.match(pattern)
if(match){result+=source.slice(0,match.index);result+=glock.string.interpret(replacement(match));source=source.slice(match.index+match[0].length);}else{result+=source;source='';}}
return glock.xS(result);},sub:function(pattern,replacement,count){count=glock.isUndefined(count)?1:count;return this.grep(pattern,function(match){if(--count<0)return match[0];return replacement(match);});},scan:function(pattern,iterator){this.grep(pattern,iterator);return glock.xS(this);},truncate:function(length,truncation){length=length||30;truncation=glock.isUndefined(truncation)?'...':truncation;return this.length>length?this.slice(0,length-truncation.length)+truncation:glock.xS(this);},strip:function(){return glock.xS(this.replace(/^\s+/,'').replace(/\s+$/,''));},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'');},stripScripts:function(){return this.replace(new RegExp(glock.ScriptFragment,'img'),'');},extractScripts:function(){var matchAll=new RegExp(glock.ScriptFragment,'img');var matchOne=new RegExp(glock.ScriptFragment,'im');return glock.xA((this.match(matchAll)||[])).map(function(scriptTag){return(scriptTag.match(matchOne)||['',''])[1];});},evalScripts:function(){return glock.xA(glock.xS(this).extractScripts()).map(function(script){return eval(script)});},escapeHTML:function(){return glock.xS(this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'));},unescapeHTML:function(){return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');},toQueryParams:function(separator){var match=this.strip().match(/([^?#]*)(#.*)?$/);if(!match)return{};return glock.xA(match[1].split(separator||'&')).inject({},function(hash,pair){if((pair=pair.split('='))[0]){var key=decodeURIComponent(pair.shift());var value=pair.length>1?pair.join('='):pair[0];if(value!=undefined)value=decodeURIComponent(value);if(key in hash){if(!glock.isArray(hash[key]))hash[key]=[hash[key]];hash[key].push(value);}
else hash[key]=value;}
return hash;});},toArray:function(){return this.split('');},succ:function(){return this.slice(0,this.length-1)+
String.fromCharCode(this.charCodeAt(this.length-1)+1);},times:function(count){return count<1?'':new Array(count+1).join(this);},camelize:function(){var parts=this.split('-'),len=parts.length;if(len==1)return parts[0];var camelized=this.charAt(0)=='-'?parts[0].charAt(0).toUpperCase()+parts[0].substring(1):parts[0];for(var i=1;i<len;i++)
camelized+=parts[i].charAt(0).toUpperCase()+parts[i].substring(1);return camelized;},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();},underscore:function(){return this.grep(/::/,'/').grep(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').grep(/([a-z\d])([A-Z])/,'#{1}_#{2}').grep(/-/,'_').toLowerCase();},dasherize:function(){return this.grep(/_/,'-');},inspect:function(useDoubleQuotes){var escapedString=this.grep(/[\x00-\x1f\\]/,function(match){var character=String.specialChar[match[0]];return character?character:'\\u00'+match[0].charCodeAt().toPaddedString(2,16);});if(useDoubleQuotes)return'"'+escapedString.replace(/"/g,'\\"')+'"';return"'"+escapedString.replace(/'/g,'\\\'')+"'";},toJSON:function(){return this.inspect(true);},unfilterJSON:function(filter){return this.sub(filter||glock.JSONFilter,'#{1}');},isJSON:function(){var str=this;if(str.blank())return false;str=this.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'');return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON())return eval('('+json+')');}catch(e){}
throw new SyntaxError('Badly formed JSON string: '+this.inspect());},include:function(pattern){return this.indexOf(pattern)>-1;},startsWith:function(pattern){return this.indexOf(pattern)===0;},endsWith:function(pattern){var d=this.length-pattern.length;return d>=0&&this.lastIndexOf(pattern)===d;},empty:function(){return this=='';},blank:function(){return/^\s*$/.test(this);},interpolate:function(object,pattern){return new glock.Template(this,pattern).evaluate(object);}};glock.string.trim=glock.string.strip;glock.extObj(glock.string,{interpret:function(value){return value==null?'':String(value);},specialChar:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','\\':'\\\\'}});glock.string.gsub=glock.string.grep;glock.str={strip:function(str){return str.replace(/^\s+/,'').replace(/\s+$/,'');}};glock.efunction={argumentNames:function(){var names=glock.xA(this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",")).invoke("strip");return names.length==1&&!names[0]?[]:names;},bind:function(){if(arguments.length<2&&glock.isUndefined(arguments[0]))return this;var __method=this,args=glock.xA(arguments),object=args.shift();return glock.xF(function(){return __method.apply(object,args.concat(glock.xA(arguments)));});},bindAsEventListener:function(){var __method=this,args=glock.xA(arguments);var object=args.shift();return function(event){return __method.apply(object,[event||window.event].concat(args));}},curry:function(){if(!arguments.length)return this;var __method=this,args=glock.xA(arguments);return function(){return __method.apply(this,args.concat(glock.xA(arguments)));}},delay:function(){var __method=this,args=glock.xA(arguments),timeout=args.shift()*1000;return window.setTimeout(function(){return __method.apply(__method,args);},timeout);},wrap:function(wrapper){var __method=this;return function(){return wrapper.apply(this,[__method.bind(this)].concat(glock.xA(arguments)));}},methodize:function(){if(this._methodized)return this._methodized;var __method=this;this._methodized=function(){return __method.apply(null,[this].concat(glock.xA(arguments)));};return this._methodized;}};glock.enumerable={oBreak:{},each:function(iterator,context){var index=0;if(glock.isFunction(iterator)){glock.xF(iterator);}
iterator=glock.xF(iterator).bind(context);try{if(this._each){this._each(function(value){iterator(value,index++);});}}catch(e){if(e!=this.oBreak)throw e;}
return this;},eachSlice:function(number,iterator,context){iterator=iterator?glock.xF(iterator).bind(context):glock.idfu;var index=-number,slices=[];if(this.toArray){var array=this.toArray();}else array=[];while((index+=number)<array.length)
slices.push(array.slice(index,index+number));return slices.collect(iterator,context);},all:function(iterator,context){iterator=iterator?glock.xF(iterator).bind(context):glock.idfu;var result=true;if(this.each){this.each(function(value,index){result=result&&!!iterator(value,index);if(!result)throw this.oBreak;});}
return result;},any:function(iterator,context){iterator=iterator?glock.xF(iterator).bind(context):glock.idfu;var result=false;if(this.each){this.each(function(value,index){result=!!iterator(value,index);if(result){throw this.oBreak;}});}
return result;},collect:function(iterator,context){iterator=iterator?glock.xF(iterator).bind(context):glock.idfu;var results=glock.xA([]);if(this.each){this.each(function(value,index){results.push(iterator(value,index));});}
return results;},detect:function(iterator,context){iterator=glock.xF(iterator).bind(context);var result;if(this.each){this.each(glock.xF(function(value,index){if(iterator(value,index)){result=value;throw this.oBreak;}}).bind(this));}
return result;},findAll:function(iterator,context){iterator=glock.xF(iterator).bind(context);var results=glock.xA([]);if(this.each){this.each(function(value,index){if(iterator(value,index))
results.push(value);});}
return results;},grep:function(filter,iterator,context){iterator=iterator?glock.xF(iterator).bind(context):glock.idfu;var results=[];if(glock.isString(filter))
filter=new RegExp(filter);if(this.each){this.each(function(value,index){if(filter.match(value))
results.push(iterator(value,index));});}
return results;},include:function(object){if(glock.isFunction(this.indexOf))
if(this.indexOf(object)!=-1)return true;var found=false;if(this.each){this.each(function(value){if(value==object){found=true;throw this.oBreak;}});}
return found;},inGroupsOf:function(number,fillWith){fillWith=glock.isUndefined(fillWith)?null:fillWith;if(this.eachSlice){return this.eachSlice(number,function(slice){while(slice.length<number)slice.push(fillWith);return slice;});}else return false;},inject:function(memo,iterator,context){if(glock.isFunction(iterator))glock.xF(iterator);if(iterator)iterator=iterator.bind(context);if(this.each){this.each(function(value,index){memo=iterator(memo,value,index);});}
return memo;},invoke:function(method){var args=glock.xA(arguments).slice(1);if(this.each){return this.map(function(value){if(value[method])
return value[method].apply(value,args);else
return false;});}},max:function(iterator,context){iterator=iterator?iterator.bind(context):glock.idfu;var result;if(this.each){this.each(function(value,index){value=iterator(value,index);if(result==null||value>=result)
result=value;});}
return result;},min:function(iterator,context){iterator=iterator?iterator.bind(context):glock.idfu;var result;if(this.each){this.each(function(value,index){value=iterator(value,index);if(result==null||value<result)
result=value;});}
return result;},partition:function(iterator,context){iterator=iterator?iterator.bind(context):glock.idfu;var trues=[],falses=[];if(this.each){this.each(function(value,index){(iterator(value,index)?trues:falses).push(value);});}
return[trues,falses];},pluck:function(property){var results=glock.xA([]);if(this.each){this.each(function(value){results.push(value[property]);});}
return results;},reject:function(iterator,context){iterator=glock.xF(iterator).bind(context);var results=[];if(this.each){this.each(function(value,index){if(!iterator(value,index))
results.push(value);});}
return results;},sortBy:function(iterator,context){iterator=iterator.bind(context);if(this.map){return this.map(function(value,index){return{value:value,criteria:iterator(value,index)};}).sort(function(left,right){var a=left.criteria,b=right.criteria;return a<b?-1:a>b?1:0;}).pluck('value');}else return false;},toArray:function(){if(this.map){return this.map();}else return false;},zip:function(){var iterator=glock.idfu,args=glock.xA(arguments);if(glock.isFunction(args.last()))
iterator=args.pop();var collections=[this].concat(args).map(glock.xA);if(this.map){return this.map(function(value,index){return iterator(collections.pluck(index));});}else return false;},size:function(){if(this.toArray){return this.toArray().length;}else return 0;},inspect:function(){return'#<Enumerable:'+this.toArray().inspect()+'>';}};glock.extObj(glock.enumerable,{map:glock.enumerable.collect,find:glock.enumerable.detect,select:glock.enumerable.findAll,filter:glock.enumerable.findAll,member:glock.enumerable.include,entries:glock.enumerable.toArray,every:glock.enumerable.all,some:glock.enumerable.any});glock.eArray={_each:function(iterator){for(var i=0,length=this.length;i<length;i++)
iterator(this[i]);},clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},compact:function(){if(this.select){return this.select(function(value){return value!=null;});}else return false;},flatten:function(){if(!this.inject)return false;return this.inject([],function(array,value){return glock.xA(array.concat(glock.isArray(value)?value.flatten():[value]));});},without:function(){var values=glock.xA(arguments);if(!this.select)return false;return this.select(function(value){return!values.include(value);});},reverse:function(inline){var x=glock.xA(inline!==false?this:this.toArray());return x._reverse();},reduce:function(){return this.length>1?this:this[0];},uniq:function(sorted){if(!this.inject)return false;return this.inject([],function(array,value,index){if(0==index||(sorted?array.last()!=value:!array.include(value)))
array.push(value);return array;});},intersect:function(array){if(!this.uniq)return false;return this.uniq().findAll(function(item){return array.detect(function(value){return item===value});});},clone:function(){return[].concat(this);},size:function(){return this.length;},inspect:function(){if(this.map){return'['+this.map(glock.inspect).join(', ')+']';}},toJSON:function(){var results=[];if(!this.each)return false;this.each(function(object){var value=glock.obj.toJSON(object);if(!glock.isUndefined(value))results.push(value);});return'['+results.join(', ')+']';}};glock.xA=function(iterable){if(!iterable)return glock.xA([]);iterable=glock.extObj(iterable,glock.enumerable);iterable=glock.extObj(iterable,glock.eArray);if((!glock.isArray(iterable))&&(iterable.toArray))iterable=iterable.toArray();return iterable;}
glock.hash=function(object){var that=glock.object(glock.enumerable);function toQueryPair(key,value){if(glock.isUndefined(value))return key;return key+'='+encodeURIComponent(glock.string.interpret(value));}
glock.extObj(that,{_each:function(iterator){for(var key in this._object){var value=this._object[key],pair=[key,value];pair.key=key;pair.value=value;iterator(pair);}},set:function(key,value){return this._object[key]=value;},get:function(key){return this._object[key];},unset:function(key){var value=this._object[key];delete this._object[key];return value;},toObject:function(){return glock.obj.clone(this._object);},keys:function(){return this.pluck('key');},values:function(){return this.pluck('value');},index:function(value){var match=this.detect(function(pair){return pair.value===value;});return match&&match.key;},merge:function(object){return this.clone().update(object);},update:function(object){return glock.hash(object).inject(this,function(result,pair){result.set(pair.key,pair.value);return result;});},toQueryString:function(){return this.map(function(pair){var key=encodeURIComponent(pair.key),values=pair.value;if(values&&typeof values=='object'){if(glock.isArray(values))
return values.map(toQueryPair.curry(key)).join('&');}
return toQueryPair(key,values);}).join('&');},inspect:function(){return'#<Hash:{'+this.map(function(pair){return pair.map(glock.obj.inspect).join(': ');}).join(', ')+'}>';},toJSON:function(){return glock.toJSON(this.toObject());},clone:function(){return glock.obj.clone(this);}});that._object=glock.isHash(object)?object.toObject():glock.obj.clone(object);that._gHash=true;that.toTemplateReplacements=that.toObject;that.from=glock.xH;return that;};glock.event={KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(event){var element;switch(event.type){case'mouseover':element=event.fromElement;break;case'mouseout':element=event.toElement;break;default:return null;}
return glock.extElement(element);}};glock.extObj(glock.event,(function(){var isButton;if(glock.env.ie){var buttonMap={0:1,1:4,2:2};isButton=function(event,code){return event.button==buttonMap[code];};}else if(glock.env.webkit){isButton=function(event,code){switch(code){case 0:return event.which==1&&!event.metaKey;case 1:return event.which==1&&event.metaKey;default:return false;}};}else{isButton=function(event,code){return event.which?(event.which===code+1):(event.button===code);};}
return{isLeftClick:function(event){return isButton(event,0)},isMiddleClick:function(event){return isButton(event,1)},isRightClick:function(event){return isButton(event,2)},element:function(event){var node=event.srcElement;return glock.extElement(node.nodeType==glock.nodeType.TEXT?node.parentNode:node);},element:function(event){var node=(event.target)?event.target:event.srcElement,type=event.type,currentTarget=event.currentTarget;if(currentTarget&&currentTarget.tagName){if(type==='load'||type==='error'||(type==='click'&&currentTarget.tagName.toLowerCase()==='input'&&currentTarget.type==='radio'))
node=currentTarget;}
if(node.nodeType==glock.nodeType.TEXT)node=node.parentNode;return glock.extElement(node);},findElement:function(elements,expression,index){if(glock.isNumber(expression)){index=expression;expression=false;}
return glock.Selector.matchElements(elements,expression||'*')[index||0];},pointer:function(event){var docElement=document.documentElement,body=document.body||{scrollLeft:0,scrollTop:0};return{x:event.pageX||(event.clientX+
(docElement.scrollLeft||body.scrollLeft)-
(docElement.clientLeft||0)),y:event.pageY||(event.clientY+
(docElement.scrollTop||body.scrollTop)-
(docElement.clientTop||0))};},pointerX:function(event){return glock.event.pointer(event).x},pointerY:function(event){return glock.event.pointer(event).y},stop:function(event){if(glock.env.ie){glock.extObj(event,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});}
event.preventDefault();event.stopPropagation();event.stopped=true;}};})());glock.extEvent=(function(){var methods=glock.obj.keys(glock.event).inject({},function(m,name){if(glock.isFunction(glock.event[name])){glock.xF(glock.event[name]);m[name]=glock.event[name].methodize();}
return m;});if(glock.env.ie){glock.extObj(methods,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(event){if(!event)return false;if(event._extendedByPrototype)return event;event._extendedByPrototype=glock.emptyFunction;var pointer=glock.event.pointer(event);glock.extObj(event,{target:event.srcElement,relatedTarget:glock.event.relatedTarget(event),pageX:pointer.x,pageY:pointer.y});return glock.extObj(event,methods);};}else{return function(event){return glock.object(event,methods);}}})();glock.extObj(glock.event,(function(){var cache=glock.event.cache;function getEventID(element){if(element._prototypeEventID)return element._prototypeEventID[0];arguments.callee.id=arguments.callee.id||1;element._prototypeEventID=[++arguments.callee.id];return element._prototypeEventID;}
function getDOMEventName(eventName){eventName=glock.xS(eventName);if(eventName&&eventName.include(':'))return glock.xS("dataavailable");return eventName;}
function getCacheForID(id){cache[id]=cache[id]||{};return cache[id];}
function getWrappersForEventName(id,eventName){var c=getCacheForID(id);c[eventName]=c[eventName]||[];return c[eventName];}
function createWrapper(element,eventName,handler){var id=getEventID(element);var c=getWrappersForEventName(id,eventName);c=glock.xA(c);if(c.pluck("handler").include(handler))return false;var wrapper=function(event){if(!glock.event||!glock.extEvent||(event.eventName&&event.eventName!=eventName))
return false;handler.call(element,event);};wrapper.handler=handler;c.push(wrapper);return wrapper;}
function findWrapper(id,eventName,handler){var c=getWrappersForEventName(id,eventName);return c.find(function(wrapper){return wrapper.handler==handler});}
function destroyWrapper(id,eventName,handler){var c=getCacheForID(id);if(!c[eventName])return false;c[eventName]=c[eventName].without(findWrapper(id,eventName,handler));}
function destroyCache(){for(var id in cache)
for(var eventName in cache[id])
cache[id][eventName]=null;}
if(window.attachEvent){window.attachEvent("onunload",destroyCache);}
return{observe:function(element,eventName,handler){element=glock.x(element);var name=getDOMEventName(eventName);var wrapper=createWrapper(element,eventName,handler);if(!wrapper)return element;if(element.addEventListener){element.addEventListener(name,wrapper,false);}else{element.attachEvent("on"+name,wrapper);}
return element;},stopObserving:function(element,eventName,handler){element=glock.x(element);var id=getEventID(element),name=getDOMEventName(eventName);if(!handler&&eventName){getWrappersForEventName(id,eventName).each(function(wrapper){element.stopObserving(eventName,wrapper.handler);});return element;}else if(!eventName){glock.keys(getCacheForID(id)).each(function(eventName){element.stopObserving(eventName);});return element;}
var wrapper=findWrapper(id,eventName,handler);if(!wrapper)return element;if(element.removeEventListener){element.removeEventListener(name,wrapper,false);}else{element.detachEvent("on"+name,wrapper);}
destroyWrapper(id,eventName,handler);return element;},fire:function(element,eventName,memo){element=glock.x(element);if(element==document&&document.createEvent&&!element.dispatchEvent)
element=document.documentElement;var event;if(document.createEvent){event=document.createEvent("HTMLEvents");event.initEvent("dataavailable",true,true);}else{event=document.createEventObject();event.eventType="ondataavailable";}
event.eventName=eventName;event.memo=memo||{};if(document.createEvent){element.dispatchEvent(event);}else{element.fireEvent(event.eventType,event);}
return Event.extend(event);}};})());glock.element={visible:function(element){return glock.x(element).style.display!='none';},toggle:function(element,show){element=glock.x(element);if(glock.isDef(show)){glock.element[show?'show':'hide'](element);}else{glock.element[glock.element.visible(element)?'hide':'show'](element);}
return element;},hide:function(element){glock.x(element).style.display='none';return element;},show:function(element){glock.x(element).style.display='';return element;},remove:function(element){element=glock.x(element);element.parentNode.removeChild(element);return element;},update:function(element,content){element=glock.x(element);if(content&&content.toElement)content=content.toElement();if(glock.obj.isElement(content))return element.update().insert(content);content=glock.obj.toHTML(content);element.innerHTML=glock.xS(content).stripScripts();glock.xF(glock.xS(content).evalScripts).bind(content).defer();return element;},replace:function(element,content){element=glock.x(element);if(content&&content.toElement)content=content.toElement();else if(!glock.obj.isElement(content)){content=glock.obj.toHTML(content);var range=element.ownerDocument.createRange();range.selectNode(element);content.evalScripts.bind(content).defer();content=range.createContextualFragment(glock.xS(content).stripScripts());}
element.parentNode.replaceChild(content,element);return element;},insert:function(element,insertions){element=glock.x(element);if(glock.isString(insertions)||glock.isNumber(insertions)||glock.isElement(insertions)||(insertions&&(insertions.toElement||insertions.toHTML)))
insertions={bottom:insertions};var content,insert,tagName,childNodes;for(var position in insertions){content=insertions[position];position=position.toLowerCase();insert=glock.element._insertionTranslations[position];if(content&&content.toElement)content=content.toElement();if(glock.isElement(content)){insert(element,content);continue;}
content=glock.obj.toHTML(content);tagName=((position=='before'||position=='after')?element.parentNode:element).tagName.toUpperCase();childNodes=glock.element._getContentFromAnonymousElement(tagName,glock.xS(content).stripScripts());if(position=='top'||position=='after')childNodes.reverse();childNodes.each(insert.curry(element));content.evalScripts.bind(content).defer();}
return element;},insertEl:function(element,position,content){function before(element,node){element.parentNode.insertBefore(node,element);}
function begining(element,node){element.insertBefore(node,element.firstChild);}
function end(element,node){element.parentNode.appendChild(node);}
function after(element,node){if(element.nextSibling){element.parentNode.insertBefore(node,element.nextSibling);}else{end(element,node);}}
if(!glock.isElement(content))return;switch(position){case'begining':case'begin':before(content,element);break;case'end':end(content,element);break;case'before':before(content,element);break;case'after':after(content,element);break;}},wrap:function(element,wrapper,attributes){element=glock.x(element);if(glock.isElement(wrapper)){glock.x(wrapper).writeAttribute(attributes||{});}else if(glock.isString(wrapper)){wrapper=glock.builder.node(wrapper,attributes);}else{wrapper=glock.builder.node('div');}
if(element.parentNode)
element.parentNode.replaceChild(wrapper,element);wrapper.appendChild(element);return wrapper;},inspect:function(element){element=glock.x(element);var result='<'+element.tagName.toLowerCase();$H({'id':'id','className':'class'}).each(function(pair){var property=pair.first(),attribute=pair.last();var value=(element[property]||'').toString();if(value)result+=' '+attribute+'='+value.inspect(true);});return result+'>';},recursivelyCollect:function(element,property){element=glock.x(element);var elements=[];while(element=element[property])
if(element.nodeType==1)
elements.push(glock.extElement(element));return elements;},ancestors:function(element){return glock.x(element).recursivelyCollect('parentNode');},descendants:function(element){return glock.x(element).select("*");},firstDescendant:function(element){element=glock.x(element).firstChild;while(element&&element.nodeType!=1)element=element.nextSibling;return glock.x(element);},immediateDescendants:function(element){if(!(element=glock.x(element).firstChild))return[];while(element&&element.nodeType!=1)element=element.nextSibling;if(element)return[element].concat(glock.x(element).nextSiblings());return[];},previousSiblings:function(element){return glock.x(element).recursivelyCollect('previousSibling');},nextSiblings:function(element){return glock.x(element).recursivelyCollect('nextSibling');},siblings:function(element){element=glock.x(element);return element.previousSiblings().reverse().concat(element.nextSiblings());},match:function(element,selector){if(glock.isString(selector))
selector=new glock.Selector(selector);return selector.match(glock.x(element));},up:function(element,expression,index){element=glock.x(element);if(arguments.length==1)return glock.x(element.parentNode);var ancestors=element.ancestors();return glock.isNumber(expression)?ancestors[expression]:glock.Selector.findElement(ancestors,expression,index);},down:function(element,expression,index){element=glock.x(element);if(arguments.length==1)return element.firstDescendant();return glock.isNumber(expression)?element.descendants()[expression]:glock.element.select(element,expression)[index||0];},previous:function(element,expression,index){element=glock.x(element);if(arguments.length==1)return glock.x(glock.Selector.handlers.previousElementSibling(element));var previousSiblings=element.previousSiblings();return glock.isNumber(expression)?previousSiblings[expression]:glock.Selector.findElement(previousSiblings,expression,index);},next:function(element,expression,index){element=glock.x(element);if(arguments.length==1)return glock.x(glock.Selector.handlers.nextElementSibling(element));var nextSiblings=element.nextSiblings();return glock.isNumber(expression)?nextSiblings[expression]:glock.Selector.findElement(nextSiblings,expression,index);},select:function(){var args=glock.xA(arguments),element=glock.x(args.shift());return glock.xA(glock.Selector.findChildElements(element,args));},adjacent:function(){var args=glock.xA(arguments),element=glock.x(args.shift());return glock.Selector.findChildElements(element.parentNode,args).without(element);},identify:function(element){element=glock.x(element);var id=element.readAttribute('id'),self=arguments.callee;if(id)return id;do{id='anonymous_element_'+self.counter++}while(glock.x(id));element.writeAttribute('id',id);return id;},readAttribute:function(element,name){element=glock.x(element);if(glock.env.ie){var t=glock.element._attributeTranslations.read;if(t.values[name])return t.values[name](element,name);if(t.names[name])name=t.names[name];if(glock.xS(name).include(':')){return(!element.attributes||!element.attributes[name])?null:element.attributes[name].value;}}
return element.getAttribute(name);},writeAttribute:function(element,name,value){element=glock.x(element);var attributes={},t=glock.builder.ATTR_MAP;if(typeof name=='object')attributes=name;else attributes[name]=glock.isUndefined(value)?true:value;for(var attr in attributes){name=t[attr]||attr;value=attributes[attr];if(value===false||value===null)
element.removeAttribute(name);else if(value===true)
element.setAttribute(name,name);else element.setAttribute(name,value);}
return element;},getHeight:function(element){return glock.x(element).getDimensions().height;},getWidth:function(element){return glock.x(element).getDimensions().width;},classNames:function(element){return glock.element.makeClassNames(element);},hasClassName:function(element,className){if(!(element=glock.x(element)))return;var elementClassName=element.className;return(elementClassName.length>0&&(elementClassName==className||new RegExp("(^|\\s)"+className+"(\\s|$)").test(elementClassName)));},addClassName:function(element,className){if(!(element=glock.x(element)))return;if(!element.hasClassName(className))
element.className+=(element.className?' ':'')+className;return element;},removeClassName:function(element,className){if(!(element=glock.x(element)))return;element.className=glock.xS(element.className.replace(new RegExp("(^|\\s+)"+className+"(\\s+|$)"),' ')).strip();return element;},toggleClassName:function(element,className){if(!(element=glock.x(element)))return;return element[element.hasClassName(className)?'removeClassName':'addClassName'](className);},cleanWhitespace:function(element){element=glock.x(element);var node=element.firstChild;while(node){var nextNode=node.nextSibling;if(node.nodeType==3&&!/\S/.test(node.nodeValue))
element.removeChild(node);node=nextNode;}
return element;},empty:function(element){return glock.x(element).innerHTML.blank();},descendantOf:function(element,ancestor){element=glock.x(element),ancestor=glock.x(ancestor);var originalAncestor=ancestor;if(element.compareDocumentPosition)
return(element.compareDocumentPosition(ancestor)&8)===8;if(element.sourceIndex&&!glock.env.opera){var e=element.sourceIndex,a=ancestor.sourceIndex,nextAncestor=ancestor.nextSibling;if(!nextAncestor){do{ancestor=ancestor.parentNode;}
while(!(nextAncestor=ancestor.nextSibling)&&ancestor.parentNode);}
if(nextAncestor&&nextAncestor.sourceIndex)
return(e>a&&e<nextAncestor.sourceIndex);}
while(element=element.parentNode)
if(element==originalAncestor)return true;return false;},scrollTo:function(element){element=glock.x(element);var pos=element.cumulativeOffset();window.scrollTo(pos[0],pos[1]);return element;},getStyle:function(element,style){element=glock.x(element);style=style=='float'?'cssFloat':glock.xS(style).camelize();var value=element.style[style];if(!value){var css=document.defaultView.getComputedStyle(element,null);value=css?css[style]:null;}
if(style=='opacity')return value?parseFloat(value):1.0;return value=='auto'?'':value;},getOpacity:function(element){return glock.x(element).getStyle('opacity');},setStyle:function(element,styles){element=glock.x(element);var elementStyle=element.style,match;if(glock.isString(styles)){element.style.cssText+=';'+styles;return styles.include('opacity')?element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]):element;}
for(var property in styles)
if(property=='opacity')element.setOpacity(styles[property]);else
elementStyle[(property=='float'||property=='cssFloat')?(glock.isUndefined(elementStyle.styleFloat)?'cssFloat':'styleFloat'):property]=styles[property];return element;},setOpacity:function(element,value){element=glock.x(element);element.style.opacity=(value==1||value==='')?'':(value<0.00001)?0:value;return element;},getDimensions:function(element){element=glock.x(element);var display=glock.x(element).getStyle('display');if(display!='none'&&display!=null)
return{width:element.offsetWidth,height:element.offsetHeight};var els=element.style;var originalVisibility=els.visibility;var originalPosition=els.position;var originalDisplay=els.display;els.visibility='hidden';els.position='absolute';els.display='block';var originalWidth=element.clientWidth;var originalHeight=element.clientHeight;els.display=originalDisplay;els.position=originalPosition;els.visibility=originalVisibility;return{width:originalWidth,height:originalHeight};},makePositioned:function(element){element=glock.x(element);var pos=glock.element.getStyle(element,'position');if(pos=='static'||!pos){element._madePositioned=true;element.style.position='relative';if(window.opera){element.style.top=0;element.style.left=0;}}
return element;},undoPositioned:function(element){element=glock.x(element);if(element._madePositioned){element._madePositioned=undefined;element.style.position=element.style.top=element.style.left=element.style.bottom=element.style.right='';}
return element;},makeClipping:function(element){element=glock.x(element);if(element._overflow)return element;element._overflow=glock.element.getStyle(element,'overflow')||'auto';if(element._overflow!=='hidden')
element.style.overflow='hidden';return element;},undoClipping:function(element){element=glock.x(element);if(!element._overflow)return element;element.style.overflow=element._overflow=='auto'?'':element._overflow;element._overflow=null;return element;},cumulativeOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);return glock.element._returnOffset(valueL,valueT);},positionedOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;if(element){if(element.tagName=='BODY')break;var p=glock.element.getStyle(element,'position');if(p!=='static')break;}}while(element);return glock.element._returnOffset(valueL,valueT);},absolutize:function(element){element=glock.x(element);if(element.getStyle('position')=='absolute')return;var offsets=element.positionedOffset();var top=offsets[1];var left=offsets[0];var width=element.clientWidth;var height=element.clientHeight;element._originalLeft=left-parseFloat(element.style.left||0);element._originalTop=top-parseFloat(element.style.top||0);element._originalWidth=element.style.width;element._originalHeight=element.style.height;element.style.position='absolute';element.style.top=top+'px';element.style.left=left+'px';element.style.width=width+'px';element.style.height=height+'px';return element;},undoAbsolutize:function(element){element=glock.x(element);if(element.getStyle('position')!='absolute')return;element.style.position='relative';var top=element._originalTop||0;var left=element._originalLeft||0;element.style.top=top+'px';element.style.left=left+'px';element.style.height=element._originalHeight;element.style.width=element._originalWidth;return element;},relativize:function(element){element=glock.x(element);if(element.getStyle('position')=='relative')return;element.style.position='relative';var top=parseFloat(element.style.top||0)-(element._originalTop||0);var left=parseFloat(element.style.left||0)-(element._originalLeft||0);element.style.top=top+'px';element.style.left=left+'px';element.style.height=element._originalHeight;element.style.width=element._originalWidth;return element;},cumulativeScrollOffset:function(element){var valueT=0,valueL=0;do{valueT+=element.scrollTop||0;valueL+=element.scrollLeft||0;element=element.parentNode;}while(element);return glock.element._returnOffset(valueL,valueT);},getOffsetParent:function(element){if(element.offsetParent)return glock.x(element.offsetParent);if(element==document.body)return glock.x(element);while((element=element.parentNode)&&element!=document.body)
if(glock.element.getStyle(element,'position')!='static')
return glock.x(element);return glock.x(document.body);},getStyleLeft:function(element){return Number(glock.xS(glock.element.getStyle(element,'left')).replace(/px/,''));},getStyleTop:function(element){return Number(glock.xS(glock.element.getStyle(element,'top')).replace(/px/,''));},viewportOffset:function(forElement){var valueT=0,valueL=0;var element=forElement;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;if(element.offsetParent==document.body&&glock.element.getStyle(element,'position')=='absolute')break;}while(element=element.offsetParent);element=forElement;do{if(!glock.env.opera||element.tagName=='BODY'){valueT-=element.scrollTop||0;valueL-=element.scrollLeft||0;}}while(element=element.parentNode);return glock.element._returnOffset(valueL,valueT);},clonePosition:function(element,source){var options=glock.extObj({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});source=glock.x(source);var p=source.viewportOffset();element=glock.x(element);var delta=[0,0];var parent=null;if(glock.element.getStyle(element,'position')=='absolute'){parent=element.getOffsetParent();delta=parent.viewportOffset();}
if(parent==document.body){delta[0]-=document.body.offsetLeft;delta[1]-=document.body.offsetTop;}
if(options.setLeft)element.style.left=(p[0]-delta[0]+options.offsetLeft)+'px';if(options.setTop)element.style.top=(p[1]-delta[1]+options.offsetTop)+'px';if(options.setWidth)element.style.width=source.offsetWidth+'px';if(options.setHeight)element.style.height=source.offsetHeight+'px';return element;},_returnOffset:function(l,t){var result=[l,t];result.left=l;result.top=t;return result;}};glock.element._attributeTranslations={read:{names:{'class':'className','for':'htmlFor'},values:{_getAttr:function(element,attribute){return element.getAttribute(attribute,2);},_getAttrNode:function(element,attribute){var node=element.getAttributeNode(attribute);return node?node.value:"";},_getEv:function(element,attribute){attribute=element.getAttribute(attribute);return attribute?attribute.toString().slice(23,-2):null;},_flag:function(element,attribute){return neo(element).hasAttribute(attribute)?attribute:null;},style:function(element){return element.style.cssText.toLowerCase();},title:function(element){return element.title;}}}};glock.element._attributeTranslations.write={names:glock.extObj({cellpadding:'cellPadding',cellspacing:'cellSpacing'},glock.element._attributeTranslations.read.names),values:{checked:function(element,value){element.checked=!!value;},style:function(element,value){element.style.cssText=value?value:'';}}};glock.element._attributeTranslations.has={};glock.xW('colSpan rowSpan vAlign dateTime accessKey tabIndex '+'encType maxLength readOnly longDesc').each(function(attr){glock.element._attributeTranslations.write.names[attr.toLowerCase()]=attr;glock.element._attributeTranslations.has[attr.toLowerCase()]=attr;});glock.element.makeClassNames=function(element){var that=glock.object(glock.enumerable);glock.extObj(that,{_each:function(iterator){glock.xA(this.element.className.split(/\s+/)).select(function(name){return name.length>0;})._each(iterator);},set:function(className){this.element.className=className;},add:function(classNameToAdd){if(this.include(classNameToAdd))return;this.set(glock.xA(this).concat(classNameToAdd).join(' '));},remove:function(classNameToRemove){if(!this.include(classNameToRemove))return;this.set(glock.xA(this).without(classNameToRemove).join(' '));},toString:function(){return glock.xA(this).join(' ');}});that.element=glock.x(element);return that;};glock.element._getContentFromAnonymousElement=function(tagName,html){var div=glock.builder.node('div'),t=glock.element._insertionTranslations.tags[tagName];if(t){div.innerHTML=t[0]+html+t[1];t[2].times(function(){div=div.firstChild});}else div.innerHTML=html;return glock.xA(div.childNodes);};glock.element._insertionTranslations={before:function(element,node){element.parentNode.insertBefore(node,element);},top:function(element,node){element.insertBefore(node,element.firstChild);},bottom:function(element,node){element.appendChild(node);},after:function(element,node){element.parentNode.insertBefore(node,element.nextSibling);},tags:{TABLE:['<table>','</table>',1],TBODY:['<table><tbody>','</tbody></table>',2],TR:['<table><tbody><tr>','</tr></tbody></table>',3],TD:['<table><tbody><tr><td>','</td></tr></tbody></table>',4],SELECT:['<select>','</select>',1]}};(function(){glock.extObj(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD});}).call(glock.element._insertionTranslations);glock.element.Simulated={hasAttribute:function(element,attribute){attribute=glock.element._attributeTranslations.has[attribute]||attribute;var node=glock.x(element).getAttributeNode(attribute);return node&&node.specified;}};if(glock.env.opera){glock.element.getStyle=glock.xF(glock.element.getStyle).wrap(function(proceed,element,style){switch(style){case'left':case'top':case'right':case'bottom':if(proceed(element,'position')==='static')return null;case'height':case'width':if(!glock.element.visible(element))return null;var dim=parseInt(proceed(element,style),10);if(dim!==element['offset'+glock.xS(style).capitalize()])
return dim+'px';var properties;if(style==='height'){properties=['border-top-width','padding-top','padding-bottom','border-bottom-width'];}
else{properties=['border-left-width','padding-left','padding-right','border-right-width'];}
return properties.inject(dim,function(memo,property){var val=proceed(element,property);return val===null?memo:memo-parseInt(val,10);})+'px';default:return proceed(element,style);}});glock.element.readAttribute=glock.xF(glock.element.readAttribute).wrap(function(proceed,element,attribute){if(attribute==='title')return element.title;return proceed(element,attribute);});}
else if(glock.env.ie){glock.element.getOffsetParent=glock.xF(glock.element.getOffsetParent).wrap(function(proceed,element){element=glock.x(element);var position=element.getStyle('position');if(position!=='static')return proceed(element);element.setStyle({position:'relative'});var value=proceed(element);element.setStyle({position:position});return value;});glock.xW('positionedOffset viewportOffset').each(function(method){glock.element[method]=glock.xF(glock.element[method]).wrap(function(proceed,element){element=glock.x(element);var position=element.getStyle('position');if(position!=='static')return proceed(element);var offsetParent=element.getOffsetParent();if(offsetParent&&offsetParent.getStyle('position')==='fixed')
offsetParent.setStyle({zoom:1});element.setStyle({position:'relative'});var value=proceed(element);element.setStyle({position:position});return value;});});glock.element.getStyle=function(element,style){element=glock.x(element);style=(style=='float'||style=='cssFloat')?'styleFloat':glock.xS(style).camelize();var value=element.style[style];if(!value&&element.currentStyle)value=element.currentStyle[style];if(style=='opacity'){if(value=(element.getStyle('filter')||'').match(/alpha\(opacity=(.*)\)/))
if(value[1])return parseFloat(value[1])/100;return 1.0;}
if(value=='auto'){if((style=='width'||style=='height')&&(element.getStyle('display')!='none'))
return element['offset'+style.capitalize()]+'px';return null;}
return value;};glock.element.setOpacity=function(element,value){function stripAlpha(filter){return filter.replace(/alpha\([^\)]*\)/gi,'');}
element=glock.x(element);var currentStyle=element.currentStyle;if((currentStyle&&!currentStyle.hasLayout)||(!currentStyle&&element.style.zoom=='normal'))
element.style.zoom=1;var filter=element.getStyle('filter'),style=element.style;if(value==1||value===''){(filter=stripAlpha(filter))?style.filter=filter:style.removeAttribute('filter');return element;}else if(value<0.00001)value=0;style.filter=stripAlpha(filter)+'alpha(opacity='+(value*100)+')';return element;};glock._elementAttributeTranslations={read:{names:{'class':'className','for':'htmlFor'},values:{_getAttr:function(element,attribute){return element.getAttribute(attribute,2);},_getAttrNode:function(element,attribute){var node=element.getAttributeNode(attribute);return node?node.value:"";},_getEv:function(element,attribute){attribute=element.getAttribute(attribute);return attribute?attribute.toString().slice(23,-2):null;},_flag:function(element,attribute){return glock.x(element).hasAttribute(attribute)?attribute:null;},style:function(element){return element.style.cssText.toLowerCase();},title:function(element){return element.title;}}}};glock._elementAttributeTranslations.write={names:glock.extObj({cellpadding:'cellPadding',cellspacing:'cellSpacing'},glock._elementAttributeTranslations.read.names),values:{checked:function(element,value){element.checked=!!value;},style:function(element,value){element.style.cssText=value?value:'';}}};glock._elementAttributeTranslations.has={};glock.xW('colSpan rowSpan vAlign dateTime accessKey tabIndex '+'encType maxLength readOnly longDesc').each(function(attr){glock._elementAttributeTranslations.write.names[attr.toLowerCase()]=attr;glock._elementAttributeTranslations.has[attr.toLowerCase()]=attr;});(function(v){glock.extObj(v,{href:v._getAttr,src:v._getAttr,type:v._getAttr,action:v._getAttrNode,disabled:v._flag,checked:v._flag,readonly:v._flag,multiple:v._flag,onload:v._getEv,onunload:v._getEv,onclick:v._getEv,ondblclick:v._getEv,onmousedown:v._getEv,onmouseup:v._getEv,onmouseover:v._getEv,onmousemove:v._getEv,onmouseout:v._getEv,onfocus:v._getEv,onblur:v._getEv,onkeypress:v._getEv,onkeydown:v._getEv,onkeyup:v._getEv,onsubmit:v._getEv,onreset:v._getEv,onselect:v._getEv,onchange:v._getEv});})(glock._elementAttributeTranslations.read.values);}
else if(glock.env.gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){glock.element.setOpacity=function(element,value){element=glock.x(element);element.style.opacity=(value==1)?0.999999:(value==='')?'':(value<0.00001)?0:value;return element;};}
else if(glock.env.webkit){glock.element.setOpacity=function(element,value){element=glock.x(element);element.style.opacity=(value==1||value==='')?'':(value<0.00001)?0:value;if(value==1)
if(element.tagName=='IMG'&&element.width){element.width++;element.width--;}else try{var n=document.createTextNode(' ');element.appendChild(n);element.removeChild(n);}catch(e){}
return element;};glock.element.cumulativeOffset=function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;if(element.offsetParent==document.body)
if(glock.element.getStyle(element,'position')=='absolute')break;element=element.offsetParent;}while(element);return glock.element._returnOffset(valueL,valueT);};}
if(glock.env.ie||glock.env.opera){glock.element.update=function(element,content){element=glock.x(element);if(content&&content.toElement)content=content.toElement();if(glock.isElement(content))return element.update().insert(content);content=glock.obj.toHTML(content);var tagName=element.tagName.toUpperCase();if(tagName in glock.element._insertionTranslations.tags){glock.xA(element.childNodes).each(function(node){element.removeChild(node)});glock.element._getContentFromAnonymousElement(tagName,glock.xS(content.stripScripts())).each(function(node){element.appendChild(node)});}
else element.innerHTML=glock.xS(content).stripScripts();glock.xF(glock.xS(content).evalScripts).bind(content).defer();return element;};}
glock.extObj(glock.element,{getElementsBySelector:glock.element.select,childElements:glock.element.immediateDescendants});if(!glock.browserFeatures.elementExtensions&&document.createElement('div').__proto__){glock.HTMLElement={};glock.HTMLElement.prototype=document.createElement('div').__proto__;glock.browserFeatures.elementExtensions=true;}
glock.element.ByTag={};glock.extElement=function(element){var property,methods,value;if(!element||element._extendedByPrototype||element.nodeType!=glock.nodeType.ELEMENT||element==window)return element;methods=glock.obj.clone(glock.element);for(property in methods){value=methods[property];if(glock.isFunction(value)&&!(property in element)){element[property]=glock.xF(value).methodize();}}
element._extendedByPrototype=glock.idfu;return element;};glock.builder={NODEMAP:{AREA:'map',CAPTION:'table',COL:'table',COLGROUP:'table',LEGEND:'fieldset',OPTGROUP:'select',OPTION:'select',PARAM:'object',TBODY:'table',TD:'table',TFOOT:'table',TH:'table',THEAD:'table',TR:'table'},node:function(elementName){elementName=elementName.toUpperCase();var parentTag=this.NODEMAP[elementName]||'div';var parentElement=document.createElement(parentTag);try{parentElement.innerHTML="<"+elementName+"></"+elementName+">";}catch(e){}
var element=parentElement.firstChild||null;if(element&&(element.tagName.toUpperCase()!=elementName))
element=element.getElementsByTagName(elementName)[0];if(!element)element=document.createElement(elementName);if(!element)return;if(arguments[1])
if(this._isStringOrNumber(arguments[1])||(arguments[1]instanceof Array)||arguments[1].tagName){this._children(element,arguments[1]);}else{var attrs=this._attributes(arguments[1]);if(attrs.length){try{parentElement.innerHTML="<"+elementName+" "+
attrs+"></"+elementName+">";}catch(e){}
element=parentElement.firstChild||null;if(!element){element=document.createElement(elementName);for(attr in arguments[1])
element[attr=='class'?'className':attr]=arguments[1][attr];}
if(element.tagName.toUpperCase()!=elementName)
element=parentElement.getElementsByTagName(elementName)[0];}}
if(arguments[2])
this._children(element,arguments[2]);return element;},_text:function(text){return document.createTextNode(text);},ATTR_MAP:{'className':'class','htmlFor':'for'},_attributes:function(attributes){var attrs=[],s;for(attribute in attributes){s=glock.xS(attributes[attribute]);attrs.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+s.escapeHTML().grep(/"/,'&quot;')+'"');}
return attrs.join(" ");},_children:function(element,children){if(children.tagName){element.appendChild(children);return;}
if(typeof children=='object'){glock.xA(children).flatten().each(function(e){if(typeof e=='object')
element.appendChild(e);else
if(glock.builder._isStringOrNumber(e))
element.appendChild(glock.builder._text(e));});}else
if(glock.builder._isStringOrNumber(children))
element.appendChild(glock.builder._text(children));},_isStringOrNumber:function(param){return(typeof param=='string'||typeof param=='number');},build:function(html){var element=this.node('div');glock.x(element).update(html.strip());return element.down();},dump:function(scope){if(typeof scope!='object'&&typeof scope!='function')scope=window;var tags=("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY "+"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET "+"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);tags.each(function(tag){scope[tag]=function(){return glock.builder.node.apply(glock.builder,[tag].concat(glock.xA(arguments)));};});}};glock.Class={create:function(){var parent=null,properties=glock.xA(arguments);if(glock.isFunction(properties[0]))
parent=properties.shift();function klass(){this.initialize.apply(this,arguments);}
glock.extObj(klass,glock.Class.Methods);klass.superclass=parent;klass.subclasses=[];if(parent){var subclass=function(){};subclass.prototype=parent.prototype;klass.prototype=new subclass;parent.subclasses.push(klass);}
for(var i=0;i<properties.length;i++)
klass.addMethods(properties[i]);if(!klass.prototype.initialize)
klass.prototype.initialize=glock.emptyFunction;klass.prototype.constructor=klass;return klass;}};glock.Class.Methods={addMethods:function(source){var ancestor=this.superclass&&this.superclass.prototype;var properties=glock.obj.keys(source);if(!glock.obj.keys({toString:true}).length)
properties.push("toString","valueOf");for(var i=0,length=properties.length;i<length;i++){var property=properties[i],value=source[property];if(ancestor&&glock.isFunction(value)&&glock.xF(value).argumentNames()[0]=="$super"){var method=value;value=glock.xF((function(m){return function(){return ancestor[m].apply(this,arguments)};})(property)).wrap(method);value.valueOf=glock.xf(method.valueOf).bind(method);value.toString=glock.xF(method.toString).bind(method);}
this.prototype[property]=value;}
return this;}};glock.Selector=glock.Class.create({initialize:function(expression){this.expression=glock.str.strip(expression);if(this.shouldUseSelectorsAPI()){this.mode='selectorsAPI';}else if(this.shouldUseXPath()){this.mode='xpath';this.compileXPathMatcher();}else{this.mode="normal";this.compileMatcher();}},shouldUseXPath:function(){if(!glock.browserFeatures.XPath)return false;var e=this.expression;if(glock.env.webkit&&(e.include("-of-type")||e.include(":empty")))
return false;if((/(\[[\w-]*?:|:checked)/).test(e))
return false;return true;},shouldUseSelectorsAPI:function(){if(!glock.browserFeatures.SelectorsAPI)return false;if(glock.Selector.CASE_INSENSITIVE_CLASS_NAMES)return false;if(!glock.Selector._div)glock.Selector._div=glock.builder.node('div');try{glock.Selector._div.querySelector(this.expression);}catch(e){return false;}
return true;},compileMatcher:function(){var e=this.expression,ps=glock.Selector.patterns,h=glock.Selector.handlers,c=glock.Selector.criteria,le,p,m,len=ps.length,name;if(glock.Selector._cache[e]){this.matcher=glock.Selector._cache[e];return;}
this.matcher=["this.matcher = function(root) {","var r = root, h = glock.Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i=0;i<len;i++){p=ps[i].re;name=ps[i].name;if(m=e.match(p)){this.matcher.push(glock.isFunction(c[name])?c[name](m):new glock.Template(c[name]).evaluate(m));e=e.replace(m[0],'');break;}}}
this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join('\n'));glock.Selector._cache[this.expression]=this.matcher;},compileXPathMatcher:function(){var e=this.expression,ps=glock.Selector.patterns,x=glock.Selector.xpath,le,m,len=ps.length,name;if(glock.Selector._cache[e]){this.xpath=glock.Selector._cache[e];return;}
this.matcher=['.//*'];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i=0;i<len;i++){name=ps[i].name;if(m=e.match(ps[i].re)){this.matcher.push(glock.isFunction(x[name])?x[name](m):new glock.Template(x[name]).evaluate(m));e=e.replace(m[0],'');break;}}}
this.xpath=this.matcher.join('');glock.Selector._cache[this.expression]=this.xpath;},findElements:function(root){root=root||document;var e=this.expression,results;switch(this.mode){case'selectorsAPI':if(root!==document){var oldId=root.id,id=glock.x(root).identify();e="#"+id+" "+e;}
results=glock.xA(root.querySelectorAll(e)).map(Element.extend);root.id=oldId;return results;case'xpath':return glock._getElementsByXPath(this.xpath,root);default:return this.matcher(root);}},match:function(element){this.tokens=[];var e=this.expression,ps=glock.Selector.patterns,as=glock.Selector.assertions;var le,p,m,len=ps.length,name;while(e&&le!==e&&(/\S/).test(e)){le=e;for(var i=0;i<len;i++){p=ps[i].re;name=ps[i].name;if(m=e.match(p)){if(as[name]){this.tokens.push([name,glock.obj.clone(m)]);e=e.replace(m[0],'');}else{return this.findElements(document).include(element);}}}}
var match=true,name,matches;for(var i=0,token;token=this.tokens[i];i++){name=token[0],matches=token[1];if(!glock.Selector.assertions[name](element,matches)){match=false;break;}}
return match;},toString:function(){return this.expression;},inspect:function(){return"#<Selector:"+this.expression.inspect()+">";}});if(glock.browserFeatures.SelectorsAPI&&document.compatMode==='BackCompat'){glock.Selector.CASE_INSENSITIVE_CLASS_NAMES=(function(){var div=document.createElement('div'),span=document.createElement('span');div.id="prototype_test_id";span.className='Test';div.appendChild(span);var isIgnored=(div.querySelector('#prototype_test_id .test')!==null);div=span=null;return isIgnored;})();}
glock.extObj(glock.Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:'/following-sibling::*',tagName:function(m){if(m[1]=='*')return'';return"[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']";},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(m){m[1]=m[1].toLowerCase();return new Template("[@#{1}]").evaluate(m);},attr:function(m){m[1]=m[1].toLowerCase();m[3]=m[5]||m[6];return new glock.Template(glock.Selector.xpath.operators[m[2]]).evaluate(m);},pseudo:function(m){var h=glock.Selector.xpath.pseudos[m[1]];if(!h)return'';if(glock.isFunction(h))return h(m);return new glock.Template(glock.Selector.xpath.pseudos[m[1]]).evaluate(m);},operators:{'=':"[@#{1}='#{3}']",'!=':"[@#{1}!='#{3}']",'^=':"[starts-with(@#{1}, '#{3}')]",'$=':"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",'*=':"[contains(@#{1}, '#{3}')]",'~=':"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",'|=':"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{'first-child':'[not(preceding-sibling::*)]','last-child':'[not(following-sibling::*)]','only-child':'[not(preceding-sibling::* or following-sibling::*)]','empty':"[count(*) = 0 and (count(text()) = 0)]",'checked':"[@checked]",'disabled':"[(@disabled) and (@type!='hidden')]",'enabled':"[not(@disabled) and (@type!='hidden')]",'not':function(m){var e=m[6],p=glock.Selector.patterns,x=glock.Selector.xpath,le,v,len=p.length,name;var exclusion=[];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i=0;i<len;i++){name=p[i].name
if(m=e.match(p[i].re)){v=glock.isFunction(x[name])?x[name](m):new glock.Template(x[name]).evaluate(m);exclusion.push("("+v.substring(1,v.length-1)+")");e=e.replace(m[0],'');break;}}}
return"[not("+exclusion.join(" and ")+")]";},'nth-child':function(m){return glock.Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m);},'nth-last-child':function(m){return glock.Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m);},'nth-of-type':function(m){return glock.Selector.xpath.pseudos.nth("position() ",m);},'nth-last-of-type':function(m){return glock.Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m);},'first-of-type':function(m){m[6]="1";return glock.Selector.xpath.pseudos['nth-of-type'](m);},'last-of-type':function(m){m[6]="1";return glock.Selector.xpath.pseudos['nth-last-of-type'](m);},'only-of-type':function(m){var p=glock.Selector.xpath.pseudos;return p['first-of-type'](m)+p['last-of-type'](m);},nth:function(fragment,m){var mm,formula=m[6],predicate;if(formula=='even')formula='2n+0';if(formula=='odd')formula='2n+1';if(mm=formula.match(/^(\d+)$/))
return'['+fragment+"= "+mm[1]+']';if(mm=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(mm[1]=="-")mm[1]=-1;var a=mm[1]?Number(mm[1]):1;var b=mm[2]?Number(mm[2]):0;predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";return new glock.Template(predicate).evaluate({fragment:fragment,a:a,b:b});}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(m){m[3]=(m[5]||m[6]);return new glock.Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);},pseudo:function(m){if(m[6])m[6]=m[6].replace(/"/g,'\\"');return new glock.Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:[{name:'laterSibling',re:/^\s*~\s*/},{name:'child',re:/^\s*>\s*/},{name:'adjacent',re:/^\s*\+\s*/},{name:'descendant',re:/^\s/},{name:'tagName',re:/^\s*(\*|[\w\-]+)(\b|$)?/},{name:'id',re:/^#([\w\-\*]+)(\b|$)/},{name:'className',re:/^\.([\w\-\*]+)(\b|$)/},{name:'pseudo',re:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/},{name:'attrPresence',re:/^\[((?:[\w]+:)?[\w]+)\]/},{name:'attr',re:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/}],assertions:{tagName:function(element,matches){return matches[1].toUpperCase()==element.tagName.toUpperCase();},className:function(element,matches){return glock.element.hasClassName(element,matches[1]);},id:function(element,matches){return element.id===matches[1];},attrPresence:function(element,matches){return glock.element.hasAttribute(element,matches[1]);},attr:function(element,matches){var nodeValue=glock.element.readAttribute(element,matches[1]);return nodeValue&&glock.Selector.operators[matches[2]](nodeValue,matches[5]||matches[6]);}},handlers:{concat:function(a,b){for(var i=0,node;node=b[i];i++)
a.push(node);return a;},mark:function(nodes){var _true=glock.emptyFunction;for(var i=0,node;node=nodes[i];i++)
node._countedByPrototype=_true;return nodes;},unmark:function(nodes){for(var i=0,node;node=nodes[i];i++)
node._countedByPrototype=undefined;return nodes;},index:function(parentNode,reverse,ofType){parentNode._countedByPrototype=glock.emptyFunction;if(reverse){for(var nodes=parentNode.childNodes,i=nodes.length-1,j=1;i>=0;i--){var node=nodes[i];if(node.nodeType==1&&(!ofType||node._countedByPrototype))node.nodeIndex=j++;}}else{for(var i=0,j=1,nodes=parentNode.childNodes;node=nodes[i];i++)
if(node.nodeType==1&&(!ofType||node._countedByPrototype))node.nodeIndex=j++;}},unique:function(nodes){if(nodes.length==0)return nodes;var results=[],n;for(var i=0,l=nodes.length;i<l;i++)
if(!(n=nodes[i])._countedByPrototype){n._countedByPrototype=glock.emptyFunction;results.push(glock.extElement(n));}
return glock.Selector.handlers.unmark(results);},descendant:function(nodes){var h=glock.Selector.handlers;for(var i=0,results=[],node;node=nodes[i];i++)
h.concat(results,node.getElementsByTagName('*'));return results;},child:function(nodes){var h=glock.Selector.handlers;for(var i=0,results=[],node;node=nodes[i];i++){for(var j=0,child;child=node.childNodes[j];j++)
if(child.nodeType==1&&child.tagName!='!')results.push(child);}
return results;},adjacent:function(nodes){for(var i=0,results=[],node;node=nodes[i];i++){var next=this.nextElementSibling(node);if(next)results.push(next);}
return results;},laterSibling:function(nodes){var h=glock.Selector.handlers;for(var i=0,results=[],node;node=nodes[i];i++)
h.concat(results,glock.element.nextSiblings(node));return results;},nextElementSibling:function(node){while(node=node.nextSibling)
if(node.nodeType==1)return node;return null;},previousElementSibling:function(node){while(node=node.previousSibling)
if(node.nodeType==1)return node;return null;},tagName:function(nodes,root,tagName,combinator){var uTagName=tagName.toUpperCase();var results=[],h=glock.Selector.handlers;if(nodes){if(combinator){if(combinator=="descendant"){for(var i=0,node;node=nodes[i];i++)
h.concat(results,node.getElementsByTagName(tagName));return results;}else nodes=this[combinator](nodes);if(tagName=="*")return nodes;}
for(var i=0,node;node=nodes[i];i++)
if(node.tagName.toUpperCase()===uTagName)results.push(node);return results;}else return root.getElementsByTagName(tagName);},id:function(nodes,root,id,combinator){var targetNode=glock.x(id),h=glock.Selector.handlers;if(!targetNode)return[];if(!nodes&&root==document)return[targetNode];if(nodes){if(combinator){if(combinator=='child'){for(var i=0,node;node=nodes[i];i++)
if(targetNode.parentNode==node)return[targetNode];}else if(combinator=='descendant'){for(var i=0,node;node=nodes[i];i++)
if(glock.element.descendantOf(targetNode,node))return[targetNode];}else if(combinator=='adjacent'){for(var i=0,node;node=nodes[i];i++)
if(glock.Selector.handlers.previousElementSibling(targetNode)==node)
return[targetNode];}else nodes=h[combinator](nodes);}
for(var i=0,node;node=nodes[i];i++)
if(node==targetNode)return[targetNode];return[];}
return(targetNode&&glock.element.descendantOf(targetNode,root))?[targetNode]:[];},className:function(nodes,root,className,combinator){if(nodes&&combinator)nodes=this[combinator](nodes);return glock.Selector.handlers.byClassName(nodes,root,className);},byClassName:function(nodes,root,className){if(!nodes)nodes=glock.Selector.handlers.descendant([root]);var needle=' '+className+' ';for(var i=0,results=[],node,nodeClassName;node=nodes[i];i++){nodeClassName=node.className;if(nodeClassName.length==0)continue;if(nodeClassName==className||glock.xS(' '+nodeClassName+' ').include(needle))
results.push(node);}
return results;},attrPresence:function(nodes,root,attr,combinator){if(!nodes)nodes=root.getElementsByTagName("*");if(nodes&&combinator)nodes=this[combinator](nodes);var results=[];for(var i=0,node;node=nodes[i];i++)
if(glock.element.hasAttribute(node,attr))results.push(node);return results;},attr:function(nodes,root,attr,value,operator,combinator){if(!nodes)nodes=root.getElementsByTagName("*");if(nodes&&combinator)nodes=this[combinator](nodes);var handler=glock.Selector.operators[operator],results=[];for(var i=0,node;node=nodes[i];i++){var nodeValue=glock.element.readAttribute(node,attr);if(nodeValue===null)continue;if(handler(nodeValue,value))results.push(node);}
return results;},pseudo:function(nodes,name,value,root,combinator){if(nodes&&combinator)nodes=this[combinator](nodes);if(!nodes)nodes=root.getElementsByTagName("*");return glock.Selector.pseudos[name](nodes,value,root);}},pseudos:{'first-child':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++){if(glock.Selector.handlers.previousElementSibling(node))continue;results.push(node);}
return results;},'last-child':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++){if(glock.Selector.handlers.nextElementSibling(node))continue;results.push(node);}
return results;},'only-child':function(nodes,value,root){var h=glock.Selector.handlers;for(var i=0,results=[],node;node=nodes[i];i++)
if(!h.previousElementSibling(node)&&!h.nextElementSibling(node))
results.push(node);return results;},'nth-child':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,formula,root);},'nth-last-child':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,formula,root,true);},'nth-of-type':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,formula,root,false,true);},'nth-last-of-type':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,formula,root,true,true);},'first-of-type':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,"1",root,false,true);},'last-of-type':function(nodes,formula,root){return glock.Selector.pseudos.nth(nodes,"1",root,true,true);},'only-of-type':function(nodes,formula,root){var p=glock.Selector.pseudos;return p['last-of-type'](p['first-of-type'](nodes,formula,root),formula,root);},getIndices:function(a,b,total){if(a==0)return b>0?[b]:[];return $R(1,total).inject([],function(memo,i){if(0==(i-b)%a&&(i-b)/a>=0)memo.push(i);return memo;});},nth:function(nodes,formula,root,reverse,ofType){if(nodes.length==0)return[];if(formula=='even')formula='2n+0';if(formula=='odd')formula='2n+1';var h=glock.Selector.handlers,results=[],indexed=[],m;h.mark(nodes);for(var i=0,node;node=nodes[i];i++){if(!node.parentNode._countedByPrototype){h.index(node.parentNode,reverse,ofType);indexed.push(node.parentNode);}}
if(formula.match(/^\d+$/)){formula=Number(formula);for(var i=0,node;node=nodes[i];i++)
if(node.nodeIndex==formula)results.push(node);}else if(m=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(m[1]=="-")m[1]=-1;var a=m[1]?Number(m[1]):1;var b=m[2]?Number(m[2]):0;var indices=glock.Selector.pseudos.getIndices(a,b,nodes.length);for(var i=0,node,l=indices.length;node=nodes[i];i++){for(var j=0;j<l;j++)
if(node.nodeIndex==indices[j])results.push(node);}}
h.unmark(nodes);h.unmark(indexed);return results;},'empty':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++){if(node.tagName=='!'||node.firstChild)continue;results.push(node);}
return results;},'not':function(nodes,selector,root){var h=glock.Selector.handlers,selectorType,m;var exclusions=new glock.Selector(selector).findElements(root);h.mark(exclusions);for(var i=0,results=[],node;node=nodes[i];i++)
if(!node._countedByPrototype)results.push(node);h.unmark(exclusions);return results;},'enabled':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++)
if(!node.disabled&&(!node.type||node.type!=='hidden'))
results.push(node);return results;},'disabled':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++)
if(node.disabled)results.push(node);return results;},'checked':function(nodes,value,root){for(var i=0,results=[],node;node=nodes[i];i++)
if(node.checked)results.push(node);return results;}},operators:{'=':function(nv,v){return nv==v;},'!=':function(nv,v){return nv!=v;},'^=':function(nv,v){return nv==v||nv&&nv.startsWith(v);},'$=':function(nv,v){return nv==v||nv&&nv.endsWith(v);},'*=':function(nv,v){return nv==v||nv&&nv.include(v);},'$=':function(nv,v){return nv.endsWith(v);},'*=':function(nv,v){return nv.include(v);},'~=':function(nv,v){return(' '+nv+' ').include(' '+v+' ');},'|=':function(nv,v){return('-'+(nv||"").toUpperCase()+'-').include('-'+(v||"").toUpperCase()+'-');}},split:function(expression){var expressions=[];glock.xS(expression).scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){expressions.push(glock.xS(m[1]).strip());});return expressions;},matchElements:function(elements,expression){var matches=glock.xx(expression),h=glock.Selector.handlers;h.mark(matches);for(var i=0,results=[],element;element=elements[i];i++)
if(element._countedByPrototype)results.push(element);h.unmark(matches);return results;},findElement:function(elements,expression,index){if(glock.isNumber(expression)){index=expression;expression=false;}
return glock.Selector.matchElements(elements,expression||'*')[index||0];},findChildElements:function(element,expressions){expressions=glock.Selector.split(expressions.join(','));var results=[],h=glock.Selector.handlers;for(var i=0,l=expressions.length,selector;i<l;i++){selector=new glock.Selector(expressions[i].strip());h.concat(results,selector.findElements(element));}
return(l>1)?h.unique(results):results;}});if(glock.env.ie){glock.extObj(glock.Selector.handlers,{concat:function(a,b){for(var i=0,node;node=b[i];i++)
if(node.tagName!=="!")a.push(node);return a;},unmark:function(nodes){for(var i=0,node;node=nodes[i];i++)
node.removeAttribute('_countedByPrototype');return nodes;}});}
glock.Template=glock.Class.create({initialize:function(template,pattern){this.template=template.toString();this.pattern=pattern||glock.Template.Pattern;},evaluate:function(object){if(glock.isFunction(object.toTemplateReplacements))
object=object.toTemplateReplacements();return glock.xS(this.template).gsub(this.pattern,function(match){if(object==null)return'';var before=match[1]||'';if(before=='\\')return match[2];var ctx=object,expr=match[3];var pattern=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;match=pattern.exec(expr);if(match==null)return before;while(match!=null){var comp=glock.xS(match[1]).startsWith('[')?glock.xS(match[2]).gsub('\\\\]',']'):match[1];ctx=ctx[comp];if(null==ctx||''==match[3])break;expr=expr.substring('['==match[3]?match[1].length:match[0].length);match=pattern.exec(expr);}
return before+glock.string.interpret(ctx);});}});glock.Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;glock.Try={these:function(){var returnValue;for(var i=0,length=arguments.length;i<length;i++){var lambda=arguments[i];try{returnValue=lambda();break;}catch(e){}}
return returnValue;}};glock.viewport={getDimensions:function(){var dimensions={};var B=glock.env;glock.xW('width height').each(function(d){var D=glock.xS(d).capitalize();dimensions[d]=(B.webkit&&!document.evaluate)?self['inner'+D]:(B.opera)?document.body['client'+D]:document.documentElement['client'+D];});return dimensions;},getWidth:function(){return this.getDimensions().width;},getHeight:function(){return this.getDimensions().height;},getScrollOffsets:function(){return glock.element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop);}};glock.ajax={getTransport:function(){return glock.Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false;},requestEvents:['Uninitialized','Loading','Loaded','Interactive','Complete'],setRequestHeaders:function(){var headers={'X-Requested-With':'XMLHttpRequest','Accept':'text/javascript, text/html, application/xml, text/xml, */*'};if(this.method=='post'){headers['Content-type']=this.options.contentType+
(this.options.encoding?'; charset='+this.options.encoding:'');if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005)
headers['Connection']='close';}
if(typeof this.options.requestHeaders=='object'){var extras=this.options.requestHeaders;if(glock.isArray(extras))
for(var i=0,length=extras.length;i<length;i+=2)
headers[extras[i]]=extras[i+1];else
glock.xH(extras).each(function(pair){headers[pair.key]=pair.value});}
for(var name in headers)
this.transport.setRequestHeader(name,headers[name]);},readyStateCallback:function(e){var response=this.transport,state=glock.ajax.requestEvents[response.readyState];if(state=='Complete'){try{this._complete=true;if((response.status>=200)&&(response.status<300)){(this.options.onSuccess||glock.emptyFunction)(response);}else{(this.options.onFailure||glock.emptyFunction)(response);}}catch(e){throw e;}}
try{(this.options['on'+state]||glock.emptyFunction)(response);}catch(e){throw e;}
if(state=='Complete'){this.transport.onreadystatechange=glock.emptyFunction;}},makeRequest:function(url,options){var that={};that.options={method:'post',asynchronous:true,contentType:'application/x-www-form-urlencoded',encoding:'UTF-8',parameters:'',evalJSON:true,evalJS:true};glock.extObj(that.options,options||{});that.transport=glock.ajax.getTransport();if(!that.transport)return;that.url=url;that.method=that.options.method;var params=glock.obj.clone(that.options.parameters);that.parameters=params;if(params=glock.obj.toQueryString(params)){if(that.method=='get')
that.url+=(glock.xS(that.url).include('?')?'&':'?')+params;else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params+='&_=';}
try{if(that.options.onCreate)that.options.onCreate(that.transport);that.transport.open(that.method.toUpperCase(),that.url,that.options.asynchronous);if(that.options.asynchronous)glock.xF(glock.ajax.readyStateCallback).bind(that).defer(1);that.transport.onreadystatechange=glock.xF(glock.ajax.readyStateCallback).bind(that);glock.ajax.setRequestHeaders.apply(that);that.body=that.method=='post'?(that.options.postBody||params):null;that.transport.send(that.body);if(!that.options.asynchronous&&that.transport.overrideMimeType)
glock.xF(glock.ajax.readyStateCallback).bind(that).defer(1);}
catch(e){throw e;}
return that;}};glock.efunction.defer=glock.xF(glock.efunction.delay).curry(0.01);glock.json={};(function(){function f(n){return n<10?'0'+n:n;}
function isDate(obj){return obj instanceof Date;}
function goJSON(obj,key){if(isDate(obj)){return obj.getUTCFullYear()+'-'+
f(obj.getUTCMonth()+1)+'-'+
f(obj.getUTCDate())+'T'+
f(obj.getUTCHours())+':'+
f(obj.getUTCMinutes())+':'+
f(obj.getUTCSeconds())+'Z';}else{return obj.valueOf();}}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value!=='function'){value=goJSON(value);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof glock.json.stringify!=='function'){glock.json.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('glock.json.stringify');}
return str('',{'':value});};}
if(typeof glock.json.parse!=='function'){glock.json.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('glock.json.parse');};}})();