// JavaScript Document
function showImage(r_dir, s_dir) {
  r_images = new Array("baseball", "basketball", "field_hockey", "football", "golf", "gymnastics", "lacrosse", "music", "officials", "soccer", "softball", "spirit", "sportsmanship", "student_council", "swimming", "tennis", "track", "volleyball", "wrestling", "xcountry");
  i_length = r_images.length;
  m_boolean = false;

  for (i = 0; i < i_length; i++) {
    if (s_dir == r_images[i]) {
	  m_boolean = true;	
	break;
	}
  }
  
  if ((m_boolean == true) && ((r_dir == "sports") || (r_dir == "activities") || (r_dir == "officials"))) {
	document.write('<img src="/images/action/'+s_dir+'.jpg" align="right" border="1">');
  } else { 
    i_src = Math.round(Math.random() * (i_length - 1));
    document.write('<img src="/images/action/'+r_images[i_src]+'.jpg" align="right" border="1">');
  }
}

function scoreBoard(sport, scores) {
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.open("GET","http://www.maxpreps.com/feeds/affiliates/chsaa/scoreboard.ashx?apikey=d0bc6c2d-6d9c-4c89-a400-35621f1a5d2b&"+sport,false);
	xmlhttp.send();
	xmlDoc=xmlhttp.responseXML;
	
	document.write("<table border='0' cellspacing='0' cellpadding='4' style='border: 1px solid #000;'>");
	document.write("<tr><th style='border-bottom: 1px solid #000;'>Date</th><th style='border: 1px solid #000; border-width: 0 0 1px 1px;'>Games</th></tr>");
	var x=xmlDoc.getElementsByTagName("Game");
	var hex='';
	if (scores) { cap=x.length; } else { cap=25; }
	  for (i=0;i<cap;i++)
	  {
	  if (i%2==0) { hex='#f1f1f1'; } else { var hex='#ffffff'; }
	  document.write("<tr bgcolor='"+hex+"'><td>");
	  document.write(x[i].attributes.getNamedItem("Date").value); 
	  document.write("</td><td style='border-left: 1px solid #000;'>");
	  document.write('<a href="'+x[i].attributes.getNamedItem("TargetURL").value+'" target="_blank">'+x[i].attributes.getNamedItem("SchoolName").value+" "+x[i].attributes.getNamedItem("Score1").value+" @ "+x[i].attributes.getNamedItem("School2Name").value+" "+x[i].attributes.getNamedItem("Score2").value+'</a>'); 
	  document.write("</td></tr>");
	  //document.write(x[i].attributes.getNamedItem("Result1").value+' <a href="'+x[i].attributes.getNamedItem("TargetURL").value+'" target="_blank">'+x[i].attributes.getNamedItem("Score1").value+"-"+x[i].attributes.getNamedItem("Score2").value+'</a>'); 
	  //document.write("</td></tr>");
	  }
	document.write("</table>");	
	document.write("<div style='float: left; margin-top: 5px;'><a href='?scores=all#bump'>more scores &raquo;</div>");	
}
