//判断浏览器
var ocw,och;
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var lang = navigator.language || navigator.userLanguage;
if (window.ActiveXObject) {
	Sys.ie = ua.match(/msie ([\d.]+)/)[1];
}
else if (document.getBoxObjectFor) {
    Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1];
}
	
function ch(objid) {
	var obj = document.getElementById(objid);
	if(obj) {
		if(obj.style.display.length==0 || obj.style.display.length==4) {
			closeapp();
			if(!Sys.ie && !Sys.firefox) {
				if(obj.id=='alltype_de') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}
				if(obj.id=='alltype_de_list') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}				
				if(obj.id=='selecttype_de') {
					obj.style.left = document.getElementById("selecttype_c").offsetLeft  - 3 + 'px';
					obj.style.top = document.getElementById("selecttype_c").offsetTop + 27 + 'px';
				}
			}
			else if(Sys.firefox) {
				if(obj.id=='alltype_de') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}
				if(obj.id=='alltype_de_list') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}				
				if(obj.id=='selecttype_de') {
					obj.style.left = document.getElementById("selecttype_c").offsetLeft  - 3 + 'px';
					obj.style.top = document.getElementById("selecttype_c").offsetTop + 27 + 'px';
				}
			}
			else if(Sys.ie == '8.0') {
				if(obj.id=='alltype_de') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}
				if(obj.id=='alltype_de_list') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop + 28 + 'px';
				}				
				if(obj.id=='selecttype_de') {
					obj.style.left = document.getElementById("selecttype_c").offsetLeft  - 3 + 'px';
					obj.style.top = document.getElementById("selecttype_c").offsetTop + 27 + 'px';
				}
			}
			else if(Sys.ie == '6.0') {
				if(obj.id=='alltype_de') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop - 25 + 'px';
				}
				if(obj.id=='alltype_de_list') {
					obj.style.left = document.getElementById("alltype_c").offsetLeft  - 8 + 'px';
					obj.style.top = document.getElementById("alltype_c").offsetTop - 25 + 'px';
				}				
				if(obj.id=='selecttype_de') {
					obj.style.left = document.getElementById("selecttype_c").offsetLeft  - 3 + 'px';
					obj.style.top = document.getElementById("selecttype_c").offsetTop - 31 + 'px';
				}
			}
			obj.style.display='block';
			//obj.focus();
		}
		else {
			obj.style.display='none';
		}
	}
}
function closeapp() {
	var objids = new Array('alltype_de','selecttype_de');
	for(i=0;i<objids.length;i++) {
		if(document.getElementById(objids[i])) {
			document.getElementById(objids[i]).style.display='none';
		}
	}
}

function co(n,a) {
	var obs,i;
	for(i=1;i<=a;i++) {
		obs = document.getElementById("alltype_de_de" + i);
		if(i==n) {
			if(obs) {
				if(!Sys.ie || Sys.ie == '8.0') {
					obs.style.left = document.getElementById("alltype_de_mm" + i).offsetWidth  - 20 + 'px';
					if(i==1) {
						obs.style.top = document.getElementById("alltype_de_mm" + i).offsetTop - 0 + 'px';
					}
					else {
						obs.style.top = document.getElementById("alltype_de_mm" + i).offsetTop - 1 + 'px';
					}
				}
				obs.style.display = 'block';
			}
		}
		else {
			if(obs) {
				obs.style.display = 'none';
			}
		}
	}
}

function   checkEnglish(str)   
{   
	var   pattern   =   /^[a-zA-Z0-9]+$/   
	if   (pattern.test(str))   
	{
		return true;
	}
	else   
	{
		return false;
	}
}   

function butSearch_onClick()
{
	if(document.getElementById('q').value == '找商品 [商品を検索]' || document.getElementById('q').value == '') {
		alert('关键字不能为空！[キーワード入力してください]');
		document.getElementById('q').focus();
	}
	else {
		if (checkEnglish(document.getElementById('q').value)) {
			document.getElementById('qtr').value=document.getElementById('q').value;
			document.getElementById("frmCommSearch").submit();
		}
		else {
			googletranslte_top(document.getElementById('q'),document.getElementById('qtr'));
		}
	}
}

//原型：单击
document.onclick = onClick;
function onClick(ev){
     ev = ev || window.event; 
     var target    = ev.target || ev.srcElement;
     var dragObj = target.getAttribute('id');
	 if(dragObj!='alltype_de' && dragObj!='alltype_de_list' && dragObj!='selecttype_de' && dragObj!='alltype_c' && dragObj!='alltype_r' && dragObj!='alltype_op' && dragObj!='selecttype_c' && dragObj!='selecttype_r'&& dragObj!='selecttype_op'&& dragObj!='alltype_c_s' && dragObj!='selecttype_c_s') {
      document.getElementById("alltype_de").style.display='none';
//      document.getElementById("alltype_de_list").style.display='block';
	  document.getElementById("selecttype_de").style.display='none';
	 }
} 

//读外部文件
var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
    
function startRequest() {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", "/Lalltype.xml", true);
    xmlHttp.send(null);
}
   
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            document.getElementById("Lalltype").innerHTML = xmlHttp.responseText;
        }
    }
}

//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2008 Valerio Proietti, <http://mad4milk.net>, MIT Style License.

/*
Script: Fx.Scroll.js
    Effect to smoothly scroll any element, including the window.

License:
    MIT-style license.
*/

Fx.Scroll = new Class({

    Extends: Fx,

    options: {
        offset: {'x': 0, 'y': 0},
        wheelStops: true
    },

    initialize: function(element, options){
        this.element = this.subject = $(element);
        this.parent(options);
        var cancel = this.cancel.bind(this, false);

        if ($type(this.element) != 'element') this.element = $(this.element.getDocument().body);

        var stopper = this.element;

        if (this.options.wheelStops){
            this.addEvent('start', function(){
                stopper.addEvent('mousewheel', cancel);
            }, true);
            this.addEvent('complete', function(){
                stopper.removeEvent('mousewheel', cancel);
            }, true);
        }
    },

    set: function(){
        var now = Array.flatten(arguments);
        this.element.scrollTo(now[0], now[1]);
    },

    compute: function(from, to, delta){
        var now = [];
        var x = 2;
        x.times(function(i){
            now.push(Fx.compute(from[i], to[i], delta));
        });
        return now;
    },

    start: function(x, y){
        if (!this.check(arguments.callee, x, y)) return this;
        var offsetSize = this.element.getSize(), scrollSize = this.element.getScrollSize();
        var scroll = this.element.getScroll(), values = {x: x, y: y};
        for (var z in values){
            var max = scrollSize[z] - offsetSize[z];
            if ($chk(values[z])) values[z] = ($type(values[z]) == 'number') ? values[z].limit(0, max) : max;
            else values[z] = scroll[z];
            values[z] += this.options.offset[z];
        }
        return this.parent([scroll.x, scroll.y], [values.x, values.y]);
    },

    toTop: function(){
        return this.start(false, 0);
    },

    toLeft: function(){
        return this.start(0, false);
    },

    toRight: function(){
        return this.start('right', false);
    },

    toBottom: function(){
        return this.start(false, 'bottom');
    },

    toElement: function(el){
        var position = $(el).getPosition(this.element);
        return this.start(position.x, position.y);
    }

});


/*
Script: Fx.Elements.js
    Effect to change any number of CSS properties of any number of Elements.

License:
    MIT-style license.
*/

Fx.Elements = new Class({

    Extends: Fx.CSS,

    initialize: function(elements, options){
        this.elements = this.subject = $$(elements);
        this.parent(options);
    },

    compute: function(from, to, delta){
        var now = {};
        for (var i in from){
            var iFrom = from[i], iTo = to[i], iNow = now[i] = {};
            for (var p in iFrom) iNow[p] = this.parent(iFrom[p], iTo[p], delta);
        }
        return now;
    },

    set: function(now){
        for (var i in now){
            var iNow = now[i];
            for (var p in iNow) this.render(this.elements[i], p, iNow[p], this.options.unit);
        }
        return this;
    },

    start: function(obj){
        if (!this.check(arguments.callee, obj)) return this;
        var from = {}, to = {};
        for (var i in obj){
            var iProps = obj[i], iFrom = from[i] = {}, iTo = to[i] = {};
            for (var p in iProps){
                var parsed = this.prepare(this.elements[i], p, iProps[p]);
                iFrom[p] = parsed.from;
                iTo[p] = parsed.to;
            }
        }
        return this.parent(from, to);
    }

});

/*
Script: Drag.js
    The base Drag Class. Can be used to drag and resize Elements using mouse events.

License:
    MIT-style license.
*/

var Drag = new Class({

    Implements: [Events, Options],

    options: {/*
        onBeforeStart: $empty,
        onStart: $empty,
        onDrag: $empty,
        onCancel: $empty,
        onComplete: $empty,*/
        snap: 6,
        unit: 'px',
        grid: false,
        style: true,
        limit: false,
        handle: false,
        invert: false,
        preventDefault: false,
        modifiers: {x: 'left', y: 'top'}
    },

    initialize: function(){
        var params = Array.link(arguments, {'options': Object.type, 'element': $defined});
        this.element = $(params.element);
        this.document = this.element.getDocument();
        this.setOptions(params.options || {});
        var htype = $type(this.options.handle);
        this.handles = (htype == 'array' || htype == 'collection') ? $$(this.options.handle) : $(this.options.handle) || this.element;
        this.mouse = {'now': {}, 'pos': {}};
        this.value = {'start': {}, 'now': {}};
        
        this.selection = (Browser.Engine.trident) ? 'selectstart' : 'mousedown';
        
        this.bound = {
            start: this.start.bind(this),
            check: this.check.bind(this),
            drag: this.drag.bind(this),
            stop: this.stop.bind(this),
            cancel: this.cancel.bind(this),
            eventStop: $lambda(false)
        };
        this.attach();
    },

    attach: function(){
        this.handles.addEvent('mousedown', this.bound.start);
        return this;
    },

    detach: function(){
        this.handles.removeEvent('mousedown', this.bound.start);
        return this;
    },

    start: function(event){
        if (this.options.preventDefault) event.preventDefault();
        this.fireEvent('beforeStart', this.element);
        this.mouse.start = event.page;
        var limit = this.options.limit;
        this.limit = {'x': [], 'y': []};
        for (var z in this.options.modifiers){
            if (!this.options.modifiers[z]) continue;
            if (this.options.style) this.value.now[z] = this.element.getStyle(this.options.modifiers[z]).toInt();
            else this.value.now[z] = this.element[this.options.modifiers[z]];
            if (this.options.invert) this.value.now[z] *= -1;
            this.mouse.pos[z] = event.page[z] - this.value.now[z];
            if (limit && limit[z]){
                for (var i = 2; i--; i){
                    if ($chk(limit[z][i])) this.limit[z][i] = $lambda(limit[z][i])();
                }
            }
        }
        if ($type(this.options.grid) == 'number') this.options.grid = {'x': this.options.grid, 'y': this.options.grid};
        this.document.addEvents({mousemove: this.bound.check, mouseup: this.bound.cancel});
        this.document.addEvent(this.selection, this.bound.eventStop);
    },

    check: function(event){
        if (this.options.preventDefault) event.preventDefault();
        var distance = Math.round(Math.sqrt(Math.pow(event.page.x - this.mouse.start.x, 2) + Math.pow(event.page.y - this.mouse.start.y, 2)));
        if (distance > this.options.snap){
            this.cancel();
            this.document.addEvents({
                mousemove: this.bound.drag,
                mouseup: this.bound.stop
            });
            this.fireEvent('start', this.element).fireEvent('snap', this.element);
        }
    },

    drag: function(event){
        if (this.options.preventDefault) event.preventDefault();
        this.mouse.now = event.page;
        for (var z in this.options.modifiers){
            if (!this.options.modifiers[z]) continue;
            this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
            if (this.options.invert) this.value.now[z] *= -1;
            if (this.options.limit && this.limit[z]){
                if ($chk(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])){
                    this.value.now[z] = this.limit[z][1];
                } else if ($chk(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])){
                    this.value.now[z] = this.limit[z][0];
                }
            }
            if (this.options.grid[z]) this.value.now[z] -= (this.value.now[z] % this.options.grid[z]);
            if (this.options.style) this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);
            else this.element[this.options.modifiers[z]] = this.value.now[z];
        }
        this.fireEvent('drag', this.element);
    },

    cancel: function(event){
        this.document.removeEvent('mousemove', this.bound.check);
        this.document.removeEvent('mouseup', this.bound.cancel);
        if (event){
            this.document.removeEvent(this.selection, this.bound.eventStop);
            this.fireEvent('cancel', this.element);
        }
    },

    stop: function(event){
        this.document.removeEvent(this.selection, this.bound.eventStop);
        this.document.removeEvent('mousemove', this.bound.drag);
        this.document.removeEvent('mouseup', this.bound.stop);
        if (event) this.fireEvent('complete', this.element);
    }

});

Element.implement({
    
    makeResizable: function(options){
        return new Drag(this, $merge({modifiers: {'x': 'width', 'y': 'height'}}, options));
    }

});



/*
Script: Hash.Cookie.js
    Class for creating, reading, and deleting Cookies in JSON format.

License:
    MIT-style license.
*/

Hash.Cookie = new Class({

    Extends: Cookie,

    options: {
        autoSave: true
    },

    initialize: function(name, options){
        this.parent(name, options);
        this.load();
    },

    save: function(){
        var value = JSON.encode(this.hash);
        if (!value || value.length > 4096) return false; //cookie would be truncated!
        if (value == '{}') this.dispose();
        else this.write(value);
        return true;
    },

    load: function(){
        this.hash = new Hash(JSON.decode(this.read(), true));
        return this;
    }

});

Hash.Cookie.implement((function(){
    
    var methods = {};
    
    Hash.each(Hash.prototype, function(method, name){
        methods[name] = function(){
            var value = method.apply(this.hash, arguments);
            if (this.options.autoSave) this.save();
            return value;
        };
    });
    
    return methods;
    
})());




/*
Script: Assets.js
    Provides methods to dynamically load JavaScript, CSS, and Image files into the document.

License:
    MIT-style license.
*/

var Asset = new Hash({

    javascript: function(source, properties){
        properties = $extend({
            onload: $empty,
            document: document,
            check: $lambda(true)
        }, properties);
        
        var script = new Element('script', {'src': source, 'type': 'text/javascript'});
        
        var load = properties.onload.bind(script), check = properties.check, doc = properties.document;
        delete properties.onload; delete properties.check; delete properties.document;
        
        script.addEvents({
            load: load,
            readystatechange: function(){
                if (['loaded', 'complete'].contains(this.readyState)) load();
            }
        }).setProperties(properties);
        
        
        if (Browser.Engine.webkit419) var checker = (function(){
            if (!$try(check)) return;
            $clear(checker);
            load();
        }).periodical(50);
        
        return script.inject(doc.head);
    },

    css: function(source, properties){
        return new Element('link', $merge({
            'rel': 'stylesheet', 'media': 'screen', 'type': 'text/css', 'href': source
        }, properties)).inject(document.head);
    },

    image: function(source, properties){
        properties = $merge({
            'onload': $empty,
            'onabort': $empty,
            'onerror': $empty
        }, properties);
        var image = new Image();
        var element = $(image) || new Element('img');
        ['load', 'abort', 'error'].each(function(name){
            var type = 'on' + name;
            var event = properties[type];
            delete properties[type];
            image[type] = function(){
                if (!image) return;
                if (!element.parentNode){
                    element.width = image.width;
                    element.height = image.height;
                }
                image = image.onload = image.onabort = image.onerror = null;
                event.delay(1, element, element);
                element.fireEvent(name, element, 1);
            };
        });
        image.src = element.src = source;
        if (image && image.complete) image.onload.delay(1);
        return element.setProperties(properties);
    },

    images: function(sources, options){
        options = $merge({
            onComplete: $empty,
            onProgress: $empty
        }, options);
        if (!sources.push) sources = [sources];
        var images = [];
        var counter = 0;
        sources.each(function(source){
            var img = new Asset.image(source, {
                'onload': function(){
                    options.onProgress.call(this, counter, sources.indexOf(source));
                    counter++;
                    if (counter == sources.length) options.onComplete();
                }
            });
            images.push(img);
        });
        return new Elements(images);
    }

});





/*Mootools 1.1 Adapter
* 
*/

Window.implement({
        ie:Browser.Engine.trident,
        ie6:Browser.Engine.trident4,
        ie7:Browser.Engine.trident5,
        gecko:Browser.Engine.gecko,
        webkit:Browser.Engine.webkit,
        webkit419:Browser.Engine.webkit419,
        webkit420:Browser.Engine.webkit420,
        opera:Browser.Engine.presto,
        xpath:Browser.Features.xpath
        });
        
Object.toQueryString=function(source){
  return Hash.toQueryString(new Hash(source));
}        
        
/*Class adapter*/
    Class.empty=$empty;



/*Element Adapter*/
Window.implement({
   $E:function(selector,scope){
      return ($(scope)||document).getElement(selector);
   },
   $ES:function(selector,scope){
      return ($(scope)||document).getElements(selector);
   }
});
Element.implement({
   setHTML:function(){
     return this.set('html',Array.flatten($A(arguments)).join('\n'));
   },
   setText:function(text){
     return this.set('text',text);
   },
   getText:function(){
     return this.get('text');
   },
   getHTML:function(){
    return this.get('html');
   },
    setOpacity:function(value){
        return this.set('opacity', value, false);
   },
   setStyles:function(styles){
      switch($type(styles)){
            case 'object': 
            for (var style in styles)this.setStyle(style, styles[style]);break;
            case 'string': this.style.cssText = styles;
        }
        return this;
   },
   getTag:function(){
   return this.tagName.toLowerCase();
   },
   replaceWith:function(el){
        var newEL=$(el, true);
        var oEL=$(this);
        this.parentNode.replaceChild(newEL, oEL);
        return newEL;
    },
    getValue: function(){
        switch(this.getTag()){
            case 'select':
                var values = [];
                for(i=0,L=this.options.length;i<L;i++){
                if (this.options[i].selected) values.push($pick(this.options[i].value, this.options[i].text));
                }
                return (this.multiple) ? values : values[0];
            case 'input': if (!(this.checked && ['checkbox', 'radio'].contains(this.type)) && !['hidden', 'text', 'password'].contains(this.type)) break;
            case 'textarea': return this.value;
        }
        return false;
    },
    getFormElements: function(){
        return $$(this.getElementsByTagName('input'), this.getElementsByTagName('select'), this.getElementsByTagName('textarea'))||[];
    },
    remove:function(){
      return this.dispose();
    },
    toQueryString: function(){
        var queryString = [];
        this.getElements('input, select, textarea', true).each(function(el){
            if (!el.name || el.disabled) return;
            if(el.type=='file'&&!!!el.value.trim())return;
            var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){
                return opt.value;
            }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;
            $splat(value).each(function(val){
                if (typeof val != 'undefined') queryString.push(el.name + '=' + encodeURIComponent(val));
            });
        });
        return queryString.join('&');
    }
});
/*Json Adapter*/
var Json={
   'toString':function(json){
     return JSON.encode(json)||"";
   },
   'evaluate':function(json,secure){
     return JSON.decode(json,secure)||{};
   }
}
Json.Remote=new Class({
      Extends:Request.JSON,
      initialize:function(url,options){
         this.parent($extend(options,{'url':url}));
      }
});

/*Cookie Adapter*/
Cookie.set=Cookie.write;
Cookie.get=Cookie.read;
Cookie.remove=Cookie.dispose;

/*XHR& AJAX Adapter*/
var XHR=new Class({
    Extends:Request,
    send:function(url,options){
        var type = $type(options);
        if (type == 'string' || type == 'element') options = {data: options};
        options = $extend({url: url}, options);
          return  this.parent(options);
    }
});

var Ajax=new Class({
     Extends:XHR,
     options: {
        data: null,
        update: false,
        onComplete: Class.empty,
        evalScripts: true,
        evalResponse: false
    },
     initialize:function(url,options){
       // this.addEvent('onSuccess', this.onComplete);
        this.parent(options);
        this.url=url;
        this.transport=this.xhr;
        return this;
     },
     processHTML: function(text){
        var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
        text = (match) ? match[1] : text;
        return text;
    },
    success: function(text,xml){
        var options = this.options, response = this.response;
        
        response.html = text.stripScripts(function(script){
            response.javascript = script;
        });
        response.html = this.processHTML(response.html);
        if (options.update){
            $(options.update).empty().setHTML(response.html);
        } 
        if (options.evalScripts) $exec(response.javascript);
        this.onSuccess(response.html,null,null,response.javascript);
    },
    onFailure:function(){
      this.fireEvent('failure', this.xhr);
    },
     request:function(data){
       return this.send(this.url,data);
     }
});

Element.implement({
    send: function(options){
        var type=$type(options);
        var sender = this.get('send');
        if(type=='object'){
            new Ajax(this.action||options.url,options).request(this);
            return this;
        } else{
        sender.send({data: this, url: options || sender.options.url});
        return this;
        }
    },
    toQueryString: function(){
        var queryString = [];
        this.getElements('input, select, textarea').each(function(el){
            if (!el.name || el.disabled) return;
            //过滤空文件上传元素
            if(el.type=='file'&&el.value.trim()=='')return;
            var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){
                return opt.value;
            }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;
            $splat(value).each(function(val){
                queryString.push(el.name + '=' + encodeURIComponent(val));
            });
        });
        //console.info(queryString);
        return queryString.join('&');
    }

});



/*FX Adapter*/
Fx.implement({
 stop:function(){
   return this.cancel();
 }
});
Fx.Style=new Class({
   Extends:Fx.Tween,
   initialize:function(el,property,options){
      this._property=property;
      this.parent(el,options);
   },
   set:function(v){
     return this.parent(this._property,v);
   },
   start:function(f,t){
     return this.parent(this._property,f,t);
   }
});
Fx.Styles=new Class({
   Extends:Fx.Morph
});

Fx.Scroll.implement({
  scrollTo:function(x,y,effect){
     if(effect)return this.start(x,y);
     return this.set(x,y);
  } 
});
Element.implement({
   effect:function(p,o){
   return new Fx.Style(this,p,o);
   },
   effects:function(o){
   return new Fx.Styles(this,o);
   }
});

/*Abstract*/
var Abstract = function(obj){
    obj = obj || {};
    obj.extend = $extend;
    return obj;
};

/*getSize Adapter*/
(function(){
Element.implement({
    getSize: function(){
        if (isBody(this)) return this.getWindow().getSize();
        return {
        x: this.offsetWidth,
        y: this.offsetHeight,
        'size':{x:this.offsetWidth,y:this.offsetHeight},
        'scroll':{x: this.scrollLeft, y: this.scrollTop},
        'scrollSize':{x: this.scrollWidth, y: this.scrollHeight}
        };
    }
});

Native.implement([Document, Window], {
    getSize: function(){
        var win = this.getWindow();
        var doc = getCompatElement(this);
        if (Browser.Engine.presto || Browser.Engine.webkit)
        return {
                x: win.innerWidth, 
                y: win.innerHeight,
                'size':{'x':win.innerWidth,'y':win.innerHeight},
                'scroll':{x: win.pageXOffset,y: win.pageYOffset},
                    'scrollSize':{
                    x: Math.max(doc.scrollWidth, win.innerWidth),
                    y: Math.max(doc.scrollHeight, win.innerHeight)
                    }
               };
        return {
        x: doc.clientWidth,
        y: doc.clientHeight,
        'size':{'x':doc.clientWidth,'y':doc.clientHeight},
        'scroll':{x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop},
          'scrollSize':{
                    x: Math.max(doc.scrollWidth, win.innerWidth),
                    y: Math.max(doc.scrollHeight, win.innerHeight)
                    }
        };
    }
});

// private methods
function isBody(element){
    return (/^(?:body|html)$/i).test(element.tagName);
};

function getCompatElement(element){
    var doc = element.getDocument();
    return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
};

})();


/*Array Adapter*/

Array.implement({
  copy:function(){
     return $A(this);
  }
});
Array.alias('erase','remove');

/*Hash Adapter*/
Hash.alias('erase','remove');
Hash.alias('getKeys','keys');
Hash.alias('getValues','values');
Hash.alias('has','hasKey');
Hash.implement({
  merge:function(){
   return  $merge.apply(null,[this].include(arguments));
  }
});



/*Drag.base Adapter*/
Drag.implement({
  options: {/*
        onBeforeStart: $empty,
        onStart: $empty,
        onDrag: $empty,
        onCancel: $empty,
        onComplete: $empty,*/
        snap: 0,
        unit: 'px',
        grid: false,
        style: true,
        limit: false,
        handle: false,
        invert: false,
        preventDefault: true,
        modifiers: {x: 'left', y: 'top'}
    }
});
Drag.Base=Drag;


/*Extends*/
[Element,Number,String].each(function(o){
    o.extend=o.implement;
 })
 
 
 /*bindwithEventL..*/
 
 Function.implement({
  bindAsEventListener: function(bind, args){
        return this.create({'bind': bind, 'event': true, 'arguments': args});
    }
 });

 /*each bug*/
 
 function $each(iterable, fn, bind){
    var type = $type(iterable);
    ((type == 'arguments' || type == 'collection' || type == 'array'||type=='element') ? Array : Hash).each(iterable, fn, bind);
};
 
/*Mootools 1.1 Adapter Define End*/