﻿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: [
"More than 3,000 children are diagnosed with leukemia every year.",
"More than 10 percent of all Americans diagnosed with leukemia are children.",
"Someone is diagnosed with leukemia or lymphoma every 5 minutes.",
"Leukemia accounts for nearly thirty percent of all cancers in children.",
"Leukemia causes more deaths than any other cancer among children.",
"At present there is no cure for leukemia.",
"The causes of most childhood cancers are unknown.",
"There are about 29,000 new cases of leukemia each year in the USA.",
"Sixty percent of leukemias are due to acute forms of leukemias, which signify rapidly progressing diseases.",
"Seventy-five percent are acute lymphoblastic leukemias.",
"Acute Lymphocytic Leukemia (ALL) accounts for approximately 75% of the leukemia cases among children.",
"Children with Down Syndrome have an increased risk of developing leukemia.",
"Cancer is the leading cause of death by disease in children under the age of 15 in the United States.",
"1 in 330 children will have the disease by age 20.",
"The median age when a child gets cancer is age 6.",
"Approximately 10,730 new cases of pediatric cancer are expected to be diagnosed in children ages 0-14 this year, or the equivalent of an average classroom of 30 children being diagnosed with cancer every day.",
"The causes of most childhood cancers are unknown.",
"At present, childhood cancer cannot be prevented.",
"Cancer in childhood occurs regularly, randomly, and spares no ethnic group, socioeconomic class, or geographic region.",
"The incidence of cancer among adolescents and young adults is increasing at a greater rate than any other age group.",
"Children with Down Syndrome have an increased risk of developing leukemia.",
"The length of treatment for childhood cancer ranges from 3 months to 2.5 years.",
"One in every four elementary schools has a child with cancer.",
"The average high school has two students who are current or former cancer patients.",
"Every 16 hours a child with neuroblastoma dies.",
"Today, up to 75% of the children with cancer can be cured, yet some forms of childhood cancers have proven so resistant to treatment that, in spite of research, a cure is still elusive."
]
};

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]), 10000);
return;
}
setOpacity(el, v);
setTimeout(bundleFunction(null, unfadeText, [el, tg]), 10);
}

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]), 10);
}

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);
};
}
