﻿	var currId = 'nomatch';
	var HidingTimer
	var currLink
	var lhref = String
	
	function showDiv(link) {
	
	    clearTimeout(HidingTimer);
		var tmpDiv = document.getElementById('smartBox');
		
		identifier = link.attributes.rev.value
		lhref = link.attributes.href.value
		
        var headDiv = '<a href="javascript:hideDiv()"></a>'
        tmpDiv.innerHTML = headDiv + 'Loading...';

        tmpDiv.style.display = 'block';
	    tmpDiv.style.left = getRealLeft(link) + 'px'
	    tmpDiv.style.top =(getRealTop(link) + 20) + 'px'
	    
        var xmlhttp = new XMLHttpRequest();
        if (lhref.indexOf('coaches',0) > 0) {
            xmlhttp.open('GET', '/services/smartplayerview.aspx?coach=true&id=' + escape(identifier), true);
        } else if (lhref.indexOf('staff',0) > 0) {
            xmlhttp.open('GET', '/services/smartplayerview.aspx?staff=true&id=' + escape(identifier), true);
        }else {
            xmlhttp.open('GET', '/services/smartplayerview.aspx?id=' + escape(identifier), true);
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
                tmpDiv.innerHTML = headDiv
                tmpDiv.innerHTML += xmlhttp.responseText
                xmlhttp=null
            }
        }
        xmlhttp.send(null);
		currId = identifier
		
		//for( var myVariable in tmpDiv ) {
        //     alert( myVariable + ' = ' + tmpDiv[myVariable] + '' );
        //}
		
		
		
    return false;
    }
    
function properties_table(objectname, object) {
  document.write("<table border=1 bgcolor=wheat><tr>");
  document.write("<td style='font-size: 18pt; font-weight: bold' colspan=2 align=center>");
  document.write("Properties of the <code>"+objectname+"</code> object</td></tr>");

  for (prop in object) {
     document.writeln("<tr><th>"+prop+"</th><td>"+
     object[prop]+"</td></tr>");
  }

  document.writeln("</table><p>");
}    

    function startHide (){
	    HidingTimer = setTimeout('hideDiv();', 1000);
    }

    function hideDiv() {
        var tmpDiv = document.getElementById('smartBox');
        tmpDiv.style.display='none';
    }

    function addDiv() {
        if (document.getElementById('smartBox') == null) {
            var bod = document.getElementsByTagName('body');
            var newDiv = 
            bod[0].innerHTML += newDiv;
        }
    }

	document.write('<div id="smartBox"></div>')
        
    //attach smartbox links    
    function smart_links() {
        ary = document.getElementsByTagName('dfn')
    
        //firefox can do this
        
        if (ary.length == 0) {return}
        
        if (ary[0].childNodes[0]) {
            for(var k=0;k<ary.length;k++) {

                try {
                    ary[k].childNodes[0].onmouseover = function() {showDiv(this)}
                    ary[k].childNodes[0].onmouseout = function() {startHide()}
                } catch(e) {
                }
            }
        //IE can do this    
        } else {
            ary = document.getElementsByTagName('a')
            for(var k=0;k<ary.length;k++) {
                if (ary[k].attributes.rev) {
                    try {
                        ary[k].onmouseover = function() {showDiv(this)}
                        ary[k].onmouseout = function() {startHide()}
                    } catch(e) {
                      }
                }
            }        
        }      
         
    }
	

	

