
function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) 
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
		{
			return document.embeds[movieName];
		}
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		return document.getElementById(movieName);
	}        
}

function TextInterface(thePath)
{
	//This is subject to change it depends on the .swf file flash application name
 	//in this case, the test swf file that I loaded is called myFilter.swf

	var movieName = window._flashConst_Name;


	this.GetText = function()
	{        
		var raw = thePath;
		return raw.replace(/<\/?FONT[^>]*>/gi, "");
	}

	this.SetText = function(text)
	{
		var set = getFlashMovieObject(movieName);
		//set.SetVariable(thePath, text);
		set.callFromJS(text);
	}
}

function callFromFlash(myPath, lang)
{
	setLanguage(lang);
	var source = new TextInterface(myPath);
                       
	try
	{
		var text = source.GetText();
	}
	catch (error)
	{
		alert("Error getting text from the Flash movie. Please check your Flash player plugin. ");
		return;
	}
	
    var spell = GetRadSpell(RadSpellClientID);
                        
    spell.GetDialogOpener().UseClassicDialogs = true;
    spell.SetTextSource(source);
    spell.StartSpellCheck();

	//spell.OnClientCheckFinished = function(){
	//getFlashMovieObject("myFilter").goHome();
	//}
}

function setLanguage(e)
{
	var radSpell = GetRadSpell(RadSpellClientID);
	radSpell.DictionaryLanguage = e;
}

//function sendModifiedText(myText){
//	getFlashMovieObject("Filter").myText(myText);	
//}

//function callMe(){
//	getFlashMovieObject("myFilter").callFromJS();;
//}

