// init vars
var rsTimer = null;
var spotlight_index = 0;
var news_index = 0;
var review_index = 0;
var photo_index = 0;
var dontUnPause = 0;

function SetDontUnPause() {
  dontUnPause = 1;
  var pauseBtn = document.getElementById('spotlight_pause');
  if(pauseBtn) {
    pauseBtn.href = "javascript:ResumeSpotlight(1)";
	pauseBtn.title = "Click To Resume Slide Show";
  }
}

function SetDoUnPause() { 
  dontUnPause = 0;
  var pauseBtn = document.getElementById('spotlight_pause');
  if(pauseBtn) {
    pauseBtn.href = "javascript:PauseSpotlight(1)";
	pauseBtn.title = "Click To Pause Slide Show";
  }
}

function PauseSpotlight(u) {
  if(u) { SetDontUnPause(); }
  if(rsTimer) {
    var img = document.images['spotlight_pause_btn'];
    if(img) { img.src="/images/pause_btn_off.gif" }
    clearTimeout(rsTimer);
  }
}

function ResumeSpotlight(u) {
  if(u) { SetDoUnPause(); }
  if(!dontUnPause) {
    var img = document.images['spotlight_pause_btn'];
    if(img) { img.src="/images/pause_btn.gif" }
    if(rsTimer) { clearTimeout(rsTimer); }
    rsTimer = setTimeout("rotateSpotlight()", 7000);
  }
}

function NextSpotlight() {
  PauseSpotlight();
  IncreaseSpotlightIndex();
  AdjustSpotlightIndex();
  UpdateSpotlight(0);
  SetDontUnPause();
}

function PreviousSpotlight() {
  PauseSpotlight();
  DecreaseSpotlightIndex();
  AdjustSpotlightIndex();
  UpdateSpotlight(0);
  SetDontUnPause();
}

function UpdateSpotlight(doTimer) {
  var ci = spotlight_info[spotlight_index];
  var lyr = document.getElementById('spotlightcontainer');
  if(lyr) {
    var txt = '<table cellpadding=10 cellspacing=0 border=0 width=100% height=200>';
    txt += '<tr>';
    txt += '<td align=center valign=top width=180>';
    txt += '<a href="'+ci['link']+'" title="'+ci['linktitle']+'"><img src="'+ci['cover']+'" width=180 border=0></a></td>';
    txt += '<td align=left valign=top width=100%>';
    txt += '<b><a href="'+ci['link']+'" title="'+ci['linktitle']+'" style="font-size:14pt;color:#000000;text-decoration:none;">'+ci['title']+'</a></b>';
	txt += '<BR>presented by '+ci['artisttitle'];
    txt += '<BR><BR>';
    txt += '<b>Details:</b><BR>';
    txt += 'Genre: '+ci['genre']+'<a href="'+ci['cartlink']+'" title="'+ci['linktitle']+'"><img src="/images/pdownload_btn.gif" border=0 align=right alt="'+ci['linktitle']+'"></a><BR>';
    txt += 'Rating: '+ci['rating']+'<BR>';
    txt += 'Audio: '+ci['audio']+'<BR>';
    txt += 'Quality: '+ci['quality']+'<BR>';
    txt += 'Total Size: '+ci['size']+'<BR></td>';
    txt += '</tr></table>';
	lyr.innerHTML = txt;
	//if(doTimer) { rsTimer = setTimeout("rotateSpotlight()", 30000); }
  }
}

function AdjustSpotlightIndex() {
  var maxIndex = spotlight_info.length - 1;
  if(spotlight_index > maxIndex) { spotlight_index = 0; } 
  else if (spotlight_index < 0) { spotlight_index = maxIndex; }
}

function IncreaseSpotlightIndex() { 
  spotlight_index++;
}

function DecreaseSpotlightIndex() {
  spotlight_index--;
}

function rotateSpotlight() {
  return; // remove this
  if(spotlight_info.length > 0) {
    IncreaseSpotlightIndex();
    AdjustSpotlightIndex();
    UpdateSpotlight(1);
  }
}

function NextNews() {
  if(news_info.length > 1) {
    IncreaseNewsIndex();
    AdjustNewsIndex();
    UpdateNews();
  }
}

function PreviousNews() {
  if(news_info.length > 1) {
    DecreaseNewsIndex();
    AdjustNewsIndex();
    UpdateNews();
  }
}

function UpdateNews() {
  var ci = news_info[news_index];
  var xl = news_info.length;
  var lyr = document.getElementById('newscontainer');
  if(lyr) {
    var txt = '<table cellpadding=0 cellspacing=2 border=0 width=100% height=300>';
    txt += '<tr>';
    txt += '<td align=left valign=top width=100% height=100%>';
    txt += '<b>'+ci['title']+'</b><BR><BR>';
    txt += ci['body'];
    txt += '</td></tr></table><BR>';
    txt += '<table cellpadding=0 cellspacing=0 border=0 width=100%>';
    txt += '<tr>';
    txt += '<td align=left width=20><a href="javascript:PreviousNews()" title="Previous Headline"><img name="news_back_btn" src="/images/back_btn.gif" border=0></a></td>';
    txt += '<td align=center width=100% valign=middle><i>Posted '+ci['posted']+' Ago</i></td>';
    txt += '<td align=right width=20><a href="javascript:NextNews()" title="Next Headline"><img name="news_next_btn" src="/images/next_btn.gif" border=0></a></td>';
    txt += '</tr>';
    txt += '</table>';
	lyr.innerHTML = txt;
	for(var x=0; x<xl; x++) {
	  var indicatorName = 'news_indicator_'+(x+1);
	  var imgSrc = (x == news_index) ? '/images/indicator_on.gif' : '/images/indicator_off.gif'; 
      var indimg = document.images[indicatorName];
      if(indimg) { indimg.src = imgSrc }
	}
  }
}

function AdjustNewsIndex() {
  var maxIndex = news_info.length - 1;
  if(news_index > maxIndex) { news_index = 0; }
  else if (news_index < 0) { news_index = maxIndex; }
}

function IncreaseNewsIndex() {
  news_index++;
}

function DecreaseNewsIndex() {
  news_index--;
}

function NextReview() {
  if(review_info.length > 1) {
    IncreaseReviewIndex();
    AdjustReviewIndex();
    UpdateReview();
  }
}

function PreviousReview() {
  if(review_info.length > 1) {
    DecreaseReviewIndex();
    AdjustReviewIndex();
    UpdateReview();
  }
}

function UpdateReview() {
  var ci = review_info[review_index];
  var xl = review_info.length;
  var lyr = document.getElementById('reviewcontainer');
  if(lyr) {
    var txt = '<table cellpadding=2 cellspacing=2 border=0 width=150 height=300>';
    txt += '<tr>';
    txt += '<td valign=top align=center width=130 height=130><a href="'+ci['link']+'" title="'+ci['linktitle']+'"><img src="'+ci['cover']+'" width=110 border=0></a><BR><BR><p align=left><b>'+ci['user']+' said ... </b><BR>'+ci['body']+'</p></td>';
    txt += '</tr>';
    txt += '</table><BR>';
    txt += '<table cellpadding=0 cellspacing=0 border=0 width=100%>';
    txt += '<tr>';
    txt += '<td align=left width=20><a href="javascript:PreviousReview()" title="Previous Review"><img name="news_back_btn" src="/images/back_btn.gif" border=0></a></td>';
    txt += '<td align=center width=100% valign=middle><i>Posted '+ci['posted']+' Ago</i></td>';
    txt += '<td align=right width=20><a href="javascript:NextReview()" title="Next Review"><img name="news_next_btn" src="/images/next_btn.gif" border=0></a></td>';
    txt += '</tr>';
    txt += '</table>';
	lyr.innerHTML = txt;
	for(var x=0; x<xl; x++) {
	  var indicatorName = 'reviews_indicator_'+(x+1);
	  var imgSrc = (x == review_index) ? '/images/indicator_on.gif' : '/images/indicator_off.gif'; 
      var indimg = document.images[indicatorName];
      if(indimg) { indimg.src = imgSrc }
	}
  }
}

function AdjustReviewIndex() {
  var maxIndex = review_info.length - 1;
  if(review_index > maxIndex) { review_index = 0; }
  else if (review_index < 0) { review_index = maxIndex; }
}

function IncreaseReviewIndex() { 
  review_index++;
}

function DecreaseReviewIndex() {
  review_index--;
}

function NextPhoto() {
  if(photo_info.length > 1) {
    IncreasePhotoIndex();
    AdjustPhotoIndex();
    UpdatePhoto();
  }
}

function PreviousPhoto() {
  if(photo_info.length > 1) {
    DecreasePhotoIndex();
    AdjustPhotoIndex();
    UpdatePhoto();
  }
}

function UpdatePhoto() {
  var ci = photo_info[photo_index];
  var xl = photo_info.length;
  var lyr = document.getElementById('photocontainer');
  if(lyr) {
    var txt = '<table cellpadding=0 cellspacing=2 border=0 width=100% height=300>';
    txt += '<tr>';
    txt += '<td valign=top align=center class="dottedbottom">';
    txt += '<table cellpadding=3 cellspacing=0 border=0>';
    txt += '<tr>';
    txt += '<td valign=top align=center><a href="'+ci['link']+'" title="'+ci['titleenc']+'"><img src="'+ci['image']+'" width=150 border=0></a></td>';
    txt += '</tr>';
    txt += '<tr>';
    txt += '<td valign=top align=left>';
    txt += '&raquo;&nbsp;<a href="'+ci['link']+'" title="'+ci['titleenc']+'">'+ci['title']+'</a><BR>';
    txt += '<font color="#FFFFFF">&raquo;&nbsp;</font>from <i><a href="'+ci['glink']+'" title="'+ci['ptitleenc']+'">'+ci['ptitle']+'</a></i><BR></td>';
    txt += '</tr>';
    txt += '</table></td>';
    txt += '</tr>';
    txt += '</table><BR>';
    txt += '<table cellpadding=0 cellspacing=0 border=0 width=100%>';
    txt += '<tr>';
    txt += '<td align=left width=20><a href="javascript:PreviousPhoto()" title="Previous Photo Album"><img name="news_back_btn" src="/images/back_btn.gif" border=0></a></td>';
    txt += '<td align=center width=100% valign=middle><i>Posted '+ci['posted']+' Ago</i></td>';
    txt += '<td align=right width=20><a href="javascript:NextPhoto()" title="Next Photo Album"><img name="news_next_btn" src="/images/next_btn.gif" border=0></a></td>';
    txt += '</tr>';
    txt += '</table>';
	lyr.innerHTML = txt;
	for(var x=0; x<xl; x++) {
	  var indicatorName = 'photo_indicator_'+(x+1);
	  var imgSrc = (x == photo_index) ? '/images/indicator_on.gif' : '/images/indicator_off.gif'; 
      var indimg = document.images[indicatorName];
      if(indimg) { indimg.src = imgSrc }
	}
  }
}

function AdjustPhotoIndex() {
  var maxIndex = photo_info.length - 1;
  if(photo_index > maxIndex) { photo_index = 0; }
  else if (photo_index < 0) { photo_index = maxIndex; }
}

function IncreasePhotoIndex() { 
  photo_index++;
}

function DecreasePhotoIndex() {
  photo_index--;
}

// initiate rotate
//var rsTimer = setTimeout("rotateSpotlight()", 7000);

