/*
 * BridgeJS Prototype Adapter
 */
window.Bridge||(Bridge={}); Object.extend(Bridge,function(){function h(a){if(a.constructor&&a.constructor==i)return a;a=new i(a);return a.source&&a}var c=window.Array.prototype.slice,d=window.Object,f=d.extend({isArray:d.isArray,isFunction:d.isFunction,isNumber:d.isNumber,isString:d.isString,isUndefined:d.isUndefined,isElement:d.isElement,keys:d.keys},Bridge.Shared.Object),l=window.$,m=window.$$,e=window.Element,i=Class.create({initialize:function(a){this.source=l(a)},addClassName:function(a){this.source.addClassName(a);return this}, removeClassName:function(a){this.source.removeClassName(a);return this},getWidth:function(){return this.source.getWidth()},getHeight:function(){return this.source.getHeight()},getDimensions:function(){return this.source.getDimensions()},cumulativeOffset:function(){return this.source.cumulativeOffset()},cumulativeScrollOffset:function(){return this.source.cumulativeScrollOffset()},hide:function(){this.source.hide();return this},show:function(){this.source.show();return this},toggle:function(){this.source.toggle(); return this},remove:function(){this.source.remove()},insert:function(a){var b={};if(a.source||f.isElement(a)||f.isString(a))b.bottom=a.source||a;else for(var c in a)b[c]=a[c].source||a[c];this.source.insert(b);return this},update:function(a){this.source.update(a.source||a);return this},writeAttribute:function(a){this.source.writeAttribute(a);return this},setStyle:function(){e.setStyle.apply(this,[this.source].concat(c.call(arguments)));return this},getStyle:function(){return e.getStyle.apply(this, [this.source].concat(c.call(arguments)))},setOpacity:function(a){this.source.setOpacity(a);return this},select:function(a){a=this.source.select(a);return new k(a)},match:function(a){return this.source.match(a)},up:function(){return e.up.apply(this,[this.source].concat(c.call(arguments)))},down:function(){return e.down.apply(this,[this.source].concat(c.call(arguments)))},previous:function(){return e.previous.apply(this,[this.source].concat(c.call(arguments)))},next:function(){return e.next.apply(this, [this.source].concat(c.call(arguments)))},store:function(a,b){this.source.store(a,b);return this},retrieve:function(a){return this.source.retrieve(a)},eliminate:function(a){this.store(a,null);return this},observe:function(){var a=[this.source].concat(c.call(arguments));e.observe.apply(null,a);return this},stopObserving:function(){var a=[this.source].concat(c.call(arguments));e.stopObserving.apply(null,a);return this}}),k=Class.create({initialize:function(a){var b=[],a=f.isArray(a)?a:m(a);g._each(a, function(a){b.push(new i(a))});this.source=b},invoke:function(){var a=c.call(arguments),b=a.shift();g._each(this.source,function(c){c[b].apply(c,a)});return this},each:function(a,b){var c=0;g._each(this.source,function(d){a.call(b,d,c++)});return this}}),g=f.extend({find:function(a,b){return a.find(b)},without:function(a,b){return a.without(b)},include:function(a,b){return a.include(b)}},Bridge.Shared.Array),j=window.Event,d=f.extend({observe:function(a){var a=h(a),b=[a.source].concat(c.call(arguments, 1));j.observe.apply(null,b)},stopObserving:function(a){var a=h(a),b=[a.source].concat(c.call(arguments,1));j.stopObserving.apply(null,b)}},j);return{Array:g,Ajax:Ajax,each:g.each,_each:g._each,Element:function(a,b){b=b||{};return h(document.createElement(a)).writeAttribute(b)},Event:d,Function:Bridge.Shared.Function,String:Bridge.Shared.String,Object:f,domloaded:function(a){document.loaded?a.call(document):document.observe("dom:loaded",a)},$:h,$$:function(a){return new k(a)},emptyFunction:Prototype.emptyFunction, K:Prototype.K,Viewport:document.viewport}}(Bridge));
