$(function(){
	$('.maxbg').maxImage({
		maxFollows:'height',
		overflow:'auto',
		position:'relative',
		isBackground:true,
		zIndex:-10,
		verticalAlign:'center',
		horizontalAlign:'center',
		maxAtOrigImageSize:false,
		//slideShow:(false),
		//slideDelay:(5),
		//slideShowTitle:(true|false),
		loaderClass:'loader'
	});
	
	auto_resize();
	obiwidth();
	
	$(window).resize(function(){
		auto_resize();
		obiwidth();
	});
	var thpos = '125px';
	var bhpos = '-62px';
	var ntitle  = $("#news h2 img");
	var etitle  = $("#event h2 img");
	
	$("#home #news h2 img").click(function(){
		if($("#home #news").css("bottom") != thpos){
			$("#home #news:not(:animated)").animate({
				bottom:thpos
			}, downimg(ntitle));
		}else{
			$("#home #news:not(:animated)").animate({
				bottom:bhpos
			}, upimg(ntitle));
		}
	});
	$("#home #event h2 img").click(function(){
		if($("#home #event").css("bottom") != thpos){
			$("#home #event:not(:animated)").animate({
				bottom:thpos
			}, downimg(etitle));
		}else{
			$("#home #event:not(:animated)").animate({
				bottom:bhpos
			}, upimg(etitle));
		}
	});
	
	var newevent = $("#event dl");
	var newsback = $('#news dl');
	
	newevent.mouseover(function(){
		$(this).css("background", "#e6e1d7");
	})
	.mouseout(function(){
		$(this).css("background", "#fff");
	});
	
	newsback.live('mouseover', function(){
		$(this).css("background", "#e6e1d7");
	
	});
	newsback.live('mouseout', function(){
		$(this).css("background", "#fff");
	
	});
	
	$('#header ul').droppy();
	
	function downimg(elm)
	{
		var r = elm.attr("src").replace("_up", "_down");
		elm.attr("src", r);
	}
	function upimg(elm)
	{
		var r = elm.attr("src").replace("_down", "_up");
		elm.attr("src", r);
	}
	function obiwidth()
	{
		var w = $(window).width();
		var obiw = w - 1135;
		$("#obi").css("width", obiw);
	}
	function auto_resize()
	{
		var h = $(window).height();
		$("#wrap").css("height",h);
	}
	
	
	var elem = $('#header h1 img, #footer .bnr p img, #news h2 img, #event h2 img, #news p img, #event p img');
	
	elem.mouseover(function(){
		$(this).css('opacity', 0.8);
	})
	.mouseout(function(){
		$(this).css('opacity', 1.0);
	});
	
});

