$( function(){
	ro();
	if( $(".index-wrapper .mast-cycle-panels").length > 0 ){
	$(".index-wrapper .mast-cycle-panels").cycle({
		timeout: 5000
		,speed: 1000
		,fx: 'fade'
		,easing: 'easeOutExpo'
		,cleartype: !$.support.opacity
		,cleartypeNoBg: true
		,next: '#background-info .next'
		,prev: '#background-info .prev'
		,before: function(){
			$("#background-info .title").html(this.alt);
			$("#background-info .desc span").html(this.title);
		}
	});
	}
	if( $("#spring-feature-panels").length > 0 ){
	$("#spring-feature-panels").cycle({
		timeout: 0
		,speed: 400
		,fx: 'fade'
		,easing: 'easeOutExpo'
		,next: '#spring-feature-panel-cycler .next'
		,prev: '#spring-feature-panel-cycler .prev'
		,cleartype: !$.support.opacity
		,cleartypeNoBg: true
		,pager:  '#spring-features-nav'
		,pagerAnchorBuilder: function(idx, slide) {
			return '#spring-features-nav li:eq(' + idx + ') a';
		}
	});
	}
	if( $(".event-panels").length > 0 ){
	$(".event-panels").cycle({
		timeout: 5000
		,speed: 400
		,fx: 'blindX'
		,easing: 'easeOutExpo'
		,cleartype: !$.support.opacity
		,cleartypeNoBg: true
		,pager:  '.event-panels-nav'
		,pagerAnchorBuilder: function(idx, slide) {
			return '.event-panels-nav li:eq(' + idx + ') a';
		}
	});
	}
	if( $("#spring-forth-panels").length > 0 ){
	$("#spring-forth-panels").cycle({
		timeout: 0
		,speed: 400
		,fx: 'blindX'
		,easing: 'easeOutExpo'
		,pager:  '#spring-forth-nav'
		,cleartype: !$.support.opacity
		,cleartypeNoBg: true
		,pagerAnchorBuilder: function(idx, slide) {
			return '#spring-forth-nav li:eq(' + idx + ') a';
		}
	});
	}
	
	$("#showEventDates .datepicker").datepicker();
	
	//$(".cal-panel:not(:first)").hide();
	$(".cal-panel-hide").hide();
	$(".cal-nav a").click( function( e ){
		e.preventDefault();
		$(".cal-panel").hide();
		$( $(this).attr('href') ).show();
	})
	$("#main-nav .top").hover( function(){
		$("div", this).slideDown('400','easeOutExpo');
	},
	function(){
		$("div", this).slideUp('400','easeOutExpo');
	});
	
	// seasonal nav
	$("#navbar h1").hover( function(){ $("div", this).toggle(); });
	
	if( $("#tweetsLoadHere").length > 0 ){ getTwitterStatuses(); }
	function getTwitterStatuses(){
		$.getJSON(
			"#"
			,function (twitters) {
				  var statusHTML = [];
					  for (var i=0; i<twitters.length; i++){
					    var username = twitters[i].user.screen_name;
					    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
					      return '<a href="'+url+'">'+url+'</a>';
					    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
					      return  reply.charAt(0)+'<a class="byWho" href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
					    });
					    statusHTML.push('<div class="entry"><div class="inner">'+status+'<br/><a class="byWhen" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></div></div>');
					  }
					  document.getElementById('tweetsLoadHere').innerHTML = statusHTML.join('');

			}
		);
	}
	function ro()
	{
		$('.ro').mouseover( function()
		{
			rep = ".";
			ext = $(this).attr('src').substr(-4, 4);
			src = $(this).attr('src').replace(rep, "-on.");
			$(this).attr('src', src);
		
		});
		$('.ro').mouseout( function()
		{
			rep = "-on.";
			ext = $(this).attr('src').substr(-4, 4);
			src = $(this).attr('src').replace(rep, ".");
			$(this).attr('src', src);
		
		});
	}
	$(".expander").live( 'click' , function( e ){
		e.preventDefault();
		if( $(this).hasClass('active')){
			$(this).removeClass('active');
			$('#'+$(this).attr('rel')).hide();
		}else{
			$(".expander").removeClass('active');
			$('.expanded-info').hide();
			$(this).addClass('active');
			$('#'+$(this).attr('rel')).show();
		}
	});
});
