var centralSb = null;

function isDigit(num) 
{
    // Borrowed from web and seems a bit clunky - 
    // surely JS has one of these? Maybe I hope for
    // too much.
	if (num.length>1)
	{
	    return false;
	}
    var string="1234567890";
    
	if (string.indexOf(num)!=-1)
	{
	    return true;
	}
	return false;
}
function MediaElementMouseEnter(sender, args)
{
    // Probably get into all kind of race conditions
    // here. 
    if (centralSb != null)
    {
        centralSb.Stop();
        centralSb = null;
    }
    var name = sender.Name;    
    var number = name.charAt(name.length - 1);    
    var x = name.charAt(name.length - 2);
    
    if (isDigit(x))
    {
        number = name.substr(name.length - 2, 2);
    }
    var sbName = "sb" + number;    
    centralSb = getXamlElement("wpfeControl1", sbName);
    
    centralSb.Begin();    
}
function ErrorHandler(line, col, hr, string)
{
    var str = "Error on line, column ("+line+","+col+")\n"+string+"\n";
    str += "HRESULT: "+hr;
    alert(str);
};    