<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<meta name="generator" content="Adobe GoLive 7" />
		<title>BridgeSample</title>
	</head>

	<body>
		<hr />
		<p>ADOBE SYSTEMS INCORPORATED</p>
		<p>Copyright 2005 Adobe Systems Incorporated<br />
			All Rights Reserved</p>
		<p>NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it. If you have received this file from a source other than Adobe, then your use, modification, or distribution of it requires the prior written permission of Adobe.</p>
		<hr />
		<p><b>Extension Name:</b> BridgeSample</p>
		<p><b>Folder name: </b>BridgeSample</p>
		<hr />
		<p><b>Description:</b></p>
		<p>This sample shows how to use Bridge to communicate with the Adobe GoLive.</p>
		<hr />
		<p><b>Module Definition:</b></p>
		<jsxmodule debug="debug" info="This sample shows how to use Bridge to communicate with the Adobe GoLive." name="BridgeSample" version="1.0" /> 
		<p><b>Scripts:</b></p>
		<script><!--
//--------------------------------------------------------------------
// GLOBAL VARIABLES
//--------------------------------------------------------------------

// global variables
var msgID = -1;
var msg = 'Adobe Applications Running: \n';
var appName = new Array('aftereffects',
'atmosphere',
'audition',
'bridge',
'encore',
'golive',
'illustrator',
'indesign',
'photoshop',
'premiere');


//--------------------------------------------------------------------
// CALLBACK FUNCTIONS
//--------------------------------------------------------------------


//---------------------------------------------------------------
// MODULE CALLBACKS


//---------------------------------------------------------
// initializeModule - called after the module has been loaded
//
// Description
//   Use to initialize global variables and data structures, and
//   create Picture objects using createPicture.

function initializeModule()
{
	menus['bridgeSmpl'].addEventListener( 'menuSignal', bridgeMenu, true );
}


//--------------------------------------------------------------------
// CUSTOM EXTENSION FUNCTIONS
//--------------------------------------------------------------------

//---------------------------------------------------------
// bridgeMenu - menu handler when any of the menu items  
// in the bridgeSample menu are clicked.

function bridgeMenu( evObj )
{
	switch( evObj.target.name )
	{
		case 'launchbridge':
			BridgeTalk.launch( 'bridge' );
			break;
			
		case 'dispApps':
		{
			var names = chkAppsRunning();
			if (names.length == 0)
			{
				names = 'None';
			}
			Window.alert( msg + names );
		}
		break;
		
		case 'sendMsg':
		{
			var msgToSend = Window.prompt( 'Message to send:' );
			sendBridge( msgToSend );
		}
		break;
	}
}


//---------------------------------------------------------
// chkAppsRunning - Called when 'Display Running Adobe Apps'
// menu item is clicked to check which applications are 
// running.

function chkAppsRunning()
{
	var reply;
	var apps="";
	for (var i=0 ; i < appName.length; i++)
	{
		reply = BridgeTalk.isRunning( appName[i] );
		
		if (reply == true )
		{
			apps += appName[i] + '\t';
		}
	}
	return apps;
}

//---------------------------------------------------------
// sendBridge - Called when 'Send Message To Bridge...'
// menu item is clicked to process the message in Bridge and 
// send result back to GoLive.

function sendBridge( message )
{
	msgID++;
	var bt = new BridgeTalk;
	bt.target = 'bridge';
	bt.body = message;
	bt.onReceived = bridgeReceived;
	bt.onResult = bridgeResult;
	bt.onError = bridgeError;
	bt.send();
}

//---------------------------------------------------------
// bridgeReceived - Called to send the message to Bridge. 

function bridgeReceived( btMsg )
{
	printLog( 'received', btMsg );
}

//---------------------------------------------------------
// bridgeReceived - Called to receive the result from Bridge. 

function bridgeResult( btMsg )
{
	printLog( 'result', btMsg );
}

//---------------------------------------------------------
// bridgeReceived - Called when an erro occurs while Bridge
// Bridge processes the message. 

function bridgeError( btMsg )
{
	printLog( 'error', btMsg );
}

//---------------------------------------------------------
// printLog - Called to process the different phases when
// Bridge processes a message entered. 

function printLog( type, btMsg )
{
	writeln( 'Type : ' + type );

	for( i in btMsg )
		writeln( '\t' + i.toString() + '\t=\t' + btMsg[i].toString() );
}
//-->
</script>
		<hr />
		<p><b>User Interface Tags:</b></p>
		<p><b>Menu Bar</b> Menu and Menu bar defintions - new menu items and menus in the GoLive menu bar</p>
		<jsxmenubar name="value">
			<jsxmenu name="Extensions" title="Extensions">
			<jsxmenu name="bridgeSmpl" title="BridgeSample">
				<jsxitem dynamic="dynamic" name="launchbridge" title="Launch Bridge Application" />
				<jsxitem dynamic="dynamic" name="sendMsg" title="Send Message to Bridge..." />
				<jsxitem dynamic="dynamic" name="dispApps" title="Display Running Adobe Apps" />
			</jsxmenu>
			</jsxmenu>
		</jsxmenubar>
	</body>

</html>