var TBM=TBM||{} ;

if(!Array.prototype.forEach){
Array.prototype.forEach=function(b){
var a=this.length;
if(typeof b!="function"){

throw new TypeError()

} var d=arguments[1];

for(var c=0;

c<a;

c++){

if(c in this){

b.call(d,this[c],c,this)

}
}
}
}

(function(){

["forEach"].forEach(function(a){

if(!Array[a]){

Array[a]=function(b){

return Array.prototype[a].apply(b,Array.prototype.slice.call(arguments,1))

} 

} 

} )

} )();

TBM.Util=TBM.Util||{


} ;

TBM.Util=function(){

var c=[];

function b(g){

return(g.nodeType==1)?g:document.getElementById(g)

} function f(){

Array.forEach(c,function(g){

if(typeof g=="function"){

g()

} 

} )

} function e(i,h){

h=h||window;

var k=h.document,g=false;

var j=function(){

if(!g){

g=true;

i()

} 

} ;

(function(){

try{

k.documentElement.doScroll("left")

} catch(l){

setTimeout(arguments.callee,50);

return

} j()

} )()

} var a=function(){

return !!window.ActiveXObject

} ();

var d=function(){

return a&&!window.XMLHttpRequest

} ();

(function(){

if(document.addEventListener){

document.addEventListener("DOMContentLoaded",f,false)

} else{

e(f)

} 

} )();

return{

isIE:a,isIE6:d,trim:function(g){

return g.replace(/^\s+|\s+$/g,"")

} ,get:b,getElementsByClassName:function(n,h,j){

n=this.trim(n);

h=h||"*";

j=(j)?b(j):null||document;

if(!j){

return[]

} var k=[],o=j.getElementsByTagName(h),m=this.hasClass;

for(var l=0,g=o.length;

l<g;

++l){

if(m(o[l],n)){

k[k.length]=o[l]

} 

} return k

} ,hasClass:function(h,g){

h=b(h);

if(!h||!g||!h.className){

return false

} return h.className.indexOf(g)>-1

} ,addClass:function(h,g){

h=b(h);

if(!h||!g){

return

} if(this.hasClass(h,g)){

return

} h.className+=" "+g

} ,removeClass:function(h,g){

h=b(h);

if(!this.hasClass(h,g)){

return

} h.className=h.className.replace(new RegExp(g,"g"),"");

if(!this.trim(h.className)){

h.removeAttribute(this.isIE?"className":"class")

} 

} ,getEvt:function(g){

return window.event||g

} ,getTarget:function(h){

h=this.getEvt(h);

var g=h.srcElement||h.target;

try{

if(g&&3==g.nodeType){

return g.parentNode

} 

} catch(i){


} return g

} ,addEvent:function(i,h,g){

i=b(i);

if(!i||!h||typeof(g)!="function"){

return

} if(i.addEventListener){

i.addEventListener(h,g,false)

} else{

if(i.attachEvent){

i.attachEvent("on"+h,g)

} 

} 

} ,stopPropagation:function(g){

g=this.getEvt(g);

if(g.stopPropagation){

g.stopPropagation()

} else{

g.cancelBubble=true

} 

} ,preventDefault:function(g){

g=this.getEvt(g);

if(g.preventDefault){

g.preventDefault()

} else{

g.returnValue=false

} 

} ,onDOMReady:function(g){

c.push(g)

} 

} 

} ();

TBM.Mall=TBM.Mall||{


} ;

TBM.Mall=function(){

var e=TBM.Util;

var b=100;

var d="current";

var a=null;

var c=false;

return{

showSubItems:function(f){

f=e.get(f);

if(!f){

return false

} var g,h=null,l=e.get("all-items");

var j=e.getElementsByClassName("subcontent","div",f);

function m(o,p){

if(p!=null){

while(p.parentNode){

if((p=p.parentNode)==o){

return true

} 

} 

} return false

} function n(p,r){

var q=e.getTarget(p);

var o=h;

g=setTimeout(function(){

if(q.tagName=="STRONG"){

var u=q.parentNode.offsetTop,z=document.documentElement,y=document.body.getElementsByTagName("DIV")[0];

var w=l.offsetTop+(y.offsetTop||e.get("header").offsetTop);

var x=e.getElementsByClassName("subcontent","div",q.parentNode)[0];

var s=x.getElementsByTagName("b")[0];

x.style.zIndex="1999";

e.addClass(q.parentNode,d);

var v=u+w-5+x.offsetHeight-z.scrollTop;

if(v>z.clientHeight){

if((x.offsetHeight+5)>z.clientHeight){

x.style.top=(5+z.scrollTop-u-w)+"px"

} else{

x.style.top=(z.clientHeight-x.offsetHeight-u-w+z.scrollTop-5)+"px"

} 

} else{

x.style.top="-6px"

} var t=(Math.abs(x.offsetTop)+3);

s.style.top=((t>=x.offsetHeight)?(x.offsetHeight-16):t)+"px";

h=x;

if(o){

e.removeClass(o.parentNode,d);

o.style.top="-6px"

} 

} 

} ,b)

} function i(p,q){

if(g){

clearTimeout(g)

} var o=null;

if(p.toElement){

o=p.toElement

} else{

if(p.relatedTarget){

o=p.relatedTarget

} 

} if(!m(f,o)&&f!=o){

if(h){

e.removeClass(h.parentNode,d);

h=null

} 

} 

} try{

e.addEvent(f,"mouseover",n);

e.addEvent(f,"mouseout",i)

} catch(k){


} 

} ,toggleAllItems:function(f,k){

f=e.get(f);

k=e.get(k);

if(!f||!k){

return false

} var i=f.parentNode;

var j=k.parentNode;

function g(){

e.addClass(i,"collapse-head");

e.addClass(f,"extend-trigger");

e.addClass(k,"show")

} function h(){

e.removeClass(i,"collapse-head");

e.removeClass(f,"extend-trigger");

e.removeClass(k,"show")

} j.onmouseover=g;

j.onmouseout=h

} ,simulateSelect:function(f,n){

f=e.get(f);

n=e.get(n);

try{

var o=f.getElementsByTagName("span")[0];

var m=f.getElementsByTagName("ul")[0];

var j=m.parentNode;

var l=m.getElementsByTagName("li");

var i,g;

j.isShow=false;

if(l.length){

var h=e.getElementsByClassName("selected","li",m);

i=h[0]||l[0];

g=i.getAttribute("value");

o.innerHTML=i.innerHTML;

n.value=(g=="all")?"":g

} else{

return

} e.addEvent(o,"click",function(p){

e.stopPropagation(p);

if(a&&a!=j){

e.removeClass(a,"extend");

a.isShow=false

} if(!j.isShow){

e.addClass(j,"extend");

j.isShow=true;

a=j

} else{

e.removeClass(j,"extend");

j.isShow=false

} 

} );

e.addEvent(document.body,"click",function(p){

e.stopPropagation(p);

e.removeClass(j,"extend");

j.isShow=false

} );

Array.forEach(l,function(p){

if(e.isIE6){

e.addEvent(p,"mouseenter",function(){

e.addClass(p,d)

} );

e.addEvent(p,"mouseleave",function(){

e.removeClass(p,d)

} )

} e.addEvent(p,"click",function(s){

var q=e.getEvt(s);

var r=e.getTarget(q);

o.innerHTML=r.innerHTML;

n.value=r.getAttribute("value");

e.removeClass(j,"extend");

j.isShow=false

} )

} )

} catch(k){


} 

} ,init:function(){

if(c){

return

} c=true;

var f=e.get("searchTop");

this.toggleAllItems("J_Toggle","J_Allitems_Content");

this.showSubItems("J_Menu");

this.simulateSelect("J_Select_type","type");

this.simulateSelect("J_Select_cat","cat_id");

e.addEvent(f,"submit",function(i){

e.preventDefault(i);

var g=e.get("name[]"),h=e.get("cat_id").value;

if(!g.value&&(h===""||h==="all")){

location.href="#";

return

} f.submit()

} )

} 

} 

} ();

function getElementID(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}

//首页特价产品
function selectDiv(num){
 for(var ii=1;ii<=2;ii++){
  var divid = "naTab_Content" + ii;
  if(ii==num)
  {
   if(getElementID(divid))
     getElementID(divid).style.display="block";
  }else{
   if(getElementID(divid))
     getElementID(divid).style.display="none";       
  }
 }
for(var kk=1;kk<=2;kk++){
  var navid = "naTab_T" + kk;
  if(kk==num)
  {
   if(getElementID(navid))
     getElementID(navid).className="current";
  }else{
   if(getElementID(navid))
     getElementID(navid).className="";       
  }
 } 
}
//首页栏目推广selectTabB
function selectTabB(num){
 for(var ii=1;ii<=3;ii++){
  var divid = "naTab_CB" + ii;
  if(ii==num)
  {
   if(getElementID(divid))
     getElementID(divid).style.display="block";
  }else{
   if(getElementID(divid))
     getElementID(divid).style.display="none";       
  }
 }
for(var kk=1;kk<=3;kk++){
  var navid = "naTab_B" + kk;
  if(kk==num)
  {
   if(getElementID(navid))
     getElementID(navid).className="current";
  }else{
   if(getElementID(navid))
     getElementID(navid).className="";       
  }
 } 
}
//首页栏目推广selectTabC
function selectTabC(num){
 for(var ii=1;ii<=3;ii++){
  var divid = "naTab_CC" + ii;
  if(ii==num)
  {
   if(getElementID(divid))
     getElementID(divid).style.display="block";
  }else{
   if(getElementID(divid))
     getElementID(divid).style.display="none";       
  }
 }
for(var kk=1;kk<=3;kk++){
  var navid = "naTab_C" + kk;
  if(kk==num)
  {
   if(getElementID(navid))
     getElementID(navid).className="current";
  }else{
   if(getElementID(navid))
     getElementID(navid).className="";       
  }
 } 
}
//首页栏目推广selectTabD
function selectTabD(num){
 for(var ii=1;ii<=3;ii++){
  var divid = "naTab_CD" + ii;
  if(ii==num)
  {
   if(getElementID(divid))
     getElementID(divid).style.display="block";
  }else{
   if(getElementID(divid))
     getElementID(divid).style.display="none";       
  }
 }
for(var kk=1;kk<=3;kk++){
  var navid = "naTab_D" + kk;
  if(kk==num)
  {
   if(getElementID(navid))
     getElementID(navid).className="current";
  }else{
   if(getElementID(navid))
     getElementID(navid).className="";       
  }
 } 
}
//首页快速
function selectDivu(num){
 for(var ii=1;ii<=2;ii++){
  var divid = "naTabu_Content" + ii;
  if(ii==num)
  {
   if(getElementID(divid))
     getElementID(divid).style.display="block";
  }else{
   if(getElementID(divid))
     getElementID(divid).style.display="none";       
  }
 }
for(var kk=1;kk<=2;kk++){
  var navid = "naTabu_T" + kk;
  if(kk==num)
  {
   if(getElementID(navid))
     getElementID(navid).className="current";
  }else{
   if(getElementID(navid))
     getElementID(navid).className="";       
  }
 } 
}


//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*/
