// JavaScript Document
var d = document;

//Horizontal Scrolling Nav Code
var Timer;

function ScrollLeft(divName)
{
  Timer = setInterval("document.getElementById('" + divName + "').scrollLeft -= 6", 35);
//  alert("document.getElementById('" + divName + "').scrollLeft -= 6");
}
function ScrollRight(divName)
{
  Timer = setInterval("document.getElementById('" + divName + "').scrollLeft += 6", 35);
//  alert("document.getElementById('" + divName + "').scrollLeft += 6");
}

//Set Home Nav Array
var homeNavArray = new Array("heroesPromoLayer","heroesAboutLayer","heroesGalleriesLayer","heroesVideoLayer","heroesExclusivesLayer","heroesCommunityLayer","heroesDownloadsLayer");

//Define CSS Sub Nav Fields to Swap Code
function showHide(lyrId, prop, display) {
	var lyrObj = (d.layers)?d[lyrId]:d.all?d.all[lyrId].style:d.getElementById(lyrId).style;
	lyrObj.visibility = prop;
	lyrObj.display = display;
}

//Swap Sub Nav Visible Layers Code
function showHomeNavSection(lyrId) {
	for (var i=0; i<homeNavArray.length; i++) {
		if (lyrId == homeNavArray[i]) {
			showHide(homeNavArray[i], 'visible', 'inline');
		} else {
			showHide(homeNavArray[i], 'hidden', 'none');
		}
	}
}

//Define CSS Sub Nav Fields to Swap Code
function showHide(lyrId, prop, display) {
	var lyrObj = (d.layers)?d[lyrId]:d.all?d.all[lyrId].style:d.getElementById(lyrId).style;
	lyrObj.visibility = prop;
	lyrObj.display = display;
}

//Swap Sub Nav Visible Layers Code
function showProfileSection(lyrId) {
	for (var i=0; i<subNavArray.length; i++) {
		if (lyrId == subNavArray[i]) {
			showHide(subNavArray[i], 'visible', 'inline');
		} else {
			showHide(subNavArray[i], 'hidden', 'none');
		}
	}
}


function genRanNum(limit){
	var ranNum = Math.floor(Math.random()*limit);
	return ranNum;	
}


function getRanBG(){
	var ranNum = genRanNum(3);
	
	heroesPromoBg ="/heroes/images/main/promos/heroes_photoClaireBG.jpg";
	
/*	if (ranNum == 0) {
		heroesPromoBg ="/heroes/images/main/promos/heroes_fanartBG1_lg.jpg";
	}
	else if (ranNum == 1) {
		heroesPromoBg ="/heroes/images/main/promos/heroes_fanartBG2_lg.jpg";
	}
	else {
		heroesPromoBg ="/heroes/images/main/promos/heroes_fanartBG3_lg.jpg";
	}*/
	return heroesPromoBg;
}

function getRanContent(){

	//iSMS
/*document.write('<h3 class="gray1">PLAY INSIDER SMS FOR <br />A CHANCE TO WIN $10K</h3><p>Get real-time polls and trivia quizzes <br />on your mobile as you watch. Plus:<br /> $10K sweepstakes! <a href="/heroes/sprint/isms/" class="gray2"> Learn more</a></p><!--Heroes Main Promo Image Link-->');*/


	//Sneak Peeks
/*document.write('<h3 class="gray1">HEROES: SNEAK PEEK</h3><p>Watch an online preview<br /> of Monday\'s Heroes. <br /> <a href="/heroes/sprint/sneak-peek/" class="gray2">Click here</a></p><!--Heroes Main Promo Image Link-->');*/
	
	//Cast Commentary
/*	document.write('<h3 class="gray1">CAST COMMENTARY</h3><p>Check out full-length replays with<br /> commentary from creators and cast.<br /><a href="/heroes/sprint/cast-commentary/" class="gray2">Click here</a></p><!--Heroes Main Promo Image Link-->');*/

	//Episode Recaps
document.write('<h3 class="gray1">NEW CLAIRE  <br />PHOTO GALLERY</h3><p>Browse the best of <br />Claire from Season 3.<br /><a href="/heroes/photos/gallery#gallery=3728" class="gray2">Click here</a></p><!--Heroes Main Promo Image Link-->');

	//Photo Gallery 
/*	document.write('<h3 class="gray1">HEROES PHOTO <br/>GALLERIES</h3><p>Browse pix of <br />your favorite Heroes. <br /><a href="/heroes/photos/categories/the-cast/1361/" class="gray2">Click here</a></p><!--Heroes Main Promo Image Link-->');
*/
}

function promote(castImage,castLink,altTag){
	this.castImage = castImage;
	this.castLink = castLink;
	this.altTag = altTag;
}

function genRanPromo(){
	var promotes = new Array();
	
	var ipath = '/Heroes/images/main/promos/';
	var lpath = '/Heroes/photos/#cat=1100';
	
	promotes[0] = new promote(ipath + 'heroes_galleryMohinder.jpg', lpath ,'Sendhil Ramamurthy');
	promotes[1] = new promote(ipath + 'heroes_galleryPeter.jpg', lpath ,'Milo Ventimiglia');
	promotes[2] = new promote(ipath + 'heroes_galleryMaya.jpg', lpath ,'Dania Ramirez');
	promotes[3] = new promote(ipath + 'heroes_gallerySylar.jpg', lpath ,'Zachary Quinto');
	promotes[4] = new promote(ipath + 'heroes_galleryNiki.jpg', lpath ,'Ali Larter');
	promotes[5] = new promote(ipath + 'heroes_galleryClaire.jpg', lpath ,'Hayden Panettiere');
	
	var i = genRanNum(promotes.length);
	
	document.write('<a href="' + promotes[i].castLink + '"><img src="' + promotes[i].castImage + '" alt="' + promotes[i].altTag + '" /></a>');
  document.write('<h4>Cast Gallery</h4>');
  document.write('<p>Great photos, right from the set.</p>');
  document.write('<a href="' + promotes[i].castLink + '" class="gray2">Click here</a>');
}


