$(document).ready(function(){
	
	//$('img._crs_img').load(function(){ //working alternative (depricated)
	// This function centers the image by subtracting the container size from the image size to find how much is overflowing, then shifts the image by half that.
	$('._crs_img').each(function(){
		$(this).parent().css('position', 'relative'); // Make parent relative to prevent overflow in IE7
		if ($(this).height() > $(this).width()) { // If the image is tall...
			$(this).width("100%");
			var parentHeight = $(this).parent().height();
			$(this).css('top', '-' + (((this.height)-parentHeight)/2) + 'px').css('position', 'relative');
		} else { // If the image is wide...
			$(this).height("100%"); 
			var parentWidth = $(this).parent().width();
			$(this).css('left', '-' + (((this.width)-parentWidth)/2) + 'px').css('position', 'relative');
		}
	});
	
	// jquery cycle
	/*
	$('#header').cycle({
		fx:    'fade', 
		speed:  1000
	});*/
	
	$('#eventroll').cycle({
		fx:    'fade',
		speed:   1200,
		timeout: 7000,
		pause:	1,
		pager:	'#eventclick',
		pagerEvent:	'click',
		cleartype:     0
	});
	$('#newsroll').cycle({
		fx:    'fade',
		speed:   600,
		timeout: 6000,
		pause:	1,
		cleartype:	0
	});
	$('#newsroll2').cycle({
		fx:    'fade',
		speed:   600,
		timeout: 6000,
		pause:	1,
		cleartype:	0
	});
	$('#event1').click(function() { 
		$('#eventroll').cycle(0); 
		return false; 
	}); 
	 
	$('#event2').click(function() {  
		$('#eventroll').cycle(1);  
		return false;  
	});
	
	$('#event3').click(function() {  
		$('#eventroll').cycle(2);  
		return false;  
	});
	
	$(".searchfield").focus(function() {
		$(this).val("");
		}).blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].defaultValue);
			}
	});
	
	$('.azindex_show').click(function () {
		if ($('#azindex').is(":hidden")) {
			$('#azindex').slideDown("slow");
		} else {
			$('#azindex').slideUp("slow");
		}
	});
	
	
});

