/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 5000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(39,39,40); // start color (red, green, blue)
var endcolor=new Array(255,255,255); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="">'; //set opening tag, such as font declarations


fcontent[0]="<a href='http://www.tripadvisor.com/Hotel_Review-g1098922-d545854-Reviews-Alpine_Lodge-St_Arnaud_South_Island.html' target='_blank' title='Rave reviews on TripAdvisor.com'><img src='images/news/tripadvisor.png' width='80' height='40' style='float:right;'/>Rave reviews at TripAdvisor.com … look!</a>";

fcontent[4]="<a href='http://touristtravel.com/blog/2010/03/06/backroads-of-new-zealand-part-3-nelson-lakes-national-park/' target='_blank' title='Backroads of New Zealand'><img src='http://touristtravel.com/blog/wp-content/uploads/2010/03/glider-prep.jpg' width='80' height='40' style='float:right;'/>The Alpine Lodge is in the Travel Blog.</a>";

//fcontent[1]="<a href='http://www.stuff.co.nz/nelson-mail/features/fresh/3333819/Appetite-for-the-great-outdoors' target='_blank' title='Appetite for the Great Outdoors'><img src='images/news/mel_iain.png' width='80' height='40' style='float:right;'/>Mel &amp; Iain at the Alpine Lodge Cafe star in the Nelson Mail.</a>";

fcontent[1]="<a href='starnaud.html?tab=webcam' title='Photo of St Arnaud Range taken in the last minute.'><img src='webcam_image9.jpg' width='80' height='40' style='float:right;'/>Check the webcam here<br/>at St. Arnaud ...</a>";

fcontent[3]="<a href='http://brewersguild.org.nz/beer-loving-bars' title='New Zealand Brewers Guild have the Alpine Lodge listed as a craft/premium beer bar'><img src='images/news/brewersguild.png' width='80' height='40' style='float:right;'/>Brewers Guild list Alpine Lodge for premium beer.</a>";

fcontent[2]="<a href='http://www.glidingnelson.co.nz/Nelson_Lakes_Gliding_Club/Nelson_Lakes_Gliding_Club.html' title='2012 6-day glider training camp!'> <img src='http://2.bp.blogspot.com/-XOiAQMdv3m8/Txpy_HUJOEI/AAAAAAAAAKI/gD8eJm3NGtI/s320/IMG_3232-736724.jpeg' width='80' height='40' style='float:right;'/>February 2012 6-day glider training camp!</a>";

//fcontent[0]="<a href='specials/big_skiandstay2011.png' alt='Ski &amp; Stay $199 Ski Passes and Accommodation' title='Ski &amp; Stay $199 Ski Passes and Accommodation' rel='lightbox'> <img src='images/news/skiandstay.png' width='80' height='40' style='float:right;'/>&quot;Ski &amp; Stay&quot; &nbsp; $199 Rainbow Ski Passes and Accommodation</a>";


closetag='</div>';

var fwidth='240px'; //set scroller width
var fheight='40px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


//function to change content
function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){
    document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent()", delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2)
  document.write('<div id="fscroller" style="width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent


