/*
 * teamDetails.js v1.0 (created: 2007/08/16, updated: 2007/10/03)
 * 
 * Company: Statusfirm
 * Coded by: Chesley Brown
 * Contact: c.brown@statusfirm.com
 * 
 * ***Description***
 * Used for getting team info, news info, games info and history info using Ajax
 * ******
 * 
 * *****Requires*****
 * jquery.js (tested with v1.2)
 * switchPage.js (tested with v1.0)
 * ******
 * 
 */
function classTeamDetails() { this.teamID = ''; this.historyID = ''; this.teamName = ''; this.teamIDCurrent = new Object(); this.teamIDCurrent['info'] = ''; this.teamIDCurrent['news'] = ''; this.teamIDCurrent['games'] = ''; this.teamIDCurrent['history'] = ''; this.historyIDCurrent = ''; this.teamNameCurrent = ''; this.setTeamDetails = setTeamDetails; this.getTeamDetails = getTeamDetails;}
function setTeamDetails(teamID, historyID, teamName) { var lockCheck = false; if (typeof(myTeamDetails_info) != 'undefined' && myTeamDetails_info.pageLoadingLock == true) { lockCheck = true;}
if (typeof(mySearchTeamDetails_news) != 'undefined' && mySearchTeamDetails_news.pageLoadingLock == true) { lockCheck = true;}
if (typeof(myTeamNewsStory) != 'undefined' && myTeamNewsStory.pageLoadingLock == true) { lockCheck = true;}
if (typeof(mySearchTeamDetails_games) != 'undefined' && mySearchTeamDetails_games.pageLoadingLock == true) { lockCheck = true;}
if (typeof(myTeamGamesInfo) != 'undefined' && myTeamGamesInfo.pageLoadingLock == true) { lockCheck = true;}
if (typeof(mySearchTeamDetails_history) != 'undefined' && mySearchTeamDetails_history.pageLoadingLock == true) { lockCheck = true;}
if (typeof(myTeamHistoryInfo) != 'undefined' && myTeamHistoryInfo.pageLoadingLock == true) { lockCheck = true;}
if (lockCheck == false) { if (typeof(teamID) != 'undefined' && typeof(historyID) != 'undefined' && typeof(teamName) != 'undefined') { this.teamID = teamID; this.historyID = historyID; this.teamName = teamName; if (typeof(myTeamNewsStory) != 'undefined') { myTeamNewsStory.previousSearch = '';}
if (typeof(myTeamGamesInfo) != 'undefined') { myTeamGamesInfo.previousSearch = '';}
if (typeof(myTeamHistoryInfo) != 'undefined') { myTeamHistoryInfo.previousSearch = '';}
this.getTeamDetails();}
}
}
function getTeamDetails() { if (document.getElementById('TeamDetails_info_tabheader') != null && document.getElementById('TeamDetails_info_tabheader').className == myTeamDetailsTabs.headerSelectedClassName) { if (this.teamIDCurrent['info'] != this.teamID && this.historyIDCurrent != this.historyID) { myTeamDetails_info.getTeamInfo(this.teamID, this.historyID); myTeamDetailsTabs.switchTabs('TeamDetails_info'); this.teamIDCurrent['info'] = this.teamID; this.historyIDCurrent = this.historyID;}
}
if (document.getElementById('TeamDetails_news_tabheader') != null && document.getElementById('TeamDetails_news_tabheader').className == myTeamDetailsTabs.headerSelectedClassName) { if (this.teamNameCurrent != this.teamName) { mySearchTeamDetails_news.searchParametersString['search'] = this.teamName; mySearchTeamDetails_news.startCustomSearch(); myTeamDetailsTabs.switchTabs('TeamDetails_news'); this.teamNameCurrent = this.teamName;}
}
if (document.getElementById('TeamDetails_games_tabheader') != null && document.getElementById('TeamDetails_games_tabheader').className == myTeamDetailsTabs.headerSelectedClassName) { if (this.teamIDCurrent['games'] != this.teamID) { mySearchTeamDetails_games.searchParametersString['teamid'] = this.teamID; mySearchTeamDetails_games.startCustomSearch(); myTeamDetailsTabs.switchTabs('TeamDetails_games'); this.teamIDCurrent['games'] = this.teamID;}
}
if (document.getElementById('TeamDetails_history_tabheader') != null && document.getElementById('TeamDetails_history_tabheader').className == myTeamDetailsTabs.headerSelectedClassName) { if (this.teamIDCurrent['history'] != this.teamID) { mySearchTeamDetails_history.searchParametersString['teamid'] = this.teamID; mySearchTeamDetails_history.startCustomSearch(); myTeamDetailsTabs.switchTabs('TeamDetails_history'); this.teamIDCurrent['history'] = this.teamID;}
}
}
function classTeamInfo() { this.baseHREF = document.getElementsByTagName("base")[0].href; this.xmlLocation = 'teams/_xmlTeamInfo.php'; this.method = 'GET'; this.xmlCache = false; this.dataType = 'xml'; this.ajaxTimeout = 20000; this.IDExt = '_info'; this.useEffects = true; this.effectsFadeDuration = 500; this.effectsSlideDuration = 500; this.displayPageID = 'TeamDetailsContents'; this.pageLoadingLock = false; this.pageLoadingID = 'TeamDetailsLoading'; this.useAlternatingRowClass = true; this.rowClass1 = 'row1'; this.rowClass2 = 'row2'; this.msgErrorIcon = 'images/btn-error-whitebg.gif'; this.msgErrorTimeout = 'Timeout Error'; this.msgErrorTimeoutLong = 'Your request has timed out, please try again'; this.msgErrorPageNotFound = 'Page Not Found'; this.msgErrorPageNotFoundLong = 'Sorry, the page could not be found'; this.msgErrorUnknown = 'Unknown Error'; this.msgErrorUnknownLong = 'Sorry, an unknown error was encountered'; this.getTeamInfo = getTeamInfo; this.switchPageStart = switchPageStart; this.switchPageMiddle = switchPageMiddle; this.switchPageComplete = switchPageComplete; this.switchPageContent = switchPageContent;}
function getTeamInfo(teamID, historyID) { if (this.pageLoadingLock == false && teamID != '' && historyID != '') { var self = this; this.switchPageStart(); var opt = { url: this.baseHREF + this.xmlLocation, type: this.method, dataType: this.dataType, cache: this.xmlCache, timeout: this.ajaxTimeout, data: 'teamid=' + teamID + '&historyid=' + historyID, success: function(data) { var xmlRoot = $(data.documentElement); var xmlEntry = $(xmlRoot).find('entry')[0]; var entryData = new Object(); var newEntryData = ''; var rowClass = self.rowClass2; if ($(xmlRoot).attr('status') == 'ok' && $(xmlRoot).children().length > 0) { for (var i = 0; i < xmlEntry.childNodes.length; i++) { if(xmlEntry.childNodes[i].hasChildNodes() && xmlEntry.childNodes[i].firstChild.data.replace(/^\s+|\s+$/g, '').length > 0) { entryData[xmlEntry.childNodes[i].getAttribute('title')] = xmlEntry.childNodes[i].firstChild.data;} else { }
}
newEntryData = newEntryData + "<div id='TeamDetails' style='display: block;'>"; for (key in entryData) { if (self.useAlternatingRowClass == true) { rowClass = (rowClass == self.rowClass2 ) ? self.rowClass1 : self.rowClass2; var entryRowClass = " class='" + rowClass + "'";} else { var entryRowClass = '';}
newEntryData = newEntryData + "<div" + entryRowClass + ">"; newEntryData = newEntryData + "<div style='float: left; font-weight: bold; margin-left: 5px;'>" + key + ":</div> "; newEntryData = newEntryData + "<div style='text-align: right; margin-right: 5px;'>" + entryData[key] + "</div>"; newEntryData = newEntryData + "</div>";}
} else { newEntryData = newEntryData + "<div id='TeamDetails' style='display: block;'>"; newEntryData = newEntryData + "<div class='" + rowClass + "'>"; newEntryData = newEntryData + "<span style='font-style:italic;'>* Sorry, no results found</span>"; newEntryData = newEntryData + "</div>";}
newEntryData = newEntryData + "</div>"; self.switchPageMiddle( function() { document.getElementById(self.displayPageID + self.IDExt).innerHTML = newEntryData;} ); self.switchPageComplete();}, error: function(data, status) { if (status == 'timeout') { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorTimeout + ":</b> " + self.msgErrorTimeoutLong + "</div></div>";} else { if (data.status == 404) { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorPageNotFound + ":</b> " + self.msgErrorPageNotFoundLong + "</div></div>";}
else { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorUnknown + ":</b> " + self.msgErrorUnknownLong + "</div></div>";}
}
self.switchPageComplete();}
}
$.ajax(opt);}
}
function classTeamNewsStory() { this.baseHREF = document.getElementsByTagName("base")[0].href; this.xmlLocation = 'teams/_xmlTeamNewsStory.php'; this.method = 'GET'; this.xmlCache = false; this.dataType = 'xml'; this.ajaxTimeout = 20000; this.IDExt = '_news'; this.useEffects = false; this.effectsFadeDuration = 500; this.effectsSlideDuration = 500; this.objectName = 'myTeamNewsStory'; this.displayPageID = 'TeamDetailsContents'; this.previousSearch = ''; this.previousPageNum = ''; this.pageLoadingLock = false; this.pageLoadingID = 'SearchLoading'; this.useAlternatingRowClass = false; this.rowClass1 = 'row1'; this.rowClass2 = 'row2'; this.msgErrorIcon = 'images/btn-error-whitebg.gif'; this.msgErrorTimeout = 'Timeout Error'; this.msgErrorTimeoutLong = 'Your request has timed out, please try again'; this.msgErrorPageNotFound = 'Page Not Found'; this.msgErrorPageNotFoundLong = 'Sorry, the page could not be found'; this.msgErrorUnknown = 'Unknown Error'; this.msgErrorUnknownLong = 'Sorry, an unknown error was encountered'; this.getTeamNewsStory = getTeamNewsStory; this.switchPageStart = switchPageStart; this.switchPageMiddle = switchPageMiddle; this.switchPageComplete = switchPageComplete; this.switchPageContent = switchPageContent; this.newsStoryCache = new Array();}
function getTeamNewsStory(newstextID) { if (this.pageLoadingLock == false) { if (this.previousSearch == newstextID) { if (document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = '';} else { if (this.newsStoryCache[newstextID] != null) { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.newsStoryCache[newstextID]; if (document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display == 'none') { document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display = 'block';}
}
}
var displayPageClosed = true;} else { var displayPageClosed = false;}
}
if (this.pageLoadingLock == false && mySearchTeamDetails_news.pageLoadingLock == false && this.previousSearch != newstextID && displayPageClosed == false) { var customCheck = true; if (this.newsStoryCache[newstextID] != null) { customCheck = false; this.displayPageID = 'newstext_id_' + newstextID; document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (this.previousSearch != '' && document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display = 'none';}
this.previousSearch = newstextID;}
if (customCheck == true) { this.displayPageID = 'newstext_id_' + newstextID; var self = this; mySearchTeamDetails_news.pageLoadingLock = true; this.switchPageStart(); document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (document.getElementById('newstext_id_' + this.previousSearch + this.IDExt) != null) { document.getElementById('newstext_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = newstextID;} else { this.previousSearch = newstextID;}
var opt = { url: this.baseHREF + this.xmlLocation, type: this.method, dataType: this.dataType, cache: this.xmlCache, timeout: this.ajaxTimeout, data: 'newstextid=' + newstextID, success: function(data) { var xmlRoot = $(data.documentElement); var xmlEntry = $(xmlRoot).find('entry')[0]; var entryData = new Object(); var newEntryData = ''; var rowClass = self.rowClass2; newEntryData = newEntryData + "<div style='display: block;'>"; newEntryData = newEntryData + "<div style='text-align: right; border-bottom: 1px solid gray; padding: 2px; font-size: 9px;'><a href='JavaScript:myTeamNewsStory.getTeamNewsStory(" + newstextID + ");'>[close]</a></div>"; if ($(xmlRoot).attr('status') == 'ok' && $(xmlRoot).children().length > 0) { for (var i = 0; i < xmlEntry.childNodes.length; i++) { if(xmlEntry.childNodes[i].hasChildNodes() && xmlEntry.childNodes[i].firstChild.data.replace(/^\s+|\s+$/g, '').length > 0) { entryData[xmlEntry.childNodes[i].getAttribute('title')] = xmlEntry.childNodes[i].firstChild.data;} else { }
}
for (key in entryData) { if (self.useAlternatingRowClass == true) { rowClass = (rowClass == self.rowClass2 ) ? self.rowClass1 : self.rowClass2; var entryRowClass = " class='" + rowClass + "'";} else { var entryRowClass = '';}
newEntryData = newEntryData + "<div" + entryRowClass + ">"; if (key != '') { newEntryData = newEntryData + "<div style='font-weight: bold; margin:0 0 5px 5px;'>" + key + ":</div> ";}
newEntryData = newEntryData + "<div style='margin:0 0 15px 15px;'>" + entryData[key] + "</div>"; newEntryData = newEntryData + "</div>";}
} else { newEntryData = newEntryData + "<div class='" + rowClass + "'>"; newEntryData = newEntryData + "<span style='font-style:italic;'>* Sorry, no results found</span>"; newEntryData = newEntryData + "</div>";}
newEntryData = newEntryData + "<div style='text-align: right; border-top: 1px solid gray; padding: 2px; font-size: 9px;'><a href='JavaScript:myTeamNewsStory.getTeamNewsStory(" + newstextID + ");'>[close]</a></div>"; newEntryData = newEntryData + "</div>"; self.newsStoryCache[newstextID] = newEntryData; self.switchPageMiddle( function() { document.getElementById(self.displayPageID + self.IDExt).innerHTML = self.newsStoryCache[newstextID];} ); self.switchPageComplete(); mySearchTeamDetails_news.pageLoadingLock = false;}, error: function(data, status) { if (status == 'timeout') { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorTimeout + ":</b> " + self.msgErrorTimeoutLong + "</div></div>";} else { if (data.status == 404) { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorPageNotFound + ":</b> " + self.msgErrorPageNotFoundLong + "</div></div>";}
else { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorUnknown + ":</b> " + self.msgErrorUnknownLong + "</div></div>";}
}
self.switchPageComplete(); mySearchTeamDetails_news.pageLoadingLock = false;}
}
$.ajax(opt);} else { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.newsStoryCache[newstextID];}
}
}
function classTeamGamesAlert() { this.IDExt = '_gamesalert'; this.getTeamGamesAlert = getTeamGamesAlert;}
function getTeamGamesAlert(gameID) { if (document.getElementById('game_id_' + gameID + this.IDExt) != null) { if (document.getElementById('game_id_' + gameID + this.IDExt).style.display == 'none') { document.getElementById('game_id_' + gameID + this.IDExt).style.display = 'block';}
else if (document.getElementById('game_id_' + gameID + this.IDExt).style.display == 'block') { document.getElementById('game_id_' + gameID + this.IDExt).style.display = 'none';}
}
}
function classTeamGamesInfo() { this.baseHREF = document.getElementsByTagName("base")[0].href; this.xmlLocation = 'teams/_xmlTeamGamesInfo.php'; this.method = 'GET'; this.xmlCache = false; this.dataType = 'xml'; this.ajaxTimeout = 20000; this.IDExt = '_games'; this.useEffects = false; this.effectsFadeDuration = 500; this.effectsSlideDuration = 500; this.displayPageID = 'TeamDetailsContents'; this.previousSearch = ''; this.previousPageNum = ''; this.pageLoadingLock = false; this.pageLoadingID = 'SearchLoading'; this.objectName = 'myTeamGamesInfo'; this.useAlternatingRowClass = true; this.rowClass1 = 'row1'; this.rowClass2 = 'row2'; this.msgErrorIcon = 'images/btn-error-whitebg.gif'; this.msgErrorTimeout = 'Timeout Error'; this.msgErrorTimeoutLong = 'Your request has timed out, please try again'; this.msgErrorPageNotFound = 'Page Not Found'; this.msgErrorPageNotFoundLong = 'Sorry, the page could not be found'; this.msgErrorUnknown = 'Unknown Error'; this.msgErrorUnknownLong = 'Sorry, an unknown error was encountered'; this.getTeamGamesInfo = getTeamGamesInfo; this.switchPageStart = switchPageStart; this.switchPageMiddle = switchPageMiddle; this.switchPageComplete = switchPageComplete; this.switchPageContent = switchPageContent; this.gameInfoCache = new Array();}
function getTeamGamesInfo(gameID) { if (this.pageLoadingLock == false) { if (this.previousSearch == gameID) { if (document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = '';} else { if (this.gameInfoCache[gameID] != null) { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.gameInfoCache[gameID]; if (document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display == 'none') { document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display = 'block';}
}
}
var displayPageClosed = true;} else { var displayPageClosed = false;}
}
if (this.pageLoadingLock == false && mySearchTeamDetails_games.pageLoadingLock == false && this.previousSearch != gameID && displayPageClosed == false) { var customCheck = true; if (this.gameInfoCache[gameID] != null) { customCheck = false; this.displayPageID = 'game_id_' + gameID; document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (this.previousSearch != '' && document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display = 'none';}
this.previousSearch = gameID;}
if (customCheck == true) { this.displayPageID = 'game_id_' + gameID; var self = this; mySearchTeamDetails_games.pageLoadingLock = true; this.switchPageStart(); document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (document.getElementById('game_id_' + this.previousSearch + this.IDExt) != null) { document.getElementById('game_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = gameID;} else { this.previousSearch = gameID;}
var opt = { url: this.baseHREF + this.xmlLocation, type: this.method, dataType: this.dataType, cache: this.xmlCache, timeout: this.ajaxTimeout, data: 'gameid=' + gameID, success: function(data) { var xmlRoot = $(data.documentElement); var xmlEntry = $(xmlRoot).find('entry')[0]; var entryData = new Object(); var newEntryData = ''; var rowClass = self.rowClass2; newEntryData = newEntryData + "<div style='display: block;'>"; newEntryData = newEntryData + "<div style='text-align: right; border-bottom: 1px solid gray; padding: 2px; font-size: 9px;'><a href='JavaScript:myTeamGamesInfo.getTeamGamesInfo(" + gameID + ");'>[close]</a></div>"; if ($(xmlRoot).attr('status') == 'ok' && $(xmlRoot).children().length > 0) { for (var i = 0; i < xmlEntry.childNodes.length; i++) { if(xmlEntry.childNodes[i].hasChildNodes() && xmlEntry.childNodes[i].firstChild.data.replace(/^\s+|\s+$/g, '').length > 0) { entryData[xmlEntry.childNodes[i].getAttribute('title')] = xmlEntry.childNodes[i].firstChild.data;} else { }
}
for (key in entryData) { if (self.useAlternatingRowClass == true) { rowClass = (rowClass == self.rowClass2 ) ? self.rowClass1 : self.rowClass2; var entryRowClass = " class='" + rowClass + "'";} else { var entryRowClass = '';}
newEntryData = newEntryData + "<div" + entryRowClass + " style='height: 1em;'>"; newEntryData = newEntryData + "<div style='float: left; font-weight: bold;'>" + key + ":</div> "; newEntryData = newEntryData + "<div style='float: right;'>" + entryData[key] + "</div>"; newEntryData = newEntryData + "</div>";}
} else { newEntryData = newEntryData + "<div class='" + rowClass + "'>"; newEntryData = newEntryData + "<span style='font-style:italic;'>* Sorry, no results found</span>"; newEntryData = newEntryData + "</div>";}
newEntryData = newEntryData + "<div style='text-align: right; border-top: 1px solid gray; padding: 2px; font-size: 9px; margin: 5px 0 0 0;'><a href='JavaScript:myTeamGamesInfo.getTeamGamesInfo(" + gameID + ");'>[close]</a></div>"; newEntryData = newEntryData + "</div>"; self.gameInfoCache[gameID] = newEntryData; self.switchPageMiddle( function() { document.getElementById(self.displayPageID + self.IDExt).innerHTML = self.gameInfoCache[gameID];} ); self.switchPageComplete(); mySearchTeamDetails_games.pageLoadingLock = false;}, error: function(data, status) { if (status == 'timeout') { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorTimeout + ":</b> " + self.msgErrorTimeoutLong + "</div></div>";} else { if (data.status == 404) { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorPageNotFound + ":</b> " + self.msgErrorPageNotFoundLong + "</div></div>";}
else { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorUnknown + ":</b> " + self.msgErrorUnknownLong + "</div></div>";}
}
self.switchPageComplete(); mySearchTeamDetails_games.pageLoadingLock = false;}
}
$.ajax(opt);} else { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.gameInfoCache[gameID];}
}
}
function classTeamHistoryInfo() { this.baseHREF = document.getElementsByTagName("base")[0].href; this.xmlLocation = 'teams/_xmlTeamHistoryInfo.php'; this.IDExt = '_history'; this.useEffects = false; this.effectsFadeDuration = 500; this.effectsSlideDuration = 500; this.displayPageID = 'TeamDetailsContents'; this.previousSearch = ''; this.previousPageNum = ''; this.pageLoadingLock = false; this.pageLoadingID = 'SearchLoading'; this.objectName = 'myTeamHistoryInfo'; this.useAlternatingRowClass = true; this.rowClass1 = 'row1'; this.rowClass2 = 'row2'; this.msgErrorIcon = 'images/btn-error-whitebg.gif'; this.msgErrorTimeout = 'Timeout Error'; this.msgErrorTimeoutLong = 'Your request has timed out, please try again'; this.msgErrorPageNotFound = 'Page Not Found'; this.msgErrorPageNotFoundLong = 'Sorry, the page could not be found'; this.msgErrorUnknown = 'Unknown Error'; this.msgErrorUnknownLong = 'Sorry, an unknown error was encountered'; this.getTeamHistoryInfo = getTeamHistoryInfo; this.switchPageStart = switchPageStart; this.switchPageMiddle = switchPageMiddle; this.switchPageComplete = switchPageComplete; this.switchPageContent = switchPageContent; this.historyInfoCache = new Array();}
function getTeamHistoryInfo(historyID) { if (this.pageLoadingLock == false) { if (this.previousSearch == historyID) { if (document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = '';} else { if (this.historyInfoCache[historyID] != null) { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.historyInfoCache[historyID]; if (document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display == 'none') { document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display = 'block';}
}
}
var displayPageClosed = true;} else { var displayPageClosed = false;}
}
if (this.pageLoadingLock == false && mySearchTeamDetails_history.pageLoadingLock == false && this.previousSearch != historyID && displayPageClosed == false) { var customCheck = true; if (this.historyInfoCache[historyID] != null) { customCheck = false; this.displayPageID = 'history_id_' + historyID; document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (this.previousSearch != '' && document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display == 'block') { document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display = 'none';}
this.previousSearch = historyID;}
if (customCheck == true) { this.displayPageID = 'history_id_' + historyID; var self = this; mySearchTeamDetails_history.pageLoadingLock = true; this.switchPageStart(); document.getElementById(this.displayPageID + this.IDExt).style.display = 'block'; if (document.getElementById('history_id_' + this.previousSearch + this.IDExt) != null) { document.getElementById('history_id_' + this.previousSearch + this.IDExt).style.display = 'none'; this.previousSearch = historyID;} else { this.previousSearch = historyID;}
var opt = { url: this.baseHREF + this.xmlLocation, type: this.method, dataType: this.dataType, cache: this.xmlCache, timeout: this.ajaxTimeout, data: 'historyid=' + historyID, success: function(data) { var xmlRoot = $(data.documentElement); var xmlEntry = $(xmlRoot).find('entry')[0]; var entryData = new Object(); var newEntryData = ''; var rowClass = self.rowClass2; newEntryData = newEntryData + "<div style='display: block;'>"; newEntryData = newEntryData + "<div style='text-align: right; border-bottom: 1px solid gray; padding: 2px; font-size: 9px;'><a href='JavaScript:myTeamHistoryInfo.getTeamHistoryInfo(" + historyID + ");'>[close]</a></div>"; if ($(xmlRoot).attr('status') == 'ok' && $(xmlRoot).children().length > 0) { for (var i = 0; i < xmlEntry.childNodes.length; i++) { if(xmlEntry.childNodes[i].hasChildNodes() && xmlEntry.childNodes[i].firstChild.data.replace(/^\s+|\s+$/g, '').length > 0) { entryData[xmlEntry.childNodes[i].getAttribute('title')] = xmlEntry.childNodes[i].firstChild.data;} else { }
}
for (key in entryData) { if (self.useAlternatingRowClass == true) { rowClass = (rowClass == self.rowClass2 ) ? self.rowClass1 : self.rowClass2; var entryRowClass = " class='" + rowClass + "'";} else { var entryRowClass = '';}
newEntryData = newEntryData + "<div" + entryRowClass + " style='height: 1em;'>"; newEntryData = newEntryData + "<div style='float: left; font-weight: bold;'>" + key + ":</div> "; newEntryData = newEntryData + "<div style='float: right;'>" + entryData[key] + "</div>"; newEntryData = newEntryData + "</div>";}
} else { newEntryData = newEntryData + "<div class='" + rowClass + "'>"; newEntryData = newEntryData + "<span style='font-style:italic;'>* Sorry, no results found</span>"; newEntryData = newEntryData + "</div>";}
newEntryData = newEntryData + "<div style='text-align: right; border-top: 1px solid gray; padding: 2px; font-size: 9px; margin: 5px 0 0 0;'><a href='JavaScript:myTeamHistoryInfo.getTeamHistoryInfo(" + historyID + ");'>[close]</a></div>"; newEntryData = newEntryData + "</div>"; self.historyInfoCache[historyID] = newEntryData; self.switchPageMiddle( function() { document.getElementById(self.displayPageID + self.IDExt).innerHTML = self.historyInfoCache[historyID];} ); self.switchPageComplete(); mySearchTeamDetails_history.pageLoadingLock = false;}, error: function(data, status) { if (status == 'timeout') { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorTimeout + ":</b> " + self.msgErrorTimeoutLong + "</div></div>";} else { if (data.status == 404) { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorPageNotFound + ":</b> " + self.msgErrorPageNotFoundLong + "</div></div>";}
else { document.getElementById(self.displayPageID + self.IDExt).innerHTML = "<div style='height: 2em;'><div style='float: left;'><img alt='Error' style='align: absmiddle;' src='" + self.msgErrorIcon + "' /></div><div style='float: left; margin-left: 5px;'><b>" + self.msgErrorUnknown + ":</b> " + self.msgErrorUnknownLong + "</div></div>";}
}
self.switchPageComplete(); mySearchTeamDetails_history.pageLoadingLock = false;}
}
$.ajax(opt);} else { document.getElementById(this.displayPageID + this.IDExt).innerHTML = this.historyInfoCache[historyID];}
}
}
