/*
@@@BUILDINFO@@@ AdobeStockPhotos.jsx 466 16-March-2007
*/

/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2005 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/

/*
@@@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>Adobe Stock Photos</dc:title>
    <dc:description>This script enables other applications to communicate with Adobe Stock Photos</dc:description>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="da_DK">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Dette script betyder, at andre programmer kan kommunikere med Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="de_DE">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Mithilfe dieses Skripts kÃ¶nnen andere Anwendungen mit Adobe Stock Photos kommunizieren.</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="es_ES">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Este script posibilita que otras aplicaciones se comuniquen con Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="fi_FI">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>TÃ¤mÃ¤n komentosarjan avulla muut sovellukset ja Adobe Stock Photos voivat kommunikoida keskenÃ¤Ã¤n</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="fr_FR">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Ce script permet Ã  d'autres applications de communiquer avec Adobe Stock Photos.</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="it_IT">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Questo script consente ad altre applicazioni di comunicare con Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ja_JP">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>ã“ã®ã‚¹ã‚¯ãƒªãƒ—ãƒˆã¯ã€ä»–ã®ã‚¢ãƒ—ãƒªã‚±ãƒ¼ã‚·ãƒ§ãƒ³ã¨ Adobe Stock Photos ã¨ã®é€šä¿¡ã‚’æœ‰åŠ¹ã«ã—ã¾ã™ã€‚</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="ko_KR">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>"ì´ ìŠ¤í¬ë¦½íŠ¸ë¥¼ ì‚¬ìš©í•˜ë©´ ë‹¤ë¥¸ ì‘ìš© í”„ë¡œê·¸ëž¨ì—ì„œ Adobe Stock Photos ê³¼(ì™€) í†µì‹ í•  ìˆ˜ ìžˆìŠµë‹ˆë‹¤.</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="nb_NO">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Skriptet gjÃ¸r at andre programmer kan kommunisere med Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="nl_NL">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Dit script laat andere toepassingen toe te communiceren met Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="pt_BR">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Este script permite que outros aplicativos se comuniquem com o Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="sv_SE">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>Det hÃ¤r skriptet gÃ¶r det mÃ¶jligt fÃ¶r andra program att kommunicera med Adobe Stock Photos</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="zh_CN">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>"æ­¤è„šæœ¬ä½¿å…¶å®ƒåº”ç”¨ç¨‹åºèƒ½å¤Ÿä¸Ž Adobe Stock Photos è¿›è¡Œé€šä¿¡</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
<ScriptInfo xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="zh_TW">
    <dc:title>Adobe Stock Photos</dc:title>
    <dc:description>"æ­¤æŒ‡ä»¤ç¢¼èƒ½è®“å…¶ä»–æ‡‰ç”¨ç¨‹å¼èˆ‡ Adobe Stock Photos é€²è¡Œé€šè¨Šã€‚</dc:description>
    <dc:source>http://www.adobe.com/downloads/updates/</dc:source>
</ScriptInfo>
@@@END_XML@@@
*/ 

$.level=0;

// stockphoto_insideBridgeApp - Indicates whether Bridge is loading this script
var stockphoto_insideBridgeApp   = false;
// stockphoto_exist - Indicates whether StockPhotos 1.0.x has already been loaded
var stockphoto_exist              = false;

// First, check if Bridge is loading this script.
if ( BridgeTalk.appName == "bridge" )
{
    stockphoto_insideBridgeApp = true;
}
try
{
    // Note: Don't use 'if (stockphoto != undefined)' comparisons for this check
    // since it is a possibility that stockphoto itself is not defined at this point
    // by the older script
	if ( ( typeof stockphoto != "undefined" ) && ( typeof stockphoto.core != "undefined") )
	{
		stockphoto_exist = true;
	}
} catch(e)
{ ; }

// 	Check if Stock Photos is ever loaded
//	-> on MAC, use the existing one
//	-> on Win, discard the existing and use the new one
if ( stockphoto_insideBridgeApp && stockphoto_exist )
{
        // Since stockphoto_exist is true, both 'stockphoto' and 'stockphoto.core'
        // exist and are not undefined at this point
	   try
	   { // unload BM library and release resources, if it's already loaded
        	if( ( typeof stockphoto.core.BoxCar != "undefined" )&&
        		( typeof stockphoto.core.BoxCar.AnalyzeXmlFileObj != "undefined" ) )
        	{
        		stockphoto.core.BoxCar.AnalyzeXmlFileObj.removeMem();
        		delete stockphoto.core.BoxCar.AnalyzeXmlFileObj;
        		stockphoto.core.BoxCar.AnalyzeXmlFileObj = undefined;
        	}
        	if( ( typeof stockphoto.HTMLUtil != "undefined" )&&
        		( typeof stockphoto.HTMLUtil.ConvertToPriceStringObj != "undefined" ) )
        	{
        		delete stockphoto.HTMLUtil.ConvertToPriceStringObj;
        		stockphoto.HTMLUtil.ConvertToPriceStringObj = undefined;
        	}
        	if ( ( typeof stockphoto.core.eventTaskID != "undefined" )
                && ( stockphoto.core.eventTaskID != 0) )
        	{
        		app.cancelTask(stockphoto.core.eventTaskID, false);
        		stockphoto.core.eventTaskID = 0;
        	}
        	if ( ( typeof stockphoto.core.init != "undefined" )
        		&& ( typeof stockphoto.core.init.isScriptLoaded != "undefined" )
                && ( stockphoto.core.init.isScriptLoaded ) )
        	{
        		stockphoto.impl.terminate();
        		stockphoto.impl = undefined;
        		stockphoto.lib  = undefined;
        	}
        } catch(e) { /* failing to release resources that might have been loaded by the previous startup script*/ ; }
        try
        { // remove previous event handler
        	app.eventHandlers[ ( app.eventHandlers.length - 1 ) ].handler = function(event){ var result={handled:false}; return result; };
        } catch(e) { /* we failed to install eventHandler at previous time */ ; }
} // stockphoto_needToLoad && stockphoto_exist

// It's OK to declare stockphoto here for global use.
// If it's already defined, this statement will have no effect.
// http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf (Section 10.1.3)
var stockphoto;

if ( stockphoto_insideBridgeApp ) // Bridge 2.0+ is loading us...
{
    stockphoto = { };
    stockphoto.timeKeeper = { };

    //	stockphoto.timeKeeperOn = true;
    //	When the switch "stockphoto.timeKeeperOn" above is set to be true,
    //	a log entry is created in the script log file. The log says which
    //	jsx component is loaded, when it starts and when it finish.
    if( ( typeof stockphoto.timeKeeperOn != "undefined" ) && ( stockphoto.timeKeeperOn ) )
	{
		stockphoto.timeKeeper.StartUpJsx        = {};
		stockphoto.timeKeeper.StartUpJsx.StTime = new Date();
	}
	
	stockphoto.isMac = (File.fs == "Macintosh");
	stockphoto.isWin = (File.fs == "Windows");
	stockphoto.paths = { };
	
	if(stockphoto.isMac)
	{
		stockphoto.paths.scripts = Folder.startup + "/../../../../Adobe Stock Photos CS3/Adobe Stock Photos CS3.app/Contents/Resources/Scripts" ;
		stockphoto.startUpFolderForMac = Folder.startup.fsName + "/../../../../Adobe Stock Photos CS3/Adobe Stock Photos CS3.app/Contents";
	}
	else
	{
		stockphoto.paths.scripts = Folder.startup + "/../Adobe Stock Photos CS3";
	}
	
    stockphoto.loadScript = function (path)
	{
		var file = File(path);
		var	result;
		if (file.exists)
		{
			file.open();
			var	script = file.read();
			file.close();
			result = eval(script);
		}
		return result;
	};
	try
	{
		//RSS:  The following line has been changed from loading 'st00Core.jsx' to minimize the
		//load time for Bridge.
		stockphoto.loadScript(stockphoto.paths.scripts + "/st22Init.jsx");
	}
	catch (error)
	{
		Window.alert(error);
	}
}
else
{
    stockphoto = { };
    
	// Point App APIs
	stockphoto.displayStartPage = function( maximize )
	{
		if (maximize == undefined)
		{
			maximize = false;
		}
		var bt = new BridgeTalk;
		bt.target = "bridge";
		bt.body = "stockphoto.pointApp.displayStartPage(" + maximize + ");";
		bt.send();
		return 0;
	}

	stockphoto.buy = function( imageIdList )
	{
		var bt=new BridgeTalk;
	    bt.target = "bridge";
	    bt.body   = "stockphoto.buy(" + imageIdList + ");";
	    bt.send();
	    return 0;
	}

	stockphoto.checkLicense = function( imageIdList )
	{
		var bt=new BridgeTalk;
	    bt.target = "bridge";
	    bt.body   = "stockphoto.checkLicense(" + imageIdList + ");";
	    bt.send();
	    return 0;
	}
} // Defined Point Products API
