$(document).ready(function() {
	sy = $("#startmonth").val();
	ey = $("#endmonth").val();
	my = $("#maxmonth").val();
	var months = ["jan", "feb", "maa", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec"];
	$("#slider-range").slider({
        range: true,
        min: 83,
        max: my,
        values: [sy, ey],
        step:1,
        change: function(event, ui) {
        	$("#startmonth").val(ui.values[0]);
        	$("#endmonth").val(ui.values[1]);
        	changeForm();
        },
        slide: function(event, ui) {
			
			s = new Date(2000, ui.values[0]-1, 1);
			$("#startval").html(months[s.getMonth()] + " " + s.getFullYear());
			
			e = new Date(2000, ui.values[1]-1, 1);
			$("#endval").html(months[e.getMonth()] + " " + e.getFullYear());
			
		}
    });
	$('#newssearch .filter').click(function() {
		changeForm();
	});
	function changeForm() {
		$('#newslist').animate({"opacity":.2}, function() {
			$('#newssearch').ajaxSubmit({
			    // success identifies the function to invoke when the server response
		        // has been received; here we apply a fade-in effect to the new content
		        success: function(data) {
		            $('#newslist').html($('#newslist', data).html());
		            initlinks();
		            $('#newslist').animate({"opacity":1}, 500, function() {
		            	if($("#multiImage").length > 0) {
		            		$("#multiImage").scrollerScroll();
		            	}
		            });
		        }
			});
		})	;
	}
	
	$("a.read-more").live("click", function() {
		var u = $(this).attr("href");
		$('#newslist').animate({"opacity":.2}, function() {
			document.location.hash = "listlocation";
			$.get(u, function(data) {
				$('#newslist').html($("#popinfo", data).html());
				initlinks();
				$('#newslist').animate({"opacity":1}, 500, function() {
					if($("#multiImage").length > 0) {
		        		$("#multiImage").scrollerScroll();
		        	}
		        });
			});
		});
		return false;
	});
	
	$("a.terug").live("click", function() {
		changeForm();
		return false;
	});
	if($("#multiImage").length > 0) {
		$("#multiImage").scrollerScroll();
	}

});

