<!--

if( !parent || !parent.WebPlayer )
	if(self.parent.frames.length != 0)
		self.parent.location.href = document.location.href;

document.onkeydown = documentKeyDownHandler

function documentKeyDownHandler(e)
{
	var keyCode = 0;
	var tagName = "";

	if(document.all) // IE
	{
		keyCode = event.keyCode;
		tagName = event.srcElement.tagName;
	}
	else if(document.getElementById) // every other modern browser
	{
		keyCode = e.which;
		tagName = e.target.tagName;
	}

	// prevent unintentional form submission by cancelling enter unless we are in a <textarea>
	if((keyCode != null) && (keyCode == 13))
	{
		if(tagName.toLowerCase() != "textarea")
		{
			event.returnValue = false;
			event.cancel = true;
		}
	}
}
		
// Enables an Enter press when a control has the focus.
// Called via the onKeyDown attribute of an element.
function clickButtonOnEnter(buttonId, event)
{
	var doClick = false;

	if(document.all) // IE
	{
		if(event.keyCode == 13) doClick = true;
	}
	else if(document.getElementById) // every other modern browser
	{
		if(event.which == 13) doClick = true;
	}

	if(doClick)
	{
		event.returnValue = false;
		event.cancel = true;

		document.getElementById(buttonId).click();
	}
}

function focusOnWebControl(controlID)
{
	window.onload = function()
	{
		if(document.getElementById(controlID) != null)
			document.getElementById(controlID).focus();
	}
}


var scorchInstalled = false;

// Check if we're running MSIE on Windows, in which case we can use
// VBScript.

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

if(isIE && isWin)
{
	document.write('<S' + 'CRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('scorchInstalled = (IsObject(CreateObject("ScorchActiveXPlugin.ScorchPlugin.1"))) \n');
	document.write('</S' + 'CRIPT\> \n');
}

// Version using navigator.plugins array, if it exists (which it doesn't, on MSIE).
function detectScorch() 
{
	if (navigator.plugins) 
	{
		if (navigator.plugins["ScorchNetscapePlugin"]) 
		{
			scorchInstalled = true;
		}
	}

	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth() + 12);

	var cookieExpires = nowDate.toUTCString();
	document.cookie = "scorchInstalled=" + scorchInstalled + ";expires=" + cookieExpires + ";";
}
	
function debugObject(obj)
{
	var msg = "";
	var i = 0;

	for(prop in obj)
	{
		msg += prop + ": " + obj[prop] + "\t";

		if((i % 4) == 0)
			msg += "\n";

		i++;
	}
	alert(msg);
}

function resdetect(baseUrl, fit_to)
{
	var scr_height = screen.availHeight;
	var scr_width = screen.availWidth;
	var redirectUrl = baseUrl + "&width=" + scr_width + "&height=" + scr_height + "&fit_to=" + fit_to;
	location.replace(redirectUrl);
}

function detectUserScreenResolution()
{
	// check to see if user res cookie exists
	var cookieValue = document.cookie;
	if (cookieValue != null)
	{
		var heightStartsAt = cookieValue.indexOf(' ' + 'height=');
		
		if (heightStartsAt == -1)
		{
			heightStartsAt == cookieValue.indexOf("height=");
		}

		if (heightStartsAt == -1)
		{
			// here we know the value is not yet set 
			createUserScreenResolutionCookie();
		}
	}
	else
	{
		createUserScreenResolutionCookie();
	}
}

function createUserScreenResolutionCookie()
{
	// grab screen dimensions
	var scr_height = screen.availHeight;
	var scr_width = screen.availWidth;
	
	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth() + 12);
	
	var cookieExpires = nowDate.toUTCString();

	document.cookie = "height=" + scr_height + ";expires=" + cookieExpires;
	document.cookie = "width=" + scr_width + ";expires=" + cookieExpires;
}

function interrogate(what) {
	var output = '';
	for (var i in what)
		output += i + ' ';
	alert(output);
}

var formInUse = false;

function setFocus()
{
	if(!formInUse)
	{
		document.Default.ucHeaderControlCollection_ucSearchBar_txtSearch.focus();
	}
}

// Globals
// Major version of Flash required
var requiredMajorVersion = 5;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;

// Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;

// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i)
	{
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25; i>0; i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
}

function detectFlash()
{
	var cookieValue = document.cookie;
	var flashVsn;

	if (cookieValue != null)
	{
		flashVsn = cookieValue.indexOf(' ' + 'flashVsn=');
		
		if (flashVsn == -1)
		{
			flashVsn == cookieValue.indexOf("flashVsn=");
		}

		if (flashVsn == -1)
		{
			createUserFlashCookie();
		}
	}
	else
	{
		createUserFlashCookie();
	}
}

function createUserFlashCookie()
{
	// here we know the value is not yet set 
	var flashVsn = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth() + 12);
	
	var cookieExpires = nowDate.toUTCString();

	document.cookie = "flashVsn=" + flashVsn + ";expires=" + cookieExpires;
}

function install( aEvent, extName, iconURL)  {   
	if (!navigator.userAgent.match(/Firefox/)) {
		if (confirm("The Sheetmusicdirect Toolbar requires the web browser Firefox.\n\nTo download Firefox, click on the link below:")) {
			window.location.href = "http://www.getfirefox.com/";
			return false;
		}
		if (!confirm("Would you like to try to install the Sheetmusicdirect Toolbar anyway?")) {
			return false;
			}
		}
		var params = new Array();
		params[extName] = {
		URL: aEvent.target.href,
		IconURL: iconURL,
		toString: function () { return this.URL; }
	};
	InstallTrigger.install(params);
	return false;
}

function addEngine(name,ext,cat,type)
{
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		window.sidebar.addSearchEngine(
		"http://mycroft.mozdev.org/install.php/" + type + "/" + name + ".src",
		"http://mycroft.mozdev.org/install.php/" + type + "/" + name + "."+ ext, name, cat );
		} else {
		alert("You will need a Mozilla based browser to install a search plugin.");
	}
}

function numbersOnly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

//-->