NYWEvents = function() {

    return {
    
        init: function() {
            var eventsRules = {
            
                'div#events-filter-region-market a': function(element) {
                    Event.stopObserving(element, 'click', NYWEvents.processAjaxRequest);
					Event.observe(element, 'click', NYWEvents.processAjaxRequest);
                },
                
                'div#events-filter-dates a': function(element) {
                    Event.stopObserving(element, 'click', NYWEvents.processAjaxRequest);
					Event.observe(element, 'click', NYWEvents.processAjaxRequest);
                },
                
                'div#events-filter-calendar a': function(element) {
                    Event.stopObserving(element, 'click', NYWEvents.processAjaxRequest);
					Event.observe(element, 'click', NYWEvents.processAjaxRequest);
                },
                
                 'div#events-filter-calendar-int a': function(element) {
                    Event.stopObserving(element, 'click', NYWEvents.processAjaxRequest);
					Event.observe(element, 'click', NYWEvents.processAjaxRequest);
                }
            };
            
            Behaviour.register(eventsRules);
        },
        
        processAjaxRequest : function(evt) {
            Event.stop(evt);
            
            NYWine.showCntMask();
            
            var aEle = Event.element(evt);
            
            if($(aEle).readAttribute('href') == null || $(aEle).readAttribute('href') == '')
            {
                aEle = $(aEle).up();
            }
                
			if ($(aEle).href != '#') {
				new Ajax.Updater('events-sub-content', $(aEle).href, {
					method : 'post',
					parameters : {
						dt : new Date()
					},
					evalScripts : true,
					onComplete: function() {
					    NYWine.hideCntMask();
					}
				});
			}
		} 
    }
}();


Event.observe(window, 'load', function() {
    NYWEvents.init();
    Behaviour.apply();
});
