home_slide_events = {
	a:null,
	n:null,
	o:null,
	t:null,
	next:function(){
		home_slide_events.a = home_slide_events.o.filter('.active');
		if (home_slide_events.a.length == 0 ){ home_slide_events.a = home_slide_events.o.filter(':last'); }
		home_slide_events.n =  home_slide_events.a.next().length ? home_slide_events.a.next() : home_slide_events.o.filter(':first');
		home_slide_events.a.addClass('last-active').animate({opacity:0}, 500, function() {
			home_slide_events.n.css({opacity: 0.0}).addClass('active').animate({opacity:1}, 500, function() { home_slide_events.a.removeClass('active last-active'); });
		});
	},
	start:function(){
		var $o = $("#events > ul li");
		home_slide_events.o = $o;
		$("#events").hover(function(){ window.clearInterval(home_slide_events.t); },function(){ home_slide_events.t = window.setInterval("home_slide_events.next()", 6000 ); });
		home_slide_events.t = window.setInterval("home_slide_events.next()", 6000 );
	}
};

home_slide_announcements = {
	a:null,
	n:null,
	o:null,
	t:null,
	next:function(){
		home_slide_announcements.a = home_slide_announcements.o.filter('.active');
		if (home_slide_announcements.a.length == 0 ){ home_slide_announcements.a = home_slide_announcements.o.filter(':last'); }
		home_slide_announcements.n =  home_slide_announcements.a.next().length ? home_slide_announcements.a.next() : home_slide_announcements.o.filter(':first');
		home_slide_announcements.a.addClass('last-active').animate({opacity:0}, 500, function() {
			home_slide_announcements.n.css({opacity: 0.0}).addClass('active').animate({opacity:1}, 500, function() { home_slide_announcements.a.removeClass('active last-active'); });
		});
	},
	start:function(){
		var $o = $("#announcements > ul li");
		home_slide_announcements.o = $o;
		$("#announcements").hover(function(){ window.clearInterval(home_slide_announcements.t); },function(){ home_slide_announcements.t = window.setInterval("home_slide_announcements.next()", 6000 ); });
		home_slide_announcements.t = window.setInterval("home_slide_announcements.next()", 6000 );
	}
};

home_slide_news = {
	a:null,
	n:null,
	o:null,
	t:null,
	next:function(){
		home_slide_news.a = home_slide_news.o.filter('.active');
		if (home_slide_news.a.length == 0 ){ home_slide_news.a = home_slide_news.o.filter(':last'); }
		home_slide_news.n =  home_slide_news.a.next().length ? home_slide_news.a.next() : home_slide_news.o.filter(':first');
		home_slide_news.a.addClass('last-active').animate({opacity:0}, 500, function() {
			home_slide_news.n.css({opacity: 0.0}).addClass('active').animate({opacity:1}, 500, function() { home_slide_news.a.removeClass('active last-active'); });
		});
	},
	start:function(){
		var $o = $("#news > ul li");
		home_slide_news.o = $o;
		$("#news").hover(function(){ window.clearInterval(home_slide_news.t); },function(){ home_slide_news.t = window.setInterval("home_slide_news.next()", 4000 ); });
		home_slide_news.t = window.setInterval("home_slide_news.next()", 4000 );
	}
};

home_slide_sponsors = {
	a:null,
	n:null,
	o:null,
	t:null,
	next:function(){
		home_slide_sponsors.a = home_slide_sponsors.o.filter('.active');
		if (home_slide_sponsors.a.length == 0 ){ home_slide_sponsors.a = home_slide_sponsors.o.filter(':last'); }
		home_slide_sponsors.n =  home_slide_sponsors.a.next().length ? home_slide_sponsors.a.next() : home_slide_sponsors.o.filter(':first');
		home_slide_sponsors.a.addClass('last-active').animate({opacity:0}, 500, function() {
			home_slide_sponsors.n.css({opacity: 0.0}).addClass('active').animate({opacity:1}, 500, function() { home_slide_sponsors.a.removeClass('active last-active'); });
		});
	},
	start:function(){
		var $o = $("#sponsors > ul li");
		home_slide_sponsors.o = $o;
		$("#news").hover(function(){ window.clearInterval(home_slide_sponsors.t); },function(){ home_slide_sponsors.t = window.setInterval("home_slide_sponsors.next()", 4000 ); });
		home_slide_sponsors.t = window.setInterval("home_slide_sponsors.next()", 4000 );
	}
};


$(function() {
 	$("body").addClass("js")
	
	if ($.browser.msie && $.browser.version < 7) {
		$("img[src$='.png']").ifixpng();
		$("#banner_img").ifixpng();
	}
	
	home_slide_events.start();
	home_slide_announcements.start();
	home_slide_news.start();
	
	/*$("#navigation li").each(function() {
		if($(this).children("ul").length>0){
			$submenu = $(this).children("ul").eq(0)
			$clone = $(this).clone();
			$clone.prependTo($submenu).children("ul").eq(0).remove();
			$("<strong></strong>").appendTo($clone);
			$clone.children("a").appendTo($clone.children("strong").eq(0))
		}
	});*/
	/*
	for(var o_i=1,o_m=5;o_i<o_m;o_i+=1){
		var imgdir = "images/banners/";
		var imgname = "banner"+o_i+"_";
		var swfvars = "max="+5+"&amp;imgDir="+encodeURIComponent(imgdir)+"&amp;imgName="+encodeURIComponent(imgname)+"&amp;imgStart="+o_i+"&amp;fadeTime=3&amp;fadeDelay=2000";
		var swfdir = "";
		var swffont = "images.swf";
		var newwidth_t = "250px";
		var newheight_t = "152px";
		var newid = "swfimages"+o_i+"_"+Math.floor(Math.random()*100000);
		if($.browser.msie){
			var obj = "<object data=\""+swfdir+swffont+"\" id=\""+newid+"\" width=\""+newwidth_t+"\" height=\""+newheight_t+"\" type=\"application/x-shockwave-flash\"><param name=\"type\" value=\"application/x-shockwave-flash\" /><param name=\"src\" value=\""+swfdir+swffont+"\" /><param name=\"data\" value=\""+swfdir+swffont+"\" /><param name=\"codebase\" value=\""+swfdir+swffont+"\" /><param name=\"movie\" value=\""+swfdir+swffont+"\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\"><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /><param name=\"flashvars\" value=\""+swfvars+"\" /></object>";
		}else{
			var obj = "<object data=\""+swfdir+swffont+"\" id=\""+newid+"\" width=\""+newwidth_t+"\" height=\""+newheight_t+"\" type=\"application/x-shockwave-flash\"><param name=\"type\" value=\"application/x-shockwave-flash\" /><param name=\"src\" value=\""+swfdir+swffont+"\" /><param name=\"data\" value=\""+swfdir+swffont+"\" /><param name=\"codebase\" value=\""+swfdir+swffont+"\" /><param name=\"movie\" value=\""+swfdir+swffont+"\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\"><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /><param name=\"flashvars\" value=\""+swfvars+"\" /></object>";
		}
		$(obj).appendTo("#banner_object_"+o_i);
	}*/
	
	swfobject.embedSWF("images.swf", "banner_object_1", 1000, 152, "9.0.0", null, {max:7,imgDir:encodeURIComponent("images/banners/"),imgName:"banner-",imgSufx:"",imgStart:0,fadeTime:2,fadeDelay:4000,imgNamePad:10},{wmode:"transparent"});
	
	
	$("#navigation > ul").superfish({delay: 200, speed: 'fast', dropShadows: false });
	
	if($("#container").hasClass('local_events')==1){
		if(String(window.location).indexOf("#")==-1){
			var this_date = new Date();
			var this_month=Number(this_date.getMonth())+1;
			var this_month_z=String("00").substring(String(this_month).length);
			window.location=String(window.location)+("#events_"+this_date.getFullYear()+"_"+this_month_z+this_month);
		}
		$("#local_events").tabs();
	}else if($("#container").hasClass('news')==1||$("#container").hasClass('news_archive')==1||$("#container").hasClass('announcements')==1||$("#container").hasClass('announcements_archive')==1){
		if(String(window.location).indexOf("#")==-1){
			var this_date = new Date();
			var this_month=Number(this_date.getMonth())+1;
			var this_month_z=String("00").substring(String(this_month).length)
			window.location=String(window.location).concat("#events_"+this_date.getFullYear()+"_"+this_month_z+this_month);
		}
		$("#news_list").tabs();
	}

	$("div.photo a").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("New Window: ").length);
		$(this).attr({'title':newtitle,'rel':'photo'});
	});
	$("div.photo a, a[rel='photo']").colorbox({transition:'fade',speed:500,slideshow:false});
	
	$("a[title^='New Window: ']").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("New Window: ").length);
		$(this).attr('title',newtitle);
		$(this).click(function(){ var newwin = window.open($(this).attr('href'),'newbinkcentralwin'); newwin.focus(); return false; });
	});
	
 });
