jQuery(document).ready(function() {
	jQuery(document).pngFix();
	
	jQuery('.menu_menu a').each(function(){
		// get the width of the text
		var wid = jQuery(this).width();
		if(jQuery(this).is('.menu_active')){
			jQuery(this).addClass('menu_bold');
		}
		jQuery(this).css({'padding':'0px'});
		jQuery(this).parent().css({'width':(wid+18)+'px'});
	});
	
//	jQuery('.menu_menu li.parent').mouseenter(function(){
//		jQuery(this).addClass('parent_active');
//	}).mouseleave(function(){
//		if(jQuery(this).is('.already_active')){
//			return;
//		}else
//			jQuery(this).removeClass('parent_active');
//	});
	
	jQuery('.video_link_i').click(function(){
		my_href = jQuery(this).attr('href');
		
		jQuery.fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'none',
			'padding'		: 	0,
			'autoScale'		: 	false,
			'title'			: 	'',
			'width'			: 	680,
			'height'		: 	495,
			'href'			: 	my_href,
			'type'			: 	'iframe',
			'swf'			: {
	   	 	'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	
	jQuery('.video_link').click(function(){
		my_href = jQuery(this).attr('href');
		
		jQuery.fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'none',
			'padding'		: 	0,
			'autoScale'		: 	false,
			'title'			: 	'',
			'width'			: 	680,
			'height'		: 	495,
			'href'			: 	my_href,
			'type'			: 	'swf',
			'swf'			: {
	   	 	'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	
	jQuery('.art_photos').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '240px' }); 
	
	jQuery('.art_thumb').click(function() {
		  
		  new_src = jQuery(this).attr('src');
		  
		  my_id = jQuery(this).attr('id');
		  my_id = my_id.replace('th_','');
		  
		  
		  par1 = jQuery(this).parent();
		  jQuery(par1).find('.art_photos li').hide();
		  jQuery(par1).find('.art_photos li#li_'+my_id).show();
		  		  
	});
	
	 
	
	jQuery('input[title!=""],textarea[title!=""]').hint();
	
	jQuery("a.article").fancybox(
			{
				'easingIn'				: 'easeOutBack',
				'easingOut'				: 'easeInBack',
				'hideOnContentClick'	: false

			}
	);
	
	jQuery(function() {
		jQuery("#tree").treeview({
			collapsed: true,
			animated: "medium",
			control:"#sidetreecontrol"			
		});
	});
	

	


});


jQuery('.filter_input').live('keyup',function(){
	show_count(jQuery(this));
	
});	

function show_count(obj){
	jea = '';
	my_name = jQuery(obj).attr('name');
	if(jQuery('.home_filter').length==0)
		jQuery('.page_filter').find("input,select").each(
			function() {
				  jea = jea + '&'+jQuery(this).attr('name')+'='+jQuery(this).val();
			});
	else
		jQuery('.home_filter').find("input,select").each(
				function() {
					  jea = jea + '&'+jQuery(this).attr('name')+'='+jQuery(this).val();
				});	

	jQuery.ajax({
		   type: "POST",
		   url: "/pages/ajax.php",
		   data: jea,
		   dataType: 'json',
		   success: function(msg){
				jQuery('.count_span').html(msg.nr_count);
				if(my_name!='zoek')
					jQuery('input[name="zoek"]').val(msg.zoek);
				//if(my_name!='activiteit')
					jQuery('select[name="activiteit"]').html(make_select(msg.activiteit_ar, msg.activiteit));
				//if(my_name!='lengte')
					jQuery('select[name="lengte"]').html(make_select(msg.lengte_ar, msg.lengte));
				//if(my_name!='thema')
					jQuery('select[name="thema"]').html(make_select(msg.thema_ar, msg.thema));
			}
	});
	return false;
}

function make_select(sel_array, sel){
	my_sel = '';
	for (var i in sel_array){
		if(sel == i)
			my_sel += '<option selected="selected" value="'+i+'">'+sel_array[i]+'</option>';
		else
			my_sel += '<option value="'+i+'">'+sel_array[i]+'</option>';
	}
	return my_sel;

}
