// Homepage scripting
//
// This file makes use of three jQuery plugins defined in jquery.CHP.js (CHPticker, 
// CHPaccordion, and CHPfeatures) to bring dynamic functionality to the campaign's
// new homepage.

jQuery(document).ready(function(){

///////////////////////////////////////////////
// SlideShow Widget

////////////////////////////////////////////////

	// Define active stories:
	var stories = [
		{
			caption:'OSU College of Business enters new era with gifts, plans for $50 million building',
			cat:'Oregon',
			link:'/news/featurednews/current/cob_building/index.htm',
			image:'images/rotating_stories/572x323_cob.png'
		}	
	/*
		{
			caption:'Horse treadmill unique in Oregon',
			cat:'Oregon',
			link:'/news/featurednews/current/treadmill/index.htm',
			image:'images/rotating_stories/572x323_mckenzie.png'
		},	
		{
			caption:'Beetle specialist becomes Rice Professor',
			cat:'the World',
			link:'/news/featurednews/current/maddison/index.htm',
			image:'/images/rotating_stories/572x323_maddison.png'
		},
		{
			caption:'Students give back to KidSpirit',
			cat:'Students',
			link:'/news/featurednews/current/kidspirit/index.htm',
			image:'/images/rotating_stories/572x323_kasra.png'
		},
		{
			caption:'Student-built vehicles take center stage',
			cat:'Students',
			link:'/news/featurednews/current/engineeringvehicles/',
			image:'/images/rotating_stories/572x323_baja-rover.png'
		}
		*/
		
	/*	// to add more of these....
		,{	caption:'',
			cat:'',
			video:'',
			link:'',
			image:'' } //etc...*/
	];	

	// Create the slideshow. You will need to move the declaration of features 
	// out of this enclosure if you want to use global-style scripting to control
	// the show (e.g. <a onclick="dosomething();"></a>), then refer to the features
	// object. <a href="#" onclick="features.pause();"></a>
	
	var features = jQuery('#show').CHPfeatures({
		stories:stories,
		interval:50000}).FeatureStory;
		
	// And either go to a random image...
	//		features.goto(	(Math.random()*stories.length)|0	);
	// ..or start the show playing:
			features.play();


////////////////////////////////////////////////
// Tweaks for the menu:
////////////////////////////////////////////////

	// Add a dropshadow to each line item:
	jQuery('#menuh a.top_parent').each(function(){
		var s = this.innerHTML;
		//this.innerHTML = '<span class="shadow">'+s+'</span>' + s;
	});

////////////////////////////////////////////////
// Accordion Widget
////////////////////////////////////////////////
	
	// How long to slide up/down?
	var slide_time = 500;

	// Create the accordions (1, 2, 3!):
	jQuery('#acc1').CHPaccordion({delay:slide_time});
	jQuery('#acc2').CHPaccordion({delay:slide_time});
	jQuery('#acc3').CHPaccordion({delay:slide_time});


////////////////////////////////////////////////
// Campaign Progress Widget
////////////////////////////////////////////////

	// Edit this value to indicate campaign progress:
	var progress = 575;		// how far we are (millions of $)

	(function CampaignProgress() { // Show the progress of the campaign
		var goal = 625; 	// campaign goal (millions)
		var time = 1500;	// animation time (ms)
		
		// Display progress so far:
		jQuery('#campaign-progress-goal').html('Goal:<br />$' + goal + ' Million');
		jQuery('#campaign-progress-raised').html('Raised:<br />$' + progress + ' Million');
		
		// Default CSS for progress bars:
		var style_0 = {'margin-top': 93 +'px','height':21+'px'};

		// Animate 'Campaign Goal' progress bar:
		jQuery('#target').css(style_0).animate({ 
			marginTop:0+'px',
			height:114+'px'
		}, time);
	
		// Animate 'Campaign Progress' bar:
		jQuery('#goal').css(style_0).animate({ 
			marginTop:(114-parseInt(114*progress/goal))+'px',
			height:(parseInt(114*progress/goal))+'px'
		}, time);
	})();
	
////////////////////////////////////////////////
// News Ticker
////////////////////////////////////////////////
	jQuery('#ticker').CHPticker({
		//feed:'includes/ticker/feed.php',			// the RSS feed to draw stories from
		timer:5000							// the time each story should show for
	});

});