current_menu = "";
current_global_menu = "";
menu_on = 0;
global_menu_on = 0;


//------------------------------- Code for Navigation -------------------//


function buildMenu(menu_name, menu_array, section)
{
	// [0] - Background Color
	// [1] - Border Color
	// [2] - Highlight Color
	// [3] - Link Name
	// [4] - Link HREF
	// [5] - Link Target

	document.write("<span id=\"" + menu_name + "\" style=\"position: Relative; top: 2px; left: 0px; display: none;\" onMouseOver=\"stopTimer();\" onMouseOut=\"startTimer();\">\n");   
	document.write("<table class=mainnav border=0 cellpadding=0 cellspacing=0>\n");
	document.write("<tr>\n");
	
	for (i = 3; i < menu_array.length; i = i + 3)
	{
		if (menu_array[i] == "")
		{
			break;
		}
		
		document.write("<td id=\"" + menu_name + i + "\" style=\"border-bottom: 0px solid #" + menu_array[1] + "; border-left: 0px solid #" + menu_array[1] + "; border-right: 0px solid #" + menu_array[1] + ";\"\n");

		if(menu_array[i+1].indexOf("javascript:")==-1){
			document.write("<span onClick=\"goUrl('" + menu_array[i+1] + "', '" + menu_array[i+2] + "');\" onMouseOver=\"stopTimer(), menuItemOn('" + menu_name + i + "', '" + menu_array[2] + "');\" onMouseOut=\"menuItemOff('" + menu_name + i + "', '" + menu_array[0] + "');\">\n");
		}
		else{
			document.write("<span onClick=\""+menu_array[i+1]+"\" onMouseOver=\"stopTimer(), menuItemOn('" + menu_name + i + "', '" + menu_array[2] + "');\" onMouseOut=\"menuItemOff('" + menu_name + i + "', '" + menu_array[0] + "');\">\n");
		}
		
		document.write("<table width=\"100%\" border=0 cellpadding=0 cellspacing=0><tr><td class=\"dhtml_link_cell\" width=\"100%\">\n");
		
		if (menu_array[i+2] == "")
		{
			if(menu_array[i+1].indexOf("javascript:")==-1){
				document.write("<a class=\"dhtml_link\" href=\""  + menu_array[i+1] + "\">" + menu_array[i] + "</a>\n");
			}
			else{
				document.write("<a class=\"dhtml_link\" href=\"javascript:doNothing();\">" + menu_array[i] + "</a>\n");
			}	
			
		}
		else
		{
			document.write("<a class=\"dhtml_link\" href=\"javascript:doNothing();\">" + menu_array[i] + "</a>\n");	
		}
		
		document.write("</td></tr></table>\n");
		document.write("</span>\n");
		document.write("</td>\n");
		
	}
	
	document.write("</tr>\n");
	document.write("</table>\n");
	document.write("</span>\n");

}

function buildParentLink(nav_font_color, nav_format, menu_counter, link_name, link_url)
{
	document.write("<tr>");
	
	document.write("<td>");
		document.write("<span id=\"parent_span_menu_" + menu_counter + "\" onMouseOver=\"stopTimer(), showMenu('menu_" + menu_counter + "');\" onMouseOut=\"startTimer();\">");
		document.write("<table id=\"parent_menu_" + menu_counter + "\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"150\">");
		document.write("<tr>");
		
		document.write("<td valign=\"top\" width=\"5\"><img src=\"images/home_" + nav_format + "_arrow.gif\" width=\"5\" height=\"10\" hspace=\"0\" vspace=\"4\" alt=\"nav arrow\" border=\"0\" id=\"parent_arrow_menu_" + menu_counter + "\"/></td>");
		document.write("<td width=\"110\" class=\"dhtml_parent_cell\"><a href=\"" +js_section_special +js_section + "_nav_go.asp?name=" + escape(link_name) + "&url=" + escape(link_url) + "\" style=\"color: #" + nav_font_color + "; text-decoration: none; font-weight: bold; font-size: 13px;\" id=\"parent_link_menu_" + menu_counter + "\">" + link_name + "</a></td>");
		
		document.write("</tr>");
		document.write("</table>");
		document.write("</span>");
	
	document.write("</td>");
	
	document.write("</tr>");
}

function buildParentGlobalLink(nav_font_color, nav_format, menu_counter, link_name, link_url)
{
	if (link_url.search(/javascript\:/) == -1)
	{
		rtn_string = "<span id=\"parent_link_global_menu_" + menu_counter + "\"><a class=\"topnav\" href=\"global_" +js_section + "_nav_go.asp?name=" + escape(link_name) + "&url=" + escape(link_url) + "\" onMouseOver=\"stopTimer(), showGlobalMenu('global_menu_" + menu_counter + "');\" onMouseOut=\"startTimer();\">" + link_name + "</a></span> &nbsp;&nbsp;|&nbsp;&nbsp;";
	}
	else
	{
		rtn_string = "<span id=\"parent_link_global_menu_" + menu_counter + "\"><a class=\"topnav\" href=\"" + link_url + "\">" + link_name + "</a><span> &nbsp;&nbsp;|&nbsp;&nbsp;";
	}
	
	return rtn_string;
}

function menuItemOn(element_name)
{
	eval("document.getElementById(\"" + element_name + "\")");
}

function menuItemOff(element_name)
{
	//alert("in");
	eval("document.getElementById(\"" + element_name + "\")");
}

function showMenu(menu_name)
{
	if (current_menu != "")
	{
		hideMenu();
	}
	
	current_menu = menu_name;
	
	parentWidth = eval("document.getElementById(\"parent_" + menu_name + "\").offsetWidth");

	xPos = getAbsPos("parent_" + menu_name)[0];
	yPos = getAbsPos("parent_" + menu_name)[1];
	xPos += parentWidth - 5;
	
	// show menu
	eval("document.getElementById(\"" + menu_name + "\").style.left='" + xPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.top='" + yPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.display='block'");
	
	// highlight parent link
//	eval("document.getElementById(\"parent_link_" + menu_name + "\").style.textDecoration='underline'");
	//eval("document.getElementById(\"parent_arrow_" + menu_name + "\").src=nav_arrow_on.src");
	//eval("document.getElementById(\"parent_" + menu_name + "\").style.background='#BBCDDF'");
}

function showGlobalMenu(menu_name)
{
	if (current_menu != "")
	{
		hideMenu();
	}
	
	current_menu = menu_name;
	
	yPos = -5;
	xPos = 0;
	
	// show menu
	eval("document.getElementById(\"" + menu_name + "\").style.left='" + xPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.top='" + yPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.display='block'");
}

function hideMenu()
{
	// hide menu
	eval("document.getElementById(\"" + current_menu + "\").style.display='none'");
	
	// un-highlight parent link
//	eval("document.getElementById(\"parent_link_" + current_menu + "\").style.textDecoration='none'");
	if (eval("document.getElementById(\"parent_arrow_" + current_menu + "\")") != null)
	{
		//eval("document.getElementById(\"parent_arrow_" + current_menu + "\").src=nav_arrow_off.src");
		//eval("document.getElementById(\"parent_" + current_menu + "\").style.background='#ffffff'");
	}
	
	current_menu = "";
}

function startTimer()
{
	menu_on = setTimeout("hideMenu()", 500);
}

function stopTimer()
{
	if (menu_on != 0)
	{
		clearTimeout(menu_on);
	}
}

function goUrl(go_url, go_target)
{
	if (go_url != "")
	{
		if (go_target != "")
		{
			window.open(go_url);
		}
		else
		{
			location.href = go_url;
		}
	}
}

function getX(el) 
{ 
	xPos = el.offsetLeft; 
	tempEl = el.offsetParent; 
	while (tempEl != null) 
	{ 
		xPos += tempEl.offsetLeft; 
		tempEl = tempEl.offsetParent; 
	} 
	return xPos; 
} 

function getY(el) 
{ 
	yPos = el.offsetTop; 
	tempEl = el.offsetParent; 
	
	while (tempEl != null) 
	{ 
		yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; 
	} 
	
	return yPos; 
} 

function getAbsPos(id) 
{ 
	var el = document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : null; 
	
	if (el) 
	{ 
		var trueX = getX(el); 
		var trueY = getY(el); 
	} 
	
	return new Array(trueX, trueY);
} 

function underLine(learn_link){

	eval("document.getElementById(\"learn_"+learn_link+"\").style.textDecorationUnderline");

}

function removeU(learn_link){

	eval("document.getElementById(\"learn_"+learn_link+"\").style.textDecorationNone");

}


//------------------------------- Code to Display Players on Homepage -------------------//

var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}


xmlDoc.async=false;
xmlDoc.load("home_xml/playerprofile.xml");
var strx=xmlDoc.getElementsByTagName("Player");
//alert(strx.length)
var strlen = strx.length
var li=0;
var j=1;


function next()
{
  if((li > strlen) || (j > strlen-1))
  {
    li=0;
    j=1; 
    

  }
  else
  {
	li=li+2;
    j=j+2;
  }
display();
}


function previous()
{

  if (li>1 || j>1)
  {
    li=li-2;
    j=j-2;
  }
  else
  { 
    li=strlen;
    j=strlen-1; 
  }
display();
}


function display()
{ 
   if(j < strlen)
   {
  
	strname=(strx[j].getElementsByTagName("Name")[0].childNodes[0].nodeValue);
	strNum=(strx[j].getElementsByTagName("Number")[0].childNodes[0].nodeValue);
	strthmb=(strx[j].getElementsByTagName("Thumbnail")[0].childNodes[0].nodeValue);
	strID=(strx[j].getElementsByTagName("playerID")[0].childNodes[0].nodeValue);
	
	document.getElementById("show1").innerHTML= "<a href=derbygirls.asp?Sid=" + j + " class=blacknav><img src='images/skaters/" + strthmb + "' border=0 width=92 height=97><br />" + strname + "<br /></A>";
   }	
   else
   {
 
	document.getElementById("show1").innerHTML= "" ;
   }
	
   if(li < strlen)
   {
   
	strname=(strx[li].getElementsByTagName("Name")[0].childNodes[0].nodeValue);
	strNum=(strx[li].getElementsByTagName("Number")[0].childNodes[0].nodeValue);
	strthmb=(strx[li].getElementsByTagName("Thumbnail")[0].childNodes[0].nodeValue);
	strID=(strx[li].getElementsByTagName("playerID")[0].childNodes[0].nodeValue);
	
	document.getElementById("show").innerHTML= "<a href=derbygirls.asp?Sid=" + li + " class=blacknav><img src='images/skaters/"+ strthmb +"' border=0 width=92 height=97><br />" + strname + "<br /></A>";
   }
   else
   {

	document.getElementById("show").innerHTML= "";
   }
}






//-----------------------------Random Sponsor Stuff ------------------------//
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// build Array from the Sponsor XML
var imgs = new Array();
	var xmlDoc;
	// code for IE
	if (window.ActiveXObject)
	{
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation.createDocument)
	{
	xmlDoc=document.implementation.createDocument("","",null);
	}
	
	xmlDoc.async=false;
	xmlDoc.load("home_xml/sponsor.xml");
	var s=xmlDoc.getElementsByTagName("SponsorData");

//imgs = document.getElementsByTagName("img")
	for (var t=0;t<s.length;t++)
	{
		strimg=(s[t].getElementsByTagName("image")[0].childNodes[0].nodeValue);
		imgs[t]= "images/sponsor/banner/"+ strimg;
		
		//if(imgs[t].width>"280")
		//{
			//alert("Img larger then 280")
			//imgs[t].src=setDefaultErrImg;
			//imgs[t].setAttribute("width","280");
		//}
		//else
		//{
		//	imagesArr[stri].setAttribute("alt",tempImgAttrib);
		//}
		
	}
	


// delay in milliseconds between image swaps 1000 = 1 second 
var delay = 1750;
var counter = 0;

function preloadImgs(){
	for(var i=0;i<imgs.length;i++){
		MM_preloadImages(imgs[i]);
	}
}

function randomImages(){
	if(counter == (imgs.length)){
		counter = 0;
	}
	MM_swapImage('rotator', '', imgs[counter++]);
	setTimeout('randomImages()', delay);
}
//-->