#target bridge-2.0


/*
@@@BUILDINFO@@@ "Bridge Start Meeting.jsx" 1.0.1.0  4/16/07
@@@START_XML@@@
<?xml version="1.0" encoding="UTF-8"?>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en_US">
     <dc:title>Start Meeting</dc:title>
     <dc:description>This script enables users to launch an Acrobat Connect meeting from within Bridge.</dc:description>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="de_DE">
     <dc:title>Meeting eröffnen</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="fr_FR">
     <dc:title>Démarrer la réunion</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ja_JP">
     <dc:title>会議を開始</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ar_AE">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ar_SA">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="az_AZ">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="be_BY">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="bg_BG">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ca_ES">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="cs_CZ">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="da_DK">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="el_GR">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="es_ES">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="es_LA">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="et_EE">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="fi_FI">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="he_IL">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="hi_IN">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="hr_HR">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="hu_HU">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="is_IS">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="it_IT">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="kk_KZ">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ko_KR">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="lt_LT">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="lv_LV">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="mk_MK">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="nb_NO">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="nl_NL">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="nn_NO">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="no_NO">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="pl_PL">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="pt_BR">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="pt_PT">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ro_RO">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ru_RU">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sh_YU">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sk_SK">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sl_SI">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sq_AL">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sr_YU">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sv_SE">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="th_TH">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="tr_TR">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="uk_UA">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="vi_VN">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="zh_CN">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="zh_TW">
     <dc:title>Start Meeting</dc:title>
</ScriptInfo>
*/

$.localize = true;

if(acrobatconnect == undefined && ($.locale == "ja_JP" ||
												$.locale == "en_US" ||
												$.locale == "fr_FR" ||
												$.locale == "de_DE")  )
{
	var acrobatconnect = {};
		
	if(app.preferences.acrobatconnect_meetingURL == undefined) app.preferences.acrobatconnect_meetingURL = "";
	if(app.preferences.acrobatconnect_login == undefined) app.preferences.acrobatconnect_login = "";	
	if(app.preferences.acrobatconnect_rememberBox == undefined) app.preferences.acrobatconnect_rememberBox= false;
	if(app.preferences.acrobatconnect_password == undefined ) app.preferences.acrobatconnect_password = "";
	

	// Tells us where this script is running from
	acrobatconnect.installFolder = "/Bridge%20CS3%20Extensions/Bridge%20Start%20Meeting";

	acrobatconnect.getScriptFolder = function() 
	{		
		return "file://" + Folder.commonFiles +  "/Adobe" + acrobatconnect.installFolder ;
	}	
	
	acrobatconnect.eventHandlers = function (event)
	{
		if( event.object.constructor.name == "Document" ) {
			if( event.type == "create" ){
				acrobatconnect.attachJSCallbacks();
			}
		}		
		else if (event.location == "prefs") 
		{
			if(event.type == "create")
			{				
				acrobatconnect.doPrefs(event.object);
			}
			else if (event.type == "ok"  ) 
			{	
				acrobatconnect.savePrefs();
			}	
		}
	}


	acrobatconnect.attachJSCallbacks = function()
	{					
		if( !app.document.jsFuncs )
		{				
			app.document.jsFuncs = 
			{
			saveLoginInfo: function(meetingURL, login, password, remember){acrobatconnect.saveLoginInfo(meetingURL, login, password, remember)},			
			openURL: function(url){ acrobatconnect.openNewDefaultBrowser(url) }	,
			openPrefsES: function() { app.scheduleTask("app.document.chooseMenuItem('Prefs');", 500, false); },
			getLocaleES: function() { return $.locale }
			};						
		}
	}

	// Find localized files
	acrobatconnect.beginLocalize = function()
	{
		acrobatconnect.oldZStringPath = app.zStringPathSpecifier;
		app.zStringPathSpecifier = acrobatconnect.getScriptFolder() + "/Resources/Language/"+ $.locale + "/locale.dat" ;   
	}

	acrobatconnect.endLocalize = function()
	{
		app.zStringPathSpecifier = acrobatconnect.oldZStringPath;
	}

	acrobatconnect.localize = function( str )
	{
	    acrobatconnect.beginLocalize();
	    var result = localize( str );
	    acrobatconnect.endLocalize();
	    return result;
	}

	acrobatconnect.DemandLoadJSXTable=[
		/* 00 */ { n:"-Unused slot-", e:false },	
		/* 01 */ { n:"TEA", e:false },
		/* 02 */ { n:"Net", e:false },
		/* 03 */ { n:"ContextMenu", e:false },
		/* 04 */ { n:"Preferences", e:false },
		/* 05 */ { n:"MeetingFav", e:false },
		/* 06 */ { n:"MenuItem", e:false },
		/* 07 */ { n:"URLHandler", e:false } ];


	acrobatconnect.demandJsxLoading = function( id ) 
	{
		var bRet=false;
		var js="";
		if( ( id > 0 )&&( id < acrobatconnect.DemandLoadJSXTable.length ) ) 
		{
			if( acrobatconnect.DemandLoadJSXTable[id].e )
			{
				return true;
			}
			//$.write("script folder:" + acrobatconnect.getScriptFolder() );
			var fs = new File( acrobatconnect.getScriptFolder() + "/Resources/Scripts/" + acrobatconnect.DemandLoadJSXTable[id].n + ".jsx" );
			if( fs != undefined ) 
			{
				if( fs.exists  && !acrobatconnect.DemandLoadJSXTable[id].e) 
				{
					fs.open();
					js = fs.read();
					fs.close();				
					try 
					{
						eval(js);
					} 
					catch(e) 
					{ // this is to catch .jsx error
						Window.alert("failed to eval jsx" + acrobatconnect.DemandLoadJSXTable[id].n);
						delete fs;
						return false;
					}
					acrobatconnect.DemandLoadJSXTable[id].e = true;
					bRet = true;
				}
				delete fs;
			}
			if( ! bRet )
			{
				Window.alert("failed to load jsx" + acrobatconnect.DemandLoadJSXTable[id].n);
			}
		}
		return bRet;    
	}


	acrobatconnect.openNewDefaultBrowser = function(url)
	{
		app.openUrl( url);	
	}
	
	
	acrobatconnect.saveLoginInfo = function(meetingURL, login, password, remember)
	{
		//$.write("saveLoginInfo: meetingURL:" + meetingURL +  " login:" + login + " password:" + password + " remember:" + remember);
		app.preferences.acrobatconnect_prefsSaved = true;
		app.preferences.acrobatconnect_meetingURL = meetingURL;
		app.preferences.acrobatconnect_login = login;
		var cipherText = acrobatconnect.tea.TEAencrypt(password, login);
		app.preferences.acrobatconnect_password = cipherText;		
		app.preferences.acrobatconnect_rememberBox = remember;
		//Update url params for meeting favorite
		var theFile = File(acrobatconnect.flexURL());			
		acrobatconnect.startMeeting.displayPath = theFile ;		
	}
	
	for(var itr = 1 ; itr < acrobatconnect.DemandLoadJSXTable.length; ++itr)
	{
		acrobatconnect.demandJsxLoading(itr);		
	}
		
	acrobatconnect.rightClickHandler( true ); 
	acrobatconnect.showMenuItem( true ); 
	acrobatconnect.makeFavorite( true ); 

	//Handler for generating preferences panel
	//Handler for adobebridge:acrobatconnect: requests
	if(app != undefined)
	{	
		if(app.eventHandlers  != undefined)
		{	
			app.eventHandlers.push( { handler: acrobatconnect.eventHandlers } );			
		}
		if(app.registerLinkHandler  != undefined)
		{
			app.registerLinkHandler( "acrobatconnect", acrobatconnect.connectLinkHandler );	
		}
	}
	
}
                                                                                                                                                                       