// Copyright Graham Nott of Star Global, 2000
function settoday() {
   months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
   var dt=new Date();
   var yr=dt.getFullYear();
   var mnth=dt.getMonth();
   var date=dt.getDate();

   var today="" + months[mnth] + " " + date + ", " + yr;
   return today;
}

function newWindow(a) {
      a.target = "_blank";
}

var browse;
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
   browse="ie4";
}
else {
   if((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3))
      browse="ns3";
}


function show (Name) {
 if (browse=="ns3" || browse=="ie4"){
    document [Name].src = eval(Name + 1 + ".src");
    return true;
 }
}

function hide (Name) {
 if (browse=="ns3" || browse=="ie4"){
    document [Name].src = eval(Name + 0 + ".src");
    return true;
 }
}

if (browse=="ns3" || browse=="ie4") {

        nav_generic0 = new Image();
				nav_generic0.src = "nav/nav_generic0.gif";
				nav_generic1 = new Image();
        nav_generic1.src = "nav/nav_generic1.gif";
}


function popup (a, name, w, h) {
	url = a.href;
  var details= "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizeable=yes,status=no,width=" + w + ",height= " + h + " ";
  window.open(url,name,details);
}


function popupView (url, name, w, h) {
  var details= "toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizeable=yes,status=no,width=" + w + ",height= " + h + " ";
  window.open(url,name,details);
}


function jumpURL(object) {
   if (object.options[object.selectedIndex].value != "") {
      newWindow = window.open('','quickLink');
      newWindow.location.href = object.options[object.selectedIndex].value;
   }
}



// array for the randomLogo() function
	var logoArray = new Array();
		// new Array in form of ('src', 'width', 'height', 'alt', 'link', 'caption');
		logoArray[0] = new Array('cheknews', 80, 44, 'Chek News', 'http://www.chtv.com/ch/cheknews/index.html', '');
		logoArray[1] = new Array('tc', 100, 33, 'The Times Colonist', 'http://www.canada.com/victoriatimescolonist/index.html', '');
		logoArray[2] = new Array('ocean', 60, 39, 'Ocean 98.5', 'http://www.ocean985.com/', '');


function randomLogo() {

	////----Start of number selection----////
	// the highest key in the logoArray
	var logoArrayLength = logoArray.length;

	// array will be populated with random numbers representing the logos to be displayed
	var randNumbersArray = new Array();

	var x = 0;
	var tempNum;
	// this loop selects 3 random and unique numbers
	for(x=0;x<3;x++) {
	  tempNum = Math.floor(Math.random()*logoArrayLength);
		// if the random number is 1 the temp number will be one higher than the highest key in the
		// logoArray.  subtracting 1 from the tempNum will fix this.
		if (tempNum == logoArrayLength) {
			tempNum = tempNum - 1;
		}

		// check if tempNum is already in the randNumbersArray.
		var i = 0;
		var duplicateTest = 0;
		for(i=0;i<=randNumbersArray.length;i++) {
			if(tempNum == randNumbersArray[i]) {
				duplicateTest = 1;
			}
		}

		// If the number is not a duplicate add it to the array, other wise decrement the counter so an
		// extra loop is preformed, and a new number selected
		if(duplicateTest != 1) {
			randNumbersArray[x] = tempNum;
		} else {
			x--;
			duplicateTest = 0;
		}
	}
	////----End of number selection----////


	////---- Begin writing HTML Output ----////
	var logoHTML = "<table cellpadding='0' cellspacing='0' border='0' id='bottomlogos'>";
	var tempSrc;
	var tempWidth;
	var tempHeight;
	var tempAlt;
	var tempLink;
	var tempCaption
	var tempArrayNum;

	for(x=0;x<randNumbersArray.length;x++) {
		tempArrayNum = randNumbersArray[x];
		tempSrc = logoArray[tempArrayNum][0];
		tempWidth = logoArray[tempArrayNum][1];
		tempHeight = logoArray[tempArrayNum][2];
		tempAlt = logoArray[tempArrayNum][3];
		tempLink = logoArray[tempArrayNum][4];
		tempCaption = logoArray[tempArrayNum][5];

		// logoHTML = logoHTML + "<td><img src='images/logos/" + tempSrc + ".gif' width='" + tempWidth + "' height='" + tempHeight + "' alt='" + tempAlt + "' /></td>";
		
		logoHTML = logoHTML + "<td>";
		
		if(tempLink != '') {
			logoHTML = logoHTML + "<a href='" + tempLink + "' onclick='newWindow(this);'>";
		}
		
		logoHTML = logoHTML + "<img src='images/logos/" + tempSrc + ".gif' width='" + tempWidth + "' height='" + tempHeight + "' alt='" + tempAlt + "' />"

		if(tempLink != '') {
			logoHTML = logoHTML + "</a>";
		}
		
		if(tempCaption != '') {
			if(tempLink != '') {
				logoHTML = logoHTML + "<a href='" + tempLink + "' onclick='newWindow(this);'>";
			}
			
			logoHTML = logoHTML + tempCaption;
			
			if(tempLink != '') {
				logoHTML = logoHTML + "</a>";
			}
		}
		
		logoHTML = logoHTML + "</td>";
	}

	logoHTML = logoHTML + "</table>";

	document.getElementById("rotatinglogos").innerHTML=logoHTML;
	////----End of writing HTML Output----////

	// call the function after 5000 milliseconds delay, to rotate the logos
	// temporarily deactivate the Timeout until there are more logos to rotate through
	// setTimeout("randomLogo()",5000);
}