<!--
//Start Default Button
 
 //Set The Focus on the Default Button
   
function setDefaultButton(DefaultButton1,DefaultButton2,DefaultButton3)
{
      var fhTextBox = document.getElementById("frmFindHockey");
      var topSearchTextBox = document.getElementById("Header1_SearchTextBox");
      var DefaultButton=document.getElementById(DefaultButton1);
      
      if(DefaultButton==null)
      {
        DefaultButton=document.getElementById(DefaultButton2);                
        
        if(DefaultButton==null)
        {
            DefaultButton=document.getElementById(DefaultButton3);   
        }
      }
       
      if(DefaultButton!=null)
      { if(DefaultButton.disabled==false && DefaultButton.visible==true)
         { 
        DefaultButton.focus();
        }
      }
   
//Code commented intentionally so it can be used in future to handle the focus events on CMSSearch TextBox and FindHockey TextBox   
//      fhTextBox["focussed"] = false; 
//      fhTextBox.onfocus = function(){this["focussed"] = true;}; 
//      fhTextBox.onblur = function(){this["focussed"] = false;}; 
//      fhTextBox["isfocussed"] = function(){return this.focussed;};
//       
//      topSearchTextBox["focussed"] = false; 
//      topSearchTextBox.onfocus = function(){this["focussed"] = true;}; 
//      topSearchTextBox.onblur = function(){this["focussed"] = false;}; 
//      topSearchTextBox["isfocussed"] = function(){return this.focussed;}; 

}

 function searchRedirect(url)
 {
    parent.window.location.href = url;
 }
 
 function KeyDownHandler(DefaultButton1,DefaultButton2,DefaultButton3,e)
 {
        // process only the Enter key
         var key;
        
         if(window.event)
              key =e.keyCode;     //IE
         else
              key = e.which;     //firefox
  
         if (key == 13)
         {
        
//Code commented intentionally so it can be used in future to handle the focus events on CMSSearch TextBox and FindHockey TextBox
//             var fhTextBox = document.getElementById("frmFindHockey");
//             var topSearchTextBox = document.getElementById("Header1_SearchTextBox");
//            
//             if(fhTextBox.isfocussed != "undefined")
//             {
//                if( fhTextBox.isfocussed()) 
//                {
//                    searchRedirect('../FindHockey/AdvSearchResult.aspx?SimpleSearch=' + fhTextBox.value);
//                    if(window.event)
//                    { 
//                        event.returnValue=false;
//                        event.cancel = true; 
//                        return;
//                    }
//                    else
//                    {
//                        e.preventDefault();
//                        return;     
//                    }
//                }
//             }
//             else if(topSearchTextBox.isfocussed != "undefined")
//             {
//                if( topSearchTextBox.isfocussed()) 
//                {
//                    alert("CMS  Search");
//                    searchRedirect('../CMSFiles/CMSSearchUsahockey.aspx?SearchText=' + topSearchTextBox.value);
//                    if(window.event)
//                    { 
//                        event.returnValue=false;
//                        event.cancel = true; 
//                        return;
//                    }
//                    else
//                    {
//                         e.preventDefault();
//                         return;     
//                     }
//                 }
//             }
//             else
//             {
                //ID of default button 
                var DefaultButton=document.getElementById(DefaultButton1);
          
                if(DefaultButton==null)
                {
                    DefaultButton=document.getElementById(DefaultButton2);
                    
                    if(DefaultButton==null)
                    {
                        DefaultButton=document.getElementById(DefaultButton3);   
                    }
                }
                
                if (DefaultButton!=null)
                {   
                    
                    if(window.event)
                    {  
                        DefaultButton.click();
                        event.returnValue=false;
                        event.cancel = true; 
                        return;
                    }
                    else
                    {  
                        DefaultButton.click();
                        e.preventDefault();
                        return;
                    } 
                }
//             }
         }
     }
  function KeyDownHandler_TextArea(DefaultButton1,DefaultButton2,DefaultButton3,DefaultArea1,DefaultArea2,e)
 {
        // process only the Enter key
         var key;
        
         if(window.event)
              key =e.keyCode;     //IE
         else
              key = e.which;     //firefox
  
         if (key == 13)
         {
        
//Code commented intentionally so it can be used in future to handle the focus events on CMSSearch TextBox and FindHockey TextBox
//             var fhTextBox = document.getElementById("frmFindHockey");
//             var topSearchTextBox = document.getElementById("Header1_SearchTextBox");
//            
//             if(fhTextBox.isfocussed != "undefined")
//             {
//                if( fhTextBox.isfocussed()) 
//                {
//                    searchRedirect('../FindHockey/AdvSearchResult.aspx?SimpleSearch=' + fhTextBox.value);
//                    if(window.event)
//                    { 
//                        event.returnValue=false;
//                        event.cancel = true; 
//                        return;
//                    }
//                    else
//                    {
//                        e.preventDefault();
//                        return;     
//                    }
//                }
//             }
//             else if(topSearchTextBox.isfocussed != "undefined")
//             {
//                if( topSearchTextBox.isfocussed()) 
//                {
//                    alert("CMS  Search");
//                    searchRedirect('../CMSFiles/CMSSearchUsahockey.aspx?SearchText=' + topSearchTextBox.value);
//                    if(window.event)
//                    { 
//                        event.returnValue=false;
//                        event.cancel = true; 
//                        return;
//                    }
//                    else
//                    {
//                         e.preventDefault();
//                         return;     
//                     }
//                 }
//             }
//             else
//             {
                //ID of default button 
                var DefaultButton=document.getElementById(DefaultButton1);
          
                if(DefaultButton==null)
                {
                    DefaultButton=document.getElementById(DefaultButton2);
                    
                    if(DefaultButton==null)
                    {
                        DefaultButton=document.getElementById(DefaultButton3);   
                    }
                }
                
                if (DefaultButton!=null)
                {   
                    if(window.event)
                    {  
                        
                        if(DefaultArea1!=null ||DefaultArea2!=null)
                        {
                         if(event.srcElement.id==DefaultArea1 ||event.srcElement.id==DefaultArea2 )
                        {
                           return;
                           }
                        }
                        
                        DefaultButton.click();
                        event.returnValue=false;
                        event.cancel = true; 
                        return;
                    }
                    else
                    { 
                   if(DefaultArea1!=null ||DefaultArea2!=null)
                        {
                        
                        if(e.target.id==DefaultArea1 || e.target.id==DefaultArea2)
                           return; 
                           }
                        DefaultButton.click();
                        e.preventDefault();
                        return;
                    } 
                }
//             }
         }
     }
//End Default button
//Browser Detection
function browserSniff() 
{ 
	var browserName=navigator.appName; 
	if (browserName=="Netscape")
	{ 
		if (parseInt(navigator.appVersion) < 5 ) 
		{location.href="/Browser.html";}
	}
	else if (browserName=="Microsoft Internet Explorer")
	{
		if (parseInt(navigator.appVersion) < 4 ) 
		{location.href="/Browser.html";}
	}
	//else
	//{location.href="/Browser.html";}
}
browserSniff();



//prevent news and other sites from loading this site in a frame
if (top != self)
{                                 
   
   top.location = self.location; 

}

function setImageActive(imgname)
{document.images[imgname].src = eval(imgname + "_over.src");}

function setImageInactive(imgname)
{document.images[imgname].src = eval(imgname + "_off.src");}

function setImageInactive_on(imgname)
{document.images[imgname].src = eval(imgname + "_on.src");}

function setImageInactive_over(imgname)
{document.images[imgname].src = eval(imgname + "_over.src");}


/** Opens a help menu and places it over the location of the mouse */
function showPhotoCredit(event, id, valueToMoveXcoordUp) {
          var el, x, y;
          el = document.getElementById(id);

          // don't run this if the element is already visible
          if(el.style.visibility == "visible") return;
         
          // position help item and make it visible
          if (window.event) {
			x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
          }

          else {
          x = event.clientX + window.scrollX;
          y = event.clientY + window.scrollY;
          }

          x -= 150; y -= valueToMoveXcoordUp;
          el.style.left = x + "px";
          el.style.top  = y + "px";
          el.style.visibility = "visible";
}

function hideDiv(id) {
	el = document.getElementById(id);
	el.style.visibility = "hidden";
}

function showDiv(id) {
	el = document.getElementById(id);
	el.style.visibility = "visible";
}

function expandDiv(layerName) {
	var layerName = layerName;
	document.getElementById(layerName).style.display = "block";
}

function collapseDiv(layerName) {
	var layerName = layerName;
	document.getElementById(layerName).style.display = "none";
}


function toggleDiv(divToToggle, imageToUpdate) {
	if (document.getElementById(divToToggle).style.display == "none") {
		expandDiv(divToToggle); 
		document.images[imageToUpdate].src = eval("minusSign.src");
	}
	else {
		collapseDiv(divToToggle);
		document.images[imageToUpdate].src = eval("plusSign.src");
	}
}


// preload universal images
if (document.images)
{
	plusSign = new Image();
	plusSign.src = "/Images/USAH/Navigation/tabs/icon_list-on.gif";
	minusSign = new Image();
	minusSign.src = "/Images/USAH/Navigation/tabs/icon_list-off.gif";
	
	tab_1_over = new Image();
	tab_1_over.src = "/Images/USAH/Navigation/tabs/tab_A_bg_over.gif";
	tab_1_off = new Image();
	tab_1_off.src = "/Images/USAH/Navigation/tabs/tab_A_bg.gif";
	tab_1_on = new Image();
	tab_1_on.src = "/Images/USAH/Navigation/tabs/tab_A_bg_over.gif";
	
	tab_2_over = new Image();
	tab_2_over.src = "/Images/USAH/Navigation/tabs/tab_B_bg_over.gif";
	tab_2_off = new Image();
	tab_2_off.src = "/Images/USAH/Navigation/tabs/tab_B_bg.gif";
	tab_2_on = new Image();
	tab_2_on.src = "/Images/USAH/Navigation/tabs/tab_B_bg_over.gif";
	
	tab_3_over = new Image();
	tab_3_over.src = "/Images/USAH/Navigation/tabs/tab_B_bg_over.gif";
	tab_3_off = new Image();
	tab_3_off.src = "/Images/USAH/Navigation/tabs/tab_B_bg.gif";
	tab_3_on = new Image();
	tab_3_on.src = "/Images/USAH/Navigation/tabs/tab_B_bg_over.gif";
	
	tab_4_over = new Image();
	tab_4_over.src = "/Images/USAH/Navigation/tabs/tab_C_bg_over.gif";
	tab_4_off = new Image();
	tab_4_off.src = "/Images/USAH/Navigation/tabs/tab_C_bg.gif";
	tab_4_on = new Image();
	tab_4_on.src = "/Images/USAH/Navigation/tabs/tab_C_bg_over.gif";	
}
/* commented as per chris bryant 4/17/07
function addCaption(oImgElem)
{
  // Insert Caption
  var oCaptionElem = document.createElement("div");
  oCaptionElem.className = "caption";


  var oCaptionTextElem = document.createElement("div");
  oCaptionTextElem.className = "caption-text";
  var oCaptionText = document.createTextNode( oImgElem.alt );
  oCaptionTextElem.appendChild(oCaptionText );
  oCaptionElem.appendChild(oCaptionTextElem);

  if(oImgElem.nextSibling) 
    oImgElem.parentNode.insertBefore(oCaptionElem,
      oImgElem.nextSibling);
  else
    oImgElem.parentNode.appendChild(oCaptionElem);

  with(oImgElem.style)
  {
    oCaptionElem.style.width = (oImgElem.width+borderLeft+
      borderRight+paddingLeft+paddingRight)+"px";
  }

  return true; 
}
*/
function addCaption(oImgElem)
{
  // Insert Caption
  var oCaptionElem = document.createElement("div");
  oCaptionElem.className = "caption";

  var oCaptionTextElem = document.createElement("div");
  oCaptionTextElem.className = "caption-text";
  var oCaptionText = document.createTextNode(oImgElem.alt);
  oCaptionTextElem.appendChild(oCaptionText);
  oCaptionElem.appendChild(oCaptionTextElem);

  if (oImgElem.parentNode.childNodes.length < 3)
  {
           if(oImgElem.nextSibling)
              oImgElem.parentNode.insertBefore(oCaptionElem, oImgElem.nextSibling);
            else
              oImgElem.parentNode.appendChild(oCaptionElem);

           with(oImgElem.style)
            {
             oCaptionElem.style.width = (oImgElem.width+borderLeft+
                borderRight+paddingLeft+paddingRight)+"px";
            }
  }

  return true; 
}

//function positionTertFlyoutNav(oDivToAlignTo,oDivToPosition)
//{
	//alert(getAnchorPosition(oDivToAlignTo).y);
	/* alert(document.getElementById(oDivToAlignTo).style.top); 
	var el1 = document.getElementById(oDivToAlignTo);
	var el2 = document.getElementById(oDivToPosition);
	alert("-" + getObjectTop(el1) + "-");
	alert("-" + GetCurrentStyle(el1,top) + "-");
	el2.style.top = el1.style.top;
	alert (eval(GetCurrentStyle(oDivToAlignTo,top)));*/
//}
function hideDiv(id) {
    if (document.getElementById(id) != null) {
        el = document.getElementById(id);
        el.style.visibility = "hidden";
    }
}

function showAndPositionDivToAnchor(anchorname,divID) {
    if (document.getElementById(divID) != null) {
	    el = document.getElementById(divID);
	    el.style.top = getAnchorPosition(anchorname).y
	    el.style.visibility = "visible";
    }
}

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}
// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}


function P7_colH2()
{ 
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;
 if(dA&&dA.length)
 {
    for(i=1;i<dA.length;i+=2)
    {
       // alert(dA[2].id);
       if(dA[i+1].id!='p7eq1')
        dA[i+1].style.paddingBottom='';
    }
    for(i=1;i<dA.length;i+=2)
    {
        oh=dA[i].offsetHeight;h=(oh>h)?oh:h;
    }
    for(i=1;i<dA.length;i+=2)
        {
            oh=dA[i].offsetHeight;
            if(oh<h)
            {
                np=h-oh;
                if(!an&&dA[0]==1)
                {
                    if(dA[i+1].id!='p7eq1')
                    P7_eqA2(dA[i+1].id,0,np);
                }
                else
                {
                if(dA[i+1].id!='p7eq1')
                dA[i+1].style.paddingBottom=np+"px";
                }
            }
        }
    document.p7eqa=1;
    document.p7eqth=document.body.offsetHeight;
    document.p7eqtw=document.body.offsetWidth;
 }
}

function P7_eqT2()
{ 
    if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth)
    {
    P7_colH2();
    }
}

function P7_equalCols2()
{ 
    document.p7eqc=new Array();
    document.p7eqc[0]=arguments[0];
    var c,e,el;
 if(document.getElementById)
 {
    document.p7eqc=new Array();
    document.p7eqc[0]=arguments[0];
    //alert(arguments[0]+'-'+arguments[1]+'-'+arguments[2]+'-'+arguments[3]+'-'+arguments[4]+'-'+arguments[5]+'-'+arguments[6]);

    for(i=1;i<arguments.length;i+=2)
    {
      
        el=null;
        c=document.getElementById(arguments[i]);
        if(c)
        {
            e=c.getElementsByTagName(arguments[i+1]);
            if(e)
            {
                if (e != null && e.length > 0) {
                    el=e[e.length-1];
                    if(el!= null)
                    {
                        if(!el.id)
                        {
                               el.id="p7eq"+i;
                       
                        }
                    }
                }
             }
         }
         if(c&&el)
         {
            document.p7eqc[document.p7eqc.length]=c;
            document.p7eqc[document.p7eqc.length]=el
         }
     }
     
            setInterval("P7_eqT2()",10);
   }
 
}

function P7_eqA2(el,p,pt)
{ 
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

// global array used to persist status of errors messages across ajax calls
var errorShownPreviously = new Array();

function ShowAnyErrors(errorClassName)
{        
    modalErrors = $(errorClassName);
    
    for(var i=0; i < modalErrors.length; ++i)
    {
        var elem = modalErrors[i];       
        
        // if error had been already been previously shown, don't animate it (show instantly)
        var showspeed = (errorShownPreviously[i]) ? "" : "fast";
        
        // if error had already been previously hidden, don't animate it as well
        var hidespeed = (errorShownPreviously[i]) ? "fast" : "";

        if(HasTextContent(elem))  // utility function from master.js
        {                           
            $(elem).show(showspeed);                 
            errorShownPreviously[i] = true;
        }
        else
        {
            $(elem).show();
            $(elem).hide(hidespeed);            
            errorShownPreviously[i] = false;
        }
    }            
}

// stripping whitespace will show length of 0 if element truly does not have text content    
function HasTextContent(elem)
{
        var textContent = elem.textContent || elem.innerText;                            

        // NOTE: replace regex contains Safari fix since that browser uses &#160; to indicate non-breaking space
        return (textContent.replace(/[\s\xA0]/g, "").length > 0);  
}

//-->
