(function() {
	var _$ = function(id, ctx) {
		return this.find(id, ctx);
	};
	
	_$.prototype = {
		el:null,
		
		find: function(id, ctx) {
            this.el = ((ctx)?((ctx.el)?ctx.el:ctx):document).getElementById(id);            
            
			return this;
		},
		
        on: function(type, fn) {
            this.el.addEventListener(type, fn, false);
            
            return this;
        },
        
        html: function(html) {
            this.el.innerHTML = html;
            
            return this;
        },
        
        /* STYLE */
        
        setStyle: function(prop, val) {
            this.el.style[prop] = val;
            
            return this;
        },
        
        hasClass: function(className) {
            var re = this.getClassRegEx(className);
            
            return re.test(this.el.className);
        },
        
        addClass: function(className) {
            if (this.hasClass(this.el,className)==false) {
                this.el.className += ' '+className;
            }

            return this;
        },
        
        removeClass: function(className) {
            var re = this.getClassRegEx(className);

            this.el.className = this.el.className.replace(re, ' ');

            return this;
        },
        
        setClass: function(className) {
            this.el.className = className;

            return this;
        },
        
        setValue: function(value) {
            if(this.el.tagName.toLowerCase() == 'select') {
                for(var a in this.el.options) {
                    if(this.el.options[a].value == value) {
                        this.el.selectedIndex = a;
                        break;
                    }
                }
            }
            else {
                this.el.value = value;
            }
        },
        
        show: function() {
            this.setStyle('display','block');
        },

        hide: function() {
            this.setStyle('display','none');
        },
        
        reClassNameCache: {},
    
        getClassRegEx: function(className) {
            var re = this.reClassNameCache[className];
            if (!re) {
                re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
                this.reClassNameCache[className] = re;
            };
            
            return re;
        }
	};
	
	window.$ = function(id) {
		return new _$(id);
	}
})();/*--------------------------------------------------------------------------
 *  Smooth Scroller Script, version 1.0.1
 *  (c) 2007 Dezinerfolio Inc. <midart@gmail.com>
 *
 *  For details, please check the website : http://dezinerfolio.com/
 *
/*--------------------------------------------------------------------------*/

Scroller = {
	// control the speed of the scroller.
	// dont change it here directly, please use Scroller.speed=50;
	speed:3,

	// returns the current scroll position
	scrollTop: function (){
		body=document.body;
	    d=document.documentElement;
	    if (body && body.scrollTop) {
	        return body.scrollTop;
	    };
	    if (d && d.scrollTop) {
	        return d.scrollTop;
	    };
	    if (window.pageYOffset) {
	        return window.pageYOffset;
	    };
	    return 0;
	},

	// attach an event for an element
	// (element, type, function)
	add: function(event, body, d) {
	    if (event.addEventListener) {
	        return event.addEventListener(body, d,false);
	    };
	    if (event.attachEvent) {
	        return event.attachEvent('on'+body, d);
	    }
	},

	// kill an event of an element
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
      		return;
    	};
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault();
	      e.stopPropagation();
	    };
	},
	
	// move the scroll bar to the particular div.
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop();
		if(d>a) {
			if(h-d>i) {
				a+=Math.ceil((d-a)/Scroller.speed);
		    }
			else {
				a+=Math.ceil((d-a-(h-d))/Scroller.speed);
	        }
	    }
		else {
			a = a+(d-a)/Scroller.speed;
	    }
		window.scrollTo(0,a);
	  	if(a==d || Scroller.offsetTop==a) {
	  	    clearInterval(Scroller.interval);
	  	};
	  	Scroller.offsetTop=a;
	},
	
	scrollTo: function(d) {
        clearInterval(Scroller.interval);
        Scroller.interval=setInterval('Scroller.scroll('+d+')',10);
	}
};


/*------------------------------------------------------------
 *						END OF CODE
/*-----------------------------------------------------------*/var eat = {};

eat.core = {
    browser: {
        symbian: ((navigator.userAgent.toLowerCase().indexOf("symbian")!=-1)?true:false),
        iphone: ((navigator.userAgent.toLowerCase().indexOf("iphone")!=-1)?true:false),
        opera: ((navigator.userAgent.toLowerCase().indexOf("opera")!=-1)?true:false),
		msie: ((navigator.userAgent.toLowerCase().indexOf("msie")!=-1)?true:false),
		webkit: ((navigator.userAgent.toLowerCase().indexOf("webkit")!=-1)?true:false),
		gecko: ((navigator.userAgent.toLowerCase().indexOf("gecko")!=-1)?true:false),
		firefox: ((navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)?true:false),
		safari: ((navigator.userAgent.toLowerCase().indexOf("safari")!=-1)?true:false)
    },
    
    ajax: function(url, params, callback) {
        var paramstr = '?';
        
        for(var a in params) {            
            if(paramstr != '?') {
                paramstr += "&";
            }
        
            paramstr += a+"="+escape(params[a]);
        }
    
        var req = new XMLHttpRequest();
        
        req.open('GET', url+paramstr, true);
        
        req.onreadystatechange = function() {
            if (req.readyState == 4 && req.status == 200) {
                try {
                    callback(eval("("+req.responseText+")"));
                }
                catch(e) {
                    alert(e);
                    window.console.log(e);
                    window.console.log(req.responseText);
                }
            }
        };
        
        req.send(false);
    },
    
    message: function(obj, str, opt) {     
        var core = $('progress');

        if(!obj) {
            var obj = $('progressMessage');
            var mask = $('progressMask');
        }
    
        if(!opt) opt = {};
        
        if(str) {
            window.setTimeout(function() {
                obj.html('<div class="data">'+str+'</div>');
                
                if(opt.style) {
                    obj.addClass(opt.style);
                }
            
                obj.show();
                core.show(); 
                
                if(mask) {
                    mask.show();
                }
            
                if(opt.time != -1) {
                    window.setTimeout(function() {
                        if(opt.callback) {
                            opt.callback();
                        }
                        
                        obj.html('');
                        obj.hide();
    
                        if(opt.style) {
                            obj.removeClass(opt.style);
                        }
                        
                        core.hide(); 
                        
                        if(mask) {
                            mask.hide();
                        }
                    }, ((opt.time)?opt.time:1000));
                }
            }, ((opt.delay)?opt.delay:0));
        }
        else {
            window.setTimeout(function() {
                obj.html('');
                
                obj.hide();
                core.hide(); 
                
                if(mask) {
                    mask.hide();
                }
            }, ((opt.delay)?opt.delay:0));
        }
    },
    
    domCache: function(dom, elements) {
        for(var a in elements) {
            dom[elements[a]] = $(elements[a]);
        }
    },
    
    getWidth: function() {
        return window.innerWidth;
    },
    
    getHeight: function() {
        return window.innerHeight;
    },
    
    setCookie: function(c_name, value, expiredays, domain, path) {
        var exdate = new Date();

        exdate.setDate(exdate.getDate()+expiredays);
        
        document.cookie = c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";domain="+domain+";path="+path);
    },

    deleteCookie: function(c_name, domain, path) {
        document.cookie = c_name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT;domain="+domain+";path="+path;
    },
    
    setCheckbox: function(entryId, checkboxId) {
        var entry = $(entryId);
        var checkbox = $(checkboxId);
        
        if(entry.hasClass('on')) {
            entry.removeClass('on');
            checkbox.el.checked = false;
        }
        else {
            entry.addClass('on');
            checkbox.el.checked = true;        
        };
    },

    setRadio: function(entryId, radioId) {
        var entry = $(entryId);
        var radio = $(radioId);
        
        var entries = entry.el.parentNode.getElementsByTagName('a');
        
        for(var a in entries) {
            entries[a].className = '';
        }

        entry.addClass('on');
        radio.el.checked = true;        
    },
    
    scrollTop: function() {
        Scroller.scrollTo(0);
    },
    
    loadPage: function(url) {
        var self = this;
        
        this.scrollTop();
        
        window.setTimeout(function() {        
            self.message(false, __('common.loading'), { time:-1 });
                    
            window.setTimeout(function() {
                document.location = url;
            }, 750);
        }, 250);
    },
    
    locateMe: function(urlWithLocation, urlWithoutLocation) {
        var successCallback = function(pos) {
            if (!!pos.coords && pos.coords.accuracy < 1000) {
                var c = "config=redirect:category_search%3Fmode=both";
                if (config && config.style) {
                    c += ";style:" + config.style;
                }
                location.href = urlWithLocation + "?" + c + "&lat=" + pos.coords.latitude + "&lng=" + pos.coords.longitude;
            } else {
                location.href = urlWithoutLocation;
            }
        };
        
        if ("geolocation" in navigator) {
            $("sections").show();
            
            navigator.geolocation.getCurrentPosition(successCallback, function(err) {
                location.href = urlWithoutLocation;
            }, {
                enableHighAccuracy: true
            });
        } else if (window.google && google.gears) {
            $("sections").show();
            
            var geo = google.gears.factory.create('beta.geolocation');
            geo.getCurrentPosition(successCallback, function(err) {
                location.href = urlWithoutLocation;
            }, {
                enableHighAccuracy: true,
                gearsLocationProviderUrls: null
            });
        } else {
            location.href = urlWithoutLocation;
            return;
        }
        
        // continue after 15 seconds, even if loading has not finished
        window.setTimeout(function() {
            location.href = urlWithoutLocation;
        }, 15000);
    }
};

// DUMMY

eat.main = {
    init: function() {}
};

// MISC

function __(id) {
	if(strings[id]) {
		return strings[id];
	}
	else {
		return id;
	};
};
