var show_img_path = "/CNNI/images/whatson/";


var show_images = new Array
(
//"asia.now.jpg",
//"biz.news.jpg",
"biz.traveller.jpg",
//"business.central.jpg",
"business.international.jpg",
//"diplomatic.license.jpg",
//"global.challenges.jpg",
"inside.africa.jpg",
//"insight.jpg",
"international.correspondent.jpg",
"larry.king.live.jpg",
"living.golf.jpg",
//"news.biz.today.jpg",
//"people.in.the.news.jpg",
"talk.asia.jpg",
"the.daily.show.jpg",
// "the.music.room.jpg",
"world.business.today.jpg",
"world.news.jpg",
"world.report.jpg",
"world.sport.jpg",
"your.world.today.jpg",
"mainsail.jpg",
"lateedition.jpg",
//"spark.jpg",
"presents.jpg",
//"go.jpg",
"cnntoday.jpg",
"wdzasia.jpg",
"wdzeurope.jpg"
//"design360.jpg"
);



var show_titles = new Array
(
//"Asia Now",
//"Biz News",
"CNN Business Traveller",
//"Business Central",
"Business International",
//"Diplomatic License",
//"Global Challenges",
"Inside Africa",
//"Insight",
"International Correspondents",
"Larry King Live",
"Living Golf",
//"News Biz Today",
//"People in the News",
"Talk Asia",
"The Daily Show: Global Edition",
//"The Music Room",
"World Business Today",
"World News",
"World Report",
"World Sport",
"Your World Today",
"MainSail",
"Late Edition",
//"Spark",
"CNN Presents",
//"Global Office",
"CNN Today",
"World News Asia",
"World News Europe"
//"Design 360"
);



var show_blurbs = new Array
(
//"Tune in for international news and business info with a focus on Asia.",
//"Check out the latest news and business developments from around the world.",
"For business people on the go: get the latest travel tips and insights.",
//"Catch the European financial markets as they open and digest the analysis of their global impact.",
"Find out how business, global and political news are linked together to impact your world.",
//"Learn how the United Nations impacts world events in this weekly in-depth report.",
//"Shines light on sustainable development and improvements in science and technology.",
"Get an inside look at the political, economic and cultural affairs in Africa with host Femi Oke.",
//"Tune in for a thought-provoking look at a critical global issue or key news story of the day.",
"Join some of the world's leading international journalists for a discussion on current news topics.",
"Tune in for interviews with Hollywood stars, well-known politicians and the day’s newsmakers.",
"A weekly look at one of the world's most popular sports, both on and off the course.",
//"All the top global news stories, business info, sport and weather updates, anchored from Hong Kong.",
//"An exciting look at the people and stories you want to know more about.",
"See intimate interviews with Asia's most intriguing personalities from politics to film and business to sport.",
"U.S. comedian Jon Stewart parodies the news -- tune in on the weekends!",
// "Tune in this weekend for the hottest musical acts and rising talents from around the world",
"Join us for a complete picture of the day's global business news with a European focus.",
"For the latest global news, sports, business and weather information-- tune in.",
"See the world as it sees itself through informative and entertaining reports from broadcasters around the globe.",
"Watch the definitive world sports show that offers key highlights and the latest scores.",
"Go beyond the headlines for penetrating analysis and provocative questioning of the top stories of the day.",
"Sail the seven seas each month\!",
"Get the latest news from Washington and insight from some of the most influential newsmakers around the world.",
//"Watch how technology sparks change in business and our lives.",
"Don\'t miss this award-winning documentary series.",
//"Tips and management techniques for the global business executive.",
"All the essential news you need to start your day\!",
"Tune in to this newscast presented from Hong Kong by Andrew Stevens.",
"Tune in to this newscast presented from London by Fionnuala Sweeney."
//"Get a 360 degree view of design around the world."
);



var show_urls = new Array
(
//"/CNNI/Programs/asia.now/",
//"/CNNI/Programs/biznews/",
"/CNNI/Programs/business.traveller/",
//"/CNNI/Programs/business.central/",
"/CNNI/Programs/business.international/",
//"/CNNI/Programs/diplomatic.license/",
//"/CNNI/Programs/global.challenges/",
"/CNNI/Programs/insideafrica/",
//"/CNNI/Programs/insight/",
"/CNNI/Programs/intl.correspondents/",
"/CNN/Programs/larry.king.live/",
"/CNNI/Programs/living.golf/",
//"/CNNI/Programs/news.biz.today/",
//"/CNN/Programs/people/",
"/ASIA/talkasia/",
"/CNNI/Programs/daily.show/",
// "/CNNI/Programs/music.room/",
"/CNNI/Programs/world.business.today/",
"/CNNI/Programs/world.news/",
"/CNNI/Programs/world.report/",
"/WORLDSPORT/",
"/CNNI/Programs/ywt/",
"/CNNI/Programs/main.sail/",
"/CNN/Programs/late.edition/",
//"/CNNI/Programs/spark/",
"/CNNI/",
//"/CNNI/Programs/global.office/",
"/CNNI/Programs/cnntoday/",
"/CNNI/Programs/world.news/",
"/CNNI/Programs/world.news/"
//"/CNNI/Programs/design360/"
);




var num_shows;
var shows = new Array(num_shows);
var show_preloaded_images = new Array();
		         
		         
							 
							 
		         
		         	



/******************************************
 * Returns true if the image has not been *
 * picked, false if it has.               *
 ******************************************/

function isNewShow(num) {
	for (var i=0; i < num_shows; i++) {
		if (shows[i] == num) {
			return 0;
		}
	}
	return 1;
}







/**************************************
 * Randomly selects a new image index *
 **************************************/
 
function getNewShow() {
	var n;
	while (1) {
		n = Math.floor(Math.random()*(show_images.length));
		if (isNewShow(n) == 1) {
			return n;
		}
	}

}




/***************************************************
 * Selects the images to be displayed, then stores *
 * the indexes of the images in an array           *
 ***************************************************/

function SelectRandomShows() {
	shows = new Array();
	for (var i=0; i < num_shows; i++) {
		shows[i] = getNewShow();
	}

}




function PreLoadShows() {
	for (var i=0;i < num_shows; i++){
	   show_preloaded_images[i] = new Image();
		show_preloaded_images[i].src = show_img_path + show_images[shows[i]];
	}	
}






function DisplayShows() {
	document.whatsOnImage1.src = show_preloaded_images[0].src;
	document.whatsOnImage1.alt = show_titles[shows[0]];
	//setShowText('whatsOnHead1', show_titles[shows[0]]);
	//setShowText('whatsOnBlurb1', show_blurbs[shows[0]]);

	document.whatsOnImage2.src = show_preloaded_images[1].src
	document.whatsOnImage2.alt = show_titles[shows[1]];
	//setShowText('whatsOnHead2', show_titles[shows[1]]);
	//setShowText('whatsOnBlurb2', show_blurbs[shows[1]]);
}





function startShows(num) {
	num_shows = num;
	SelectRandomShows();
	PreLoadShows();
}








function getLayer(id) { 
	var l = document.getElementById ? document.getElementById(id) : 
			  document.all ? document.all[id] : 
			  document.layers ? document.layers[id] : 
			  null;
	return l; 
} 




function setShowText(id, content) {
	var lay;
	if (document.getElementById || document.all) { 
		lay = getLayer(id); 
		lay.innerHTML = content;	
	} 
	if (document.layers) {
		lay = getLayer(id + "_NS"); 
		lay.document.open();
		if (id.indexOf("Head") > 0)
			lay.document.write('<span class="cnnWebPromoHead">'); 
		else
			lay.document.write('<span class="cnnWebPromoBlurb">'); 
		lay.document.write(content);
		lay.document.write('</span>');
		lay.document.close(); 
	}
} 


function loadshow(i) {
	document.location = show_urls[shows[i]];
}



function checkNavigator() {
	if (navigator.appName == "Netscape" && navigator.appVersion.substr(0,1) == "4") {
		document.write('<div id="whatsOnHead1_NS">&nbsp;</div>');
		document.write('<div id="whatsOnBlurb1_NS">&nbsp;</div>');
		document.write('<div id="whatsOnHead2_NS">&nbsp;</div>');
		document.write('<div id="whatsOnBlurb2_NS">&nbsp;</div>');
	}
}
