
/*	
	FlashAid
	
	Allows JavaScript to check if an accessibility aid (currently: screen reader)
	is active on the user's computer by using a Flash application. Only works on
	Internet Explorer.

	See index.html for usage instructions.

	Contributors: Aral Balkan, Jeremy Keith, Niqui Merret.
	
	Copyright (c) 2006 Aral Balkan. Released under the open source MIT License.
	For more information, see: http://aralbalkan.com
	
	flashAid() method embeds the FlashAid SWF file and initializes with the 
	references to the various callback functions.
	
	callback (String): 				Name of the callback function. This method
									is called with a boolean value that indicates whether
									an accessibility aid is currently active and communicating
									with the Flash Player. The only accessibility aid currently
									supported is a screen reader. If your callback is called
									with the value true, you can be sure that the user has a 
									screen reader active. 
									
	failureCallback (String): 		Name of the callback function to call if the call fails. (More
									than likely, the user has the wrong version of the Flash player.)
	
	displayVersionMessage (Bool): 	Whether or not to display a warning message if the correct
									Flash version does not exist for FlashAid to work.

*/	

//alert('this is flashAid');
function flashAid ( callback, failureCallback, displayVersionMessage)
{
	
	// Create a new SWFObject
	var so = new SWFObject("../../flashaid_v1_2/swf/flashAid.swf", "flashAidSwf", 1, 1, 8);
	
	
	
	// Lets take the minimum CPU possible. The movie is already set to
	// 1 pixel x 1 pixel and 1 FPS. 
	so.addParam("quality", "low");
	so.addParam("allowScriptAccess", "all");

	// Pass the success handler's name to the Flash application. Flash 
	// will call this handler using ExternalInterface.
	so.addVariable("callback", callback);

	// Try and write out the SWFObject
	var success = so.write("flashAid");


	// If there's a problem in writing the tag, try to give the user more 
	// information (they've probably got the wrong version of the player)
	
	if ( success )
	{
		// Successfully embedded. Now give the Flash movie focus
		// or else it will be ignored by the screen reader and not
		// get an update on isActive.
		document.getElementById("flashAidSwf").focus();
		
	}
	else
	{
		// Embedding the Flash application failed. 
	
		// Display the version message in the flashAid div only
		// if we've been asked to do so.
		if ( displayVersionMessageBool )
		{
			var version = deconcept.SWFObjectUtil.getPlayerVersion();
			if (document.getElementById && (version['major'] > 0)) 
			{
				document.getElementById(sampleName).innerHTML = "<p>This sample requires Flash Player version " + requireVersion + ". You have Flash player "+ version['major'] +"."+ version['minor'] +"."+ version['rev'] +" installed. <a href='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>Download the latest Flash Player</a> to run the sample.</p>";
			}
		}
		
		// Call the failure callback
		this [ failureCallback ]();
	}
}