var ShopSearch = Class.create();
ShopSearch.prototype = {
    initialize: function() {
        if($('changeShowNum')) {
            Event.observe($('changeShowNum'),'change',this.changeShowNum.bindAsEventListener(this));
        }
    },
    changeShowNum: function(e, node) {
        var form = $('changeShowNum');
        var select = form.options[form.selectedIndex];
        var refUrl = location.protocol+'//'+location.host+location.pathname;
        location.href = refUrl+'?showNum='+select.value;
    },
    changeTab: function(onId, offId) {
        
        var onChildNode = this.findFirstChild($(onId));
        
        if(onChildNode && onChildNode.tagName.eqi('a')) {
            var ImgNode = this.findFirstChild(onChildNode);
            var onSrc = ImgNode.src.replace('\.gif','_on\.gif');
            ImgNode.src = onSrc;
            $(onId).removeChild(onChildNode);
            $(onId).appendChild(ImgNode);
            
            var offChildNode = this.findFirstChild($(offId));
            var offSrc = offChildNode.src.replace('_on\.gif','\.gif');
            offChildNode.src = offSrc;
            var anchor = document.createElement('a');
            anchor.href = "#";
            anchor.title = offChildNode.alt;
            anchor.appendChild(offChildNode);
            $(offId).appendChild(anchor);
        }
    },
    findFirstChild: function(node)
    {
        nodes = node.childNodes;
        var ret = null;
        for(var i=0;i<nodes.length;i++) {
            if(nodes[i].tagName) {
                var ret = nodes[i];
                break;
            }
        }
        return ret;
    },
    registCookie: function(name, value, delFlg) {
        if(!name || !value) return false;
        var str = name + '=' + escape(value) +';path = /;';
        if(delFlg) {
            date = new Date();
            date.setTime(date.getTime()-100000);
            str += "expires = "+ date.toGMTString() + ';';
        }
        document.cookie = str;   
    }
    
}

