  function getTimestamp(len) {

	// formats the time into YYYYMMDDHHMiSS
	// option param to specifiy how many chars to return - so that you can limit it to hours mins etc
	// len = 11 would return to the 10th min
	
	timeStamp = new Date();
	tsYear = timeStamp.getYear();
	if (tsYear < 2000) tsYear = 1900 + tsYear;
	
	tsMonth = timeStamp.getMonth() + 1 + "";
	if (tsMonth.length == 1) tsMonth = "0" + tsMonth;

	
	tsDay = timeStamp.getDate() + "";
	if (tsDay.length == 1) tsDay = "0" + tsDay;
	
	tsHours = timeStamp.getHours() + "";
	if (tsHours.length == 1) tsHours = "0" + tsHours;
	
	tsMins = timeStamp.getMinutes() + "";
	if (tsMins.length == 1) tsMins = "0" + tsMins;
	
	tsVar = tsYear + tsMonth + tsDay + tsHours + tsMins;
	
	if (len) {		
		return (tsVar.substr(0,len));	
	} else {
		return tsVar;
	}
	 
}function renderLdb(response) {					
	
	var cardHTML = '';
		
	var totalCards = response.scores.card.length;

	if (totalCards > 0) {

		// we have scorecards		
		
		for(var i = 0; i < totalCards; i++) {
			currCard = response.scores.card[i];
			cardHTML += '<table class="ms-tables-s3" width="100%">';
			cardHTML += '<caption>' + currCard.name + '</caption>';
			cardHTML += '<thead><tr>';			
			if (currCard.bestof == "5") {
				cardHTML += '<th width="5%" title="Set 1">1</th><th width="5%" title="Set 2">2</th><th width="5%" title="Set 3">3</th><th width="5%" title="Set 4">4</th>';
			} else {
				cardHTML += '<th width="10%" title="Set 1">1</th><th width="10%" title="Set 2">2</th>';
			}
			cardHTML += '<th width="50%" title="Players">Players</th><th width="10%" title="Sets">S</th><th width="10%" title="Games">G</th><th width="10%" title="Points">Pts</th>';
			cardHTML += '</tr></thead><tbody>';
			// ok, so we've setup the headers, now loop through each player
			var totalPlayers = currCard.players.length;
			for(var p = 0; p < totalPlayers; p++) {
				currPlayer = currCard.players[p];
				cardHTML += '<tr>';
				cardHTML += '<td style="text-align:center">' + currPlayer.set1 + '</td>';
				cardHTML += '<td style="text-align:center">' + currPlayer.set2 + '</td>';				
				if (currCard.bestof == "5") {
					cardHTML += '<td style="text-align:center">' + currPlayer.set3 + '</td>';
					cardHTML += '<td style="text-align:center">' + currPlayer.set4 + '</td>';
				} else {
					//cardHTML += '<td>&nbsp;</td>';
				}
				cardHTML += '<td>';
					cardHTML += currPlayer.name;
					//if (currPlayer.server == "1") {
					//	cardHTML += "&nbsp;*";
					//}
				cardHTML += '</td>';
				cardHTML += '<td style="text-align:center">' + currPlayer.setswon + '</td>';
				cardHTML += '<td style="text-align:center">' + currPlayer.games + '</td>';
				cardHTML += '<td style="text-align:center">' + currPlayer.points + '</td>';
				cardHTML += '</tr>';
			}
			
			cardHTML += '</tbody></table>';
		}
		
		document.getElementById('ldbPromo').innerHTML = cardHTML;
		
	} else {
		
		// no live scorecards, just display a holding message
		cardHTML += '<table class="ms-tables-s3" width="100%">';
		cardHTML += '<caption>Live Scorecards</caption>';
		cardHTML += '<tbody><tr><td>';			
		cardHTML += 'Live coverage will appear here once play commences.';
		cardHTML += '</td></tr></tbody></table>';
		
		document.getElementById('ldbPromo').innerHTML = cardHTML;
		
	} // end if totalCards
				
		
}

function openScorePop (url, no, w, h) {
	popName = 'score' + no;
	eval("window.open(url,'" + popName + "', 'scrollbars=yes,width=" + w + ",height=" + h +"')");
	return false;
}

function renderLdbLatest(response, fullPath) {					
	
	var cardHTML = '';
		
	var totalCards = response.scores.card.length;
	if (totalCards) {

		// we have scorecards		
		cardHTML += '<h2 class="ms-header-s3 ms-header-s3-1">Live Matches</h2>';
		
		for(var i = 0; i < totalCards; i++) {
			
			currCard = response.scores.card[i];		
				
			cardHTML += '<div id="ms-tables-home">';
			cardHTML += '<table class="ms-tables-s2" cellpadding="0" cellspacing="0" width="100%">';
			cardHTML += '<caption>' + currCard.name + '</caption>';			
			cardHTML += '<thead><tr>';
			cardHTML += '<th scope="col" class="ms-left">Player</th><th scope="col" width="7%">S</th><th scope="col" width="7%">G</th><th scope="col" width="7%">P</th>';
			cardHTML += '</tr></thead>';			
			cardHTML += '<tbody>';
									
			// ok, so we've setup the headers, now loop through each player
			var totalPlayers = currCard.players.length;
			for(var p = 0; p < totalPlayers; p++) {
				currPlayer = currCard.players[p];	
				cardHTML += '<tr class="ms-even">';			
				cardHTML += '<td class="ms-left">' + currPlayer.name;
					//if (currPlayer.server == "1") {
					//	cardHTML += "&nbsp;*";
					//}
				cardHTML += '</td>';
				cardHTML += '<td>' + currPlayer.setswon + '</td>';				
				cardHTML += '<td>' + currPlayer.games + '</td>';
				cardHTML += '<td>' + currPlayer.points + '</td>';
				cardHTML += '</tr>';
			}
			
			
			// scores etc are done now...let's pop some links in to the live popup
			cardHTML += '<tr><td colspan="4"><ul class="ms-list-style2">';
			
			var myServer = document.URL;
			if (myServer.match("skysports")) {
				var popPath = 'http://www.sportinglife.com/clients/skysports/tennis/wimbledon2008/live/desktop.auto?/opt/ASFapache/htdocs/site/tennis/wimbledon2008/live/';								
			} else {
				var popPath = 'http://www.sportinglife.com/tennis/wimbledon2008/live/desktop.auto?/opt/ASFapache/htdocs/site/tennis/wimbledon2008/live/';				
			}
			var popWidth = '310';
			var popHeight = '140';
			popPath += 'score' + currCard.cardno + '.insdat';
			var popFunc = "openScorePop('" + popPath + "','" + currCard.cardno + "','" +  popWidth + "','" + popHeight + "'); return false;";
			
			cardHTML += '<li><a href="' + popPath + '" onClick="' + popFunc + '">Popup</a></li>';
			
			// keeping it relative 
			cardHTML += '<li><a href="/tennis/wimbledon/schedule">Schedule</a></li>';
			//cardHTML += '<li><a href="/tennis/wimbledon/results">Results</a></li>';
			cardHTML += '</ul></td></tr>';
			
			cardHTML += '</tbody>';
			cardHTML += '</table></div>';
		}
		
		document.getElementById('ldbLatest').innerHTML = cardHTML;
		
	} // end if totalCards
						
}

function getLdbLinks(response) {
	var totalCards = response.scores.card.length;
	if (totalCards) {
		var name = new Array();
		for(var i = 0; i < totalCards; i++) {
			var currCard = response.scores.card[i];
			var cardNum = currCard.cardno;
			var totalPlayers = currCard.players.length;
			for(var p = 0; p < totalPlayers; p++) {
				var currPlayer = currCard.players[p].name;
				currPlayer = currPlayer.replace("*","");
				if (currPlayer.search("/") == -1) {
					var splitName = currPlayer.split(" "); 
					name[p] = splitName[1];
					for(var x = 2; x < splitName.length; x++) {
						name[p] += " " + splitName[x]; 
					}
					if (name[p] == "Williams") {
						name[p] = splitName[0].charAt(0) + ". " + splitName[1];
					}
				} else {
					name[p] = currPlayer;
				}
			}
			linkHTML = "<img src='/Images/m_skysports/wimbledon/site/icon-pop.gif' border='0' style='padding-right:5px;'>";
			linkHTML += name[0] + " v " + name[1];		
			linkItem = document.getElementById("matchLink"+cardNum);
			linkItem.innerHTML = linkHTML;
			linkItem.style.display = "inline";
		}
	}
}