/* WNBA Game Info Custom js scripts - HM */

var customCSS = {
	
	customBorderCSS: function() {
		
		var tableObj = document.getElementsByTagName("table");
		
		for (var x = 0; x < tableObj.length; x++) {
			if (this.checkCSS(tableObj[x].className, "custcss")) {
				var row = tableObj[x];
				for (var r = 0; r < (row.rows).length; r++) {
					if (this.checkCSS(row.rows[r].className, "crow")) {
						this.borderCSSRow(row.rows[r]);
					}
				}
			}
		}
		
	},
	
	borderCSSRow: function(obj) {

		for (var x = 0; x < (obj.childNodes).length; x++) {
			if (x == (obj.childNodes).length-2 && (obj.childNodes[x]).nodeType == 1) {
				obj.childNodes[x].style.borderRight = "1px solid #DB6D1B";

			}
		}
		
	},
	
	checkCSS: function(obj, css) {
	
		if (obj.toLowerCase().indexOf(css) > -1)
			return true;
		else
			return false;
	
	}
	
	
}


function runScripts(gamestatus) {
	
	tabLinksCheck(gamestatus);
}

function setNavBar() {
	document.getElementById("articlespan").style.display = '';
	document.getElementById("boxscorespan").style.display = '';
	document.getElementById("playbyplayspan").style.display = '';
}

function tabLinksCheck(gamestatus) {

	var loc = window.location.pathname;
	
	var lastIndex = loc.lastIndexOf("/");
	var path = loc.substring(0, lastIndex + 1);
	
	if (!gamestatus || gamestatus > 2) {   // when game is in the postgame state
	
		// check if recap file exists
		var recapXmlhttpJ = helper.setXMLHttpRequest();
		var recap_path = path + "recap.html";

		if (recapXmlhttpJ) {

			recapXmlhttpJ.open("GET", recap_path, false);
			recapXmlhttpJ.send(null);

			if (recapXmlhttpJ.readyState == 4) {
				if (recapXmlhttpJ.status == 200) {
					document.getElementById("articlespan").style.display = "";
					document.getElementById("articlelink").innerHTML = "Recap";
					document.getElementById("articlelink").href = "recap.html";
				}
			}
		}
	} else if (gamestatus < 2) {   // when game is in the pre-game state
	
		// check if preview file exists
		var previewXmlhttpJ = helper.setXMLHttpRequest();
		var preview_path = path + "preview.html";

		if (previewXmlhttpJ) {

			previewXmlhttpJ.open("GET", preview_path, false);
			previewXmlhttpJ.send(null);

			if (previewXmlhttpJ.readyState == 4) {
				if (previewXmlhttpJ.status == 200) {
					document.getElementById("articlespan").style.display = "";
					document.getElementById("articlelink").innerHTML = "Preview";
					document.getElementById("articlelink").href = "preview.html";
				}
			}
		}
	}
	
}