// Parses in Unix Time and prints out formatted timestamp
function nbaRenderTimeStamp(date,timeString) {

nbaStoryPublishTime = (date) ? new Date(date) : nbaStoryPublishTime;
var days = new Array('Sun','Mon','Tue','Wed','Thur','Fri','Sat');
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var nbaDay = days[nbaStoryPublishTime.getUTCDay()];
var nbaMonth = months[nbaStoryPublishTime.getUTCMonth()];
var nbaYear = nbaStoryPublishTime.getUTCFullYear();
var nbaDate = nbaStoryPublishTime.getUTCDate();
var nbaHour = nbaStoryPublishTime.getHours();
var nbaMinutes = nbaStoryPublishTime.getMinutes();
var nbaAMPM = '';
var nbaDateSuffix='';

//Set am/pm
if (nbaHour   > 11) {
nbaAMPM = "pm"; 
}else{
nbaAMPM = "am"; 
}

// Set Hour
if (nbaHour   > 12) { nbaHour = nbaHour - 12;}

// Add a zero if less than 10
if (nbaMinutes < 10){nbaMinutes = "0" + nbaMinutes;}

// Add number suffix
if (nbaDate == 1){
nbaDateSuffix = "st";
}else if (nbaDate == 2) {
nbaDateSuffix = "nd";
}else if (nbaDate == 3) {
nbaDateSuffix = "rd";
}else{
nbaDateSuffix = "th";
}
document.write(nbaMonth + '&nbsp;' + nbaDate+nbaDateSuffix+'&nbsp;'+ nbaYear + ' ' + nbaHour+ ':' +nbaMinutes+ '&nbsp;' +nbaAMPM);

}

// script tableau T1
	var stories = new Array('T1Story1','T1Story2','T1Story3','T1Story4');
	var rotate = null;
	var r = Math.floor((Math.random()*4) + 1);
	
// script classement C1
	var stories2 = new Array('C1Story1','C1Story2');
	var rotate2 = null;
	var r2 = Math.floor((Math.random()*2) + 1);
	
	
	function RotateT1() {
		ShowT1(r);
		if (r < 4) {
			rotate = setTimeout('RotateT1()',8000);
		} else if (r = 4) {
			r = 0;
			rotate = setTimeout('RotateT1()',8000);
		}
		r++;
	}
	
	function RotateT1Continue(){
		clearTimeout(rotate);
		rotate = null;

		RotateT1();
	}
	function SetPosition(oPosition){
		r = oPosition;
	}
	
	function ShowT1(n) {

		for (i = 0; i < stories.length; i++) {
			if (document.getElementById(stories[i])) { 
				document.getElementById(stories[i]).style.display = (('T1Story' + n) == stories[i]) ? 'block':'none'; 
			}
		}
		
	// Gets current position of the array

	// changes class of current thumb
	var thumbs = document.getElementById('T1Thumbs').getElementsByTagName('a');	
		for (j = 0; j < thumbs.length; j++) {
			thumbs[j].className = ((j + 1) == n) ? 'Selected':'';
		}
		
		//set the positon of the rotate array
		SetPosition(n);
	}





// Headline Tabs
function HideLinks() {
	var MainLinks = new Array ("nbaRailPodsnav1", "nbaRailPodsnav2");
	var SubLinks = new Array ("nbaRailPodsnavL", "nbaRailPodsnavR");
	for (var i=0; i<MainLinks.length; i++) {
		document.getElementById(MainLinks[i]).className = "nbaRailPodsNavItem";
		document.getElementById(MainLinks[i]).hideFocus = true;
	}
	for (var i=0; i<SubLinks.length; i++) {
		document.getElementById(SubLinks[i]).className = "nbaRailPodsnavL hide";
	}
}
function ShowLink(MainLinkId, SubLinkId) {
	document.getElementById(MainLinkId).className = "nbaRailPodsNavItem RailPodsNavactive";
	document.getElementById(SubLinkId).className = "nbaRailPodsnavL show";
}
function ActiveMenu(MainLinkId, SubLinkId) {
	HideLinks();
	ShowLink(MainLinkId, SubLinkId);
}	

// Zebra color for Headline div
function init() {
alternate('nbaTabHeader');
}
function alternate(nbaTabHeader){
 if(document.getElementsByTagName){  
   var list = document.getElementById(nbaTabHeader);  
   var rows = list.getElementsByTagName("li");  
   for(i = 0; i < rows.length; i++){          
 //manipulate rows
     if(i % 2 == 0){
       rows[i].className = "nbaHeadlinesLiBg";
     } 
   }
 }
}

// script classement C1
	var stories2 = new Array('C1Story1','C1Story2');
	var rotate2 = null;
	var r2 = Math.floor((Math.random()*2) + 1);
	
	function RotateC1() {
		ShowC1(r2);
		if (r2 < 2) {
			rotate2 = setTimeout('RotateC1()',8000);
		} else if (r2 = 2) {
			r2 = 0;
			rotate2 = setTimeout('RotateC1()',8000);
		}
		r2++;
	}
	
	function RotateC1Continue(){
		clearTimeout(rotate2);
		rotate2 = null;

		RotateC1();
	}
	
	function SetPosition2(oPosition2){
		r2 = oPosition2;
	}
	
	function ShowC1(n) {

		for (i = 0; i < stories2.length; i++) {
			if (document.getElementById(stories2[i])) { 
				document.getElementById(stories2[i]).style.display = (('C1Story' + n) == stories2[i]) ? 'block':'none'; 
			}
		}
		
	// Gets current position of the array

	// changes class of current thumb
	var thumbs2 = document.getElementById('C1Thumbs').getElementsByTagName('a');	
		for (j = 0; j < thumbs2.length; j++) {
			thumbs2[j].className = ((j + 1) == n) ? 'Selected':'';
		}
		
		//set the positon of the rotate array
		SetPosition2(n);
	}

window.onload = function (){
RotateT1();
RotateC1();
init();
}