var timer = false;
var marginTop = 0;
var speed = 5;
var maxSpeed = 30;
var showDescription = true;
var url = '';

url="/fileadmin/scripts/autocomplete.php";
$.alfadir =  {
	descriptionTimer :false,
	scrollTimer : false,
	
	init:function() {
		$('.itemTitle').bind('click',function(){
			activeDiv = $('#'+this.id+'_sub');
			activeDiv.slideToggle('fast',function(){
					titleID =this.id.split('_',1);
					if(activeDiv.css('display')=='block') {
						$('#'+titleID).addClass('open');
						$('#'+titleID).removeClass('closed');
						
					} else {
						$('#'+titleID).removeClass('open');
						$('#'+titleID).addClass('closed');
					}
			});
		})
		
	
		if ( $("#searchfieldautocomplete").length > 0 ) {

			$("#searchfieldautocomplete").autocomplete(url);
			$('#searchfieldautocomplete').result(function(event, data, formatted) {
			 //submit the form
			 
			 $('#filterForm').submit();
			});
		
	
			
			//$("#scrollingListHeader").bind('click',function(){
			//	$("div.hoverscroll").slideToggle('slow', function(){
			//		if($(this).css('display')=='block') {
			//			$("#scrollingListHeader").addClass('open');
			//			$("#scrollingListHeader").removeClass('closed');
			//		} else {
			//			$("#scrollingListHeader").addClass('closed');
			//			$("#scrollingListHeader").removeClass('open');
			//		}
			//	});
			//	return false;
			//})
			
			//$('#scrollinglist').hoverscroll({
			//	vertical: true,
			//	height: 200,
			//	width: 170,
			//	speed: 3,
			//	arrows: false
			//});
	
			//$('#scrollinglist').bind('mouseenter mouseleave',function(e){
			//	$(this).toggleClass('listHover');
			//});
	
			//$('#scrollinglist').find('li').bind('mouseover',function(e){
			//	$(this).addClass("itemHover");
			//	$(this).next().addClass("itemHover-2nd");
			//	$(this).prev().addClass("itemHover-2nd");
			//	$(this).next().next().addClass("itemHover-3rd");
			//	$(this).prev().prev().addClass("itemHover-3rd");
			//	
			//}),
			
			//reset all values for the list element when the mouse leaves the box
			//$('#scrollinglist').find('li').bind('mouseleave',function(){
			//	$(this).removeClass("itemHover");
			//	$(this).next().removeClass("itemHover-2nd");
			//	$(this).prev().removeClass("itemHover-2nd");
			//	$(this).next().next().removeClass("itemHover-3rd");
			//	$(this).prev().prev().removeClass("itemHover-3rd");
			//})
		}
	}
}
		
	
//				
//				activeDiv.slideToggle('fast',function() {
//					check if div is shown or hidden and adjust class of titleDiv accordingly
//					titleID =this.id.split('_',1);
//					
//					if(activeDiv.css('display')=='block') {
//						$('#'+titleID).addClass('open');
//						$('#'+titleID).removeClass('closed');
//						
//					} else {
//						$('#'+titleID).removeClass('open');
//						$('#'+titleID).addClass('closed");
//					}


//			});
//				
//			
//		},
//	};
//	

$(document).ready(function() {
        $.alfadir.init();
});
