//--------------------------------------
//	Flash Script Command, version 1.0
//		author: Fictiony Chen
//		email:  fictiony@china.com
//		date:   2003.7.28
//--------------------------------------
//warning: this script can only run under IE!

//define fscommand actions
if (typeof(FlashObjects) == "object") {
	for (var i in FlashObjects) {
		document.writeln('<SCRIPT LANGUAGE=VBScript>');
		document.writeln('on error resume next');
		document.writeln('Sub ' + FlashObjects[i] + '_FSCommand(ByVal command, ByVal args)');
		document.writeln('  call onFSCommand(' + FlashObjects[i] + ', command, args)');
		document.writeln('end sub');
		document.writeln('<\/SCRIPT>');
	}
}

//FSCommand event handler
function onFSCommand(sender, command, args) {
	command				= command.split(":");
	switch (command[0]) {
	case "function":
		eval(command[1])(args);
		break;
	case "eval":
		var result		= eval(args);
		if (command[1] != null) sender.SetVariable(command[1], result);
		break;
	case "submit":
		var frameName	= "Frame:" + sender.id + ":" + command[1];
		if (typeof(document[frameName]) == 'undefined') {
			document.body.insertAdjacentHTML('beforeEnd', '<IFRAME NAME="' + frameName
				+ '" WIDTH=0 HEIGHT=0><\/IFRAME>');
		}
		args			= args.split(",");
		if (args.length > 1) {
			args[1]		= args[1].split("&");
			for (var i in args[1]) {
				var t	= args[1][i].split("=");
				args[1][i]	= '<INPUT TYPE="text" NAME="' + t[0] + '" VALUE="' + unescape(t[1]) + '">';
			}
		}
		document.body.insertAdjacentHTML('beforeEnd', '<FORM NAME="temp" METHOD="post" TARGET="' + frameName
			+ '" ACTION="' + args[0] + '">' + (args.length>1 ? args[1].join('') : '') + '<\/FORM>');
		temp.submit();
		temp.removeNode(true);
		break;
	}
}