/**
 * "mini" Selector Engine
 * Copyright (c) 2009 James Padolsey
 * Version: 0.01 (BETA)
 */
 function helper(obj){
	if (!obj) return;
	if (!obj.clear){
		obj.clear = function()
		{
			if (this.innerHTML) this.innerHTML="";
		};
	}
	if (!obj.show){	
		obj.show = function()
		{
			if (this.style.display) this.style.display="";
		};
		obj.isShow = function()
		{
			return this.style.display && this.style.display=="";
		};		
	}
	if (!obj.hide){		
		obj.hide = function()
		{
			if (this.style.display) this.style.display="none";
		};
		obj.isHide = function()
		{
			return this.style.display && this.style.display=="none";
		};			
	}
	if (!obj.setClass){	
		obj.setClass = function(className)
		{
			this.className=className;
		};
	}
	if (!obj.addClass){	
		obj.addClass = function(className)
		{
			if (className!='' && this.className.indexOf(className)<0) this.className+=' '+className;				
		};
	}
	if (!obj.removeClass){		
		obj.removeClass = function(className)
		{
			if (this.className && this.className.indexOf(className)>=0) this.className=this.className.replace(className,'');				
		};
	}
 }

var $obj = (function(){
    var snack = /(?:[\w\-\\.#]+)+(?:\[\w+?=([\'"])?(?:\\\1|.)+?\1\])?|\*|>/ig,
        exprClassName = /^(?:[\w\-_]+)?\.([\w\-_]+)/,
        exprId = /^(?:[\w\-_]+)?#([\w\-_]+)/,
        exprNodeName = /^([\w\*\-_]+)/,
        na = [null,null];
    function _find(selector, context) {
        context = context || document;
		var objs;
        var simple = /^[\w\-_#]+$/.test(selector);
        
        if (!simple && context.querySelectorAll) {
            objs= realArray(context.querySelectorAll(selector));
        }
        
        if (!objs && selector.indexOf(',') > -1) {
            var split = selector.split(/,/g), ret = [], sIndex = 0, len = split.length;
            for(; sIndex < len; ++sIndex) {
                ret = ret.concat( _find(split[sIndex], context) );
            }
            objs= unique(ret);
        }
        if (!objs){
			var parts = selector.match(snack),
				part = parts.pop(),
				id = (part.match(exprId) || na)[1],
				className = !id && (part.match(exprClassName) || na)[1],
				nodeName = !id && (part.match(exprNodeName) || na)[1],
				collection;
				
			if (className && !nodeName && context.getElementsByClassName) {
				
				collection = realArray(context.getElementsByClassName(className));
				
			} else {
				
				collection = !id && realArray(context.getElementsByTagName(nodeName || '*'));
				
				if (className) {
					collection = filterByAttr(collection, 'className', RegExp('(^|\\s)' + className + '(\\s|$)'));
				}
				
				if (id) {
					var byId = context.getElementById(id);
					objs= byId?[byId]:[];
				}
			}
		}
        if (!objs){
			objs= parts[0] && collection[0] ? filterParents(parts, collection) : collection;
		}
		objs.clear = function(idx)
		{
			for (var i = 0, l = objs.length; i < l; ++i) {
				objs[i].innerHTML="";
			}
		};
		objs.show = function()
		{
			for (var i = 0, l = objs.length; i < l; ++i) {
				objs[i].style.display="";
			}
		};
		objs.isShow = function()
		{
			for (var i = 0, l = objs.length; i < l; ++i) {
				return objs[i].style.display=="";
			}
		};			
		objs.hide = function()
		{
			for (var i = 0, l = objs.length; i < l; ++i) {
				objs[i].style.display="none";
			}
		};
		objs.isHide = function()
		{
			for (var i = 0, l = objs.length; i < l; ++i) {
				return objs[i].style.display=="none";
			}
		};			
		objs.setClass = function(className)
		{
			for (var i = 0, l = objs.length; i < l; ++i)	
				objs[i].className=className;
		};
		objs.addClass = function(className)
		{
			for (var i = 0, l = objs.length; i < l; ++i)	
				if (className!='' && objs[i].className.indexOf(className)<0) objs[i].className+=' '+className;
		};		
		objs.removeClass = function(className)
		{
			for (var i = 0, l = objs.length; i < l; ++i)	
				if (objs[i].className.indexOf(className)>=0) objs[i].className=objs[i].className.replace(className,'');
		};			
	
		return objs;
    }
    
    function realArray(c) {
        try {
            return Array.prototype.slice.call(c);
        } catch(e) {
            var ret = [], i = 0, len = c.length;
            for (; i < len; ++i) {
                ret[i] = c[i];
            }
            return ret;
        }
        
    }
    
    function filterParents(selectorParts, collection, direct) {
        var parentSelector = selectorParts.pop();
        
        if (parentSelector === '>') {
            return filterParents(selectorParts, collection, true);
        }
        
        var ret = [],
            r = -1,
            id = (parentSelector.match(exprId) || na)[1],
            className = !id && (parentSelector.match(exprClassName) || na)[1],
            nodeName = !id && (parentSelector.match(exprNodeName) || na)[1],
            cIndex = -1,
            node, parent,
            matches;
            
        nodeName = nodeName && nodeName.toLowerCase();
            
        while ( (node = collection[++cIndex]) ) {
            
            parent = node.parentNode;
            
            do {
                
                matches = !nodeName || nodeName === '*' || nodeName === parent.nodeName.toLowerCase();
                matches = matches && (!id || parent.id === id);
                matches = matches && (!className || RegExp('(^|\\s)' + className + '(\\s|$)').test(parent.className));
                
                if (direct || matches) { break; }
                
            } while ( (parent = parent.parentNode) );
            
            if (matches) {
                ret[++r] = node;
            }
        }
        
        return selectorParts[0] && ret[0] ? filterParents(selectorParts, ret) : ret;
        
    }
    
    
    var unique = (function(){
        
        var uid = +new Date();
                
        var data = (function(){
         
            var n = 1;
         
            return function(elem) {
         
                var cacheIndex = elem[uid],
                    nextCacheIndex = n++;
         
                if(!cacheIndex) {
                    elem[uid] = nextCacheIndex;
                    return true;
                }
         
                return false;
         
            };
         
        })();
        
        return function(arr) {
        
            /**
             * Returns a unique array
             */
            
            var length = arr.length,
                ret = [],
                r = -1,
                i = 0,
                item;
                
            for (; i < length; ++i) {
                item = arr[i];
                if (data(item)) {
                    ret[++r] = item;
                }
            }
            
            uid += 1;
            
            return ret;
    
        };
    
    })();
    
    function filterByAttr(collection, attr, regex) {
        var i = -1, node, r = -1, ret = [];
        
        while ( (node = collection[++i]) ) {
            if (regex.test(node[attr])) {
                ret[++r] = node;
            }
        }
        
        return ret;
    }
    
    return _find;
    
})();

function TabBox(menus,pages,onClass,moveShow)
{
	this.menus=menus;//$('.tabList > a.on');
	this.pages=pages;//$('.contentBox > div');
	this.onClass=onClass;	
	if (pages.length>=menus.length){
		for (var i = 0, l = menus.length; i < l; ++i) {
			helper(pages[i]);
			helper(menus[i]);
			menus[i].onclick=this.showPage;
			menus[i].tab=this;
			menus[i].page=pages[i];
		}
		if (moveShow)
			for (var i = 0, l = menus.length; i < l; ++i) {
				menus[i].onmousemove=this.showPage;
			}		
	}

}
TabBox.prototype.showPage = function()
{
	if (this.className==this.tab.onClass && this.page.isShow()) return;
	this.tab.menus.removeClass(this.tab.onClass);
	this.tab.pages.hide();
	this.addClass(this.tab.onClass);
	this.page.show();
};

