// init
Event.observe(document, 'DOMContentLoaded',
	function () { log('DOMContentLoaded!');
		// apply onclick handlers
		set_handlers(document);
        // start the back button / history fix
		window['chaste_history_controller'] = new ChasteHistory();
        // initialize the advanced search 
    window['hextra_search'] = new SexySearch();
        // initialise the video player
		//mvp.initialize();
        // initialize the main sliders
        sliders['action_slot'] = new Fx.Slide('action_slot', {duration: 300});
        sliders['main_slot'] = new Fx.Slide('main_slot', {duration: 300});
		// apply sliding within the page 
		hextra_apply_sliding('main_slot');
		hextra_apply_sliding('action_slot');
		// if the user is logged in (@@ set in the page by the render_master template)
		if (USER_IS_LOGGED_IN) {
		    // @@ hide the chat scrolls as default...
            toggle_chat_scroll_bars();
            // apply sliding within the chat
            hextra_apply_sliding('chat_slot');
    		// init the manual chat events
    		var chat_toggler = $('chat_slot').getElementsBySelector('div.toggler').first();
    		Event.observe(chat_toggler, 'click', toggle_chat_scroll_bars);
    		Event.observe(chat_toggler, 'click', open_the_chat);
		}
		if (Prototype.Browser.IE) {
		  // hackety hack - don't fight back
  		var middle_slot = $('middle_slot');
  		if (middle_slot) {
  		  middle_slot.hide();
  		  middle_slot.show();
  		}
  	}
  	$('loading').setStyle({'display': 'block'});
  	$('loading').hide();
  	var view_by = $('viewBy');
    if (view_by) {
      view_by.hide();
      view_by.show();
    }
    window.setTimeout('window.hextra_search.show_advanced_search()', 1000);
	}
);