// JavaScript Document

function rotateText(el, textGroup) {
setOpacity(el, 0);
var t = rotateText.texts[textGroup];
var t = t[Math.floor(Math.random() * (t.length - 1))];
el.innerHTML = t;
unfadeText(el, textGroup);
}
rotateText.texts = {
quotes: [
"Go Go Guitar! Is absolutely on the money and is such a well thought out idea that turns teaching on its head and makes it pay. - Susan Cherrett",
"We never imagined that we would get over half a million hits on our website in the space of three months. - Savetheworldwithmusic",
"We put too much emphasis on the music - instead of getting gigs, running a small business and making money. - The Undercovers",
"Structure your final presentation rather than merely describe what you did. This was detailed in tutorials, had you attended them. - Tutor Feedback",
"You are giving opportunities to young musicians and stretching out in a way that feels genuine and inclusive. - Head of Music Bath City College",
"We started the promotion process too late, focusing on prizes. The effective promotion was via schools. - Shining Stars Talent Competition",
"Get started early. It's what you have to do.' - Ian Evans, IME",
"Thank you for being such an integral part of the Bristol Eco Veggie Fayre, it has been a pleasure to have you all on board.",
"We are pleased to have Little Eskimo on board and are confident they'll do a great job at event managing the Spiegel garden stage. - Bath Fringe Festival",
"Just a quick message to say how impressed we are with your overall approach to the Little Eskimo Project - Head of Music Bath City College",
"You guys are very well organised and easy to deal with. Our students take you seriously and are motivated to take part in the projects",
"It went so well. It turned out to be some much bigger and better than I expected. - Ian Evans IME",
"We decided that a happy entrant is a future entrant. We made sure anyone could contact us directly with feedback. - Unsigned Song Contest",
"Get started early. It's what you have to do. - Ian Evans, IME"
],
authors: [
"- Charles Dickens",
"- Chair of Business Plan Awards 2009",
"- Edgar Allen Poe"
],
restaurants: [
"Burger King",
"McDonalds",
"Taco Bell",
"Wendy's"
]
};

function setOpacity(el, value) {
el.style.opacity = value / 100;
el.style.filter = "alpha(opacity=" + value + ")";
}

function unfadeText(el, tg) {
var v = el.style.opacity * 100 + 1;
if(v > 100) {
setOpacity(el, 100);
setTimeout(bundleFunction(null, fadeText, [el, tg]), 8000);
return;
}
setOpacity(el, v);
setTimeout(bundleFunction(null, unfadeText, [el, tg]), 20);
}

function fadeText(el, tg) {
var v = el.style.opacity * 100 - 1;
if(v < 0) {
setOpacity(el, 0);
rotateText(el, tg);
//or... setTimeout(bundleFunction(null, rotateText, [el, tg]), NUMBER);
return;
}
setOpacity(el, v);
setTimeout(bundleFunction(null, fadeText, [el, tg]), 20);
}

function bundleFunction(context, func, args) {
context = context || null;
if(typeof func == "string" && context)
func = context[func];
if(!args)
args = [];
else if(!(args instanceof Array))
args = [args];
return function() {
return func.apply(context, args);
};
}
