window.addEvent('domready', function() {

	$$('.notify').highlight();
	
	$$('.expanderLink').each(function(element) {
				
		var theBlock = $(element.id.replace("Expander",""));			
		
		if(theBlock) {			
			theBlock.slide('hide');	
			
			element.addEvent('click',function(e){
				e.stop();			
				theBlock.slide('toggle');
			})
		}
		
	});
	
	if($('search_criteria') && $('search_type') && $('search_box')) {
	
	  	var searchCriteriaAjax = new Request.HTML({url:'/search_box_ajax.php',update: $('search_criteria')});
  		
	    $('search_type').addEvent('change', function() {
			searchCriteriaAjax.post($('search_box'));
		});
	
		searchCriteriaAjax.post($('search_box'));
	
	}
	
	
	
	if ($$('.sortbookmarks')) {
	
		 folder = new Sortables($$('.sortbookmarks'), {
	  	  revert: true,
	  	  clone: true,
	  	  handle: '.dragHandle',
	  	  opacity: 0.7,
	  	  constrain: true,
	  	  onComplete: function() {	
	    	var myRequest = new Request({
				url:'reorder_bookmarks.php'                    
			}).get({
				'order': this.serialize(function(element){
	    			return element.getProperty('id').replace('item_','');
				}).join(','),	
				'action': 'reorder_bookmarks'
			});     
	  	  } 	  	
	  	});
	}
	
})
