// counter to keep track of li index
var ccnt=0;
var ecnt=0;
// carousel state
var state = "collapsed";
// initialize arrays for completed, featured and upcoming match lists
var cMatchList = new Array();
var fMatchList = new Array();
var uMatchList = new Array();
// initialize the starting position for carousel
var matchStartPos = 1;
// initialize the start position for match lists
var cMatchPos = 0;
var fMatchPos = 0;
var uMatchPos = 0;
// load status vars
var fMatchLoad = false;
var cMatchLoad = false;
var uMatchLoad = false;
// returns the abbreviated round name
function getAbbrRound(round) {
var roundName = "";
switch (round) {
case "1" : roundName = "R1"; break;
case "2" : roundName = "R2"; break;
case "3" : roundName = "R3"; break;
case "4" : roundName = "R4"; break;
case "5" : roundName = "R5"; break;
case "6" : roundName = "R6"; break;
case "Q" : roundName = "QF"; break;
case "S" : roundName = "SF"; break;
case "F" : roundName = "Finals"; break;
default: break;
}
return roundName;
}
// returns the expanded round name
function getExpRound(round) {
var roundName = "";
switch (round) {
case "1" : roundName = "Round 1"; break;
case "2" : roundName = "Round 2"; break;
case "3" : roundName = "Round 3"; break;
case "4" : roundName = "Round 4"; break;
case "Q" : roundName = "Quarterfinals"; break;
case "S" : roundName = "Semifinals"; break;
case "F" : roundName = "Finals"; break;
default: break;
}
return roundName;
}
// returns the match status text
function getStatusName(status) {
var statusName = "";
switch (status) {
case "In Progress" : statusName = "Live"; break;
case "Complete" : statusName = "Completed"; break;
case "B" : statusName = "Upcoming"; break;
default: break;
}
return statusName;
}
// reads the xml and loads the match arrays
function startFeaturedMatches() {
$.ajax( {
url : "/en_AU/xml/gen/sumScores/featured.xml",
//url : "/en_AU/featured.xml",
type :'GET',
dataType :'xml',
timeout :10000,
error : function() {
//if (console && console.error) { console.error('Error loading XML document') };
},
success : function(xml) {
fMatchLoad = true;
loadMatch(xml, fMatchList, "Live");
//alert('fMatchList size: ' + fMatchList.length);
}
});
$.ajax( {
url :"/en_AU/xml/gen/sumScores/featuredCompleted.xml",
//url : "/en_AU/featuredCompleted.xml",
type :'GET',
dataType :'xml',
timeout :10000,
error : function() {
//if (console && console.error) { console.error('Error loading XML document') };
},
success : function(xml) {
cMatchLoad=true;
loadMatch(xml, cMatchList, "Completed");
//alert('cMatchList size: ' + cMatchList.length);
}
});
$.ajax( {
url :"/en_AU/xml/gen/sumScores/featuredUpcoming.xml",
//url : "/en_AU/featuredUpcoming.xml",
type :'GET',
dataType :'xml',
timeout :10000,
error : function() {
//if (console && console.error) { console.error('Error loading XML document') };
},
success : function(xml) {
uMatchLoad=true;
loadMatch(xml, uMatchList, "Upcoming");
}
});
}
/****************************************************
* When the dom is ready, start building
****************************************************/
$(document).ready(function(){
// matchHtml is html for completed, featured and upcoming matches 
var matchCollapsedHtml = buildCollapsedHtml(cMatchList) + buildCollapsedHtml(fMatchList) + buildCollapsedHtml(uMatchList);
matchCollapsedHtml = '<ul id="mycarousel_collapsed" class="jcarousel-skin-collapsed">' + matchCollapsedHtml + '</div>'
var matchExpandedHtml = buildExpandedHtml(cMatchList) + buildExpandedHtml(fMatchList) + buildExpandedHtml(uMatchList);
matchExpandedHtml = '<ul id="mycarousel_expanded" class="jcarousel-skin-expanded">' + matchExpandedHtml + '</div>'
// set the starting match position. Needs to start at 1st live match.
if (cMatchList.length > 0 && fMatchList.length > 0) {
matchStartPos = cMatchList.length + 1;
}
//determine the position completed, featured and upcoming matches start.
if (cMatchList.length > 0) {
cMatchPos=1;
}
if (fMatchList.length > 0) {
fMatchPos = cMatchList.length + 1;
}
if (uMatchList.length > 0) {
uMatchPos = cMatchList.length + fMatchList.length + 1;
}
// disable jumpto buttons if necessary
if (null == cMatchList || cMatchList.length == 0){
$('#completed.button').attr('src','/images/misc/aus_ms_00000b9_off.gif');
$('#completed.button').css('cursor','default');
} else {
$('#completed.button').css('cursor','pointer');
}
if (null == fMatchList || fMatchList.length == 0){
$('#featured.button').attr('src','/images/misc/aus_ms_00000ba_off.gif');
$('#featured.button').css('cursor','default');
} else {
$('#featured.button').css('cursor','pointer');
}
if (null == uMatchList || uMatchList.length == 0){
$('#upcoming.button').attr('src','/images/misc/aus_ms_00000bb_off.gif');
$('#upcoming.button').css('cursor','default');
} else {
$('#upcoming.button').css('cursor','pointer');
}
/*****************************************
* callback function for collapsed carousel
****************************************/
function collapsed_initCallback(carousel) {
//measure next and previous buttons
jQuery('.jcarousel-prev').bind('click',function (){
if(state == 'collapsed'){
measureApp('Home','Featured Matches','Previous Button');
}
});
jQuery('.jcarousel-next').bind('click',function (){
if (state == 'collapsed') {
measureApp('Home','Featured Matches','Next Button');
}
});
// expand button clicked
jQuery('li .expand').bind('click', function() {
measureApp('Home','Featured Matches','View Match');
var liIndex = $(this).attr('id');
$('#mycarousel_collapsed').fadeOut('slow', function() {
document.getElementById('matchListContainer').innerHTML = matchExpandedHtml;
startExpandedCarousel(jQuery.jcarousel.intval(liIndex));
});
return false;
});
// upcoming button clicked
if (uMatchList.length > 0) {
jQuery('#upcoming.button').bind('click', function() {
carousel.scroll(uMatchPos);
return false;
});
}
//featured/live button clicked
if (fMatchList.length > 0) {
jQuery('#featured.button').bind('click', function() {
carousel.scroll(fMatchPos);
return false;
});
}
// completed button clicked
if (cMatchList.length > 0) {
jQuery('#completed.button').bind('click', function() {
carousel.scroll(cMatchPos);
return false;
});
}
};
/*****************************************
* callback function for expanded carousel
*****************************************/
function expanded_initCallback(carousel) {
//measure next and previous buttons
jQuery('.jcarousel-prev').bind('click',function (){
if(state == 'expanded'){
measureApp('Home','Featured Matches','Previous Button');
}
});
jQuery('.jcarousel-next').bind('click',function (){
if (state == 'expanded') {
measureApp('Home','Featured Matches','Next Button');
}
});
// collapsed button clicked
jQuery('li .collapseContainer').bind('click', function() {
var liIndex = $(this).attr('id');
$('#mycarousel_expanded').fadeOut('slow',function() {
document.getElementById('matchListContainer').innerHTML = matchCollapsedHtml;
startCollapsedCarousel(jQuery.jcarousel.intval(liIndex));
});
return false;
});
//upcoming button clicked
if (uMatchList.length > 0) {
jQuery('#upcoming.button').bind('click', function() {
carousel.scroll(uMatchPos);
return false;
});
}
//featured-live button clicked
if (fMatchList.length > 0) {
jQuery('#featured.button').bind('click', function() {
carousel.scroll(fMatchPos);
return false;
});
}
// completed button clicked
if (cMatchList.length > 0) {
jQuery('#completed.button').bind('click', function() {
carousel.scroll(cMatchPos);
return false;
});
}
};
/***************************************
* creates collapsed carousel
**************************************/
function startCollapsedCarousel(index) {
state = "collapsed";
// initialize-create the collapsed carousel
jQuery('#mycarousel_collapsed').jcarousel({
// Configuration goes here
scroll:4,
start: index, 
initCallback: collapsed_initCallback,
easing: "linear",
animation: "slow"
});
}
/**************************************
* creates expanded carousel
**************************************/
function startExpandedCarousel(startPos){
state = "expanded";
jQuery('#mycarousel_expanded').jcarousel({
// Configuration goes here
scroll:1,
start: startPos, 
initCallback: expanded_initCallback,
easing: "linear",
animation: "slow"
});
}
if (!fMatchLoad && !cMatchLoad && !uMatchLoad) {
document.getElementById('matchListContainer').innerHTML = "<div class=\"message\">There are no featured matches to display at this time. Please try again later.</div>";
state="error";
}
else if (fMatchList.length == 1 || ccnt < 4) {
document.getElementById('matchListContainer').innerHTML = matchExpandedHtml;
//$('#matchListContainer').html(matchCollapsedHtml);
startExpandedCarousel(matchStartPos);
}
else {
document.getElementById('matchListContainer').innerHTML = matchCollapsedHtml;
//$('#matchListContainer').html(matchCollapsedHtml);
startCollapsedCarousel(matchStartPos);
}
});
/***************************************************************************
function to build collapsed html
***************************************************************************/
function buildCollapsedHtml(matchList) {
var sMatchHtml = "";
if (null != matchList && matchList.length > 0) {
var status = matchList[0].status;
for (var i=0; i < matchList.length; i++ ) {
ccnt++;
var match = matchList[i];
var team1 = matchList[i].teamList[0];
var team2 = matchList[i].teamList[1];
sMatchHtml += '<li class="collapsed">';
sMatchHtml += ' <div class="header"><span class="'+match.status+'">'+ match.status+'</span>';
if (browser.isIE5up || browser.isFirefox) {
sMatchHtml += ' <img id="'+ccnt+'" class="expand" src="/images/misc/aus_ms_00000gd.gif" width="13" height="13" border="0" alt="Expand" />';
}
if (match.status == 'Live') {
sMatchHtml += '<a href="javascript:launch(\'score\',\''+match.crt+'\');"><img class="follow" src="/images/misc/aus_ms_00000gc.gif" width="53" height="13" border="0" alt="Follow" /></a>';
}
sMatchHtml += '</div>';
sMatchHtml += ' <div class="content">';
sMatchHtml += ' <table class="smallMatch" border="0" padding="0" cellspacing="0">';
sMatchHtml += ' <tr class="event">';
sMatchHtml += ' <td colspan="6">' + match.event + ' - ' + match.abbrRound + '</td>';
sMatchHtml += ' </tr>';
sMatchHtml += ' <tr class="team">';
sMatchHtml += ' <td class="player" valign="middle"><a href="/en_AU/players/overview/' + team1.playerIdA + '.html">' + team1.playerNameA + '</a>'
if (null != team1.playerIdB || "" == team1.playerIdB) {
sMatchHtml += ' <br /><a href="/en_AU/players/overview/' + team1.playerIdB + '.html">' + team1.playerNameB + '</a>';
}
sMatchHtml += ' </td>';
var loser = "";
(team1.set1 < team2.set1) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team1.set1 + '</td>';
(team1.set2 < team2.set2) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team1.set2 + '</td>';
(team1.set3 < team2.set3) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team1.set3 + '</td>';
(team1.set4 < team2.set4) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team1.set4 + '</td>';
(team1.set5 < team2.set5) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team1.set5 + '</td>';
sMatchHtml += ' </tr>';
sMatchHtml += ' <tr class="game">';
sMatchHtml += ' <td class="vs">vs</td>';
sMatchHtml += ' <td>1</td>';
sMatchHtml += ' <td>2</td>';
sMatchHtml += ' <td>3</td>';
sMatchHtml += ' <td>4</td>';
sMatchHtml += ' <td>5</td>';
sMatchHtml += ' </tr>';
sMatchHtml += ' <tr class="team">';
sMatchHtml += ' <td class="player" valign="middle"><a href="/en_AU/players/overview/' + team2.playerIdA + '.html">' + team2.playerNameA + '</a>'
if (null != team2.playerIdB || "" == team2.playerIdB) {
sMatchHtml += ' <br /><a href="/en_AU/players/overview/' + team2.playerIdB + '.html">' + team2.playerNameB + '</a>';
}
sMatchHtml += ' </td>';
(team2.set1 < team1.set1) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team2.set1 + '</td>';
(team2.set2 < team1.set2) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team2.set2 + '</td>';
(team2.set3 < team1.set3) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team2.set3 + '</td>';
(team2.set4 < team1.set4) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team2.set4 + '</td>';
(team2.set5 < team1.set5) ? loser = ' loser' : loser = '';
sMatchHtml += ' <td class="score' + loser + '">' + team2.set5 + '</td>';
sMatchHtml += ' </tr>';
sMatchHtml += ' </table>';
sMatchHtml += ' </div>';
sMatchHtml += ' <div class="bottom"></div>';
sMatchHtml += '</li>';
}
}
// alert(sMatchHtml);
return(sMatchHtml);
}
/***************************************************************************
function to build expanded html
***************************************************************************/
function buildExpandedHtml(matchList) {
var lMatchHtml = "";
if (null != matchList && matchList.length > 0) {
var status = matchList[0].status;
for (var i=0; i < matchList.length; i++ ) {
ecnt++;
var match = matchList[i];
var team1 = matchList[i].teamList[0];
var team2 = matchList[i].teamList[1];
var isDoubles = true; // there are many places where we SHOULD be using this var to check for doubles.
if (null == team1.playerIdB || "" == team1.playerIdB || '-1' == team1.playerIdB) {isDoubles = false;}
lMatchHtml += '<li class="expanded">';
lMatchHtml += '<div class="leftEdge"></div>';
lMatchHtml += '<div class="middleSection">';
lMatchHtml += '<div class="gameSection">';
if (null == team1.playerIdB || "" == team1.playerIdB || '-1' == team1.playerIdB) {
lMatchHtml += ' <div class="singlesPlayerPhoto1">';
if (team1.imgA != "") {
lMatchHtml += ' <img src="/images/players/small/' + team1.imgA + '" width="74" height="101" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_74x101.gif" width="74" height="101" alt="" border="0" />';
}
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="singlesGameInfo">';
lMatchHtml += ' <table class="singlesScoreTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="player">';
lMatchHtml += ' <img class="flag" width="22" height="14" src="/images/flags/'+team1.playerNationA+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team1.playerIdA + '.html">'+team1.playerNameA + ' '+team1.teamSeed + '</a>';
if (status=='Completed' && match.winner == '1') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gaa.gif" width="16" height="16" border="0" />';
}
if (status=='Live' && match.server == '1') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gw.gif" width="16" height="18" border="0" />';
}
lMatchHtml += ' </td>';
lMatchHtml += ' <td class="score">'+team1.set1+'</td>';
lMatchHtml += ' <td class="score">'+team1.set2+'</td>';
lMatchHtml += ' <td class="score">'+team1.set3+'</td>';
lMatchHtml += ' <td class="score">'+team1.set4+'</td>';
lMatchHtml += ' <td class="score">'+team1.set5+'</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' <table class="singlesVsTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="versus"><div style="margin-left:40px;">VERSUS</div></td>';
lMatchHtml += ' <td class="set">1</td>';
lMatchHtml += ' <td class="set">2</td>';
lMatchHtml += ' <td class="set">3</td>';
lMatchHtml += ' <td class="set">4</td>';
lMatchHtml += ' <td class="set">5</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' <table class="singlesScoreTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="player">';
lMatchHtml += ' <img class="flag" width="22" height="14" src="/images/flags/'+team2.playerNationA+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team2.playerIdA + '.html">'+team2.playerNameA + ' '+team2.teamSeed + '</a>';
if (status=='Completed' && match.winner == '2') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gaa.gif" width="16" height="16" border="0" />';
}
if (status=='Live' && match.server == '2') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gw.gif" width="16" height="18" border="0" />';
}
lMatchHtml += ' </td>';
lMatchHtml += ' <td class="score">'+team2.set1+'</td>';
lMatchHtml += ' <td class="score">'+team2.set2+'</td>';
lMatchHtml += ' <td class="score">'+team2.set3+'</td>';
lMatchHtml += ' <td class="score">'+team2.set4+'</td>';
lMatchHtml += ' <td class="score">'+team2.set5+'</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="singlesPlayerPhoto2">';
if (team2.imgA != "") {
lMatchHtml += ' <img src="/images/players/small/' + team2.imgA + '" width="74" height="101" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_74x101.gif" width="74" height="101" alt="" border="0" />';
}
lMatchHtml += ' </div>';
} else {
lMatchHtml += ' <div class="doublesPlayerPhoto1">';
if (team1.imgA != "") {
lMatchHtml += ' <img src="/images/players/small/' + team1.imgA + '" width="48" height="65" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_48x65.gif" width="48" height="65" alt="" border="0" />';
}
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="doublesPlayerPhoto2">';
if (team1.imgB != "") {
lMatchHtml += ' <img src="/images/players/small/' + team1.imgB + '" width="48" height="65" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_48x65.gif" width="48" height="65" alt="" border="0" />';
}
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="doublesGameInfo">';
lMatchHtml += ' <table class="doublesScoreTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="player">';
lMatchHtml += ' <img class="flag" width="22" height="14" src="/images/flags/'+team1.playerNationA+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team1.playerIdA + '.html">'+team1.playerNameA + ' '+team1.teamSeed + '</a>';
if (status=='Completed' && match.winner == '1') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gaa.gif" width="16" height="16" border="0" />';
}
if (status=='Live' && match.server == '1') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gw.gif" width="16" height="18" border="0" />';
}
lMatchHtml += '<br /><img class="flag" width="22" height="14" src="/images/flags/'+team1.playerNationB+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team1.playerIdB + '.html">'+team1.playerNameB + '</a>';
lMatchHtml += ' </td>';
lMatchHtml += ' <td class="score">'+team1.set1+'</td>';
lMatchHtml += ' <td class="score">'+team1.set2+'</td>';
lMatchHtml += ' <td class="score">'+team1.set3+'</td>';
lMatchHtml += ' <td class="score">'+team1.set4+'</td>';
lMatchHtml += ' <td class="score">'+team1.set5+'</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' <table class="doublesVsTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="versus"><div style="margin-left:40px;">VERSUS</div></td>';
lMatchHtml += ' <td class="set">1</td>';
lMatchHtml += ' <td class="set">2</td>';
lMatchHtml += ' <td class="set">3</td>';
lMatchHtml += ' <td class="set">4</td>';
lMatchHtml += ' <td class="set">5</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' <table class="doublesScoreTbl" cellpadding="0" cellspacing="0" border="0">';
lMatchHtml += ' <tr>';
lMatchHtml += ' <td class="player">';
lMatchHtml += ' <img class="flag" width="22" height="14" src="/images/flags/'+team2.playerNationA+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team2.playerIdA + '.html">'+team2.playerNameA + ' '+team2.teamSeed + '</a>';
if (status=='Completed' && match.winner == '2') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gaa.gif" width="16" height="16" border="0" />';
}
if (status=='Live' && match.server == '2') {
lMatchHtml += ' <img class="icon" src="/images/misc/aus_ms_00000gw.gif" width="16" height="18" border="0" />';
}
lMatchHtml += '<br /><img class="flag" width="22" height="14" src="/images/flags/'+team2.playerNationB+'_sm.gif" />&nbsp;&nbsp;<a href="/en_AU/players/overview/' + team1.playerIdA + '.html">'+team2.playerNameB + '</a>';
lMatchHtml += ' </td>';
lMatchHtml += ' <td class="score">'+team2.set1+'</td>';
lMatchHtml += ' <td class="score">'+team2.set2+'</td>';
lMatchHtml += ' <td class="score">'+team2.set3+'</td>';
lMatchHtml += ' <td class="score">'+team2.set4+'</td>';
lMatchHtml += ' <td class="score">'+team2.set5+'</td>';
lMatchHtml += ' </tr>';
lMatchHtml += ' </table>';
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="doublesPlayerPhoto3">';
if (team2.imgA != "") {
lMatchHtml += ' <img src="/images/players/small/' + team2.imgA + '" width="48" height="65" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_48x65.gif" width="48" height="65" alt="" border="0" />';
}
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="doublesPlayerPhoto4">';
if (team2.imgB != "") {
lMatchHtml += ' <img src="/images/players/small/' + team2.imgB + '" width="48" height="65" alt="" border="0" />';
} else {
lMatchHtml += ' <img src="/images/players/small/BioPhotoNotAvail_48x65.gif" width="48" height="65" alt="" border="0" />';
}
lMatchHtml += ' </div>';
}
lMatchHtml += ' </div>';
lMatchHtml += ' <div class="matchInfo">';
lMatchHtml += ' <div class="'+match.status+'">'+ match.status+'</div>';
if (ccnt >= 4) {
if (browser.isIE5up || browser.isFirefox) {
lMatchHtml += ' <div class="collapseContainer"><div style="float:left; margin-top:-3px; width:35px;">close</div><img id="'+ecnt+'" class="collapse" src="/images/misc/aus_ms_00000gz.gif" width="13" height="12" border="0" alt="Collapse" /></div>';
}
}
lMatchHtml += ' <div class="court">Court: '+ match.court +'</div>';
lMatchHtml += ' <div class="event">Event: '+ match.event +' - ' + match.abbrRound + '</div>';
if (status=='Live') {
lMatchHtml += ' <div class="follow"><a href="javascript:launch(\'score\',\''+match.crt+'\');"><img src="/images/misc/aus_ms_00000gx.gif" width="148" height="13" alt="Follow Match Live" border="0" /></a></div>';
}
if (status != 'Upcoming') {
if (!isDoubles){
lMatchHtml += ' <div class="viewStats"><a href="/en_AU/scores/stats/day'+match.day+'/'+match.id+'ms.html"><img src="/images/misc/aus_ms_00000gy.gif" width="148" height="13" alt="View Match Stats" border="0" /></a></div>';
}
}
lMatchHtml += ' </div>';
lMatchHtml += '</div>';
lMatchHtml += '<div class="rightEdge"></div>';
lMatchHtml += '</li>';
}
}
// alert(lMatchHtml);
return(lMatchHtml);
}
/***************************************************************************
function to create match objects
***************************************************************************/
function match(){
this.status;
//this.video;
this.pt;
this.crt;
this.id;
this.court;
this.teamList;
this.event;
this.round;
this.roundName;
this.winner;
this.server;
this.day;
}
/***************************************************************************
function to create team objects
***************************************************************************/
function team(){
this.id;
this.teamSeed;
this.playerIdA;
this.playerIdB;
this.playerNameA;
this.playerNameB;
this.set1;
this.set2;
this.set3;
this.set4;
this.set5;
this.playerNationA;
this.playerNationB;
this.imgA;
this.imgB;
}
/***************************************************************************
function to load data into match objects
***************************************************************************/
function loadMatch(xmlDoc,list, s) {
$(xmlDoc).find("match").each(function() {
list[list.length] = new match();
list[list.length-1].status = s; //getStatusName($(this).attr('status'));
list[list.length-1].pt = $(this).attr('pt');
list[list.length-1].crt = $(this).attr('crt');
list[list.length-1].id = $(this).attr('id');
list[list.length-1].court = $(this).attr('court');
list[list.length-1].event = $(this).attr('event');
list[list.length-1].round = $(this).attr('round');
list[list.length-1].abbrRound = getAbbrRound($(this).attr('round'));
list[list.length-1].expRound = getExpRound($(this).attr('round'));
list[list.length-1].teamList = loadTeamList($(this));
var winner = $(this).attr('winner');
if (null == winner || winner == "") {winner = "";}
list[list.length-1].winner = winner;
var server = $(this).attr('server');
if (null == server || server == ""){server = "";}
list[list.length-1].server = $(this).attr('server');
list[list.length-1].day = $(this).attr('day');
});
}
/***************************************************************************
*function to load data into team objects
***************************************************************************/
function loadTeamList(matchNode) {
var teamList = new Array();
$(matchNode).find("team").each(function() {
teamList[teamList.length] = new team();
teamList[teamList.length-1].id = $(this).attr('id');
var seed = $(this).attr('teamSeed');
if (null==seed || "" == seed){
seed= ""
} else
{ seed = "("+seed+")"};
teamList[teamList.length-1].teamSeed = seed;
teamList[teamList.length-1].playerIdA = $(this).attr('playerIdA');
teamList[teamList.length-1].playerIdB = $(this).attr('playerIdB');
teamList[teamList.length-1].playerNameA = $(this).attr('playerNameA');
teamList[teamList.length-1].playerNameB = $(this).attr('playerNameB');
teamList[teamList.length-1].playerNationA = $(this).attr('playerNationA');
teamList[teamList.length-1].playerNationB = $(this).attr('playerNationB');
teamList[teamList.length-1].set1 = $(this).attr('set1');
teamList[teamList.length-1].set2 = $(this).attr('set2');
teamList[teamList.length-1].set3 = $(this).attr('set3');
teamList[teamList.length-1].set4 = $(this).attr('set4');
teamList[teamList.length-1].set5 = $(this).attr('set5');
teamList[teamList.length-1].imgA = $(this).attr('imgA');
teamList[teamList.length-1].imgB = $(this).attr('imgB');
});
return teamList;
}
function loopTimer() {
//setTimeout("startFeaturedMatches()",ajaxRefresh);
}
/***************************************************************************
function to remove duplicate items in an array
***************************************************************************/
Array.prototype.unique = function () {
var r = new Array();
o:for(var i = 0, n = this.length; i < n; i++)
{
for(var x = 0, y = r.length; x < y; x++)
{
if(r[x]==this[i])
{
continue o;
}
}
r[r.length] = this[i];
}
return r;
}
startFeaturedMatches();