dataMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
dataDays = new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");

function drawButton(b_url,b_action,b_isDark,b_text,b_help) {
  btnStr = "<div style='position: relative; width: 88px; height: 19px;'><div class='clButton_base' style='background-image: url(images/button_glass_" + (b_isDark?"dark":"lite") + ".gif);'>" + b_text + "</div>";
//  btnStr = "<div style='position: relative; width: 79px; height: 19px;'><div class='clButton_base' style='background-image: url(images/button" + (b_isDark?"_bl":"") + ".gif);'>" + b_text + "</div>";
  if (b_help == undefined || b_help == "") {
    b_help = b_text;
  }
  if (b_url != "") {
    btnStr += "<a href='javascript:void(0)' onclick='document.location.href=\"" + b_url + "\"'>";
//    btnStr += "<a href=\"" + b_url + "\">";
  } else {
    btnStr += "<a href='javascript:void(0)' onclick='" + b_action + "'>";
  }
  btnStr += "<div class='clButton_link'><img src='images/spacer.gif' width='88' height='19' alt='" + b_help + "' title='" + b_help + "'></div></a></div>";
  document.write(btnStr);
}

function check4Enter(formID,evnt) {
  if (window.event) {
    keycode = window.event.keyCode;
  } else if (evnt) {
    keycode = evnt.which;
  } else {
    return true;
  }
  if (keycode == 13) {
    document.forms[formID].submit();
    return false;
  }
  return true;
}

function checkEmail(trgEmail) {
  emailChars = /^[\w\.\+&-]{2,}@\w{2,}(\.\w{2,})+$/;

  var tmpStr = "";
  if (trgEmail == "") {
    tmpStr = "Please enter your email address.";
  } else if (!emailChars.test(trgEmail)) {
    tmpStr = "Please enter a valid email address.";
  }

  if (tmpStr != "") {
    alert (tmpStr);
    return false;
  }
  return true;
}

function reqPrint(id,objType) {
  nwin = reqWindow(objType + "Print.php?aID=" + id);
  nwin.print();
  return false;
}

function reqImgBrowser(sportID) {
  nwin = reqWindow("selectImage.php?spID=" + sportID, "SportsReport");
  nwin.focus();
}

function reqImgUploader() {
  nwin = reqWindow("imgUpload.php",400,200);
  nwin.focus();
}

function reqBannerUploader() {
  nwin = reqWindow("bannerUpload.php",400,200);
  nwin.focus();
}

function reqWindow(newUrl, winW, winH) {
  if (typeof(winW) == "undefined") winW = 600;
  if (typeof(winH) == "undefined") winH = 400;
  return window.open(newUrl, "SportsReport", "toolbar=no,directories=no,resizable=yes,location=no,scrollbars=yes,menubar=no,status=yes,width="+winW+",height="+winH);
}

function getMouseCoord(evnt) {
	if (!evnt) var evnt = window.event;
	if (evnt.target) gCoord = evnt.target;
	else if (evnt.srcElement) gCoord = evnt.srcElement;
	if (gCoord.nodeType == 3) gCoord = gCoord.parentNode;
	cX = gCoord.offsetLeft;
	cY = gCoord.offsetTop;
	while (gCoord = gCoord.offsetParent) {
		cX += gCoord.offsetLeft;
		cY += gCoord.offsetTop;
  }
  return new Array(cX,cY);
}

function dispPopup(htmlStuff,evnt) {
  var mcoord = getMouseCoord(evnt);
  with ($("popupDiv")) {
    innerHTML = htmlStuff;
    style.display = "block";
    style.left = (mcoord[0] - offsetWidth - 5) + "px";
    style.top = ((mcoord[1] + offsetHeight > document.body.scrollHeight)?(document.body.scrollHeight - offsetHeight - 50):mcoord[1]) + "px";
  }
}

function dispFullImg(imgUrl,evnt,imgType,imgW,imgH,bID) {
  if (imgType) {
    switch (imgType) {
      case 'f':
        dC = "<div style='width:" + imgW + "px;height:" + imgH + "px;'>" + addFlash(imgUrl,imgW,imgH,"bID" + bID,'','',true) + "</div>";
//        dC = "<div style='width:" + imgW + "px;height:" + imgH + "px;'><script>addFlash(\"" + imgUrl + "\",\"bID" + bID + "\"," + imgW + "," + imgH + ")</script></div>";
        break;
      case 't':
        dC = "N/A";
        break;
      default: // i
        dC = "<img src=\"" + imgUrl + "\" width=\""+ imgW +"\" height=\""+ imgH +"\">";
        break;
    }
  } else {
    dC = "<img src=\"" + imgUrl + "\" width=\""+ imgW +"\" height=\""+ imgH +"\">";
  }
  dispPopup(dC,evnt);
}

function addSpecChar(targetObj,evnt) {
  specChars = new Array(192,224,193,225,194,226,195,227,196,228,197,229,198,230,200,232,201,233,202,234,203,235,204,236,205,237,206,238,207,239,209,241,210,242,211,243,212,244,213,245,214,246,217,249,218,250,219,251,220,252,221,253,199,231,223,208);
  htm = "<table border='0' cellpadding=0 cellspacing=0><tr>";
  for (i=0; i < specChars.length; i++) {
    htm += "<td align='center'><a href='javascript:void(0);' onClick='document.forms[0]." + targetObj + ".value += String.fromCharCode(" + specChars[i] + ");document.getElementById(\"popupDiv\").style.display=\"none\";document.forms[0]." + targetObj + ".focus();' class='letterBox'>" + String.fromCharCode(specChars[i]) + "</a></td>";
    if (Math.floor((i+1)/8) == (i+1)/8) htm += "</tr><tr>";
  }
  htm += "</tr></table><br><div align='center'><a href='javascript:void(0);' onClick='document.getElementById(\"popupDiv\").style.display=\"none\";document.forms[0]." + targetObj + ".focus();' class='smallButtonGreen'>Close</a></div>";
  dispPopup(htm,evnt);
}

function toggleNav(navid,isSub) {
	if (!isSub && (typeof(previd) != "undefined" && previd != navid)) {
		$(previd).style.display = "none";
		$(previd).previousSibling.firstChild.setAttribute("src","images/arrow_right.gif");
	}
	if ($(navid)) {
		thisObj = $(navid);
		if (thisObj.style.display =="none") {
			thisObj.style.display = "inline";
			thisObj.previousSibling.firstChild.setAttribute("src","images/arrow_down.gif");
		} else {
			thisObj.style.display = "none";
			thisObj.previousSibling.firstChild.setAttribute("src","images/arrow_right.gif");
		}
		if (!isSub) previd = navid;
	}
}

function switchTab(tId) {
	for (k in document.getElementsByTagName("div")) {
		if (document.getElementsByTagName("div")[k].className == "scoreBoard") {
			document.getElementsByTagName("div")[k].style.display = "none";
		}
	}
	$("st" + tId).style.display = "block";
	for (k in document.getElementsByTagName("a")) {
		if (typeof(document.getElementsByTagName("a")[k].className) != "undefined" && document.getElementsByTagName("a")[k].className.indexOf("scTab") > -1) {
			document.getElementsByTagName("a")[k].className = "scTab";
		}
	}
	$("lst" + tId).className += " selected";
}
