// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1
// @author    Adam Michela

var c = 0;

var pledges = [
"\"not take a ride to work ever. It's just as easy to walk & I get to read poetry.\" -Mimi",
"\"donate my car & commute via bus/Flexcar.\" -Robert",
"\"live so I can walk or bike to work.\" -Candice",
"\"ride to errands when it’s raining.\" -Barb",
"\"ride in the rain!\"  -Lily",
"\"not drive to any destination adjacent to or in downtown Seattle.\"  -Aaron",
"\"walk/jog to work as an experiment.\"  -John",
"\"drive less than 50 miles for Oct.\"  -Barbara",
"\"increase bike commuting by 50%.  Try bus other days.\"  -Stephanie",
"\"not drive on Tuesdays and Thursdays.\"  -Barbara",
"\"bicycle to groceries.\"  -Barbara",
"\"show people my undriver license as I ride the bus.\"  -Kris",
"\"never drive to the grocery – even if it’s in the middle of the night.\"  -Elizabeth",
"\"talk to people about bicycle safety.\"  -Mike",
"\"just one car trip a week or less .. and walk, bike, bus, scooter the rest.\" -Vic",
"\"car free days one day a week.\"  -Susan",
"\"change the way we move people & goods in WA state! I’ll start with my husband :-)\" -Shefali",
"\"walk kids to school, walk to work – back home.  Get gear for rain to be prepared!\"  -Ruby",
"\"bundle my errand trips. Cut down to 3 days of driving / week.\"  -Steph",
"\"not drive my car … maybe sell it?\"  -Cheryl",
"\"not replace our 2nd car.\"  -Cris",
"\"drive the car 5 times in the month of October.\"  -Patrick",
"\"commute to work via bus or bike.  Limit driving miles to 75 for the month.\" -Claire",
"\"post my biking and plumbing experience on the online blog once it’s up and running.\"  -Doug",
"\"use a motorcycle, not a car when I’m by myself.\"  -Jack",
"\"not drive for work or food.\"  -Brian",
"\"not drive daughter to school, have her take bus.\"  -Gil",
"\"walk or bike kids to school.\"  -Trina",
"\"skateboard to Sunny’s Teriyaki.\"  -Ian",
"\"ride more than 80% of work days + encourage others.\"  -Noam",
"\"ride the bus more, walk more, make more phone calls.\" -Elizabeth",
"\"sell my car.\" -Rob",
"\"walk to work as it’s less than two miles away from my home.\" -Jason",
"\"not drive at all except for one Flexcar trip on one day.  Use bus + foot.\" -R Mike",
"\"find and use a rolling cart this month.\" -Audrey",
"\"bus to my volunteer job.  Walk to shopping.  Get my bike back in riding condition.\" -Terry",
"\"ride my bike to school (Ballard to Capitol Hill) one time a week for full quarter.\" -Cheryl",
"\"only ride in a car five times all month.\" -Tony",
"\"combine more errands to once a week driving.\" -Janet",
"\"stay at home more and walk to the bar, and encourage housemates to carpool together.\" -Colin",
"\"carpool to work 2 days a week.\" -Emily",
"\"walk if it’s less than 3 miles, bus if it’s less than 10, bike locally.\" -Kelcey",
"\"ride my bike to go out with friends.\" -Charles",
"\"undrive to buy groceries – bike or walk.\"",
"\"walk at least 3 days a week rather than driving to the pool.\"",
"\"sell my car!  Ride the bus, bike or walk to work.\" -Shaundra",
"\"help my neighbour drive less by organizing a car-share.  Bike to work.\" -Charlotte",
"\"walk to Ballard Market + walk/bus for weekend night outs.\" -Stephanie",
"\"i promise not drive in October.\" -Bob",
"\"not drive to Tacoma or Everett but take the Sounder.\" -Nancy",
"\"drive 10% less with bike use.  Walking and riding with others.  Use more biodiesel.\" -Jon",
"\"ride my bike and sell my car this month!\" -Lindsey",
"\"preplan errands better.\" -Lars",
"\"use the bus to take my daughter to school at least three times per week.\" -Cindy",
"\"have two passengers in the car or “Martha” doesn’t start.\" -Kate",
"\"ride the bus more, check online for best routes.\" -Suzanne",
"\"only drive 2 weekends in October.\" -Beth",
"\"not drive to work for the first two weeks of October.\" -Rosie",
"\"drive less.  Reduce driving from 7 days to 4 days.\" -Kevin",
"\"combine by errands into one trip and make more of my trips on my bike.\" -David",
"\"prepare to sell our second car – carpool – and look into a bike buggy for errands.\" -Rebecca",
"\"commute more on my bicycle, regardless of nasty cold and wet October weather.\" -Timothy",
"\"not drive any gas vehicle.\" -Vic",
"\"not drive unless it’s w/ 4 people + in my car.  Drive no more than 2x a week.\" -Eric",
"\"walk to grocery store.  Not use car 4 days a week.\" -Deborah",
"\"bike, bus and walk 95%, Flexcar 5% of my time.\" -Ann",
"\"not drive to downtown Ballard from home, or from Ballard to home.\" -Amy",
"\"carry this pledge with me.\" -John",
"\"not drink and drive, stay out of bars.  Not drive, let someone else drive.\" -Richard",
"\"ride my bike to the library + grocery store on weekends.\" -Keith",
"\"get groceries by either biking or walking to the store.\" -Susan",
"\"bike even when it’s raining, and to my appt. in Montlake on Wednesdays.\" -Amity",
"\"resist pressure to buy a 2nd car.  Bike more.  Walk more.\" -Marcia",
"\"ask for fewer rides from my friends.\" -Nathan",
"\"only drive my truck 3 times this October.  For cleaner air.\" -Isaac",
"\"take the bus instead – since it’s almost impossible to park downtown.\" -Stan",
"\"only drive if I am heading out of the city.\" -Jessica",
"\"carpool or ride the bus to all events throughout the month.\" -Kevin",
"\"work at home 3 days/week.\" -Duke",
"\"not drive on weekend.\" -Kathryn",
"\"bus, walk, ride bikes to take my son to school.\" -Stella",
"\"use my solar scooter more.\" -SolaRichard",
"\"bike to work @ least 66% of the days I work!\" -Jo",
"\"talk to others about the steps we’ve taken to reduce driving.\" -Pat",
"\"suggest to my friends to not drive to meet me places.\" -Kyla",
"\"tell 10 people I know about my experiences w/ undriving.\" -Eden",
"\"promote Undriving at work (and everywhere else, too!)\" -Rachel",
"\"keep not driving and to ridicule those that do.\" -Mike",
"\"speak to 6 people about the benefits of not owning an automobile.\" -Luke",
"\"help coworkers and friends stop driving.\" -Adam",
"\"drive less and to talk my wife into driving less.\" -Brian",
"\"walk, bike, bus, not use petrol, preach the gospel of conservation.\" -Dan",
"\"talk the good talk about biking everywhere.\" -Kira",
"\"advocate ways to reduce dependence on cars.\" -Joseph",
"\"encourage my yoga students to bike, bus or walk to class.\" -Cathy",
"\"continue educating others on how to be able to not drive!\"  -Mark",
"\"bug my co-workers.\" -Manu",
"\"drive only when moving furniture, and in all other cases bike or use public transit.\" -Damon",
"\"encourage others to use alternate transportation methods and enjoy walking more.\" -Gilbert",
"\"commute 5 days a week by bus or bike.  Bike or carpool to church and meetings.\" -Stacy",
"\"discourage co-worker driving 3 blocks to Walgreens everyday because that’s silly.\" -Kelsey",
"\"go on the road to Las Vegas, SF and Fresno not renting a car or driving at all!\" -Rae",
"\"bus or bike to campus/work everyday – even on weekends when parking is free!\"  -Libby",
"\"bus more often on weekends; continue to encourage co-workers to bus/carpool.\" -Bryan",
"\"not drive at all. Convince at least 3 people to not drive at least 1x day/wk.\" -Kent",
"\"encourage others to walk 1x/wk for errands and colleagues to telecommute 1x/wk.\" -Maryann",
"\"use ½ tank this month (1 whole tank for the household); bike downtown more often.\" -Jean",
"\"avoid starting up the car for round-trips < 2 miles, e.g. grocery, bank, pharmacy…\" -Sarah",
"\"continue bike/bus commute; continue to explore undriving errands/shopping options.\"  -Paul",
"\"ride bike or walk for errands in the community – RAIN OR SHINE! 3x / wk.\"  -Joel",
"\"ride to work five days a week (and only ride the bus if bike is broken).\" -Sean",
"\"bicycle to gym & grocery store.  Bike to site visits in Fremont, Ballard, Wallingford.\" -Sooz",
"\"not drive at all! Walk from school at least 2x / wk … ride my bike more!\" -Laura, age 13",
"\"walk home from work (4 miles) 1x / wk.  I already walk to work  each morning to UW.\" -Carol",
"\"bus home from work instead of asking for a ride (if driver has to go out of their way).\" -Jana",
"\"reduce in-person meetings for organizations I work with, meet by phone, email, …\" -Michael",
"\"run the dogs at local parks once a week instead of driving to a farther away park.\" -Daphne",
"\"carpool or bicycle to work 4 out of 5 days a week.  Bicycle on errands within 5 miles.\" -Martin",
"\"drive 50% less then a normal month by walking, riding my bicycle, and riding the bus.\" -Scott",
"\"walk 2x per week instead of drive to coffee.  And bus 2x per week to kids’ activities.\" -Holly",
"\"not drive a car until April of 2008.  To ride my bike to + fro work.  Allllrigggght.\" -Ali",
"\"make Emily bike with me; yell at Damon when he drives for free things on Craigslist.\" -Nikki",
"\"never use my car in the center of Ballard – always to walk around the neighborhood.\" -Ginger",
"\"take the bus to school every day.\" -Anna, age 11",
"\"walk to school every day.\" -Katia, age 8",
"\"talk to friends how we get around.\" -Alonzo, age 10",
"\"try to not have my mom drive the car.\" -Taryna, age 10",
"\"not drive ride bike a lot.\" -Alexander, age 11",
"\"walk or ride my bike to school.\" -Molly, age 9",
"\"ride on the back of my mom’s bike.\" -Georgia, age 2",
"\"ride my bike or scooter to school.\" -Truman, age 5",
"\"walk to school at least twice a week instead of driving.\" -Miranda, age 16",
"\"not ride in a car on Sunday.\" -Lewis, age 11",
"\"walk to school and skateboard and bus around.\" -Olav, age 15 ½",
"\"drive 75% less around Ballard\" -Arden, age 13",
"\"walk to school one day a week\" -Isabelle, age 7",
"\"get parents to use car less.\" -Andrew, age 12",
"\"take the bus a lot.\" -Jonathan, age 15",
"\"ride the bus or bike to school.  Use my bike more.\" -Peter, age 12",
"\"carpool w/ people as much as possible.\" -Dylan, age 14",
"\"bike for stuff.\" -Richard, age 7",
"\"take the bus to crew every day and take the bus wherever I can.\" -Isabella, age 14",
];


var TextFat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	rotate_all : function (id,dur)
	{
		var a = document.getElementById(id);
		var i = Math.floor(Math.random() * (pledges.length));

		TextFat.fade_text(id,null,dur,"transparent","#000000");
		setTimeout("TextFat.fade_text('"+id+"',null,"+dur+",'#000000','transparent');",3000);
		a.innerHTML = pledges[i];
	},
	fade_text : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 30;
		if (!duration) duration = 3000;
		if (!from || from=="#") from = this.get_bgcolor(id);
		if (!to) to = "#FFFFFF";

		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;

		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);

		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);

		var r,g,b,h;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);

			setTimeout("TextFat.set_color('"+id+"','"+h+"')", delay);
			

			frame++;
			delay = interval * frame; 
		}
		setTimeout("TextFat.set_color('"+id+"','"+to+"')", delay);
	},
	set_color : function (id, c)
	{
		var o = document.getElementById(id);
		o.style.color = c;
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	}
}

addLoadEvent(function ()  {
	window.setInterval( "TextFat.rotate_all('tagline',500);", 5000);
//	setTimeout("TextFat.fade_text('tagline',null,2000,'#FFFFFF','#121d4a');",6000);
	TextFat.rotate_all('tagline',500);
});


