// source: http://javascript.internet.com/text-effects/
// http://javascript.internet.com/text-effects/fading-marquee.html

function setupFadeLinks() {
	arrFadeLinks[0] = "http://www.columbiasurgery.org/news/2009_heart_center.html";
	arrFadeTitles[0] = "NYP/CUMC Heart Center Opens";
	arrFadeLinks[1] = "http://asp.cumc.columbia.edu/facdb/profile_list.asp?uni=crs2&DepAffil=Surgery";
	arrFadeTitles[1] = "Craig R. Smith, MD, Appointed Chairman of Surgery and Surgeon-in-Chief";
	arrFadeLinks[2] = "http://www.prnewswire.com/news-releases/thoratec-announces-fda-approval-of-heartmate-iir-for-destination-therapy-82182087.html";
	arrFadeTitles[2] = "HeartMate II LVAS Receives Approval as Destination Therapy for Advanced Heart Failure";
	arrFadeLinks[3] = "http://asp.cumc.columbia.edu/facdb/profile_list.asp?uni=bs170&DepAffil=Surgery";
	arrFadeTitles[3] = "Dr. Schrope named surgical director of Valley Hospital Weight Loss Surgery Center";
	arrFadeLinks[4] = "http://asp.cpmc.columbia.edu/facdb/profile_list.asp?uni=eb2704&DepAffil=Surgery";
	arrFadeTitles[4] = "Emile Bacha, MD, Joins Surgery Faculty as Director, Pediatric Cardiac Surgery";
	arrFadeLinks[5] = "http://www.livermd.org/news_cldt.html#prservation";
	arrFadeTitles[5] = "Liver Preservation Moves into the 21st Century";
	arrFadeLinks[6] = "http://www.livermd.org/news_cldt.html#brooklyn";
	arrFadeTitles[6] = "Brooklyn woman on brink of death thrives after five transplants";
	arrFadeLinks[7] = "http://www.columbiasurgery.org/pat/lungtx/news_lungtx.html#ecmo";
	arrFadeTitles[7] = "Dr. Bacchetta and ECMO Featured in USA Today Profile of Lung Transplant Patient";
	arrFadeLinks[8] = "http://www.columbiasurgery.org/news/news/newsmakers/index_2009.html#NYT";
	arrFadeTitles[8] = "Columbia Abdominal Surgeons Featured in NYT Spotlight of 43-hour Ex Vivo Surgery";
	arrFadeLinks[9] = "http://www.facebook.com/columbiasurgery";
	arrFadeTitles[9] = "Surgery Launches on Facebook and Twitter";
	arrFadeLinks[10] = "http://www.columbiasurgery.org/news/pat/cardiac/news_cardiac.html#anniversary";
	arrFadeTitles[10] = "25th Anniversary of Pediatric Heart Transplantation for Columbia and World";	
	arrFadeLinks[11] = "http://www.columbiasurgery.org/news/newsmakers/index_2009.html#joseph";
	arrFadeTitles[11] = "Dr. Joseph Speaks About Male Breast Cancer on Today Show";
	arrFadeLinks[12] = "http://www.columbiasurgery.org/news/oz.html#Premieres";
	arrFadeTitles[12] = "Dr. Oz Show Premieres";
	arrFadeLinks[13] = "http://www.columbiasurgery.org/thoracic/news_thoracic.html#pte";
	arrFadeTitles[13] = "Dr. Bacchetta leads first Reported NYC Area PTE Procedure";
	arrFadeLinks[14] = "http://www.livermd.org/news_nytimes_2009.html";
	arrFadeTitles[14] = "CLDT Emergency Liver Transplant Profiled by NYT";	
	arrFadeLinks[15] = "http://www.columbiasurgery.org/news/index_2009.html#100_aortic";
	arrFadeTitles[15] = "PCI Aortic Valve Replacement Volume Highest in U.S.";
	arrFadeLinks[16] = "http://www.columbiasurgery.org/news/si/index_2009.html#pte";
	arrFadeTitles[16] = "New Program Offers Innovative Surgery for Chronic Pulmonary Emboli";
	arrFadeLinks[17] = "http://www.columbiasurgery.org/news/newsmakers/index_2009.html#grant";
	arrFadeTitles[17] = "Dr. Grant on NPR's The Leonard Lopate Show";
	arrFadeLinks[18] = "http://www.columbiasurgery.org/news/index_2009.html#us_news";
	arrFadeTitles[18] = "NYP is #1 in New York, #6 in the Nation in 2009";	
	arrFadeLinks[19] = "http://www.columbiasurgery.org/news/index_2009.html#RX";
	arrFadeTitles[19] = "Surgery External Affairs Launches Marketing Services";	
	arrFadeLinks[20] = "http://www.columbiasurgery.org/news/index_2009.html#ny_mag";
	arrFadeTitles[20] = "15 Columbia Surgeons are NY magazine 2009 Top Doctors";	
}

// You can also play with these variables to control fade speed, fade color, and how fast the colors jump.

var m_FadeOut = 255;
var m_FadeIn=0;
var m_Fade = 0;
var m_FadeStep = 3;
var m_FadeWait = 8600;
var m_bFadeOut = true;

var m_iFadeInterval;
var m_iFadeInterval;

window.onload = Fadewl;

var arrFadeLinks;
var arrFadeTitles;
var arrFadeCursor = 0;
var arrFadeMax;

function Fadewl() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
  arrFadeLinks = new Array();
  arrFadeTitles = new Array();
  setupFadeLinks();
  arrFadeMax = arrFadeLinks.length-1;
  setFadeLink();
}

function setFadeLink() {
  var ilink = document.getElementById("fade_link");
  ilink.innerHTML = arrFadeTitles[arrFadeCursor];
  ilink.href = arrFadeLinks[arrFadeCursor];
}

function fade_ontimer() {
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
      setFadeLink();
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("fade_link");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}
