/*
@@@BUILDINFO@@@ st11NavBar.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.
**************************************************************************/

if( ( stockphoto.timeKeeperOn != undefined )&&( stockphoto.timeKeeperOn ) )
{
	stockphoto.timeKeeper.st11NavBar        = {};
	stockphoto.timeKeeper.st11NavBar.StTime = new Date();
}

stockphoto.NavCnv    ={}; // contains HTM Conversion table
stockphoto.NavIntFnc ={}; // internal functions
stockphoto.NavExtFnc ={}; // xternal functions
stockphoto.NavIntDt  ={};

// zsting constant
stockphoto.NavBar.zstr_FindSimilar   ="$$$/NavBar/Chip/find_similar=Get Keywords";
stockphoto.NavBar.zstr_FindSimilarBtn="$$$/NavBar/BtmNavBar/b01_But01_label=Find Similar";
stockphoto.NavBar.zstr_GettingImages = "$$$/NavBar/BtmNavBar/b1_ln1_str2G=Getting Images...";

// internal constants
stockphoto.NavIntDt._kNavType_undefined                =-1;
stockphoto.NavIntDt._kNavType_homepage                 =0;
stockphoto.NavIntDt._kNavType_addtocart                =2;
stockphoto.NavIntDt._kNavType_eCom                     =3;
stockphoto.NavIntDt._kNavType_search                   =4;
stockphoto.NavIntDt._kNavType_searchFolder             =5;
stockphoto.NavIntDt._kNavType_downloadcomp             =9;
stockphoto.NavIntDt._kNavType_shoppingCart             =11;
stockphoto.NavIntDt._kNavType_imgDetail                =13;
stockphoto.NavIntDt._kNavType_imgDetailFromShoppingCart=21;
stockphoto.NavIntDt._kNavType_moreSearch               =24;

stockphoto.NavIntDt._kKindOfNav_web                    =0;
stockphoto.NavIntDt._kKindOfNav_searchResult           =1;
stockphoto.NavIntDt._kKindOfNav_recentSearches         =2;
stockphoto.NavIntDt._kKindOfNav_downloadedComps        =3;
stockphoto.NavIntDt._kKindOfNav_purchased              =4;
stockphoto.NavIntDt._kKindOfNav_imageDetail            =5;

stockphoto.NavIntDt._kKindOfGif_none                   =0;
stockphoto.NavIntDt._kKindOfGif_loading                =1;
stockphoto.NavIntDt._kKindOfGif_imageDetail            =2;

stockphoto.NavIntDt._kWebOrFile_web                    =0;
stockphoto.NavIntDt._kWebOrFile_filesystem             =1;

stockphoto.NavIntDt._kNavHeight_short                  =0;
stockphoto.NavIntDt._kNavHeight_high                   =1;

if( stockphoto.NavBar == undefined )
{
	stockphoto.NavBar            = {};
};
stockphoto.NavBar.zc             = new stockphoto.zstringCache("st11NavBar");
stockphoto.NavBar.zc.dict        = "st11NavBar.txt";

stockphoto.NavBar.zcSearch       = new stockphoto.zstringCache(stockphoto.core.zstringFiles.NavBar, stockphoto.core.getASPSearchLangLocale());
stockphoto.NavBar.zcSearch.dict  = stockphoto.core.zstringFiles.NavBar + '.txt';

stockphoto.NavBar.cnst_HtmLDStatus_disabled        = 0
stockphoto.NavBar.cnst_HtmLDStatus_NavBarRequested = 1;
stockphoto.NavBar.cnst_HtmLDStatus_HtmIsCalled     = 2;
stockphoto.NavBar.cnst_HtmLDStatus_HtmIsRead       = 3;

stockphoto.NavBar.cnst_WorF_web                    = 0;
stockphoto.NavBar.cnst_WorF_filesystem             = 1;

stockphoto.NavIntDt.StartUpFldr  = "";
stockphoto.NavIntDt.FromBuyFlag  = false;
stockphoto.NavIntDt.PushFromES   = true;
stockphoto.NavIntDt.NoOfNavIntDt_t=0;
stockphoto.NavIntDt_t=[{_i:true},{_i:true},{_i:true},{_i:true},{_i:true},
                       {_i:true},{_i:true},{_i:true},{_i:true},{_i:true},
                       {_i:true},{_i:true},{_i:true},{_i:true},{_i:true},
                       {_i:true},{_i:true},{_i:true},{_i:true},{_i:true}];
stockphoto.NavIntDt.fTab         = ['a','b','c','d','e','f'];
stockphoto.NavIntDt.wTab         = ['r','s','t','u','v','w'];
stockphoto.NavIntDt.PaneIDnew    = [ "web", "filesystem" ]; // Do not localize it.
stockphoto.NavIntDt.TheORGEnter  = "$$$/NavBar/enter_keyword=Enter Keyword";
stockphoto.NavIntDt.TheEnter2    = stockphoto.NavBar.zc.get( stockphoto.NavIntDt.TheORGEnter );
stockphoto.NavIntDt.TheEnter1    = eval( '"'+(stockphoto.NavIntDt.TheEnter2)+'"' );
stockphoto.NavIntDt.TheEnter     = eval( '"'+(stockphoto.NavIntDt.TheEnter1)+'"' );
stockphoto.NavIntDt.TopNav_locale= "";
stockphoto.NavIntDt.PrevLangCont = "";
stockphoto.NavIntDt.CurrLangCont = "en_US";
stockphoto.NavIntDt.Const_NA     = "N/A"; // Do not localize it.
stockphoto.NavIntDt.search_id    = 0;
stockphoto.NavIntDt.PrepNoConnectionHTMPath="";

stockphoto.NavIntDt.processTable=[                                                    //      _kNavType_undefined
  { n:"DISPLAY", webORfile:0, navHeight:1, kindOfNav:0, kindOfGif:0, s:0, ky:false }, //  0 > _kNavType_homepage
  { n:"-OMEHOM", webORfile:0, navHeight:1, kindOfNav:0, kindOfGif:0, s:0, ky:false }, //  1
  { n:"ST01_AD", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:2, ky:false }, //  2 >
  { n:"IMPL.CH", webORfile:0, navHeight:0, kindOfNav:0, kindOfGif:0, s:0, ky:false }, //  3 > _kNavType_eCom
  { n:"ST03_BA", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:1, s:0, ky:true  },  //  4 > _kNavType_search
  { n:"ST03_BB", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:0, ky:true  },  //  5 > _kNavType_searchFolder
  { n:"ST04_AD", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:2, ky:true  },  //  6 >
  { n:"ST06_HO", webORfile:0, navHeight:1, kindOfNav:0, kindOfGif:0, s:0, ky:false }, //  7
  { n:"ST07_EC", webORfile:1, navHeight:1, kindOfNav:0, kindOfGif:0, s:0, ky:false }, //  8
  { n:"ST09_3_", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:2, ky:false }, //  9 >
  { n:"ST10_PR", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:0, ky:false }, // 10
  { n:"ST14_SH", webORfile:0, navHeight:1, kindOfNav:1, kindOfGif:0, s:0, ky:false }, // 11 >
  { n:"ST15_DO", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:2, ky:false }, // 12
  { n:"ST17_IM", webORfile:1, navHeight:1, kindOfNav:5, kindOfGif:2, s:1, ky:false }, // 13 > _kNavType_imgDetail
  { n:"ST20_MY", webORfile:0, navHeight:0, kindOfNav:0, kindOfGif:0, s:0, ky:false }, // 14 > my account page should display nav bar similar to other ecom pages
  { n:"ST20_GO", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:0, ky:false }, // 15 >
  { n:"ST20_SE", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:0, s:1, ky:false }, // 16
  { n:"SEARCHE", webORfile:1, navHeight:1, kindOfNav:2, kindOfGif:0, s:0, ky:false }, // 17 >
  { n:"ST20_GS", webORfile:1, navHeight:1, kindOfNav:2, kindOfGif:0, s:0, ky:false }, // 18 >
  { n:"COMPSCO", webORfile:1, navHeight:1, kindOfNav:3, kindOfGif:0, s:0, ky:false }, // 19 >
  { n:"PURCHAS", webORfile:1, navHeight:1, kindOfNav:4, kindOfGif:0, s:0, ky:false }, // 20 >
  { n:"ST17_JJ", webORfile:0, navHeight:1, kindOfNav:5, kindOfGif:2, s:1, ky:false }, // 21 > _kNavType_imgDetailFromShoppingCart
  { n:"ST20_TP", webORfile:0, navHeight:1, kindOfNav:1, kindOfGif:0, s:2, ky:false }, // 22
  { n:"ST20_PH", webORfile:0, navHeight:1, kindOfNav:0, kindOfGif:0, s:0, ky:false }, // 23 >
  { n:"ST03_MO", webORfile:1, navHeight:1, kindOfNav:1, kindOfGif:1, s:0, ky:true  },  // 24 > _kNavType_moreSearch
  { n:"ST03_BW", webORfile:0, navHeight:1, kindOfNav:1, kindOfGif:1, s:0, ky:true  }   // 25
];  //                                                               s:1 means copy the prev to curr / display uses the same menu

// Follows are the default locale depending numerical data for StyleSheet
stockphoto.NavCnv.StandardCnvTab=
{
	HEADER_COL               : "#999",
	HEADER_FONTSIZE          : "16px",
	HEADER_FONTWEIGHT        : "bold",
	BOLD_SMALL_COL           : "#000000",
	BOLD_SMALL_FONTSIZE      : "10px",
	BOLD_SMALL_FONTWEIGHT    : "bold",
	BOLD_SMALL_TEXTDECOR     : "none",
	A_SMALL_COL              : "#027abb",
	A_SMALL_FONTSIZE         : "10px",
	A_SMALL_FONTWEIGHT       : "bold",
	A_SMALL_TEXTDECOR        : "none",
	TDBOLD_A_SMALL_COL       : "#fff",
	TDBOLD_A_SMALL_FONTSIZE  : "10px",
	TDBOLD_A_SMALL_FONTWEIGHT: "bold",
	TDBOLD_A_SMALL_TEXTDECOR : "none",
	TDBOLD_A_BACLCOL         : "#999",
	BODY_FONTSIZE            : "11px",
	BOLD_BODY_FONTSIZE       : "11px",
	BOLD_BODY_FONTWEIGHT     : "bold",
	NOTE_COL                 : "#9A8F34",
	NOTE_FONTSIZE            : "10px",
	COLHEAD_COL              : "#999999",
	COLHEAD_FONTSIZE         : "10px",
	COLHEAD_FONTSIZE11       : "11px",
	COLHEAD_FONTWEIGHT       : "bold",
	COLTXT_COL               : "#027abb",
	COLTXT_FONTSIZE          : "10px",
	COLTXT_TEXTDECOR         : "none",
	FOOTER_COL               : "#666666",
	FOOTER_FONTSIZE          : "10px",
	LINE_BRDTOP              : "1px dotted #999",
	WHITE_COL                : "#FFFFFF",
	WHITE_FONTSIZE           : "11px",
	WHITE_FONTWEIGHT         : "bold",
	GRAY_COL                 : "#666666",
	GRAY_FONTSIZE            : "10px",
	GRAY_FONTWEIGHT          : "normal",
	BUTTON_FONTSIZE          : "11px",
	BUTTON_WIDTH             : "110px",
	BUTTON_HEIGHT            : "22px",

	TD_BOLD_BODY_A_COL       : "#fff",
	TD_BOLD_BODY_A_FONTSIZE  : "11px",
	TD_BOLD_BODY_A_FONTWEIGHT: "bold",
	TD_BOLD_BODY_A_TEXTDECOR : "none",
	TD_BOLD_BODY_A_BACCOL    : "#999",
	DOT_D_COL                : "#027abb",
	DOT_D_FONTSIZE           : "11px",
	DOT_D_FONTWEIGHT         : "bold",
	DOT_D_TEXTDECOR          : "dnone",
	TD_FOOTER_A_COL          : "#fff",
	TD_FOOTER_A_FONTSIZE     : "10px",
	TD_FOOTER_A_TEXTDECOR    : "none",
	TD_FOOTER_A_BACCOL       : "#999",
	DOT_B_COL                : "#666666",
	DOT_B_FONTSIZE           : "10px",
	DOT_B_FONTWEIGHT         : "normal",
	DOT_B_TEXTDECOR          : "none",
	TD_CONT_A_COL            : "#fff",
	TD_CONT_A_FONTSIZE       : "10px",
	TD_CONT_A_TEXTDECOR      : "none",
	TD_CONT_A_BACCOL         : "#999",
	DOT_C_COL                : "#027abb",
	DOT_C_FONTSIZE           : "10px",
	DOT_C_FONTWEIGHT         : "normal",
	DOT_C_TEXTDECOR          : "none",
	SUBHEADER_COL            : "#9A8F34",
	SUBHEADER_FONTSIZE       : "13px",
	SUBHEADER_FONTWEIGHT     : "bold",	

	BODY2_LINEHEIGHT         : "20px",
	BODY2_FONTSIZE           : "10px",
	BODYBLUE_LINEHEIGHT      : "20px",
	BODYBLUE_FONTSIZE        : "10px",
	BODYBLUE_COLOR           : "#027abb",

	HBLK_FONTSIZE            : "16px",
	HBLK_FONTWEIGHT          : "bold",
	SHBLK_FONTSIZE           : "13px",
	SHBLK_FONTWEIGHT         : "bold",

	HTMLSTDHEIGHT            : "13px"
};

// Follows are the default locale dependent data for Nav bar
stockphoto.NavCnv.NavCnv=
{
	PRIMARYFONT_MAC          : "'Lucida Grande', tahoma",
	PRIMARYFONT_PC           : "'Lucida Grande', tahoma",
	BTMBARBTNFONTHEIGHT_MAC  : "11px",
	BTMBARBTNFONTHEIGHT_PC   : "11px",
	CHIP_FONTSIZE            : "10px",
	CHIP_WIDTH               : 65,
	HEIGHTS                  : 27,        // Base Height of short NavBar
	HEIGHTT                  : 109,        // Base Height of high NavBar
	KEYWORDLENMAX            : 22,
	SBOX_FONTSIZE            : "11px",
	TABLE1_57_HEIGHT         : "57",
	TABLE1_29_HEIGHT         : "29",
	TABLE1_28_HEIGHT         : "28",

	GRAY_COLOR               : "#666666", // should be same above GRAY_COL	

	BARHEIGHT                : 32,        // Height-addition in case of File Content Pane
	BARHALFHEIGHT            : 0,	        
	BARDRAWEREXPANSION       : 218,       // Height of the Adv Search Drawer
	BARDRAWEREXPANSION_BC4   : 180,       // Height of the Adv Search Drawer
   
	COLLECTIONHEIGHT		     : 71,

	BLUELINEHT               : 22,

	PROGGIF_HEIGHT           : "18",
	BOTLASTLNHEIGHT          : "18",
	BOTLASTLNHEIGHT10        : "28",
	BOTLASTlnFONTHEIGHT      : "11px",	

	BUTTON_FONTSIZE          : "11px",   // redefined as above
	BUTTON_HEIGHT            : "22px",    // redefined as above
	
	MEDIATYPE_HEIGHT_PC	 	 : "18px",
	MEDIATYPE_HEIGHT_MAC	 : "20px",
	SEARCH_BUTTON_STYLE	 	 : "bold",
	SEARCH_BUTTON_TPADDING   : "2px",
	SEARCHFIELD_FONTSIZE     : "11px",
	MEDIATYPE_FONTSIZE       : "11px",
	
	XOFY_MAC					 : "63px",
	XOFY_PC					 : "70px",
	
	NAVBAR_ROW1		 		 : "27px", // Logo, icons
	NAVBAR_ROW2		 		 : "24px", // Empty Space between Logo bar and Search bar
	NAVBAR_ROW3		 		 : "20px", // Search Field bar
	NAVBAR_ROW4		 		 : "13px", // Empty Space between Search bar and Advanced Search tab
	NAVBAR_ROW5		 		 : "12px", // Advanced Search tab
	NAVBAR_ROW6		 		 : "10px", // Empty space betweeb Adv Search tab and Search control bar
	NAVBAR_ROW7		 		 : "32px", // Search Control bar with buttons and results status
	
	ADVOPTIONSBOX_HEIGHT	 : "165px",

	HOMEPAGE_TOOLTIP_WIDTH	    : "130",
	SHOPPINGCART_TOOLTIP_WIDTH  : "80",
	YOURACCOUNT_TOOLTIP_WIDTH   : "80",
	HELP_TOOLTIP_WIDTH          : "100",
	
	SEARCH_TOOLTIP_WIDTH        : "40",
	ADVSEARCH_TOOLTIP_WIDTH	    : "90",
	SPLIT_TOOLTIP_WIDTH         : "110",
	PHOTOILLUS_TOOLTIP_WIDTH	: "200",
	SEARCHWITHIN_TOOLTIP_WIDTH	: "100",
	SEARCHLANG_TOOLTIP_WIDTH_PC	: "400",
	SEARCHLANG_TOOLTIP_WIDTH_MAC: "400",
	SEARCHLANG_TOOLTIP_HEIGHT	: "10",
	GETPRICE_TOOLTIP_WIDTH		: "50",
	FINDSIM_TOOLTIP_WIDTH		: "80",
	DOWNCOMP_TOOLTIP_WIDTH      : "85",        //Download comp tolltip width
	ADDTOCART_TOOLTIP_WIDTH		: "60",
    OPENDOWNLOADSTAT_TOOLTIP_WIDTH   : "120"   //Open download status
	
};

// ========================================
// <<< Multiple window related function >>>
// ========================================
stockphoto.NavIntFnc.InitializeNavTable=function( doc_id )
{
	var i, j;
	stockphoto.NavIntDt_t[doc_id].navType       = stockphoto.NavIntDt._kNavType_homepage;
	stockphoto.NavIntDt_t[doc_id].webORfile     = stockphoto.NavIntDt._kWebOrFile_web; /* 0=web/1=file */
	stockphoto.NavIntDt_t[doc_id].kindOfNav     = stockphoto.NavIntDt._kKindOfNav_web;
	
	stockphoto.NavIntDt_t[doc_id].WorF          ="f";
	stockphoto.NavIntDt_t[doc_id].Isw           =[true, true, true]; // "web","file", key-folder unused
	stockphoto.NavIntDt_t[doc_id].UsedLangId    ="";

	stockphoto.NavIntDt_t[doc_id].UniqueCnt     =0;
	stockphoto.NavIntDt_t[doc_id].eKeywordFromJS="";

	/* NavBar state */
	stockphoto.NavIntDt_t[doc_id].NavMode       ="";
	stockphoto.NavIntDt_t[doc_id].uKeyWord      ="xyzabc";
	stockphoto.NavIntDt_t[doc_id].CurrTopBar    ="";
	stockphoto.NavIntDt_t[doc_id].FirstNav      =true;

	/* Download comp selection */
	stockphoto.NavIntDt_t[doc_id].Selections    =undefined;
	stockphoto.NavIntDt_t[doc_id].SelectionID   =0;

	/* xOfY display _NEW */
	stockphoto.NavIntDt_t[doc_id].FaN        = {};
	stockphoto.NavIntDt_t[doc_id].FaN.Last_i = 0; // [0] is a ghost

	stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex=3;
	
	stockphoto.NavIntDt_t[doc_id].NavBarHistory=[{},{},{},{}];
	for( j=0; j<4; j++ )
	{
  		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].i        = true;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].Tv       = false;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].navType  = stockphoto.NavIntDt._kNavType_undefined;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].webORfile= stockphoto.NavIntDt._kWebOrFile_web;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].navHeight= stockphoto.NavIntDt._kNavHeight_short;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].kindOfNav= stockphoto.NavIntDt._kKindOfNav_web;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].kindOfGif= stockphoto.NavIntDt._kKindOfGif_none;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].cState   = stockphoto.eventHandler.pathAnalyzer.cStateCnst_Init;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].ukw      = "";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].Nm       = "";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].fw       = "f";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].Sel      = "0";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].hx       = 0;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].hy       = 0;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].whl      = "0";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].uKeyword = "0";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].a0       = "?";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].a1       = "?";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].a2       = "?";
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].chg      = [0,0];
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].js       = ["",""];
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].sl       = 0;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].nmr      = false;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].nmr      = false;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[j].sLng     = "";
	};

	if( stockphoto.NavIntDt_t[doc_id].Ext == undefined )
	{
		stockphoto.NavIntDt_t[doc_id].Ext          = {};
	}
	stockphoto.NavIntDt_t[doc_id].Ext.HtmLDStatus      = [0,0]; // 0:disabled 1:NavBar requested 2: HTML says ready

	stockphoto.NavIntDt_t[doc_id].Ext.ifk = 0;
	stockphoto.NavIntDt_t[doc_id].Ext.fk  =
		[ {p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},
		  {p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},
		  {p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0},
		  {p:"",n:"",uky:"",x:0, y:0},{p:"",n:"",uky:"",x:0, y:0}
		];

	stockphoto.NavIntDt_t[doc_id].Ext.PrevKeyInd      = 0;
	stockphoto.NavIntDt_t[doc_id].Ext.StyleSheetLocale="";

    stockphoto.NavIntDt_t[doc_id].Cache=[
        {
            cSaveIndx:    0,
            cProcIndx:    0,
            Transmitting: false,
            requestCache: [ "","","","","","","","", "","","","","","","","",  /* 16*/
                            "","","","","","","","", "","","","","","","","",  /* 32*/
                            "","","","","","","","", "","","","","","","","",  /* 48*/
                            "","","","","","","","", "","","","","","","","",  /* 64*/
                            "","","","","","","","", "","","","","","","","",  /* 80*/
                            "","","","","","","","", "","","","","","","","",  /* 96*/
                            "","","","","","","","", "","","","","","","","",  /*112*/
                            "","","","","","","","", "","","","","","","","" ] /*128*/
        },
        {
            cSaveIndx:    0,
            cProcIndx:    0,
            Transmitting: false,
            requestCache: [ "","","","","","","","", "","","","","","","","",  /* 16*/
                            "","","","","","","","", "","","","","","","","",  /* 32*/
                            "","","","","","","","", "","","","","","","","",  /* 48*/
                            "","","","","","","","", "","","","","","","","",  /* 64*/
                            "","","","","","","","", "","","","","","","","",  /* 80*/
                            "","","","","","","","", "","","","","","","","",  /* 96*/
                            "","","","","","","","", "","","","","","","","",  /*112*/
                            "","","","","","","","", "","","","","","","","" ] /*128*/
        }
    ];

	stockphoto.NavIntDt_t[doc_id].Ext.NavDt=
	{                                                                                     // Wheel | x/y | fORw | Sel | KWd |No  |Unq|Disp
		fORw:      "f",        // [1] "f" or "w"                                           |       |     |  x   |     |     |    |   |
		Selection: "0",        // [2] true when "1" There is a selection                   |       |     |      |  x  |     |    |   |
		nWheel:    3,          // [19-22] 4 digits size of Wheel label, 0000 for no entry  |   x   |     |      |     |     |    |   |
		Wheel:     "off",      // [38-]   Wheel label or "off" or "def"                    |   x   |     |      |     |     |    |   |
		nuKeyword: 0,          // [23-26] 4 digits size of key                             |       |     |      |     |  x  |    |   |
		nmxdispKw: 22,         // [27-28] 2 digits size of key                             |       |     |      |     |  x  |    |   |
		uKeyword:  "",         // Key word                                                 |       |     |      |     |  x  |    |   |
		add:["?","?","?","?"], // [29-32] for additional                                   -       |     |      |     |     |    |   |
		UniqueID:  0,          // [33] UniqurID                                            |       |     |      |     |     |    |   |
		dispLang:  "",         // description of display language                          |       |     |      |     |     |    |   |
		valueAmt:  stockphoto.core.displayCurrency,         // AMAN
		// --------------                                                                  |       |     |      |     |     |    |   |
		change:    [0,0],                                                               // |   1   | 2/4 |  8   | 16  | 32  | 64 |128| 256
		JsStr:     ["0","0"],                                                           // -       |     |      |     |     |    |   |
		selNo:     0,                                                                   // |       |     |      |  X  |     |    |   |
		// --------------                                                               // |       |     |      |     |     |    |   |
		nWhlStr4:  "0003",
		nKWdStr4:  "0000",
		nMxLen2:   "22"
	};
	stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb     = "";
	stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordFileSys = "";

	if( stockphoto.NavIntDt_t[doc_id].core == undefined )
	{
		stockphoto.NavIntDt_t[doc_id].core            = {};
	}
	stockphoto.NavIntDt_t[doc_id].core.RecentSFld     = { path: "", name: "" };
	stockphoto.NavIntDt_t[doc_id].core.prevkey        = "zyx"; // 1:Standard 2:Compact
	stockphoto.NavIntDt_t[doc_id].core.FolderNm       = "";

	if( stockphoto.NavIntDt_t[doc_id].HP == undefined )
	{
		stockphoto.NavIntDt_t[doc_id].HP             = {};
	}

	if( stockphoto.NavIntDt_t[doc_id].search == undefined )
	{
		stockphoto.NavIntDt_t[doc_id].search         = {};
	}

	if( stockphoto.NavIntDt_t[doc_id].NavParm == undefined )
	{
		stockphoto.NavIntDt_t[doc_id].NavParm        = {};
	}

	stockphoto.NavIntDt_t[doc_id].Test={};
	stockphoto.NavIntDt_t[doc_id].Test.PointAppBuy   = true;
	
}

stockphoto.NavIntDt.FldAndNum_path="";
stockphoto.NavIntDt.FldAndNumTab  =[];
stockphoto.NavIntFnc.ContextFldNum=function( uFolderName )
{
	this.uFolderName = uFolderName;
	this.uk          = "";
	this.x           = 0;
	this.y           = 0;
	this.xStr8       = "00000000";
	this.yStr8       = "00000000";
	this.noMoreImg   = false;
	this.pageFull    = false;
	this.close       = function() { this.uFolderName = ""; };
}

stockphoto.NavExtFnc.getPageFull = function (index)
{
    if ((stockphoto.NavIntDt.FldAndNumTab == undefined)
        || (stockphoto.NavIntDt.FldAndNumTab[index] == undefined)
        || (stockphoto.NavIntDt.FldAndNumTab[index].pageFull == undefined))
    {
        return false;    
    }
    
    return stockphoto.NavIntDt.FldAndNumTab[index].pageFull;
}

stockphoto.NavExtFnc.setPageFull = function (index, value)
{
    if ((stockphoto.NavIntDt.FldAndNumTab == undefined)
        || (stockphoto.NavIntDt.FldAndNumTab[index] == undefined))
    {
        return false;    
    }
    
    stockphoto.NavIntDt.FldAndNumTab[index].pageFull = value;
}

stockphoto.NavExtFnc.ShowGettingImagesFromES = function (doc_id)
{
    // Save off the current level. The execJS may throw a runtime error
    var iSavedLevel = $.level;
    $.level = 0;
    
    var bResult;
    
    if (stockphoto.NavExtFnc.IsExecJSSafe(doc_id))
    {
        bResult = stockphoto.documents[doc_id].document.topNavbar.execJS("ShowGettingImagesFromES();");
    }
    
    // Restore
    $.level = iSavedLevel;
    
    if (bResult != true)
    {
        // Schedule
        stockphoto.NavExtFnc.FlagNextRequest(doc_id, 'def', '+');
    }

    return bResult;
}

stockphoto.NavExtFnc.UpdateXofYFromES = function (doc_id, sNewX, sNewY)
{   
    var bResult;
    
    // Save off the current level. The execJS may throw a runtime error
    var iSavedLevel = $.level;
    $.level = 0;
    
    if ((sNewX != undefined) && (sNewY != undefined))
    {
        if (stockphoto.NavExtFnc.IsExecJSSafe(doc_id))
        {
            bResult = stockphoto.documents[doc_id].document.topNavbar.execJS("UpdateXofYFromES('" + sNewX + "','" + sNewY + "');");
        }
    }
        
    // Restore
    $.level = iSavedLevel;
    
	if (bResult != true)
	{
        // Schedule
        stockphoto.NavExtFnc.FlagNextRequest(doc_id, 'xoy', '');
    }
    
    return bResult;
}

stockphoto.NavExtFnc.HideWheelFromES = function (doc_id)
{
    var bResult;
    
    // Save off the current level. The execJS may throw a runtime error
    var iSavedLevel = $.level;
    $.level = 0;
    
    if (stockphoto.NavExtFnc.IsExecJSSafe(doc_id))
    {
        bResult = stockphoto.documents[doc_id].document.topNavbar.execJS("glb_GIFDisp = true; GifHide();");
    }
    
    // Restore
    $.level = iSavedLevel;
    
    if (bResult != true)
	{
        // Schedule
        stockphoto.NavExtFnc.FlagNextRequest(doc_id, 'xoy', '');
    }
    
    return bResult;
}

stockphoto.NavExtFnc.FlagNextRequest = function( doc_id, sWheel, sAdd3)
{
    if (sWheel != '') // blank == keep the current value
    {
        stockphoto.NavIntDt_t[doc_id].NextWheel = sWheel;
    }
    
    if (sAdd3 != '') // blank == keep the current value
    {
        stockphoto.NavIntDt_t[doc_id].NextAdd3 = sAdd3;
    }
}

stockphoto.NavExtFnc.GetNextWheelFlag = function( doc_id )
{
    return stockphoto.NavIntDt_t[doc_id].NextWheel;
}

stockphoto.NavExtFnc.GetNextAdd3Flag = function ( doc_id )
{
    return stockphoto.NavIntDt_t[doc_id].NextAdd3;
}

stockphoto.NavExtFnc.IsExecJSSafe = function( doc_id )
{

    if ((stockphoto.documents[doc_id] == undefined)
    || (stockphoto.documents[doc_id].document == undefined)
    || (stockphoto.documents[doc_id].document.topNavbar == undefined)
    || (stockphoto.DL.NavBar.GetNavHeightType(doc_id) != stockphoto.NavIntDt._kNavHeight_high))
    {
        return false;
    }
        
    // Web or Filesystem Navbar type...
    // We'll get it directly from the process table
    var iWorF = stockphoto.NavExtFnc.GetNavWorFType(doc_id);
    if (iWorF == undefined)
    {
        if (app.documents[doc_id] != undefined) // outof boundary error if "oDoc = app.documents[doc_id]" comes first
        {
            var oDoc = app.documents[doc_id];
            // if table didn't have anything, try to guess it from the content pane...
            iWorF = stockphoto.NavIntFnc.get_kwORf( ( oDoc.contentPaneMode ).charAt(0) );
        }
    }
    
    if (iWorF == undefined)
    {
        return false;
    }
    
    var iHtmLDStatus = stockphoto.NavExtFnc.getHTMLDStatus( doc_id, iWorF );
    
    if (iHtmLDStatus == stockphoto.NavBar.cnst_HtmLDStatus_HtmIsRead) // HTML Ready..
    {
        return true;
    }
    else
    {
        return false;
    }
}

stockphoto.NavExtFnc.ToggleAdvDrawerFromES = function (doc_id)
{
    var bResult = false;
    
    if (stockphoto.NavExtFnc.IsExecJSSafe(doc_id))
    {
        bResult = stockphoto.documents[doc_id].document.topNavbar.execJS("ToggleAdvancedOptionsDrawer();");
    }
    
    return bResult;
}

stockphoto.NavExtFnc.writeFldAndNum_nnn=function()
{
	var i, iMax, cCnt, tCnt, cFileFldr, cFilePath, Fs  
	iMax = stockphoto.NavIntDt.FldAndNumTab.length;
	for( i=0; i<iMax; i++ )
	{
		if("undefined" != typeof stockphoto.NavIntDt.FldAndNumTab[ i ].FolderName)
		{
			cFileFldr = stockphoto.NavIntDt.FldAndNum_path+"/"+stockphoto.NavIntDt.FldAndNumTab[ i ].FolderName+"/CACHE";
			if( stockphoto.core.folder.checkAndCreateFolder( cFileFldr, true ) )
			{
				cFilePath = cFileFldr + "/searchCnts.txt";
				Fs = new File( cFilePath );
				if( Fs.exists )
				{
					Fs.remove();
					delete Fs;
					Fs = new File( cFilePath );
				}
				if( stockphoto.NavIntDt.FldAndNumTab[ i ].y > 0 )
				{
					Fs.open( "w", "TEXT", "????" );
					cCnt = 100000000 + stockphoto.NavIntDt.FldAndNumTab[ i ].x;
					tCnt = 100000000 + stockphoto.NavIntDt.FldAndNumTab[ i ].y;
					Fs.write( ( ""+cCnt )+ ( "/"+tCnt+"\n" ) );
					Fs.close();
				}
				delete Fs;
			}
		}
	} // for i
}

stockphoto.NavIntFnc.initFldNumFromFolder_nnn=function()
{
	if( stockphoto.NavIntDt.FldAndNumTab.length <= 0 )
	{	// array[0] is a fake spot
		stockphoto.NavIntDt.FldAndNumTab[0] = new stockphoto.NavIntFnc.ContextFldNum( "a0b1c2x3y4z5~0B1Adobe" );
		if( stockphoto.NavIntDt.FldAndNumTab[0] == undefined ) 
		{
			return( false );
		}
	}
	return( true );
}

stockphoto.NavExtFnc.setFldNumFromFolder_nnn=function( FolderObj )
{
	var i, iMax, p, uFolderName, cFilePath, Fs, Rec;
	if( ! stockphoto.NavIntFnc.initFldNumFromFolder_nnn() )
	{
		return( -2 );
	}
	uFolderName = ( FolderObj.name ).toUpperCase();
	iMax        = stockphoto.NavIntDt.FldAndNumTab.length;
	for( i=iMax-1; i>=0; i-- )
	{
		if( uFolderName == stockphoto.NavIntDt.FldAndNumTab[i].uFolderName )
		{
			var iImageCount = stockphoto.core.getjpgImagecount(FolderObj.path);
			if( ("undefined" != typeof stockphoto.NavIntDt.FldAndNumTab[ i ].x) && (iImageCount != stockphoto.NavIntDt.FldAndNumTab[ i ].x) ){
				stockphoto.NavIntDt.FldAndNumTab[ i ].x = iImageCount;
				if(stockphoto.NavIntDt.FldAndNumTab[ i ].x > stockphoto.NavIntDt.FldAndNumTab[ i ].y){
					stockphoto.NavIntDt.FldAndNumTab[ i ].y = stockphoto.NavIntDt.FldAndNumTab[ i ].x;
				}
				stockphoto.NavExtFnc.writeFldAndNum_nnn();					
			}

			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "NavExtFnc.setFldNumFromFolder_nnn('"
												 +FolderObj.path+ " / "+FolderObj.name+"' ) -exist-> "+i
												 +" [x,y]=["+stockphoto.NavIntDt.FldAndNumTab[i].x
												 +","+stockphoto.NavIntDt.FldAndNumTab[i].y+"]" );		
			return( i );
		}
	}
	stockphoto.NavIntDt.FldAndNumTab[ iMax ] = new stockphoto.NavIntFnc.ContextFldNum( uFolderName );
	if( stockphoto.NavIntDt.FldAndNumTab[ iMax ] == undefined ) {
		return( -1 );
	}
	if( stockphoto.NavIntDt.FldAndNum_path == "" )
	{
		stockphoto.NavIntDt.FldAndNum_path = FolderObj.path;
	}
	stockphoto.NavIntDt.FldAndNumTab[ iMax ].FolderName = FolderObj.name;
	// Load x/y
	// -- Previous way (FolderObj.path+"/"+FolderObj.name) creates escaped name.
	// -- This way preserves the Unicode name as is.
	cFilePath = FolderObj.fsName+"/CACHE/searchCnts.txt";
	Fs = new File( cFilePath );
	if( Fs != undefined )
	{
		if( Fs.exists ) 
		{
			Rec = "";
			try 
			{
				Fs.open( "r" );
				Rec = Fs.read();
				Fs.close();
			} catch(e) { ; }
			if( Rec.length > 17 )
			{
				stockphoto.NavIntDt.FldAndNumTab[ iMax ].x = stockphoto.core.util.convertToInteger( Rec.substr(  1, 8 ) );
				// KR - Now we will not read the x value from the file.. but get the actual count of files from the folder.
				stockphoto.NavIntDt.FldAndNumTab[ iMax ].x = stockphoto.core.getjpgImagecount(FolderObj.path);
				
				stockphoto.NavIntDt.FldAndNumTab[ iMax ].y = stockphoto.core.util.convertToInteger( Rec.substr( 11, 8 ) );
				if(stockphoto.NavIntDt.FldAndNumTab[ iMax ].x > stockphoto.NavIntDt.FldAndNumTab[ iMax ].y)
				{
					stockphoto.NavIntDt.FldAndNumTab[ iMax ].y = stockphoto.NavIntDt.FldAndNumTab[ iMax ].x;
				}
			}
		}
		delete Fs;
	}
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavExtFnc.setFldNumFromFolder_nnn('"
										 +FolderObj.path+ " / "+FolderObj.name+"' ) - NEW -> "+iMax
										 +" [x,y]=["+stockphoto.NavIntDt.FldAndNumTab[iMax].x
										 +","+stockphoto.NavIntDt.FldAndNumTab[iMax].y+"]" );		
	return( iMax );
}

stockphoto.NavExtFnc.GetFolderAndNumbers_NEW=function( FolderObj, doc_id, bSetZero, callFrom )
{ 
	var i, j, jMax, k, l, bExist=false;
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 

	i = stockphoto.NavExtFnc.setFldNumFromFolder_nnn( FolderObj );
	if( i < 0 )
	{
		return( 0 ); // error
	}
	stockphoto.NavIntDt_t[doc_id].FaN.Last_i = i;

	if( bSetZero )
	{
		stockphoto.NavIntDt.FldAndNumTab[ i ].x = 0;
		stockphoto.NavIntDt.FldAndNumTab[ i ].y = 0;
	}
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavExtFnc.GetFolderAndNumbers_NEW('"
										 +FolderObj.path+ " / "+FolderObj.name+"' ) -> #"+i+" y="+stockphoto.NavIntDt.FldAndNumTab[ i ].y );
	return( stockphoto.NavIntDt.FldAndNumTab[ i ].y );
}

stockphoto.NavIntFnc.updateFolderAndNumbers_NEW=function( y, doc_id )
{
	var i;
	if( stockphoto.NavIntDt_t[doc_id].FaN.Last_i >= 0 ) 
	{
		i = stockphoto.NavIntDt_t[doc_id].FaN.Last_i;
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "NavExtFnc.updateFolderAndNumbers( y="+y+", doc_id="+doc_id+" ) -> #"+i );
		stockphoto.NavIntDt.FldAndNumTab[ i ].y = y;
	}
}

stockphoto.NavIntFnc.getCntValue_NEW=function( FolderObj, iSt )
{ // (iSt) = (1) or (11)
	var i = stockphoto.NavExtFnc.setFldNumFromFolder_nnn( FolderObj );
	if( i < 0 ) 
	{
		return( 0 );
	}
	if( iSt == 1 )
	{
		return( stockphoto.NavIntDt.FldAndNumTab[ i ].x );
	}
	return( stockphoto.NavIntDt.FldAndNumTab[ i ].y );
} 

stockphoto.NavExtFnc.PrepareNavBar=function( doc_id )
{
	var newone=[{_i:true}];
	for( i=stockphoto.NavIntDt_t.length; i<=doc_id; i++ )
	{
		stockphoto.NavIntDt_t = stockphoto.NavIntDt_t.concat( newone );
	}
	if( ( stockphoto.NavIntDt_t[doc_id]._i == undefined )||
	    ( stockphoto.NavIntDt_t[doc_id]._i ) )
	{                       
		stockphoto.NavIntFnc.InitializeNavTable( doc_id );
		stockphoto.NavIntDt_t[doc_id]._i = false;
		if( stockphoto.NavIntDt.NoOfNavIntDt_t <= doc_id )
		{
			stockphoto.NavIntDt.NoOfNavIntDt_t = doc_id + 1;
		}
	}
	if( ! stockphoto.NavIntFnc.initFldNumFromFolder_nnn() )
	{
		return( 0 );
	}
	return( stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i );
}

stockphoto.NavIntFnc.GetDocumentId=function( doc )
{
	var doc_id;
	if( ( doc == undefined )||( doc.id == undefined ) )
	{
		doc_id = app.document.id;
	}
	else
	{
		doc_id = doc.id;
	}
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	return( doc_id );
}

// <<< Internal Data >>> non-app.document <<<
stockphoto.NavExtFnc.FontNames=function()
{
	if( File.fs == "Windows" )
	{
		return stockphoto.NavCnv.NavCnv.PRIMARYFONT_PC;
	}
	else
	{
		return stockphoto.NavCnv.NavCnv.PRIMARYFONT_MAC;
	}
}

stockphoto.NavExtFnc.GetXOFYWidth=function()
{
	if( File.fs == "Windows" )
	{
		return stockphoto.NavCnv.NavCnv.XOFY_PC;
	}
	else
	{
		return stockphoto.NavCnv.NavCnv.XOFY_MAC;
	}
}

stockphoto.NavExtFnc.GetLangToolTipWidth=function()
{
	if( File.fs == "Windows" )
	{
		return stockphoto.NavCnv.NavCnv.SEARCHLANG_TOOLTIP_WIDTH_PC;
	}
	else
	{
		return stockphoto.NavCnv.NavCnv.SEARCHLANG_TOOLTIP_WIDTH_MAC;
	}
}

stockphoto.NavExtFnc.GetMediaTypeHeight= function()
{
	if( File.fs == "Windows" )
	{
		return stockphoto.NavCnv.NavCnv.MEDIATYPE_HEIGHT_PC;
	}
	else
	{
		return stockphoto.NavCnv.NavCnv.MEDIATYPE_HEIGHT_MAC;
	}
}

stockphoto.NavExtFnc.GetFontNames=function()
{
	stockphoto.NavExtFnc.PrepareNavBar( app.document.id ); // same for all pp.document
	return( stockphoto.NavBar.zc.get(stockphoto.NavExtFnc.FontNames()) );
}

stockphoto.NavExtFnc.SetStandardCnvTable=function( doc_id )
{
	// locations/dimensions
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.NavIntDt_t[doc_id].Ext.StyleSheetLocale != stockphoto.core.getValidLocale() )
	{
		if( stockphoto.core.util.loadLocaleData( "st11NavBarS.par" ))
		{
			stockphoto.NavIntDt_t[doc_id].Ext.StyleSheetLocale = stockphoto.core.getValidLocale();
		}
	}

	// fonts
	stockphoto.NavCnv.StandardCnvTab.PRIMARYFONT =stockphoto.NavExtFnc.GetFontNames();

	// misc	
	stockphoto.NavCnv.StandardCnvTab.SPACE       =" ";
	stockphoto.NavCnv.StandardCnvTab.CONST_NA    =stockphoto.NavIntDt.Const_NA;
}

stockphoto.NavExtFnc.SetFolderAndKey=function( f, unescaped_KeyWd, doc_id, sDisplayKeyword )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	var indexTo_ifk_Table=stockphoto.NavIntDt_t[doc_id].Ext.ifk, fld=new Folder(f);
	if( indexTo_ifk_Table >= 9 )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.ifk = 0;
	}
	else
	{
		stockphoto.NavIntDt_t[doc_id].Ext.ifk = indexTo_ifk_Table+1;
	}
	stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].p  = fld.path;
	stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].n  = fld.name;
	stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].uky= unescaped_KeyWd;
	
	if (sDisplayKeyword != undefined)
	{
	   stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].origKW = sDisplayKeyword;
    }
    else if ((fld != undefined) && (fld.exists == true))
	{
        var oFSObj  = new File( fld.fsName+ stockphoto.core.SearchInfoRelPath );
        oFSObj.encoding = 'UTF-16';
        if ((oFSObj != undefined) && (oFSObj.exists == true))
        {
            var arKeyword = stockphoto.DL.search.LoadSearchInfoFromFS(oFSObj, '[OriginalKeyword]');
			if ((arKeyword != undefined) && (arKeyword.length > 0))
			{
                stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].origKW = arKeyword[0];
            }
		}

		if (oFSObj != undefined)
        {
            delete oFSObj;
            oFSObj = undefined;
        }
    }

	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavExtFnc.SetFolderAndKey: uky["+indexTo_ifk_Table+"]="
										  +stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].uky );
	return( indexTo_ifk_Table );
}

stockphoto.NavIntFnc.SearchFolderAndKey=function( doc_id )
{
	var spath="", sname="", kpath, kname, i, indexTo_ifk_Table,is;
	spath = stockphoto.NavIntDt_t[doc_id].core.RecentSFld.path;
	sname = stockphoto.NavIntDt_t[doc_id].core.RecentSFld.name;
	for( j=0; j<10; j++ )
	{
		indexTo_ifk_Table = j + stockphoto.NavIntDt_t[doc_id].Ext.PrevKeyInd;
		if( indexTo_ifk_Table >= 10 )
		{
			indexTo_ifk_Table -= 10;
		}
		kpath = stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].p;
		kname = stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].n;
		if( ( spath == kpath )&&( sname == kname ) )
		{
			if( indexTo_ifk_Table == stockphoto.NavIntDt_t[doc_id].Ext.PrevKeyInd )
			{
				stockphoto.NavIntDt_t[doc_id].Ext.PrevKeyInd = indexTo_ifk_Table;
				return( indexTo_ifk_Table );
			}
		}
		// - Found if the same folder as before AND it is one of table
		//   if the different folder than before BUT the same table element as before
	}

	if( stockphoto.NavIntDt_t[doc_id].Ext.ifk <= 0 )
	{
		indexTo_ifk_Table = 9;
	}
	else
	{
		indexTo_ifk_Table = stockphoto.NavIntDt_t[doc_id].Ext.ifk - 1;
	}
	if( stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].uky != "" )
	{
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "NavExtFnc.SearchFolderAndKey: uky["+indexTo_ifk_Table+"]="+stockphoto.NavIntDt_t[doc_id].Ext.fk[indexTo_ifk_Table].uky );
		return( indexTo_ifk_Table );
	}
	return( - 1 );
}

/* -------------------------------- */
/* Prepare the Data string for HTML */
/* -------------------------------- */
stockphoto.NavIntFnc.PrepareStringForHTM=function( i_W_or_F, doc_id )
{
	var k, uKeyword, bReqSend=false, bChg, sSel, fOrw, unescaped_string, ndispLang4, nValueAmt4;
	var idx = stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;

	// add[0]=='1' means all thumbnails were recieved
	if( stockphoto.NavIntDt_t[doc_id].navType == stockphoto.NavIntDt._kNavType_searchFolder )
	{
		if( stockphoto.NavIntDt.FldAndNumTab[ idx ].x == stockphoto.NavIntDt.FldAndNumTab[ idx ].y )
		{
			stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = true;
		}
	}
	if( stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 64;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 64;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0] = '1';
		bReqSend = true;
	}
	else
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0] = '0';
	}

	stockphoto.NavIntFnc.SetIfSelectionExist( doc_id );

	bChg = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[i_W_or_F];
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[i_W_or_F] = 0;
	if( bChg == 0 )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_or_F] = "0";
	}
	else
	{
		if( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw == 'f' )
		{
			fOrw = stockphoto.NavIntDt.fTab[ stockphoto.NavIntDt_t[doc_id].kindOfNav ];
		}
		else
		{
			fOrw = stockphoto.NavIntDt.wTab[ stockphoto.NavIntDt_t[doc_id].kindOfNav ];
		}
	}

	ndispLang4 = stockphoto.NavIntFnc.CnvertStringToNum( ( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.dispLang ).length, 4 );	
	
	nValueAmt4 = stockphoto.NavIntFnc.CnvertStringToNum( ( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.valueAmt ).length, 4 );	


	var sShowDrawer = "y";
	if ((stockphoto.search.showAdvancedDrawer[ doc_id ] == undefined) || (stockphoto.search.showAdvancedDrawer[ doc_id ]==false))
	{
        sShowDrawer = "n";
  }
	
	if (fOrw != undefined)
	{
        var sWheel = stockphoto.NavExtFnc.GetNextWheelFlag(doc_id);
        var nWhlStr4;
        
        if (sWheel == undefined)
        {
            sWheel = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel;
            nWhlStr4 = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWhlStr4;
        }
        else
        {
            var nWheel = sWheel.length;
            nWhlStr4 = stockphoto.NavIntFnc.CnvertStringToNum( nWheel, 4 );
        }
	
        var sAdd3 = stockphoto.NavExtFnc.GetNextAdd3Flag(doc_id);
        
        if (sAdd3 == undefined)
        {
            sAdd3 = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[3];
        }
	
		unescaped_string =
			"1"+/*1*/fOrw+/*2*/stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection
			+/*03-10*/stockphoto.NavIntDt.FldAndNumTab[ idx ].xStr8
			+/*11-18*/stockphoto.NavIntDt.FldAndNumTab[ idx ].yStr8
			+/*19-22*/nWhlStr4
			+/*23-26*/stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nKWdStr4
			+/*27-28*/stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nMxLen2
			+/*29-32*/stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0]
			+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[1]
			+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[2]
			+ sAdd3
			+/*33*/stockphoto.NavIntDt_t[doc_id].Ext.NavDt.UniqueID
			+/*34-37*/ndispLang4
			+/*38-41*/nValueAmt4  // AMAN
			+/*38-*/sWheel
			+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword
			+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.dispLang
			+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.valueAmt // AMAN
            + sShowDrawer;
		
            stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_or_F] = escape( unescaped_string );

            stockphoto.NavExtFnc.FlagNextRequest(doc_id, undefined, undefined);
    }
           
	return( bReqSend );
}

stockphoto.NavExtFnc.FromDocIdToDoc=function( doc_id )
{
	var doc;
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
//	if( doc_id == app.document.id )
	if( ( app.document != undefined )&&( doc_id == app.document.id ) )
	{
		doc = app.document;
	} else {
		doc = undefined;
	}
	if( ( doc == undefined )||( doc.contentPaneMode == undefined )||( doc.topNavbar == undefined ) )
	{
		if( ( stockphoto.documents != undefined )||( stockphoto.documents[ doc_id ] != undefined ) )
		{
			doc = stockphoto.documents[ doc_id ].document;
			i   = 1;
		}
		if( ( doc == undefined )||( doc.contentPaneMode == undefined )||( doc.topNavbar == undefined ) )
		{
			doc = stockphoto.documents[ doc_id ];
			i   = 2;
			if( ( doc == undefined )||( doc.contentPaneMode == undefined )||( doc.topNavbar == undefined ) )
			{
				doc = stockphoto.core.findDoc( doc_id );
				i   = 4;
				if( ( doc == undefined )||
				    ( doc.contentPaneMode == undefined )||
				    ( doc.topNavbar == undefined ) )
				{
					doc = undefined;
					i   = 5;
				}
			}
		}
	}
	return( doc );
}

stockphoto.NavIntFnc.get_kwORf=function( id )
{
    if( id == "w" )
    {
        return( 0 );
    }
    return( 1 );
}

stockphoto.NavIntFnc.ClearTransmitting=function( content_wORf, kwORf, doc_id, no )
{
    stockphoto.NavIntDt_t[doc_id].Cache[ content_wORf ].Transmitting = false;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "Trans<-false #."+no+" / content_wORf="+content_wORf );
    if( content_wORf != kwORf )
    {
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "Trans<-false #."+no+" / auto kwORf="+kwORf );
        app.scheduleTask("stockphoto.NavIntDt_t["+doc_id+"].Cache["+kwORf+"].Transmitting = false;",3000,false);
    }
}

stockphoto.NavIntFnc.TransmitCachedRequest=function( kwORf, doc_id, t )
{   
    var doc, content_wORf, HtmLDStatus, j, k, saveLevel, script;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "(*)NavIntFnc.TransmitCachedRequest() #.1: doc_id="+doc_id+", t="+t );
	doc = stockphoto.NavExtFnc.FromDocIdToDoc( doc_id );
	if( doc == undefined )
    {
        content_wORf= -1;
        HtmLDStatus = -1;
    }
    else
    {
        content_wORf= stockphoto.NavIntFnc.get_kwORf( ( doc.contentPaneMode ).charAt(0) );
        HtmLDStatus = stockphoto.NavIntDt_t[ doc_id ].Ext.HtmLDStatus[ content_wORf ];

    }
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "(*)TransmitCachedRequest() #.2: HtmLDStatus="+HtmLDStatus+", t="+t );
	if( HtmLDStatus < 3 )
	{
		if( t < 240 ) // one minute try
		{
			app.scheduleTask( "stockphoto.NavIntFnc.TransmitCachedRequest("+kwORf+","+doc_id+","+(t+1)+");", 250, false );
		}
		else
		{
            if( content_wORf >= 0 )
            {
                stockphoto.NavIntFnc.ClearTransmitting( content_wORf, kwORf, doc_id, 1 );
            }
		}
	}
	else
	{ // doc!=undefined, content_wORf=0/1
		for( k=0; k<128; k++ )
		{ // at most 128 (=buffer size) times
			j = stockphoto.NavIntDt_t[ doc_id ].Cache[ content_wORf ].cProcIndx;
			if( stockphoto.NavIntDt_t[ doc_id ].Cache[ content_wORf ].requestCache[ j ] == "" )
			{ // No more cached request
                stockphoto.NavIntFnc.ClearTransmitting( content_wORf, kwORf, doc_id, 2 );
				return;
			}
			saveLevel = $.level; // This is not to display ESKT to appear
			$.level   = 0;
			try
			{
				script = 'setTimeout( \"ProcBottomNav( \''+( stockphoto.NavIntDt_t[ doc_id ].Cache[ content_wORf ].requestCache[ j ] )+'\' );\", 0);';
				if( stockphoto.core.log.DebugINIData.log != undefined ) 
				{
					stockphoto.core.log.logString( 0, "                                                fsxxxxxxxxyyyyyyyywwwwkkkkll????" );
					stockphoto.core.log.logString( 0, "      --- script= "+script );
					stockphoto.core.log.logString( 0, "          ...... Trans Cache[cProcIndx="+j+"] "+script );
				}
				stockphoto.NavIntDt_t[ doc_id ].Cache[ content_wORf ].requestCache[ j ] = "";
				stockphoto.NavIntDt_t[ doc_id ].Cache[ content_wORf ].cProcIndx         = ( j + 1 ) % 128; // pointing next one
				doc.topNavbar.execJS( script );
			} catch(e) { ; /* ignore error */ }
			$.level = saveLevel;
		}
        stockphoto.NavIntFnc.ClearTransmitting( content_wORf, kwORf, doc_id, 3 );
	} // k=0,..,127
}

stockphoto.NavIntFnc.SaveRequestToCache=function( escaped_string, i_W_OR_F, doc_id )
{
	var j, doc, kwORf;
	j = stockphoto.NavIntDt_t[doc_id].Cache[ i_W_OR_F ].cSaveIndx;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, ".... .. .. SaveRequestToCache[ cSaveIndx="+j+"] wOrF="+i_W_OR_F+" doc_id="+doc_id+" HtmLDStatus="+stockphoto.NavIntDt_t[doc_id].Ext.HtmLDStatus[i_W_OR_F]
										 +"\n           escaped_string="+escaped_string );
	
										 
	if( stockphoto.NavIntDt_t[doc_id].Cache[ i_W_OR_F ].requestCache[ j ] == "" )
	{
		stockphoto.NavIntDt_t[doc_id].Cache[ i_W_OR_F ].requestCache[ j ] = escaped_string;  // so that we can place into queue
		stockphoto.NavIntDt_t[doc_id].Cache[ i_W_OR_F ].cSaveIndx         = ( j + 1 ) % 128; // pointing next one
	}
	// dispatch processing queue
	doc = stockphoto.NavExtFnc.FromDocIdToDoc( doc_id );
    if( doc != undefined )
    {
        kwORf = stockphoto.NavIntFnc.get_kwORf( ( doc.contentPaneMode ).charAt(0) );
	    if( ! stockphoto.NavIntDt_t[ doc_id ].Cache[ kwORf ].Transmitting )
	    {
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "          Transmitting <- TRUE / kwORf="+kwORf
												 +" =ScheduleTask=> stockphoto.NavIntFnc.TransmitCachedRequest("+kwORf+","+doc_id+",0)" );
		    stockphoto.NavIntDt_t[ doc_id ].Cache[ kwORf ].Transmitting = true;
		    app.scheduleTask( "stockphoto.NavIntFnc.TransmitCachedRequest("+kwORf+","+doc_id+",0);", 0, false );
        }
        else
        {
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "..... -> dispatch held. doc_id="+doc_id+", kwORf="+kwORf );
        }
	}
}

stockphoto.NavExtFnc.SendKeyWordToHTM=function( eKeyword, doc_id, btype, t, bDoSchedule )
{	

    // btype =0(send to WebHtm) =1(send to FileSysHtm) =-1(send to currentHtm)
    var i_W_or_F, doc, script, saveLev, bOk;
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( ( bDoSchedule != undefined )&&( bDoSchedule ) )
	{
		script = "stockphoto.NavExtFnc.SendKeyWordToHTM( \'"+eKeyword+"\',"+doc_id+","+btype+",0 );";
		app.scheduleTask( script, 0, false );
		return;
	}
	doc = stockphoto.NavExtFnc.FromDocIdToDoc( doc_id );
	if( ( doc == undefined )||( doc.browseMode == "compact" ) )
	{
		return;
	}
	if( ( btype == 0 )||( btype == 1 ) )
	{
		i_W_or_F = btype;
	}
	else
	{
		i_W_or_F = stockphoto.NavIntDt_t[ doc_id ].webORfile; /* 0=web/1=file */
	}
	if( stockphoto.NavIntDt_t[ doc_id ].Ext.HtmLDStatus[ i_W_or_F ] >= stockphoto.NavBar.cnst_HtmLDStatus_HtmIsRead )
	{
		script  = 'setTimeout( \"ProcSetKeyword( \''+eKeyword+'\');\",0);';
		saveLev = $.level;
		$.level = 0;
		bOk     = true;
		try 
		{
			if( btype == 0 )
			{
				doc.navbars.web.top.execJS( script );
			}
			else if( btype == 1 )
			{
				doc.navbars.filesystem.top.execJS( script );
			}
			else
			{
				doc.topNavbar.execJS( script );
			}
		} catch(e) {
			bOk = false;
		}
		$.level = saveLev;
		if( ( ! bOk )&&( t < 100 ) )
		{
			script = "stockphoto.NavExtFnc.SendKeyWordToHTM( \'"+eKeyword+"\',"+doc_id+","+btype+","+(t+1)+" );";
			app.scheduleTask( script, 100, false );
		}
	}
}

stockphoto.NavIntFnc.SendRequestToHTM_Sub=function( doc_id, i_W_OR_F )
{
	var script, doc;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, ".... ScheduleTask=> NavIntFnc.SendRequestToHTM_Sub HtmLDStatus="
										 +stockphoto.NavIntDt_t[doc_id].Ext.HtmLDStatus[0]+"/"
										 +stockphoto.NavIntDt_t[doc_id].Ext.HtmLDStatus[1]+" index="
										 +i_W_OR_F+" PushFromES="+stockphoto.NavIntDt.PushFromES );
	if( stockphoto.NavIntDt.PushFromES )
	{
		doc = stockphoto.NavExtFnc.FromDocIdToDoc( doc_id );
		if( doc == undefined ) {
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, ".... .. unknown doc_id="+doc_id );
		}
		if( doc != undefined )
		{
			stockphoto.NavIntFnc.PrepareStringForHTM( i_W_OR_F, doc_id );
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, ".... .. Sending[doc_id="+doc.id+"] "+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_OR_F] );
			if( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_OR_F].charAt(0) != '0' )
			{
				stockphoto.NavIntFnc.SaveRequestToCache( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_OR_F], i_W_OR_F, doc_id );
				// <NewXY>
				stockphoto.NavExtFnc.SetAdd3Field('?',doc_id); // reset the spinning wheel status every time
			}
		}
	}
}

stockphoto.NavExtFnc.SendRequestToHTM=function( doc_id, bScheduleTask )
{
	var idx      = stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
   	var i_W_or_F = stockphoto.NavIntDt_t[ doc_id ].webORfile; /* 0=web/1=file */
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "SendRequestToHTM(doc_id="+doc_id+") x="
										  +stockphoto.NavIntDt.FldAndNumTab[ idx ].xStr8+" y="
										  +stockphoto.NavIntDt.FldAndNumTab[ idx ].yStr8+" ["
										  +stockphoto.NavIntDt.FldAndNumTab[ idx ].x+","
										  +stockphoto.NavIntDt.FldAndNumTab[ idx ].y+"] wheel='"
										  +stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel+"' ==> scheduleTask()" );
	
    if (bScheduleTask == true)
    {
        app.scheduleTask( "stockphoto.NavIntFnc.SendRequestToHTM_Sub("+doc_id+","+i_W_or_F+");", 10, false );
    }
    else
    {
        stockphoto.NavIntFnc.SendRequestToHTM_Sub(doc_id, i_W_or_F);
    }
}

stockphoto.NavIntFnc.CnvertStringToNum=function( inS, n )
{
	var s, v;
	if( inS < 0 )
	     v = 0;
	else v = inS;
	switch( n )
	{
		case 8:  s = "0"+(100000000+v); break;
		case 4:  s = "0"+(10000+v);     break;
		case 2:  s = "0"+(100+v);       break;
		case 1:  s = "0"+(10+v);        break;
		default: s = "000000000000";
	}
	return( s.substr( 2,n ) );
}

/* f OR w */
stockphoto.NavIntFnc.SetfORwFlag=function( iStr, doc_id )
{
	var fORw=( iStr.charAt(0) ).toLowerCase();
	if( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw != fORw )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw       = fORw;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 8;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 8;
		stockphoto.NavExtFnc.SendRequestToHTM( doc_id, true ); // default uses scheduleTask
	}
	return( fORw );
}

/* Selection */
stockphoto.NavIntFnc.SetIfSelectionExist=function( doc_id )
{
	var doc, No=0;
	
	if (("undefined" != typeof stockphoto) && ("undefined" != typeof stockphoto.documents) && ("undefined" != typeof stockphoto.documents[doc_id]))
	{
		doc = stockphoto.documents[ doc_id  ].document;
		if( doc != undefined )
		{
			if( doc.selections != undefined )
			{
				if( doc.selections.length != undefined )
				{
					No = doc.selections.length;
				}
			}
		}
	}
	else
	{
		return 0;
	}
	
	if(doc.selections[0] == undefined)
	{
		No = 0;
	}
	//Watson:1337327
	//Even if number of selections is same as previous one, we need to refresh navbar
	//if( No != stockphoto.NavIntDt_t[doc_id].Ext.NavDt.selNo )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.selNo      = No;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 16;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 16;
	}
	
	// Check if we have at least one ASP image in the selection
    var oSelResult = stockphoto.core.util.getASPImagesCount(true);
    var bSelIncludesStock = true; // default = true, in case getSelectionInfo fails...
    if ((undefined == oSelResult) || (0 == oSelResult))
    {
        bSelIncludesStock = false;
    }
	
	if ((true == bSelIncludesStock) && ( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.selNo > 0 ))
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection = "1";
	}
	else
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection = "0";
	}
	return( No );
}

/* x and y */
stockphoto.NavExtFnc.updateXofYfromExternal=function( status, xIn, yIn, sub, doc_id, searchID, from )
{
	var i, x, y;
//	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	if( stockphoto.Burp.doIt ) // in updateXofYfromExternal to register searchID
	{
/*B*/			try
/*B*/			{
/*B*/				if( stockphoto.Burp.searchWritten[ doc_id ] != undefined )
/*B*/				{
/*B*/					if( ! stockphoto.Burp.searchWritten[ doc_id ] )
/*B*/					{
/*B*/						if( stockphoto.Burp.writeSearchID( doc_id ) )
/*B*/							stockphoto.Burp.searchWritten[ doc_id ] = true; // set only file is written
/*B*/					}
/*B*/				}
/*B*/			} catch(e) { ; }
	}	
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavExtFnc.NavExtFnc.updateXofYfromExternal('"+status+"', x='"+xIn
										 +"', y='"+yIn+", '"+sub+"', doc_id="+doc_id
										 +", searchID="+searchID+"<< "+from+" >>" );
	if( ( searchID >= 0 )&&
	    ( stockphoto.NavIntDt.FldAndNumTab[ searchID ] != undefined ) )
	{
		y = parseInt( ( yIn.toString() ) );
		x = parseInt( ( xIn.toString() ) );
		if( x >= 0 )
		{
			if ( x > y )
			{
				y = x;
			}
			
			stockphoto.NavIntDt.FldAndNumTab[ searchID ].x = x;
			stockphoto.NavIntDt.FldAndNumTab[ searchID ].y = y;
			
			// <NewXY>
			if ((sub == 'pageFull') || (status == 'endSearch'))
			{
                stockphoto.NavExtFnc.setPageFull( searchID, true);
                stockphoto.NavIntDt.FldAndNumTab[ searchID ].noMoreImg = true;
            }
			else if (sub == 'initializing')
			{
                stockphoto.NavExtFnc.setPageFull( searchID, false);
                stockphoto.NavIntDt.FldAndNumTab[ searchID ].noMoreImg = false;
            }
            else if (sub == 'dir-known')
            {
                stockphoto.NavExtFnc.setPageFull( searchID, true);
            }
            else if (sub == 'foundCount')
            {
                if (stockphoto.NavExtFnc.getPageFull( searchID) == true)
                {
                    if ( stockphoto.core.log.DebugINIData.log != undefined )
                        stockphoto.core.log.logString(0, 'FOUND COUNT -- CANDIDATE FOR UPDATE - LATEUPDATE');
                    sub = 'lateUpdate';
                }
                else
                {
                    if ( stockphoto.core.log.DebugINIData.log != undefined ) 
                        stockphoto.core.log.logString(0, 'FOUND COUNT -- CANDIDATE FOR UPDATE - GETTING IMAGES');
                    sub = 'lateUpdateGetting';
                }
            }
			else
			{
                return false;
            }
			
			// Check if it is for the current window
			if( searchID == stockphoto.NavIntDt_t[doc_id].FaN.Last_i )
			{
				if( stockphoto.core.log.DebugINIData.log != undefined ) 
					stockphoto.core.log.logString( 0, "NavExtFnc.NavExtFnc.updateXofYfromExternal() .. Report for Current Window" );
				for( i=0; i<stockphoto.NavIntDt.NoOfNavIntDt_t; i++ )
				{
					if( ( stockphoto.NavIntDt_t[i]._i != undefined )&&( ! stockphoto.NavIntDt_t[i]._i ) )
					{
						if (( stockphoto.NavIntDt_t[ i ].FaN.Last_i == searchID )
						     && (stockphoto.NavIntDt_t[i].kindOfNav == stockphoto.NavIntDt._kKindOfNav_searchResult))
						{
							if( stockphoto.core.log.DebugINIData.log != undefined ) 
								stockphoto.core.log.logString( 0, "NavExtFnc.NavExtFnc.updateXofYfromExternal() .... doc_id="+i+" has the same searchID" );
							stockphoto.NavIntFnc.updateXofY( status, ""+x, ""+y, sub, i, from )
						}
					}
				} // for all doc_id=i
			}
		}
	}
}

stockphoto.NavIntFnc.updateXofY=function( status, xIn, yIn, sub, doc_id, from )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.NavIntDt_t[ doc_id ].kindOfNav <= stockphoto.NavIntDt._kKindOfNav_recentSearches /* in search */ ) 
	{
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "<Processed> NavExtFnc.updateXofY( '"+status+"', '"+xIn+"', '"
											 +yIn+"', '"+sub+"', doc_id="+doc_id+", << "+from+" >>" );
		stockphoto.NavIntFnc.doupdateXofY(status, xIn, yIn, sub, doc_id);
	} else {
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "<Cancelled> NavExtFnc.updateXofY( '"+status+"', '"+xIn+"', '"
											 +yIn+"', '"+sub+"', doc_id="+doc_id+", << "+from+" >> kindOfNav="
											 +stockphoto.NavIntDt_t[ doc_id ].kindOfNav );
	}
}

stockphoto.NavIntFnc.ForceChekingXandY=function( doc_id )
{
	var bRet=0, x=0, ik=stockphoto.NavIntFnc.SearchFolderAndKey( doc_id );
	var idx =stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavExtFnc.ForceChekingXandY( doc_id="+doc_id );
	if( ik >= 0 ) 	
	{
		x = stockphoto.NavExtFnc.CountNoOfFiles( stockphoto.NavIntDt_t[doc_id].Ext.fk[ik].p+"/"+stockphoto.NavIntDt_t[doc_id].Ext.fk[ik].n, "*.jpg" );
	}
	if( stockphoto.NavIntDt.FldAndNumTab[ idx ].x != x )
	{
		stockphoto.NavIntDt.FldAndNumTab[ idx ].x = x; // at stockphoto.NavIntFnc.ForceChekingXandY(), recalculating X by file scanning
		bRet = 2;
	}
	if( x > stockphoto.NavIntDt.FldAndNumTab[ idx ].y )
	{
		stockphoto.NavIntDt.FldAndNumTab[ idx ].y = x; // at stockphoto.NavIntFnc.ForceChekingXandY(), recalculating x by file scanning & if x > stockphoto.NavIntDt.FldAndNumTab[ idx ].y
		bRet |= 4;
	}
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= bRet;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= bRet;
}

stockphoto.NavIntFnc.doupdateXofY = function( status, xIn, yIn, sub, doc_id )
{
	var Js, x, y, bReqSend=false;
	var idx =stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;
	var xSav=stockphoto.NavIntDt.FldAndNumTab[ idx ].x;
	var ySav=stockphoto.NavIntDt.FldAndNumTab[ idx ].y;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "  NavIntFnc.doupdateXofY( status="+status
										 +", x="+xSav+"->"+xIn+", y="+ySav+"->"+yIn+", sub="+sub+", doc_id="+doc_id+" )" );
	
    // <NewXY>
    x = parseInt( ( xIn.toString() ) );
	y = parseInt( ( yIn.toString() ) );
    if( stockphoto.NavIntDt.FldAndNumTab[ idx ].x < x )
	{
		stockphoto.NavIntDt.FldAndNumTab[ idx ].x = x;
	}
	if( stockphoto.NavIntDt.FldAndNumTab[ idx ].y < y )
	{
		stockphoto.NavIntDt.FldAndNumTab[ idx ].y = y;
	}
	
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 2;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 2;
	stockphoto.NavIntDt.FldAndNumTab[ idx ].xStr8 = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt.FldAndNumTab[ idx ].x, 8 );

	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 4;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 4;
	stockphoto.NavIntDt.FldAndNumTab[ idx ].yStr8 = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt.FldAndNumTab[ idx ].y, 8 );

    // <TODO> Reorganize all the subs into switch-case...
    	
	if( sub == "pageFull" )
	{
		if ( stockphoto.core.log.DebugINIData.log != undefined )
            stockphoto.core.log.logString( 0, "Wheel OFF doupdateXofY - pageFull #1" );
		stockphoto.NavExtFnc.UpdateXofYFromES(doc_id,xIn,yIn);
		return;
	}
	if ( sub == 'initializing')
	{
    	if ( stockphoto.core.log.DebugINIData.log != undefined )
            stockphoto.core.log.logString( 0, "Wheel ON doupdateXofY - initializing #1" );
		stockphoto.NavExtFnc.ShowGettingImagesFromES(doc_id);
		return;
    }
    if( sub == "dir-known" )
	{
	    stockphoto.NavIntFnc.SetReqUniqID( doc_id );
		if ( stockphoto.core.log.DebugINIData.log != undefined )
            stockphoto.core.log.logString( 0, "Wheel OFF doupdateXofY - dir-known #1" );
		stockphoto.NavExtFnc.UpdateXofYFromES(doc_id,xIn,yIn);
		return;
	}
	if (sub == 'lateUpdate')
	{
		if ( stockphoto.core.log.DebugINIData.log != undefined )
            stockphoto.core.log.logString( 0, "Wheel OFF doupdateXofY - lateUpdate #1" );
		stockphoto.NavExtFnc.UpdateXofYFromES(doc_id,xIn,yIn);
		return;    
    }
	if ( sub == 'lateUpdateGetting')
	{
	    if ( stockphoto.core.log.DebugINIData.log != undefined )
            stockphoto.core.log.logString( 0, "Wheel ON doupdateXofY - lateUpdateGetting #1" );
		stockphoto.NavExtFnc.ShowGettingImagesFromES(doc_id);
		return;
	}
	if ( sub == 'search-start')
	{
        stockphoto.NavIntFnc.SetReqUniqID( doc_id );
        return;
    }
    if ( sub == 'refresh')
    {
        stockphoto.NavIntFnc.SetReqUniqID( doc_id );
        return;
    }
    if ( sub == 'allThumbnailsMoved')
    {
        stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = true;
    }

	return;
}

/* Wheel */

stockphoto.NavExtFnc.SpiningWheelOn=function( Label, doc_id )
{
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "----- Wheel ON @ SpiningWheelOn() Label='"+Label+"' doc_id="+doc_id );
	// if it's from stockphoto.DL.NavBar.SpiningWheelOn(), stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[3] = "+";
	var nLabel=0;
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( Label != undefined )
	{
		nLabel = Label.length;
	}
	if( nLabel <= 0 )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel=3;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel ="def";
	}
	else
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel=nLabel;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel =Label;
	}
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 1;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 1;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWhlStr4   = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel, 4 );
	stockphoto.NavExtFnc.SendRequestToHTM( doc_id, true ); // default uses scheduletask
}

stockphoto.NavExtFnc.SpiningWheelOff=function( doc_id )
{
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "----- Wheel OFF @ SpiningWheelOff() doc_id="+doc_id );
	// if it's from stockphoto.DL.NavBar.SpiningWheelOff(), stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[3] = "-";
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel     = 3;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel      = "off";
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 1;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 1;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWhlStr4   = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel, 4 );
	stockphoto.NavExtFnc.SendRequestToHTM( doc_id, true ); // default uses scheduletask

	// when gpk is up and if it has a spining wheel, it should be off
	if (( stockphoto.gpk3 != undefined ) && (stockphoto.gpk3.gpk3Sys[ doc_id ] != undefined))
		stockphoto.gpk3.KWSpiningWheel( doc_id, false /* turmimg OFF */, true /* not to schedule */, stockphoto.gpk3.KWSpiningWheel_unknown /* OFF */ ); 
}

/* ------- */		
/* KeyWord */
/* ------- */		
stockphoto.NavIntFnc.SetKeyWord=function( KeyWord, bEscaped, doc_id, bSend )
{
	var uKeyword;

	if (KeyWord == undefined) // at startup. this may be blank
		KeyWord = "abcxyz";	  // set to a default value unlikely to return results

	if( bEscaped )
	{
		uKeyword = unescape( KeyWord );
	}
	else
	{
		uKeyword = KeyWord;
	}
	stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb     = uKeyword;
	stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordFileSys = uKeyword;

	if( uKeyword != stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword   = uKeyword;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nuKeyword  = uKeyword.length;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 32;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 32;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nKWdStr4   = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nuKeyword, 4 );
        if( bSend )
        {
		    stockphoto.NavExtFnc.SendRequestToHTM( doc_id );
        }
	}
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "NavIntFnc.SetKeyWord: doc_id="+doc_id+" ukeyword="+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword );
	return( uKeyword );
}

/* -------- */
/* UniqueID */
/* -------- */
stockphoto.NavIntFnc.SetReqUniqID=function( doc_id )
{
	( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.UniqueID )++;
	if( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.UniqueID > 9 )
	{
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.UniqueID = 0;
	}		
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 128;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 128;
	stockphoto.NavExtFnc.SendRequestToHTM( doc_id );
}

/* -------- */
/* dispLang */
/* -------- */
stockphoto.NavIntFnc.SetDispLang=function( dispLang, doc_id  )
{
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.dispLang   = dispLang;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 256;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 256;
}

// AMAN
stockphoto.NavIntFnc.SetValueAmt=function( sValueAmt, doc_id )
{
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.valueAmt   = sValueAmt;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] |= 256;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] |= 256;
}

stockphoto.NavExtFnc.setXandY=function( x, y, doc_id )
{
	var idx=stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "stockphoto.NavExtFnc.setXandY( x="+x+" y="+y+" doc_id="+doc_id+" )" );
	stockphoto.NavIntDt.FldAndNumTab[ idx ].x = x;
	stockphoto.NavIntDt.FldAndNumTab[ idx ].y = y;
}

stockphoto.NavIntFnc.SetNavBarHeight=function( RetString, i_W_OR_F, doc_id )
{
	var hString, h, doc;
	hString = RetString.substring( 1,RetString.length );
	h       = stockphoto.HTMLUtil.ConvertToInteger( hString );
	doc     = stockphoto.documents[ doc_id ].document;
	
	// Check if doc is still present (this function is scheduleTask-ed...)
	if (doc == undefined)
	{
        return;
    }
    
	if( doc.contentPaneMode == "web" )
	{
		if( i_W_OR_F != stockphoto.NavIntDt._kWebOrFile_web )
			return;
	}
	else
	{
		if( i_W_OR_F != stockphoto.NavIntDt._kWebOrFile_filesystem )
			return;
	}
	if (( doc.topNavbar.height != h ) && (stockphoto.NavBar.heightUpdateScheduled != false))
	{
		doc.topNavbar.height = h;
		if ( stockphoto.core.log.DebugINIData.log != undefined )
		  stockphoto.core.log.logString( 0, "[NavIntFnc.SetNavBarHeight] Set NavBar height to " + h);
		stockphoto.NavBar.heightUpdateScheduled = false;
	}
}

stockphoto.NavIntFnc.doCmdFromHtm=function( doc_id, eCmdString, nCmd, bBasicSearch )
{
	var k, fldr, sCmd, CmdString=unescape(eCmdString);
//-dbl-	/*B*/	stockphoto.core.burpClearDblClkBuffer( app.document.id );  // command from NavBar
	if( bBasicSearch )
	{
		if( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword != stockphoto.NavIntDt.TheEnter )
		{
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "\n\n\ndoCmdFromHtm\n\n\n" );
			k = stockphoto.NavIntFnc.SearchFolderAndKey( doc_id );
			if( k >= 0 )
			{ // we do not know the folder
				stockphoto.NavIntDt_t[doc_id].Ext.fk[k].uky = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword;
			}
		}
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "doCmdFromHtm.basicSearch w="+stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb+" f="+stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordFileSys );
		sCmd = CmdString.substr( 1, nCmd-1 ); // sCmd is escaped
	}
	else
	{
		if( ( nCmd > 20 ) &&          /* 12345678901234567890 */
		    ( CmdString.substr(0,20) == "DL.search.MoreThumbs" ) )
		{
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "Wheel ON 'MoreThumbs' callback" );
		}
		else
		{
/*B*/		stockphoto.Burp.menuSorce[ doc_id ]     = "btn";  	
/*B*/		if( ( nCmd > 19 ) &&          /* 12345678901234567890 */
/*B*/		    ( CmdString.substr(0,19) == "DL.GetComp.KeepComp" ) )
//-bld-/*B*/stockphoto.Burp.listDlComps( doc_id, app.document.selections, 0, "btn" ); // doCmdFromHtm()
/*B*//*-dblnew-*/ stockphoto.Burp.getCompSource[ doc_id ] = "btn"; // doCmdFromHtm()
/*B*/		if( ( nCmd > 25 ) &&          /* 1234567890123456789012345 */
/*B*/		    ( CmdString.substr(0,25) == "DL.ShoppingCart.AddToCart" ) )
/*B*/ 			stockphoto.Burp.addCartSource = "btn";
/*B*/		if( ( nCmd > 21 ) &&          /* 1234567890123456789012345 */
/*B*/		    ( CmdString.substr(0,21) == "DL.imgDetail.getPrice" ) )
/*B*/ 			stockphoto.Burp.gpkSource = "btn";
/*B*/		if( ( nCmd > 24 ) &&          /* 1234567890123456789012345 */
/*B*/		    ( CmdString.substr(0,24) == "DL.imgDetail.getKeywords" ) )
/*B*/ 			stockphoto.Burp.gpkSource = "btn";
		}
		sCmd = CmdString;
	}
	sCmd += doc_id+");";
	stockphoto.NavIntDt_t[doc_id].Ext.InTheeCom = false;
	app.scheduleTask( "stockphoto."+sCmd, 0, false );
}

if( stockphoto.PTSGLilo_Prototype != undefined )
{
	stockphoto.NavIntFnc.loadSt33Lilo=function()
	{
		if( stockphoto.st33Lilo_Loaded != undefined )
			return( true );
		var bRet=false;
		var js="";
		var fs = new File( stockphoto.core.folder.getScriptFolder() + "/st33Lilo.jsx" );
		if( fs != undefined ) 
		{
			if( fs.exists ) 
			{
				fs.open();
				js = fs.read();
				fs.close();
				try 
				{
					eval(js);
				} 
				catch(e) 
				{ // this is to catch .jsx error
					stockphoto.DL.generalAlertBox(stockphoto.core.consts.localizedErrorString[1]+"st33Lilo.jsx", 2);
					delete fs;
					return false;
				}
				bRet = true;
			}
			delete fs;
		}
		if( ! bRet )
		{
			stockphoto.DL.generalAlertBox(stockphoto.core.consts.localizedErrorString[2]+"st33Lilo.jsx", 2);
		}
		return( bRet );
	} // stockphoto.NavIntFnc.loadSt33Lilo=function()

} // if( stockphoto.PTSGLilo_Prototype != undefined )

stockphoto.NavIntFnc.jsCallBacks=
{
//	if( stockphoto.PTSGLilo_Prototype != undefined )
//	{
		_cbNav_PTSGLilo_SpellCheck: function( str )
		{
			var doc_id = ( 1000 * ( str.charCodeAt(0) - 0x30 ) )
						+ ( 100 * ( str.charCodeAt(1) - 0x30 ) )	
						 + ( 10 * ( str.charCodeAt(2) - 0x30 ) )
						  + (     ( str.charCodeAt(3) - 0x30 ) );
			var wdIdx  = ( 1000 * ( str.charCodeAt(4) - 0x30 ) )
						+ ( 100 * ( str.charCodeAt(5) - 0x30 ) )	
						 + ( 10 * ( str.charCodeAt(6) - 0x30 ) )
						  + (     ( str.charCodeAt(7) - 0x30 ) );
			var key    = str.substr( 8, str.length-8 );
			var o;
			if( stockphoto.NavIntFnc.loadSt33Lilo() )
			{
					o = stockphoto.st33Lilo.spellChecker( key, doc_id, wdIdx );
					return( o );
			}
			return( key );
		},
		_cbNav_PTSGLilo_Thesaurus: function( str )
		{
			var doc_id = ( 1000 * ( str.charCodeAt(0) - 0x30 ) )
						+ ( 100 * ( str.charCodeAt(1) - 0x30 ) )	
						 + ( 10 * ( str.charCodeAt(2) - 0x30 ) )
						  + (     ( str.charCodeAt(3) - 0x30 ) );
			var wdIdx  = ( 1000 * ( str.charCodeAt(4) - 0x30 ) )
						+ ( 100 * ( str.charCodeAt(5) - 0x30 ) )	
						 + ( 10 * ( str.charCodeAt(6) - 0x30 ) )
						  + (     ( str.charCodeAt(7) - 0x30 ) );
			var key    = str.substr( 8, str.length-8 );
			var o;
			if( stockphoto.NavIntFnc.loadSt33Lilo() )
			{
					o = stockphoto.st33Lilo.expandThesaurus( key, doc_id, wdIdx );
					return( o );
			}
			return( key );
		},
//	} // if( stockphoto.PTSGLilo_Prototype != undefined )

	/*B*/	_burpUrl_omitBurpUrl: function()
	/*B*/	{
	/*B*/		stockphoto.Burp.omitUrl = false;
	/*B*/ 	},
	/*B*/	_cbNav_IsSearchWithin: function( iii )
	/*B*/	{
	/*B*/		var Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_IsSearchWithin" );
	/*B*/		stockphoto.NavIntDt_t[(Ret.doc_id)].Ext.IsSearchWithin = Ret.str;
	/*B*/	},
	_cbNav_ExecES: function( iii )
	{
		var Ret          = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_ExecES" );
		var doc_id       = Ret.doc_id;
		var CmdString    = Ret.str;
		var nCmd         = CmdString.length
		var bBasicSearch = false;
		var doc          = stockphoto.documents[ doc_id ].document;
		if( ( nCmd > 22 ) &&          /* 123456789012345678901 */
		    ( CmdString.substr(1,21) == "DL.search.basicSearch" ) )
		{
/*B*/		if( ( stockphoto.NavIntDt_t[ doc_id ].Ext.IsSearchWithin != undefined )&&
/*B*/			( stockphoto.NavIntDt_t[ doc_id ].Ext.IsSearchWithin == "1" ) )
/*B*/			 stockphoto.Burp.searchFrom[ doc_id ] = "with";
/*B*/		else stockphoto.Burp.searchFrom[ doc_id ] = "bas";
			bBasicSearch = true;
			if( doc.contentPaneMode == "web" )
			{ // workaround for #1135772, unfinished
				var wh = app.document.navbars.web.top.height;  	
				doc.contentPaneMode = "web";
			}
		}
		// Give an opportunity to ExtendScript to reflect the recent document.properties' change made above
		app.scheduleTask( "stockphoto.NavIntFnc.doCmdFromHtm( "+doc_id+',"'+escape(CmdString)+'",'+nCmd+","+bBasicSearch+");", 100, false );
		return( "" );
	},
	_cbNav_iExecES: function( iii )
	{  // not called from html
		var Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_iExecES" );
		app.scheduleTask( "stockphoto."+(Ret.str), 0, false );
		return( "" );
	},
	_cbNav_HTMScriptBegin: function( iii )
	{
		var i_W_OR_F, hString, h, doc;
		var Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_HTMScriptBegin" );
		if( Ret.str.charAt(0) == "1" )
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_filesystem; /* 0=web/1=file */
		}
		else
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_web;
		}
		
		// <manish> -- important location in code to insert height altering code
		stockphoto.NavBar.heightUpdateScheduled = true;
        app.scheduleTask( "stockphoto.NavIntFnc.SetNavBarHeight('"+(Ret.str)+"',"+(i_W_OR_F)+","+(Ret.doc_id)+");",10,false );
		if( stockphoto.NavIntDt_t[(Ret.doc_id)].Ext.HtmLDStatus[i_W_OR_F] < stockphoto.NavBar.cnst_HtmLDStatus_HtmIsCalled )
		{
			stockphoto.NavIntDt_t[(Ret.doc_id)].Ext.HtmLDStatus[i_W_OR_F] = stockphoto.NavBar.cnst_HtmLDStatus_HtmIsCalled;
		}
		return( "XXX" );
	},
	_cbNav_InitStrings: function( iii )
	{
		var szStr, xx, yy, i_W_OR_F, uKeyword;
		var Ret    = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_InitStrings" );
		var doc_id = Ret.doc_id;
		var idx    = stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "_cbNav_InitStrings w="+stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb+" f="+stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordFileSys );
		if( Ret.str.charAt(0) == "1" )
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_filesystem; /* 0=web/1=file */
			uKeyword = stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordFileSys;
		}
		else
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_web;
			uKeyword = stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb;
			stockphoto.NavIntDt_t[doc_id].Ext.uKeyWordWeb = stockphoto.NavIntDt.TheEnter;
		}
		if( stockphoto.NavIntDt.FldAndNumTab[ idx ].x > 0 )
		{
			xx = stockphoto.NavIntDt.FldAndNumTab[ idx ].x;
		}
		else
		{
			xx = 0;
		}
		if( stockphoto.NavIntDt.FldAndNumTab[ idx ].y > 0 )
		{
			yy = stockphoto.NavIntDt.FldAndNumTab[ idx ].y;
		}
		else
		{
			yy = 0;
		}
		szStr = ( "x" + ( 900000000 + xx ) ) + ( "y" + ( 900000000 + yy ) ) + uKeyword;
		return( szStr );
	},
	_cbNav_HTMScriptEnd: function( iii )
	{
		var i_W_OR_F;
		var Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_HTMScriptEnd" );
		if( Ret.str.charAt(0) == "1" )
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_filesystem; /* 0=web/1=file */
		}
		else
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_web;
		}
		stockphoto.NavIntDt_t[(Ret.doc_id)].Ext.HtmLDStatus[i_W_OR_F] = stockphoto.NavBar.cnst_HtmLDStatus_disabled;
		return( "XXX" );
	},
	_cbNav_SetKeyword: function( iii )
	{
		var Ret      = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_SetKeyword" );
		var eKeyword = Ret.str; // escaped string
		var uKeyword = unescape( eKeyword );
		var doc_id   = Ret.doc_id;
		stockphoto.NavIntFnc.SetKeyWord( uKeyword, false /*=unescaped*/, doc_id, false );
		var doc = stockphoto.documents[ doc_id ].document;
		if( doc.contentPaneMode == "web" )
		{
			stockphoto.NavExtFnc.SendKeyWordToHTM( eKeyword, doc_id, 1 /* filesystem */, 0, true );
		}
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "_cbNav_SetKeyword w="+stockphoto.NavIntDt_t[Ret.doc_id].Ext.uKeyWordWeb+" f="+stockphoto.NavIntDt_t[Ret.doc_id].Ext.uKeyWordFileSys+"\n\n\n" );
		return( "" );
	},
	_cbNav_GetKeyword: function( iii )
	{
		var i_W_OR_F, Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_GetKeyword" );
		var doc_id = Ret.doc_id;
		var idx    = stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;
		var i_fORw_And_TimeOut = Ret.str;
		if( i_fORw_And_TimeOut.charAt(0) == "1" )
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_filesystem; /* 0=web/1=file */
		}
		else
		{
			i_W_OR_F = stockphoto.NavIntDt._kWebOrFile_web;
		}
		if( i_fORw_And_TimeOut.charAt(1) == "1" )
		{ // Time out in html
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "Wheel OFF _cbNav_GetKeyword()" );
			if( ( stockphoto.NavIntDt.FldAndNumTab[ idx ].x > 0 )&&
			    ( stockphoto.NavIntDt.FldAndNumTab[ idx ].x == stockphoto.NavIntDt.FldAndNumTab[ idx ].y ) )
			{
				stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = true;
			}
		}
		stockphoto.NavIntFnc.PrepareStringForHTM( i_W_OR_F, doc_id );
		stockphoto.NavIntDt_t[(Ret.doc_id)].Ext.HtmLDStatus[i_W_OR_F] = stockphoto.NavBar.cnst_HtmLDStatus_HtmIsRead;
		return( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[i_W_OR_F] );
	},
	_cbNav_SetHtmLDStatus: function( iii )
	{
		var Ret = stockphoto.HTMLUtil.GetDocIDFromHTMLString( iii, "_cbNav_SetHtmLDStatus" );
		stockphoto.NavIntDt_t[ (Ret.doc_id) ].Ext.HtmLDStatus[0] = stockphoto.NavBar.cnst_HtmLDStatus_HtmIsRead;
	},
	_cbNav_DebugWrtNo: 0,
	_cbNav_DebugWrite: function( escaped_string )
	{
		var str;
		str = escape( "  fromHTML="+(++(stockphoto.NavIntFnc.jsCallBacks._cbNav_DebugWrtNo))+"=> " ) + escaped_string;
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, unescape( str ) ); 
	},
	
	_cbNav_RunHelpFile: function(iii)
	{
        stockphoto.DL.MiscDlgs.HelpTopic( stockphoto.core.helpTopicBase );
	},
		
		
	
	
	// ------------------------------------
   //AK:added by aman
    // This is called from JavaScript's SelectUI() function
    _cbNav_GetValueCollectionsFeatureFlag: function ( )
    {
     return stockphoto.core.displayValueCollectionFeatureflag;
    },
    
     // This is called from JavaScript's SelectUI() function
    _cbNav_GetPhotoObjectCollectionsFeatureFlag: function ( )
    {
     return stockphoto.core.displayPhotoObjectCollectionFeatureflag;
    },
    //AK:end of added
    
    // This is called from JavaScript's PopulateCollections() function
    _cbNav_GetCollectionsList: function ( )
    {
      var cList = [];
      cList = (stockphoto.search.getCollectionsList());
      return cList.toSource();
    },
    
    // This is called from JavaScript's setFilter() function
    _cbNav_SetFilter: function ( filterID, value, docID )
    {
      var oRet = stockphoto.HTMLUtil.GetDocIDFromHTMLString( docID, "_cbNav_SetFilter" );
      if ((filterID != undefined) && (filterID != ''))
      {
        stockphoto.search.setFilter( filterID, value, oRet.doc_id );
      }
      
      // This function will return the new Changed-from-default string...
      var oCFD = stockphoto.NavExtFnc.GetCFD(oRet.doc_id);
      return oCFD.toSource();
    },
    
    _cbNav_GetSimplifiedKeyword: function ( docID )
    {
    	var oRet = stockphoto.HTMLUtil.GetDocIDFromHTMLString( docID, "_cbNav_GetSimplifiedKeyword" );
    	return stockphoto.search.getSimplifiedKeyword( oRet.doc_id );
    },
    
    // This is called from JavaScript's ToggleAdvancedOptionsDrawer() function
    _cbNav_ToggleAdvancedOptions: function ( docID )
    {
      var oRet = stockphoto.HTMLUtil.GetDocIDFromHTMLString( docID, "_cbNav_ToggleAdvancedOptions" );
      stockphoto.DL.NavBar.ToggleAdvanceDrawer( oRet.doc_id, oRet.str );
      return;
    },
    
    _cbNav_RefreshValuesFromES: function ( docID )
    {
        var oRet = stockphoto.HTMLUtil.GetDocIDFromHTMLString( docID, "_cbNav_RefreshValuesFromES" );
        var oDefaultResult = { };
        var oResult = stockphoto.DL.NavBar.getValuesFromES( oRet.doc_id );
      
        if (oResult != undefined)
        {
            return oResult.toSource();
        }
        else
        {
            return oDefaultResult;
        }
    },
    
    _cbNav_RefreshSearchLangLocaleOps: function ()
    {
        if (stockphoto.NavBar.zcSearch != undefined)
        {
            delete stockphoto.NavBar.zcSearch;
        }
        
        stockphoto.NavBar.zcSearch       = new stockphoto.zstringCache(stockphoto.core.zstringFiles.NavBar, stockphoto.core.getASPSearchLangLocale());
        stockphoto.NavBar.zcSearch.dict  = stockphoto.core.zstringFiles.NavBar + '.txt';

        stockphoto.NavCnv.NavCnv.OP_AND 	=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_AND=AND");
		stockphoto.NavCnv.NavCnv.OP_OR 		=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_OR=OR");
		stockphoto.NavCnv.NavCnv.OP_NOT		=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_NOT=NOT");
		
		stockphoto.NavCnv.NavCnv.SEARCH_LOCALE = stockphoto.core.getASPSearchLangLocale();

        // Return executable js to HTML
        var sExecStr = 'const_Op_And = "' + stockphoto.NavCnv.NavCnv.OP_AND + '";';
        sExecStr += ' const_Op_Or = "' + stockphoto.NavCnv.NavCnv.OP_OR + '";';
        sExecStr += ' const_Op_Not = "' + stockphoto.NavCnv.NavCnv.OP_NOT + '";';
        sExecStr += ' glb_searchLocale = "' + stockphoto.NavCnv.NavCnv.SEARCH_LOCALE + '";';
        return sExecStr;
    },
	
	 // Calls NavBar's internal functions to fetch object containing CFD string
    _cbNav_GetChangedFromDefault: function( docID )
    {
    	var oRet = stockphoto.HTMLUtil.GetDocIDFromHTMLString( docID, "_cbNav_GetChangedFromDefault" );
    	var oDefaultCFD = { sCFD:'' };
        
        var oCFD = stockphoto.NavExtFnc.GetCFD(oRet.doc_id);
    	
    	if (oCFD != undefined)
    	{
	    	return oCFD.toSource();
	    }
	    else
	    {
	    	return oDefaultCFD;
	    }
    },
    
    _cbNav_displayFiltersAlertBox: function (errorCode, sAppendMessage)
    {
    	stockphoto.DL.alertBox(errorCode, undefined, undefined, sAppendMessage);
    }
    
} // stockphoto.NavIntFnc.jsCallBacks end

stockphoto.NavExtFnc.GetKeywdFromES=function( Dummy, doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	var bRet, k=stockphoto.NavIntFnc.SearchFolderAndKey( doc_id );
	if( k >= 0 )
	{
 		bRet = stockphoto.NavIntDt_t[doc_id].Ext.fk[k].origKW; // origKW from SearchInfo.txt
        if (bRet == undefined)
        {
            bRet = stockphoto.NavIntDt_t[doc_id].Ext.fk[k].uky;
        }
	}
	else
	{
		if( Dummy == "error" )
		{
			bRet = stockphoto.NavIntDt.Const_NA;
		}
		else
		{
			bRet = stockphoto.NavIntDt.TheEnter;
		}
	}
	return( bRet );
}

stockphoto.NavExtFnc.CreateStyleSheet=function( doc_id )
{
	var localeFolder;
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	stockphoto.NavExtFnc.SetStandardCnvTable( doc_id );
	if( stockphoto.DL.HTMLUtil.SubLocalHTMLbyDocID( stockphoto.core.folder.getTemplateFolder()+"/stylesheets/nstockphoto.css",
						stockphoto.NavCnv.StandardCnvTab, "stockphoto.css", doc_id, false ) )
	{
		// Since html file uses stylesheet in a relative path so we need to
		// copy it to the new directory
		( stockphoto.HTMLUtil.fsOut ).copy( stockphoto.core.folder.getTempFolder()+"/stockphoto.css" );
		localeFolder = stockphoto.core.folder.getSaveNavbarFolder();
		if( stockphoto.core.folder.checkAndCreateFolder( localeFolder ) )
		{
			( stockphoto.HTMLUtil.fsOut ).copy( localeFolder+"/stockphoto.css" );
		}
		return( true );
	}
	return( false );
}

stockphoto.NavIntFnc.setTopNavbarFile=function( doc, doc_id, place, fileName )
{
	// Looks like "doc.topNavbar.file=xxx" crashes in Bridge if opera
	// has never loaded.
	try
	{
		if( ( stockphoto.isMac )&&
			( stockphoto.NavIntDt_t[ doc_id ].operaLoaded == undefined )&&
			( doc.contentPaneMode != "web" ) )
			//( stockphoto.core.Places.home != undefined ) )
		{
			doc.contentPaneMode = "web";
			doc.thumbnail = stockphoto.core.Places.home; // this is invisible - undefined is OK
			doc.contentPaneMode = "filesystem";
			stockphoto.NavIntDt_t[ doc_id ].operaLoaded = true;
		}
		doc.topNavbar.file = fileName;
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
		{	// i.e. if Debug.ini exists
			app.document.status = "Top NavBar loaded: "+fileName;
		}
	} 
	catch(e)
	{
		stockphoto.log( "Fail to set topNavBar["+place+"]: "+fileName+"\n    -> "+e );
	}
}

stockphoto.NavIntFnc.PasteBMNavBar=function( webORfile, NewName, navHeight, kindOfNav, kindOfGif, NavMode, 
												uKeyWord, navType, doc, doc_id, bAccessDoc, idx )
{
	var Name, TopNavHeight, hTop, hBtm, h, str2;
	var bRet={bGood:false,file:"",height:0};
	var OutPath = stockphoto.core.folder.getSaveNavbarFolder()+"/"+NewName;
	var Outfs   = new File( OutPath );

	if( stockphoto.NavIntDt.TopNav_locale != stockphoto.core.getValidLocale() )
	{
		if( stockphoto.core.util.loadLocaleData( "st11NavBar.par") )
		{
			stockphoto.NavIntDt.TopNav_locale = stockphoto.core.getValidLocale();
		}
	}
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "...... PasteBMNavBar() / Out="+NewName+" locale="+stockphoto.NavIntDt.TopNav_locale
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y
		                                 +" Change["+stockphoto.NavIntDt_t[ doc_id ].Ext.NavDt.change[0]
		                                 +","+stockphoto.NavIntDt_t[ doc_id ].Ext.NavDt.change[1]+"]" );

	stockphoto.NavCnv.NavCnv.PRIMARYFONT = stockphoto.NavExtFnc.GetFontNames();
	stockphoto.NavCnv.NavCnv.MEDIATYPE_HEIGHT = stockphoto.NavExtFnc.GetMediaTypeHeight();
	stockphoto.NavCnv.NavCnv.X_OF_Y_WIDTH = stockphoto.NavExtFnc.GetXOFYWidth();
	stockphoto.NavCnv.NavCnv.SEARCHLANG_TOOLTIP_WIDTH = stockphoto.NavExtFnc.GetLangToolTipWidth();
	
	if (false == stockphoto.core.displayValueCollectionFeatureflag)
	{
		
		stockphoto.NavCnv.NavCnv.ADVOPTIONSBOX_HEIGHT = "126px"; 
	}
	
	if( navHeight == stockphoto.NavIntDt._kNavHeight_short )
	{
		hTop = stockphoto.NavCnv.NavCnv.HEIGHTS;
		Name = "st11TopSBar.htm";
	}
	else
	{
		hTop = stockphoto.NavCnv.NavCnv.HEIGHTT;
		Name = "st11TopBBar.htm";
	}

	if( webORfile == stockphoto.NavIntDt._kWebOrFile_web )
	{
	  hBtm = 0;
	}
	else
	{
		hBtm = stockphoto.NavCnv.NavCnv.BARHEIGHT;
	}
	
    h = hTop + hBtm;
  
	if( ( Outfs != undefined )&&( Outfs.exists ) )
	{
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, "........ Use "+Outfs.fsName );
		bRet.bGood = true;
	}
	else
	{
		if( uKeyWord != "" )
		{
			stockphoto.NavIntFnc.SetKeyWord( uKeyWord, false /*=unescaped*/, doc_id, true );
		}

		// misc
		if( h >= 22 )
		{
			stockphoto.NavCnv.NavCnv.MAXCHIPY   = h - 22;
	    }
		else
		{
			stockphoto.NavCnv.NavCnv.MAXCHIPY   = 0;
		}
		stockphoto.NavCnv.NavCnv.WEB_OR_FILE    = NavMode.charAt(0)
		if( Folder.fs == "Macintosh" )
		{
			stockphoto.NavCnv.NavCnv.WIN_OR_MAC = 'm';
			stockphoto.NavCnv.NavCnv.BTMBARBTNFONTHEIGHT=stockphoto.NavCnv.NavCnv.BTMBARBTNFONTHEIGHT_MAC;
		}
		else
		{
			stockphoto.NavCnv.NavCnv.WIN_OR_MAC = 'w';
			stockphoto.NavCnv.NavCnv.BTMBARBTNFONTHEIGHT=stockphoto.NavCnv.NavCnv.BTMBARBTNFONTHEIGHT_PC;
		}
		
		if( stockphoto.NavIntDt.PushFromES )
		{
			stockphoto.NavCnv.NavCnv.PushFromES = "1";
		}
		else
		{
			stockphoto.NavCnv.NavCnv.PushFromES = "0";
		}

		// labels
		stockphoto.NavCnv.NavCnv.DIALOGTITLE   =stockphoto.NavBar.zc.get("$$$/NavBar/TopNavBar/top_nav_bar=Nav Bar");
		stockphoto.NavCnv.NavCnv.DEFEDITSTRING =stockphoto.NavIntDt.TheEnter2;
		stockphoto.NavCnv.NavCnv.ENTER_KEYWORD =stockphoto.NavIntDt.TheEnter2;
		stockphoto.NavCnv.NavCnv.i_W_OR_F      =webORfile;
		stockphoto.NavCnv.NavCnv.NAVHEIGHT     =h;
		stockphoto.NavCnv.NavCnv.NAVHEIGHTADD  =stockphoto.NavCnv.NavCnv.BARHALFHEIGHT;
		
		if ((false == stockphoto.core.displayValueCollectionFeatureflag ))
	    {
	     stockphoto.NavCnv.NavCnv.NAVEXPANSION  = stockphoto.NavCnv.NavCnv.BARDRAWEREXPANSION_BC4 ;
		}
		else
		{
		 stockphoto.NavCnv.NavCnv.NAVEXPANSION  = stockphoto.NavCnv.NavCnv.BARDRAWEREXPANSION;
		} 
		 
		stockphoto.NavCnv.NavCnv.CONST_NA      =stockphoto.NavIntDt.Const_NA;
		stockphoto.NavCnv.NavCnv.b0            =kindOfNav.toString();
		stockphoto.NavCnv.NavCnv.b1            =kindOfGif.toString();

		stockphoto.NavCnv.NavCnv.SEARCH_LOCALE = stockphoto.core.getASPSearchLangLocale();

		stockphoto.NavCnv.NavCnv.MAINPAGE      =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/mainpage=Stock Photos Main Page" );
		stockphoto.NavCnv.NavCnv.SHOPCART      =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/shopcart=Shopping Cart" );
		stockphoto.NavCnv.NavCnv.STARTSER      =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/startsearch=Search" );
		stockphoto.NavCnv.NavCnv.STARTSERF     =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/startsearchRF=Search for RF Images" );
		stockphoto.NavCnv.NavCnv.STARTSERFREE  =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/startsearchRFree=Search for Royalty Free Images" );
		stockphoto.NavCnv.NavCnv.MOREWAY       =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/photodir=More ways to find images" );
		stockphoto.NavCnv.NavCnv.SERTIPS       =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/searchtip=Search Tips" );
		stockphoto.NavCnv.NavCnv.ADVSEARCH     =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/advsearch=Advanced Search" );
		stockphoto.NavCnv.NavCnv.YOURACCNT     =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/youraccount=Your Account" );
		stockphoto.NavCnv.NavCnv.MORERESULT    =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/moreresult=Display more results" );
		
		stockphoto.NavCnv.NavCnv.HELP    	   =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/help=Stock Photos Help" );
		stockphoto.NavCnv.NavCnv.SPLIT         =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/search_within_options=Search Within Options" );
		stockphoto.NavCnv.NavCnv.SPLITRE       =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/search_within_results=Search Within Results" );
		stockphoto.NavCnv.NavCnv.SEARCHCOLLEC  =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/search_collection=Search Selected Collections" );
		stockphoto.NavCnv.NavCnv.VALUECOLLEC   =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/value_collection=Search Images less than USD " )+"$";
		stockphoto.NavCnv.NavCnv.VALUEAMT   = stockphoto.core.displayCurrency;
		
		stockphoto.NavCnv.NavCnv.GET_PRICE     =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/get_price=Get Price" );
		stockphoto.NavCnv.NavCnv.DOWNLOAD_COMP =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/download_comp=Download Comp" );
		stockphoto.NavCnv.NavCnv.ADD_TO_CART   =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/add_to_cart=Add to Cart" );
		stockphoto.NavCnv.NavCnv.OPEN_DL_STATUS=stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/open_dl_status=Open Download Status" );
		stockphoto.NavCnv.NavCnv.FIND_SIMILAR  =stockphoto.NavBar.zc.get( stockphoto.NavBar.zstr_FindSimilar );
		stockphoto.NavCnv.NavCnv.PHOTO_ILLUS   =stockphoto.NavBar.zc.get( "$$$/NavBar/Chip/media_type=Search for Photos & Illustrations Options" );		
		stockphoto.NavCnv.NavCnv.ADV_PHOTOOBJECT =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/photo_photo_object=Masked Images" );
		
		stockphoto.NavCnv.NavCnv.LN1_STR3      =" ";
		stockphoto.NavCnv.NavCnv.TYPE2         =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b2_ln1_str1=Previous Searches");
		stockphoto.NavCnv.NavCnv.TYPE3         =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b3_ln1_str1=Downloaded Comps");
		stockphoto.NavCnv.NavCnv.TYPE4         =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b4_ln1_str1=Purchased Images");
		stockphoto.NavCnv.NavCnv.BTN1          =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b1_But1_label1=Get Price"); // Changed from Get Price & Keywords
		stockphoto.NavCnv.NavCnv.BTN2          =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b1_but2_label=Download Comp");
		stockphoto.NavCnv.NavCnv.BTN3          =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b1_but4_label=Add to Cart");
		stockphoto.NavCnv.NavCnv.BTN4          =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b4_but4_label=Open Download Status");
		
		stockphoto.NavCnv.NavCnv.BTN01         =stockphoto.NavBar.zc.get(stockphoto.NavBar.zstr_FindSimilarBtn);

        // Advanced Search
        stockphoto.NavCnv.NavCnv.ADV_ORIENT    =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation=Orientation" );
        stockphoto.NavCnv.NavCnv.ADV_PORTRAIT  =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation_portrait=Portrait" );
        stockphoto.NavCnv.NavCnv.ADV_SQUARE    =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation_square=Square" );
        stockphoto.NavCnv.NavCnv.ADV_LANDSCAPE =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation_landscape=Landscape" );
        stockphoto.NavCnv.NavCnv.ADV_PANORAMIC =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation_panoramic=Panoramic" );

        stockphoto.NavCnv.NavCnv.ADV_TINT      =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/tint=Tint" );
        stockphoto.NavCnv.NavCnv.ADV_COLOR     =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/tint_color=Color" );
        stockphoto.NavCnv.NavCnv.ADV_BLACKWHITE=stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/tint_blackwhite=B&W" );

		stockphoto.NavCnv.NavCnv.ADV_CONTENT      =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/content=Content" );
        stockphoto.NavCnv.NavCnv.ADV_PHOTOILLUS=stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/photo_illus=Photos & Illustrations" );
        stockphoto.NavCnv.NavCnv.ADV_PHOTO     =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/photo_illus_photo=Photos" );
        stockphoto.NavCnv.NavCnv.ADV_ILLUS     =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/photo_illus_illus=Illustrations" );

        stockphoto.NavCnv.NavCnv.ADV_COLLECT   =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/collections=Collections" );
        stockphoto.NavCnv.NavCnv.ADV_COLLECTALL=stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/collections_all=Search All Collections" );
    
        stockphoto.NavCnv.NavCnv.ADV_OPEN_AUTO =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/open_auto=Open Advanced Search automatically" );
    
        stockphoto.NavCnv.NavCnv.SEARCH         =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/Search=Search" );
        stockphoto.NavCnv.NavCnv.SEARCH_WITHIN  =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/Search_Within=Search Within" );
        stockphoto.NavCnv.NavCnv.ADV_SEARCH     =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/Advanced_Search=Advanced Search" );
    	stockphoto.NavCnv.NavCnv.MORE_INFO      =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/more_info=More Info" );
    	stockphoto.NavCnv.NavCnv.MORE_INFO_TIP  =stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/more_info_tip=Search Images Less Than " )+stockphoto.core.displayCurrency;
    	
		stockphoto.NavCnv.NavCnv.RESULT4BEG    =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/result_begin=Results for ^Q");
		stockphoto.NavCnv.NavCnv.RESULT4END    =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/result_end=^Q");
		
		// Operators
		// Load them as per ASP's Search Language Locale (zcSearch)
        stockphoto.NavCnv.NavCnv.OP_AND 	=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_AND=AND");
		stockphoto.NavCnv.NavCnv.OP_OR 		=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_OR=OR");
		stockphoto.NavCnv.NavCnv.OP_NOT		=stockphoto.NavBar.zcSearch.get("$$$/NavBar/Operations/OP_NOT=NOT");
		
		// Misc (from Core)
		stockphoto.NavCnv.NavCnv.MISC_LPAREN  =stockphoto.zc.get("$$$/StockPhoto/Misc/LPAREN=(");
		stockphoto.NavCnv.NavCnv.MISC_RPAREN  =stockphoto.zc.get("$$$/StockPhoto/Misc/RPAREN=)");
		stockphoto.NavCnv.NavCnv.MISC_COMMA   =stockphoto.zc.get("$$$/StockPhoto/Misc/COMMA=,");
		stockphoto.NavCnv.NavCnv.MISC_COLON   =stockphoto.zc.get("$$$/StockPhoto/Misc/COLON=:");
		stockphoto.NavCnv.NavCnv.MISC_ELLIPSES=stockphoto.zc.get("$$$/StockPhoto/Misc/ELLIPSES=...");
		
		// Tool tips
		if ( stockphoto.isWin )
			stockphoto.NavCnv.NavCnv.CHANGE_SEARCH_LANG_TIP =stockphoto.NavBar.zc.get("$$$/NavBar/Chip/CHANGE_Lang_Tooltip_PC=Go to Edit->Preferences->Adobe Stock Photos to change the search language");
		else
			stockphoto.NavCnv.NavCnv.CHANGE_SEARCH_LANG_TIP =stockphoto.NavBar.zc.get("$$$/NavBar/Chip/CHANGE_Lang_Tooltip_MAC=Go to Bridge->Preferences->Adobe Stock Photos to change the search language");
			
        stockphoto.NavCnv.NavCnv.PHOTOS_AND_ILLUS       =stockphoto.NavBar.zc.get("$$$/NavBar/Chip/PHOTOS_And_Illus=Search for Photos & Illustrations Options");
		
		stockphoto.NavCnv.NavCnv._xOFy_        =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/_of_= of ");
		stockphoto.NavCnv.NavCnv.LN1_STR2_IDET =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b1_ln1_str2D=Getting Image Price & Keywords...");
		stockphoto.NavCnv.NavCnv.LN1_STR2      =stockphoto.NavBar.zc.get("$$$/NavBar/BtmNavBar/b1_ln1_str2G=Getting Images...");
		stockphoto.NavCnv.NavCnv.MORERES2      =stockphoto.NavBar.zc.get("$$$/NavBar/NavBar/MoreRes2=More ");
		stockphoto.NavCnv.NavCnv.PREVSMSG      =stockphoto.NavBar.zc.get("$$$/NavBar/NavBar/PrevSMsg=Adobe Stock Photos retains all your previous search results until you delete the folders manually.");
		
        var iDocID   = doc_id + 30000;
		var strDocID = "5"+iDocID; // i.e. it is "53xxxx"
		stockphoto.NavCnv.NavCnv.DOCUMENTID = strDocID.substr( 2,4 ); // DocumentID must be 4 characters long
		if( stockphoto.PTSGLilo_Prototype != undefined )
		{
			stockphoto.NavCnv.NavCnv.PTSGLILO_PROTOTYPE = "yes";
		}
		if( stockphoto.DL.HTMLUtil.SubLocalHTMLbyDocID( stockphoto.core.folder.getTemplateFolder()+"/"+Name, stockphoto.NavCnv.NavCnv, NewName, doc_id, true ) )
		{
			bRet.bGood = true;
		}
	} // ( ( Outfs != undefined )&&( Outfs.exists ) )
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "...... PasteBMNavBar() --> bGood="+bRet.bGood+" f="+unescape( Outfs.fsName ) );

	if( bAccessDoc )
	{
		if( bRet.bGood )
		{
			doc.topNavbar.type    = "html";
			doc.topNavbar.jsFuncs = stockphoto.NavIntFnc.jsCallBacks;
			if( doc.topNavbar.file != unescape( Outfs.fsName ) )
			{
				stockphoto.NavIntDt_t[ doc_id ].Ext.HtmLDStatus[ webORfile ] = stockphoto.NavBar.cnst_HtmLDStatus_NavBarRequested;
				//doc.topNavbar.file = unescape( Outfs.fsName );
				stockphoto.NavIntFnc.setTopNavbarFile( doc, doc_id, "1", unescape( Outfs.fsName ) );  			
				if( navType == stockphoto.NavIntDt._kNavType_eCom )
				{
					doc.topNavbar.height = h;
				}
				else
				{
					doc.topNavbar.height = 1;
				}
			}
			stockphoto.eventHandler.pathAnalyzer.ChangeNavVisiblity( doc, true, "PasteBMNavBar-T" );
		}
		else
		{
			stockphoto.eventHandler.pathAnalyzer.ChangeNavVisiblity( doc, false, "PasteBMNavBar-F" );
		}
	} else {
		bRet.file   = unescape( Outfs.fsName );
		bRet.height = 1;
	}
	return( bRet );
}

stockphoto.NavIntFnc.GetTopNavBarFile=function( webORfile, kindOfNav, kindOfGif, navHeight, doc_id )
{ // webORfile:0=web/1file navHeight:0=short/1=high
	var Nm;
	Nm = "wf"+webORfile.toString()+"t"+navHeight.toString()+"d"+(doc_id)+stockphoto.NavIntDt.CurrLangCont+".htm";
	if( stockphoto.PTSGLilo_Prototype != undefined )
	{
		Nm = "LILO_wf"+webORfile.toString()+"t"+navHeight.toString()+"d"+(doc_id)+stockphoto.NavIntDt.CurrLangCont+".htm";
	} // if( stockphoto.PTSGLilo_Prototype != undefined )
	return( Nm );
}

stockphoto.NavIntFnc.GetNavMode=function( webORfile )
{
	return( stockphoto.NavIntDt.PaneIDnew[ webORfile ] );
}

stockphoto.NavExtFnc.PlaceBMNavBarScheduled=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	var doc = stockphoto.documents[ doc_id ].document, searchLang, script;
	if( ( stockphoto.NavIntDt_t[doc_id].NavParm.NavMode == undefined )||
	    ( stockphoto.NavIntDt_t[doc_id].NavParm.NavMode == "" )||
		( doc == undefined )||
	    ( app.preferences == undefined )||
		( app.preferences.bm_search_language == undefined )||
		( app.preferences.bm_search_language == "" )||
		( ! stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_Preference ) ) )
	{
		return;
	}
	searchLang = app.preferences.bm_search_language;
	script     = "stockphoto.NavIntFnc.PlaceBMNavBarEscaped(" 
					+stockphoto.NavIntDt_t[doc_id].NavParm.webORfile+","
					+stockphoto.NavIntDt_t[doc_id].NavParm.navHeight+","
					+stockphoto.NavIntDt_t[doc_id].NavParm.kindOfNav+","
					+stockphoto.NavIntDt_t[doc_id].NavParm.kindOfGif+",'"
					+escape(stockphoto.NavIntDt_t[doc_id].NavParm.uKeyWord)+"','"
					+stockphoto.NavIntDt_t[doc_id].NavParm.NavMode+"',"
					+stockphoto.NavIntDt_t[doc_id].NavParm.navType+","
					+stockphoto.NavIntDt_t[doc_id].NavParm.bClearOK+","
					+'"'+escape(searchLang)+'",'+doc_id+");";
	app.scheduleTask( script, 0, false );
}

stockphoto.NavIntFnc.PlaceBMNavBarEscaped=function( webORfile, navHeight, kindOfNav, kindOfGif, eKeyWord, NavMode, navType, bClearOK, eSearchLang, doc_id )
{
	var doc = stockphoto.documents[ doc_id ].document, bRet={};
	// return=1 (html is created ) =2 (use existing html)
	
    /********* Changes Begin ****** Watson: 0945179*********/
	var args = stockphoto.eventHandler.pathAnalyzer.AnalyzingPath( stockphoto.core.util.getDisplayPath(doc.thumbnail,""), false, false, doc );
	var showNavBar = false;
	
	// Check if BM page/folder
	if ( ("undefined" != typeof args) && ("undefined" != typeof args.k) && ( 15 > args.k ))
	{
		showNavBar = true;
	}
    
    // if showNavBar is "true" then navbar will be displayed.
	bRet = stockphoto.NavIntFnc.PlaceBMNavBar( webORfile, navHeight, kindOfNav, kindOfGif, unescape(eKeyWord), 
													NavMode, navType, bClearOK, unescape(eSearchLang), doc, doc_id, showNavBar );
	/********* Changes End ****** Watson: 0945179*********/		
												
	return( bRet.bOk );
}
		
stockphoto.NavIntFnc.PlaceBMNavBar=function( webORfile, navHeight, kindOfNav, kindOfGif, uKeyWord, NavMode, navType, 
												bClearOK, searchLang, doc, doc_id, bAccessDoc )
{
	//
	var TFl, BFl, szWorF, bRetPaste={}, bRet={bOk:0,file:"",height:0};
	var idx = stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "\n\n.... PlaceBMNavBar( webORfile="+webORfile+" t="+navHeight+" kindOfNav="+kindOfNav+" kindOfGif="
			                              +kindOfGif+" uKeyWord="+uKeyWord+" NavMode="+NavMode+" navType="+navType
			                              +" bClearOK="+bClearOK+" doc_id="+doc_id
			                              +") x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x+" y="
			                              +stockphoto.NavIntDt.FldAndNumTab[ idx ].y+"\n\n" );
	stockphoto.NavIntDt_t[doc_id].NavParm.webORfile = webORfile;
	stockphoto.NavIntDt_t[doc_id].NavParm.navHeight = navHeight;
	stockphoto.NavIntDt_t[doc_id].NavParm.kindOfNav = kindOfNav;
	stockphoto.NavIntDt_t[doc_id].NavParm.kindOfGif = kindOfGif;
	stockphoto.NavIntDt_t[doc_id].NavParm.uKeyWord  = uKeyWord;
	stockphoto.NavIntDt_t[doc_id].NavParm.NavMode   = NavMode;
	stockphoto.NavIntDt_t[doc_id].NavParm.navType   = navType;
	stockphoto.NavIntDt_t[doc_id].NavParm.bClearOK  = bClearOK;

	if( doc.topNavbar != undefined )
	{
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, ".... PlaceBMNavBar -2 doc_id="+doc.id );
		szWorF = stockphoto.NavIntDt.PaneIDnew[ webORfile ];
		stockphoto.NavIntDt_t[doc_id].WorF = szWorF.charAt(0);
		stockphoto.NavIntFnc.SetfORwFlag( szWorF, doc_id );
		stockphoto.NavIntFnc.SetReqUniqID( doc_id );
		// Nav bar
		TFl = stockphoto.NavIntFnc.GetTopNavBarFile( webORfile, kindOfNav, kindOfGif, navHeight, doc_id );
		if( TFl == stockphoto.NavIntDt_t[doc_id].CurrTopBar && doc.topNavbar.type == "html")
		{
			bRet.bOk = 2;
		}
		else
		{
			// Check if we already have a Navbar htm file. 
			var presetOne = stockphoto.core.folder.getSaveNavbarFolder()+"/"+TFl;
			var presetFs  = File( presetOne );
			
			if( presetFs.exists )
			{
				// "bAccessDoc" is passed from caller as true:display this htm file, false:do not show
				if( bAccessDoc )
				{
				    var flag = false;
				    if (doc.topNavbar.type != "html")
				    {
						doc.topNavbar.type    = "html";
						flag = true;
					}
					doc.topNavbar.jsFuncs = stockphoto.NavIntFnc.jsCallBacks;
					if( doc.topNavbar.file != unescape( presetFs.fsName ) || flag == true)
					{
						stockphoto.NavIntDt_t[ doc_id ].Ext.HtmLDStatus[ webORfile ] = stockphoto.NavBar.cnst_HtmLDStatus_NavBarRequested;
						//doc.topNavbar.file = unescape( presetFs.fsName );
						stockphoto.NavIntFnc.setTopNavbarFile( doc, doc_id, "2", unescape( presetFs.fsName ) );  			
						if( navType == stockphoto.NavIntDt._kNavType_eCom )
						{
							doc.topNavbar.height = stockphoto.NavCnv.NavCnv.HEIGHTS;
						}
						else
						{
							doc.topNavbar.height = 1;
						}
					}
					stockphoto.eventHandler.pathAnalyzer.ChangeNavVisiblity( doc, true, "PasteBMNavBar-T" );
				} else {
					bRet.file   = unescape( presetFs.fsName );
					bRet.height = 1;
				}
				stockphoto.NavIntDt_t[doc_id].uKeyWord   = uKeyWord;
				stockphoto.NavIntDt_t[doc_id].CurrTopBar = TFl;
				bRet.bOk    = 1;
				bRet.file   = unescape( presetFs.fsName );
				bRet.height = 1;
			}
			else
			{
				bRetPaste = stockphoto.NavIntFnc.PasteBMNavBar( webORfile, TFl, navHeight, kindOfNav, kindOfGif, NavMode, uKeyWord, 
																navType, doc, doc_id, bAccessDoc, idx );
				if( bRetPaste.bGood )
				{
					stockphoto.NavIntDt_t[doc_id].uKeyWord   = uKeyWord;
					stockphoto.NavIntDt_t[doc_id].CurrTopBar = TFl;
					bRet.bOk    = 1;
					bRet.file   = bRetPaste.file;
					bRet.height = bRetPaste.height;
				}
			}
		}
		if( searchLang == "" )
		{
			searchLang = stockphoto.DL.GetLanguage();
		}
		if( stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_LangCountry ) )
		{
			localizedNameOfLang = stockphoto.LangCountry.GetNameFromSearchLanguageCode( searchLang ); // localized
		}
		else
		{
			localizedNameOfLang = "";
		}
		//suudhan modified
		if( localizedNameOfLang != "" && stockphoto.NavExtFnc.searchLangDisplay())
		{
			localizedNameOfLang =
				stockphoto.NavBar.zc.get("$$$/NavBar/NavBar/search_language=Search Language") + ": " + localizedNameOfLang;
			stockphoto.NavIntFnc.SetDispLang( localizedNameOfLang, doc_id );
		}
		else
		{
			stockphoto.NavIntFnc.SetDispLang("", doc_id ); 
		}
		// stockphoto.NavIntFnc.SetDispLang( localizedNameOfLang, doc_id );

		// AK:added by aman
	
		stockphoto.core.setValueAmt();
		stockphoto.NavIntFnc.SetValueAmt( stockphoto.core.displayCurrency, doc_id );
		
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, ".... PlaceBMNavBar -3" );
		stockphoto.NavExtFnc.SendRequestToHTM( doc_id, true ); // default uses scheduletask
	} /* ( ( doc != undefined )&&( doc.topNavbar != undefined ) ) */
	
	return( bRet );
} // bRet.bOk=1 (html is created ) =2 (use existing html)

stockphoto.NavIntFnc.InvalidateCachedBMNavBar=function( webORfile, kindOfNav, kindOfGif, navHeight, doc_id )
{
	var j, fls, Fldr = new Folder( stockphoto.core.folder.getSaveNavbarFolder() );
	if( Fldr != undefined )
	{
		if( Fldr.exists )
		{
			// the folowing getFiles() for removing *.htm in NavIntFnc.InvalidateCachedBMNavBar()
			fls = Fldr.getFiles( "nav"+webORfile.toString()+kindOfNav.toString()+kindOfGif.toString()+navHeight.toString()+"*.htm" );
			if( fls != null )
			{
				for( j=0; j<fls.length; j++ )
				{
					if( fls[j] instanceof File )
					{
						( fls[j] ).remove();
					}
				}
			}
		}
		delete Fldr;
	}
	stockphoto.NavIntDt_t[doc_id].CurrTopBar = "";
}

stockphoto.NavExtFnc.RefreshBMNavBar=function( languageIn, doc /* ok */ )
{
	var hInd, navType, webORfile, kindOfNav, kindOfGif, navHeight, Name, language;
	var doc_id = stockphoto.NavIntFnc.GetDocumentId( doc );
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( ( languageIn == undefined )||( languageIn == "" ) )
	{
		language = ((stockphoto.DL.getLanguageCode()).toLowerCase())+"_"+((stockphoto.DL.getCountryCodeFromLanguageCode()).toUpperCase());
	}
	else
	{
		language = ((languageIn.substr(0,2)).toLowerCase())+"_"+((languageIn.substr(3,2)).toUpperCase());
	}
	if( language == stockphoto.NavIntDt_t[doc_id].UsedLangId )
	{
		return;
	}
	stockphoto.NavIntDt_t[doc_id].UsedLangId = language;
	if( ( doc != undefined )&&
	    ( doc.topNavbar != undefined )&&
	    ( doc.topNavbar.file != undefined )&&
	    ( doc.topNavbar.file != "" ) )
	{
		hInd = stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex;
		if( ! stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].i )
		{
			navType = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navType;
			if( ( navType >= 0 )&&( navType < stockphoto.NavIntDt.processTable.length ) )
			{
				webORfile = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].webORfile;
				kindOfNav = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfNav;
				kindOfGif = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfGif;
				navHeight = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navHeight;
				Name      = stockphoto.NavIntDt.processTable[ navType ].n;
				stockphoto.NavIntFnc.InvalidateCachedBMNavBar( webORfile, kindOfNav, kindOfGif, navHeight, doc_id );
			}
		}
	}
}

stockphoto.NavExtFnc.addBMNavBar=function( args, type /* unused  */, docIn /*Ok*/ )
{
	// [x]addBMNavBar->[i]doAddBMNavBar-+->[i]PlaceBMNavBar->[i]PasteBMNavBar
	// [x]ResetPreviousBMNavBar -------/
	var doc, doc_id;
	if( docIn == undefined )
	{
		doc = app.document;
	}
	else
	{
		doc = docIn;
	}
	doc_id  = doc.id;
	var idx = stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "addBMNavBar start"	
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y
		                                 +" Change["+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0]
		                                 +","+stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1]+"]" );

	if( ( doc.topNavbar != undefined )&&( doc.topNavbar != null ) ) 
	{
		return( stockphoto.NavIntFnc.doAddBMNavBar( args, type, doc_id ) );
	}

	var arg_k, arg_kKeyWd, arg_specifier, arg_name, arg_DOSfldr, doc_id;
	if( args.k == undefined )
	{
		arg_k = 15;
	}
	else
	{
		arg_k = args.k;
	}
	if( args.kKeyWd == undefined )
	{
		arg_kKeyWd = "";
	}
	else
	{
		arg_kKeyWd = args.kKeyWd;
	}
	if( args.specifier == undefined )
	{
		arg_specifier = "";
	}
	else
	{
		arg_specifier = args.specifier;
	}
	if( args.name == undefined )
	{
		arg_name = arg_specifier+arg_specifier;
	}
	else
	{
		arg_name = args.name;
	}
	if( args.DOSfldr == undefined )
	{
		arg_DOSfldr = "";
	}
	else
	{
		arg_DOSfldr = args.DOSfldr;
	}
	app.scheduleTask( "stockphoto.NavIntFnc.ScheduledAddBMNavBar("+arg_k+", '"+(escape(arg_kKeyWd))+"', '"+(escape(arg_specifier))+"', '"+(escape(arg_name))+"', '"+(escape(arg_DOSfldr))+"', "+type+", "+doc_id+",  0 )", 500, false );
}

stockphoto.NavIntFnc.ScheduledAddBMNavBar=function( k, escaped_kKeyWd, escaped_specifier, escaped_name, escaped_DOSfldr, type, doc_id, t )
{
	var script, args={}, doc=stockphoto.documents[ doc_id ].document;
	if( ( t >= 0 )&&( doc.topNavbar != undefined )&&( doc.topNavbar != null ) )
	{
		args = stockphoto.eventHandler.pathAnalyzer.CombineKeysToArgsObj( k, unescape(escaped_kKeyWd), unescape(escaped_specifier), unescape(escaped_name), unescape(escaped_DOSfldr) );
		stockphoto.NavIntFnc.doAddBMNavBar( args, type, doc_id );
	}
	else
	{
		if( t < 60 )
		{ // retry for 30 seconds
			script = "stockphoto.NavIntFnc.ScheduledAddBMNavBar("+k+", '"+escaped_kKeyWd+"', '"+escaped_specifier+"', '"+escaped_name+"', '"+escaped_DOSfldr+"', "+type+", "+doc_id+", "+(t+1)+" )";
			app.scheduleTask( script, 500, false );
		}
	}
}

stockphoto.NavIntFnc.doAddBMNavBar=function( args, type /* unused  */, doc_id )
{
	var doc, navType=stockphoto.NavIntDt._kNavType_undefined, i, hInd, hPrevInd, Key, bChanged, saveMode, NavMode, uKeyWord,
	    argName, FolderObj, xx, yy, ySav, str2, webORfile, navHeight, kindOfNav, kindOfGif,
		// 1152993 a variable is defined in two ways: "searchLang" and "SearchLeng"
		// which should be the same. 
	    currkey, wOSFldr, wwNm, searchLang, tmpStr, bRet, localeFolder;
	var idx = stockphoto.NavIntDt_t[ doc_id ].FaN.Last_i;

	doc = stockphoto.NavExtFnc.FromDocIdToDoc( doc_id );
	if( ( ! stockphoto.core.init.isScriptLoaded )||
	    ( doc == undefined ) )
	{
		return( false );
	}
	if( doc.browserMode == "compact" )
	{
		stockphoto.core.BoxCar.NavBar.SetIsCompactFlag( 2, doc_id, 0 );
		if( ( doc.topNavbar != undefined )&&( doc.topNavbar.visible == true ) )
		{
			stockphoto.eventHandler.pathAnalyzer.ChangeNavVisiblity( doc, false, "NavIntFnc.doPutBMNavBar #1" );
		}
		stockphoto.NavIntDt_t[doc_id].core.prevkey = "abc";
		return( false );
	}
	stockphoto.core.BoxCar.NavBar.SetIsCompactFlag( 1, doc_id, 0 );

	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "doAddBMNavBar / name="
		                                 +args.name+" \n                specifier="+args.specifier
		                                 +"\n                DOSfldr="+args.DOSfldr
		                                 +" [doc_id="+doc.id+"]"
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y );

	stockphoto.NavIntDt.TheEnter2 = stockphoto.NavBar.zc.get( stockphoto.NavIntDt.TheORGEnter );
	stockphoto.NavIntDt.TheEnter1 = eval( '"'+(stockphoto.NavIntDt.TheEnter2)+'"' );
	stockphoto.NavIntDt.TheEnter  = eval( '"'+(stockphoto.NavIntDt.TheEnter1)+'"' );

	if( ( args.name != undefined )&&( args.name != "" ) )
	{
		argName = args.name;
	}
	else
	{
		if( ( args.specifier != undefined )&&( args.specifier != "" ) )
		{
			argName = args.specifier;
		}
		else
		{
			argName = "";			
		}
	}
	if( argName.length < 7 )
	{
		return( false );
	}
	Key = ( ( argName ).substr( 0, 7 ) ).toUpperCase();
	for( i=0; i<stockphoto.NavIntDt.processTable.length; i++ )
	{
		if( Key == stockphoto.NavIntDt.processTable[i].n )
		{
			navType = i; break;
		}
	}
	if( navType < 0 )
	{
		return( false );
	}

	webORfile = stockphoto.NavIntDt.processTable[ navType ].webORfile;
	navHeight = stockphoto.NavIntDt.processTable[ navType ].navHeight;
	kindOfNav = stockphoto.NavIntDt.processTable[ navType ].kindOfNav;
	kindOfGif = stockphoto.NavIntDt.processTable[ navType ].kindOfGif;
	NavMode   = stockphoto.NavIntFnc.GetNavMode( webORfile );

	stockphoto.NavIntDt_t[doc_id].navType   = navType;
	if( stockphoto.NavIntDt_t[doc_id].webORfile != webORfile )
    {
        stockphoto.NavIntDt_t[doc_id].Cache[ webORfile ].Transmitting = false;
	    stockphoto.NavIntDt_t[doc_id].webORfile = webORfile;
    }

	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, ".. argName="+argName+" navType="+navType+" webORfile="+webORfile+" kindOfNav="+kindOfNav
						                 +" kindOfGif="+kindOfGif+" NavMode="+NavMode
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y );

	if( kindOfNav == stockphoto.NavIntDt._kKindOfNav_imageDetail )
	{
		stockphoto.NavIntDt_t[doc_id].core.prevkey = "135";
	}

	if( navType == stockphoto.NavIntDt._kNavType_searchFolder )
	{
	     stockphoto.NavIntFnc.SetKeyWord( args.kKeyWd, false /*=unescaped*/, doc_id, true );
	}
	else if( ( doc.contentPaneMode == "web" )||
	         ( ( navType != stockphoto.NavIntDt._kNavType_search )&&
			   // #1186121
	           ( navType != stockphoto.NavIntDt._kNavType_addtocart )&&
	           ( navType != stockphoto.NavIntDt._kNavType_downloadcomp )&&
	           // #1142613
	           ( navType != stockphoto.NavIntDt._kNavType_moreSearch ) ) )
	{ // DL.search.basicSearch
	     stockphoto.NavIntFnc.SetKeyWord( stockphoto.NavIntDt.TheEnter, false /*=unescaped*/, doc_id, true );
	}

	if( stockphoto.NavIntDt.processTable[ navType ].ky ) /* 4,5,6,24,25 */
	{
		uKeyWord = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword;
	}
	else
	{
		uKeyWord = "";
	}

	wwNm    = "#";
	wOSFldr = "#";
	if( ( args.DOSfldr != undefined )&&( args.DOSfldr != "" ) )
	{
		FolderObj = Folder( args.DOSfldr );
		if( FolderObj.exists )
		{
			wwNm    = ( FolderObj.name ).toUpperCase();
			wOSFldr = ( FolderObj.path ).toUpperCase()+"/"+wwNm;
		}
	}
	if( wOSFldr == "#" )
	{
		i = stockphoto.NavIntFnc.SearchFolderAndKey( doc_id );
		if( i >= 0 )
		{
			wwNm = ( stockphoto.NavIntDt_t[doc_id].Ext.fk[i].n ).toUpperCase();
		}
	}
	// record search folder name for this doc_id
	stockphoto.NavIntDt_t[doc_id].core.FolderNm = wwNm;

	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "doAddBMNavBar-1.... wOSFldr="+wOSFldr
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y );
	currkey = doc_id+"-"+( navType )+"/"+wwNm+"-"+stockphoto.NavIntDt_t[doc_id].UsedLangId;
	if( currkey == stockphoto.NavIntDt_t[doc_id].core.prevkey && doc.topNavbar.type == "html")
	{
		if( stockphoto.core.log.DebugINIData.log != undefined ) 
			stockphoto.core.log.logString( 0, ".... ---------- Same Param: "+currkey+" ----------" );
		return( false );
	}
	stockphoto.NavIntDt_t[doc_id].core.prevkey = currkey

	stockphoto.eventHandler.StartUpFolder.SetStartUpFolderIsw = false;

	// Language check
	stockphoto.DL.GetLanguage(); // set default search language if it does not exist
	stockphoto.NavIntDt.CurrLangCont = stockphoto.core.getValidLocale();
	if( stockphoto.NavIntDt.PrevLangCont != stockphoto.NavIntDt.CurrLangCont )
	{
		stockphoto.NavExtFnc.SetStandardCnvTable( doc_id );
		if( stockphoto.NavExtFnc.CreateStyleSheet( doc_id ) )
		{
			stockphoto.NavIntDt.PrevLangCont = stockphoto.NavIntDt.CurrLangCont;
		}
	}

	if( stockphoto.NavIntDt.PrevLangCont != stockphoto.NavIntDt.CurrLangCont )
	{
		return( false );
	}

//	In stead, obtain search language from preference panel
	searchLang = stockphoto.NavIntDt.CurrLangCont; // default
	if( ( app.preferences != undefined )&&
		( app.preferences.bm_search_language != undefined )&&
		( app.preferences.bm_search_language != "" )&&
		( stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_Preference ) ) )
	{
		searchLang = app.preferences.bm_search_language;
	}

	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "doAddBMNavBar-2.... wOSFldr="+wOSFldr
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y );

	// DOSfldr exists when
	//    a) "SEARCHE" One of recentSearch sub folders is selected
	//    b) "ST03_BB" move to One of recentSearch sub folders
	if( wOSFldr != "#" ) // then FolderObj did exist
	{
		stockphoto.NavExtFnc.GetFolderAndNumbers_NEW( FolderObj, doc_id, false, "doAddBMNavBar" );
		stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = false;
		stockphoto.NavIntFnc.SetReqUniqID( doc_id ); 
		xx = stockphoto.NavExtFnc.CountNoOfFiles( FolderObj.fsName, "*.jpg" );
		yy = stockphoto.NavExtFnc.getTotalImageCount( FolderObj.fsName );
		// updateXofY() call refresh "MoreResult" button
		if( yy > 0 )
		{
			stockphoto.NavIntFnc.updateXofY( "show", ""+xx, ""+yy, "dir-known", doc_id, "doAddBMNavBar yy>0" ); // at MoreThumb()
			stockphoto.NavExtFnc.FlagNextRequest(doc_id, 'xoy', '');
		}
		else
		{
			ySav = stockphoto.NavExtFnc.GetFolderAndNumbers_NEW( FolderObj, doc_id, false, "By_wOSFldr" );
			if( ySav > 0 )
			{
				stockphoto.NavIntFnc.updateXofY( "show", ""+xx, ""+ySav, "dir-known", doc_id, "doAddBMNavBar ySav>0" ); // at MoreThumb()
			}
			else
			{
                // Instead of sending y = 0 to updateXofY in an improbable situation,
                // count the number of files in folder.
                stockphoto.NavIntFnc.ForceChekingXandY(doc_id);
				stockphoto.NavIntFnc.updateXofY( "show", ""+stockphoto.NavIntDt.FldAndNumTab[ idx ].x,
                        stockphoto.NavIntDt.FldAndNumTab[ idx ].y, "dir-known", doc_id, "doAddBMNavBar ForceChekingXandY (y was 0)" ); // at MoreThumb()
			}
			stockphoto.NavExtFnc.FlagNextRequest(doc_id, 'xoy', '');
		}
		if( stockphoto.Burp.doIt ) // to get searchID when "SEARCHE" or "ST03_BB" (change folder)
		{
/*B*/				try
/*B*/				{
/*B*/					// The folloing also sets stockphoto.Burp.searchPageNo[  doc_id ] (=1,2,3,..)
/*B*/					var sId = stockphoto.Burp.readSearchID( doc_id, wOSFldr );
/*B*/					if( sId != "" )
/*B*/					{
/*B*/						stockphoto.Burp.searchId[ doc_id ] = sId;
/*B*/						if( ( stockphoto.Burp.searchLang[ doc_id ] == undefined )||
/*B*/						    ( stockphoto.Burp.searchLang[ doc_id ] == "" ) )
/*B*/							stockphoto.Burp.searchLang[    doc_id ] = app.preferences.bm_search_language;
/*B*/						stockphoto.Burp.searchFolder[  doc_id ] = wOSFldr;
/*B*/						stockphoto.Burp.searchWritten[ doc_id ] = true;
/*B*/					}
/*B*/	  				else
/*B*/	  				{
/*B*/	  					stockphoto.Burp.searchId[ doc_id ] = "InvalidID_" + File.encode( uKeyWord );
/*B*/	  				}
/*B*/					stockphoto.Burp.callSPSUI( doc_id, stockphoto.Burp.code_changeView, "searchFolder", uKeyWord, sId, File( wOSFldr ).fsName );
/*B*/				} catch(e) { ; }
		}
	}
	else
	{
        stockphoto.NavIntDt.FldAndNumTab[ idx ].pageFull = false;
    }
	
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, ".... wOSFldr="+wOSFldr
		                                 +" x="+stockphoto.NavIntDt.FldAndNumTab[ idx ].x
		                                 +" y="+stockphoto.NavIntDt.FldAndNumTab[ idx ].y );

	// Update Bar History
	hPrevInd = stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex;
	hInd     = hPrevInd + 1;
	if( hInd >= 4 )
	{
		hInd = 0;
	}
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].fw       = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].Sel      = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].hx       = stockphoto.NavIntDt.FldAndNumTab[ idx ].x;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].hy       = stockphoto.NavIntDt.FldAndNumTab[ idx ].y;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].whl      = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].uKeyword = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].a0       = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].a1       = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[1];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].a2       = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[2];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].chg[0]   = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].chg[1]   = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].js[0]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[0];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].js[1]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[1];
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].sl       = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.selNo;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].nmr      = stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg;
    stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].pageFull = stockphoto.NavIntDt.FldAndNumTab[ idx ].pageFull;

	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfNav    = kindOfNav;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfGif    = kindOfGif;
	stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].sLng         = searchLang;

	stockphoto.eventHandler.pathAnalyzer.ChangeContentPaneMode( doc, doc.contentPaneMode ); 

	if( stockphoto.NavIntDt.processTable[ navType ].s > 0 )
	{
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].i         =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].i;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].webORfile = ( webORfile = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].webORfile );
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Tv        =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].Tv;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navType   =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].navType;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navHeight = ( navHeight = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].navHeight );
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].ukw       =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].ukw;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Nm        =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].Nm;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].cState    =               stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].cState;
		if( stockphoto.NavIntDt.processTable[ navType ].s == 2 )
		{
			stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfNav = ( kindOfNav = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].kindOfNav );
			stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfGif = ( kindOfGif = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hPrevInd].kindOfGif );
		}
	}
	else
	{
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].i         = false;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Tv        = false;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].webORfile = webORfile;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navType   = navType;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navHeight = navHeight;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].ukw       = uKeyWord;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Nm        = NavMode;
		stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].cState    = stockphoto.eventHandler.pathAnalyzer.paneCurrentState;
	}
	stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex = hInd;

	stockphoto.NavIntDt_t[doc_id].kindOfNav = kindOfNav;

	// Pane Mode
	if( ( ( stockphoto.eventHandler.pathAnalyzer.paneCurrentState & stockphoto.eventHandler.pathAnalyzer.cStateCnst_ExistBMNavBar ) == 0 )&&
	    ( kindOfNav == 5 ) ) // Fixing 1125922 - for image detail
	{
		return( true );
	}
	else
	{
		bChanged = false;
		if( doc != undefined )
		{
			saveMode = doc.contentPaneMode;
			if( ( NavMode != saveMode )||( NavMode != stockphoto.NavIntDt_t[doc_id].NavMode ) )
			{
				bChanged = true;
				stockphoto.eventHandler.pathAnalyzer.ChangeContentPaneMode( doc, NavMode );
			}
			stockphoto.NavIntDt_t[doc_id].NavMode = NavMode;

			if( stockphoto.NavIntDt_t[doc_id].FirstNav )
			{
				if( webORfile == stockphoto.NavIntDt._kWebOrFile_web )
				{	// Navbar for "web"
					bRet = stockphoto.NavIntFnc.PlaceBMNavBar( 1, 1, 2, 0, "", "filesystem", 17, true, searchLang, doc, doc_id, false );
				}
				else
				{
					bRet = stockphoto.NavIntFnc.PlaceBMNavBar( 0, 1, 0, 0, "", "web",         0, true, searchLang, doc, doc_id, false );
				}
				stockphoto.NavIntDt_t[doc_id].FirstNav = false;
				// bRet.bOk=1 (html is created ) =2 (use existing html)
			}
			bRet = stockphoto.NavIntFnc.PlaceBMNavBar( webORfile, navHeight, kindOfNav, kindOfGif, uKeyWord, NavMode, 
														navType, true, searchLang, doc, doc_id, true );

			// bOk=1 (html is created ) =2 (use existing html)
			if( bRet.bOk == 1 )
			{
				stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Tv = true;
				stockphoto.eventHandler.pathAnalyzer.ChangeNavVisiblity( doc, true, "NavIntFnc.doPutBMNavBar #2" );
				stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex = hInd;
			}

			if( navType == stockphoto.NavIntDt._kNavType_imgDetailFromShoppingCart )
			{
				var tmpDispPath = stockphoto.core.util.getDisplayPath( doc.thumbnail, "doAddBMNavBar()" );
				if( ( doc.thumbnail != undefined )&&
					( doc.thumbnail.name != undefined )&&
//					( doc.thumbnail.displayPath != undefined ) )
					( ( tmpDispPath != undefined )&&( tmpDispPath != "" ) ) )
				{
					stockphoto.eventHandler.pathAnalyzer.ChangeContentPaneMode( doc, "filesystem" );
					bChanged = true;
					var Title = doc.thumbnail.name;
//					var Name  = doc.thumbnail.displayPath;
					var Name  = tmpDispPath;
					doc.refresh();
					stockphoto.core.html.doLocalHtm( Title, Name, false );
					doc.refresh();
				}
			}
			if( bChanged )
			{
				stockphoto.eventHandler.pathAnalyzer.ChangeContentPaneMode( doc, saveMode );
			}
			return( true );
		} /* ( doc ) */
	}
	return( false );
}

stockphoto.NavExtFnc.ResetPreviousBMNavBar=function( doc_idIn )
{
	var hInd, webORfile, navHeight, kindOfNav, kindOfGif, NavMode, uKeyWord, navType, doc_id, doc, SearchLang;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "ResetPreviousBMNavBar" );
	if( doc_idIn == undefined )
	{
	     doc = app.document;
	}
	else
	{
		doc = stockphoto.documents[ doc_idIn ].document;
	}
	if( doc != undefined )
	{
		doc_id  = doc.id;
		var idx = stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
		hInd = stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex - 1;
		if( hInd < 0 )
		{
			hInd = 3;
		}
		if( stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].i )
		{
			return;
		}
		webORfile  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].webORfile;
		navHeight  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navHeight;
		kindOfNav  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfNav;
		kindOfGif  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].kindOfGif;
		navType    = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].navType;
		SearchLang = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].sLng;
		uKeyWord   = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].ukw;
		NavMode    = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Nm;
		stockphoto.NavIntDt_t[doc_id].navType             = navType;
		stockphoto.NavIntDt_t[doc_id].kindOfNav           = kindOfNav;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw      = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].fw;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].Sel;
		stockphoto.NavIntDt.FldAndNumTab[ idx ].x         = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].hx;
		stockphoto.NavIntDt.FldAndNumTab[ idx ].y         = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].hy;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel     = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].whl;	
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel    = ( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel ).length;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].uKeyword;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nuKeyword = ( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword ).length;	
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nmxdispKw = stockphoto.NavCnv.NavCnv.KEYWORDLENMAX;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0]    = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].a0;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[1]    = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].a1;
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[2]    = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].a2; // not restore a3
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].chg[0];
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].chg[1];
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[0]  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].js[0];
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.JsStr[1]  = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].js[1];
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.selNo     = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].sl;
		stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = stockphoto.NavIntDt_t[doc_id].NavBarHistory[hInd].nmr;
		stockphoto.NavIntDt.FldAndNumTab[ idx ].xStr8     = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt.FldAndNumTab[ idx ].x, 8 );
		stockphoto.NavIntDt.FldAndNumTab[ idx ].yStr8     = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt.FldAndNumTab[ idx ].y, 8 );
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWhlStr4  = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel, 4 );
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nKWdStr4  = stockphoto.NavIntFnc.CnvertStringToNum( stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nuKeyword, 4 );
		stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nMxLen2   = ""+stockphoto.NavCnv.NavCnv.KEYWORDLENMAX;
		stockphoto.NavIntDt_t[doc_id].NavBarHistoryIndex  = hInd;
		// return=1 (html is created ) =2 (use existing html)
		stockphoto.NavIntFnc.PlaceBMNavBar( webORfile, navHeight, kindOfNav, kindOfGif, uKeyWord, NavMode, navType, 
												false, SearchLang, doc, doc_id, true );
	} /* ( doc != undefined ) */
}

stockphoto.NavExtFnc.CountNoOfFiles=function( fldrname, extention )
{
	var x, FolderObj, fls;
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "CountNoOfFiles( "+fldrname+", "+extention+" )" )
	FolderObj = new Folder( fldrname );
	if( FolderObj != undefined )
	{
		if( FolderObj.exists )
		{
			x = stockphoto.NavIntFnc.getCntValue_NEW( FolderObj, 1 );
			if( x <= 0 )
			{
				fls = FolderObj.getFiles( extention ); // in NavExtFnc.CountNoOfFiles()
				if( fls != null )
				{
					x = fls.length;
				}
			}
		}
		delete FolderObj;
	}
	return( x );
}

stockphoto.NavIntFnc.CountNoOfFolders=function( fldrname, extention )
{
	var x=0, ipath, fls, i;
	ipath = new Folder( fldrname);
	if( ipath.exists )
	{
		fls = ipath.getFiles( extention );
		if( fls != null )
		{
			for( i=0; i<fls.length; i++ )
			{
				if( fls[i] instanceof File )
				{
					;
				}
				else
				{
					x++;
				}
			}
		}
	}
	delete ipath;
	return( x );
}

stockphoto.NavExtFnc.PrepareForSearch=function( doc_id )
{
	var idx=stockphoto.NavExtFnc.PrepareNavBar( doc_id );  
	stockphoto.NavIntDt.FldAndNumTab[ idx ].x = 0; // at NavExtFnc.PrepareForSearch
	stockphoto.NavIntDt.FldAndNumTab[ idx ].y = 0; // at NavExtFnc.PrepareForSearch
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "Wheel ON PrepareForSearch" );
	
	stockphoto.NavExtFnc.ShowGettingImagesFromES(doc_id);
	
    stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = false;
}

stockphoto.NavExtFnc.PrepareForMoreThumb=function( fldr, Keyword, doc_id )
{
	var i, s, f, fl, x=0, y=0, bLoadOK=false;
	var idx=stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_HTMUtil ) )
	{
		bLoadOK = true;
		f       = new Folder( fldr );
		if( f != undefined )
		{
			if( f.exists )
			{
				fl= f.path+"/"+f.name;
				s = stockphoto.NavExtFnc.getTotalImageCount( fl );
				y = stockphoto.HTMLUtil.ConvertToInteger( s );
				x = stockphoto.NavIntFnc.CountNoOfFolders( fl, "*.jpg" );
			}
			delete f;
		}
	}
	stockphoto.NavIntDt.FldAndNumTab[ idx ].x = x; // NavExtFnc.PrepareForMoreThumb
	stockphoto.NavIntDt.FldAndNumTab[ idx ].y = y; // NavExtFnc.PrepareForMoreThumb
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "Wheel ON PrepareForMoreThumb #1" );
		
	stockphoto.NavExtFnc.ShowGettingImagesFromES(doc_id);
	
	stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = false;
	stockphoto.NavExtFnc.setPageFull(idx, false);
	
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[0] = 511;
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.change[1] = 511;
	var Nm = stockphoto.NavIntDt_t[ doc_id ].core.FolderNm;
	for( i=0; i<stockphoto.NavIntDt.NoOfNavIntDt_t; i++ )
	{
		if( ( i != doc_id )&&
		    ( stockphoto.NavIntDt_t[   i ]._i != undefined )&&
		    ( ! stockphoto.NavIntDt_t[ i ]._i )&&
		    ( stockphoto.NavIntDt_t[   i ].core.FolderNm == Nm )&&
		    ( stockphoto.NavIntDt_t[   i ].kindOfNav == stockphoto.NavIntDt._kKindOfNav_searchResult /* in search */ ) )
		{
			stockphoto.NavIntDt_t[i].Ext.NavDt.fORw      = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.fORw;
			stockphoto.NavIntDt_t[i].Ext.NavDt.Selection = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Selection;
			stockphoto.NavIntDt_t[i].Ext.NavDt.nWheel    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nWheel;
			stockphoto.NavIntDt_t[i].Ext.NavDt.Wheel     = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.Wheel;
			stockphoto.NavIntDt_t[i].Ext.NavDt.nmxdispKw = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nmxdispKw;
			stockphoto.NavIntDt_t[i].Ext.NavDt.nuKeyword = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.nuKeyword;
			stockphoto.NavIntDt_t[i].Ext.NavDt.uKeyword  = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.uKeyword;
			stockphoto.NavIntDt_t[i].Ext.NavDt.add[0]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[0];
			stockphoto.NavIntDt_t[i].Ext.NavDt.add[1]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[1];
			stockphoto.NavIntDt_t[i].Ext.NavDt.add[2]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[2];
			stockphoto.NavIntDt_t[i].Ext.NavDt.add[3]    = stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[3];
			stockphoto.NavIntDt_t[i].Ext.NavDt.change[0] = 511;
			stockphoto.NavIntDt_t[i].Ext.NavDt.change[1] = 511;
			if( stockphoto.core.log.DebugINIData.log != undefined ) 
				stockphoto.core.log.logString( 0, "Wheel ON PrepareForMoreThumb #2 ["+i+"]" );
			
            stockphoto.NavExtFnc.ShowGettingImagesFromES(i);
		
		}
	}
	stockphoto.NavExtFnc.SendRequestToHTM( doc_id , true); // default uses scheduleTask
}

stockphoto.NavExtFnc.PrepareNoConnectionHTM=function( doc )
{
	var fsOut, NoConnCnv={};
	var doc_id = stockphoto.NavIntFnc.GetDocumentId( doc );
	if( stockphoto.NavIntDt.PrepNoConnectionHTMPath != "" )
	{
		var fsIn = new File( stockphoto.NavIntDt.PrepNoConnectionHTMPath );
		if( ( fsIn != undefined )&&( fsIn.exists ) )
		{
			return( stockphoto.NavIntDt.PrepNoConnectionHTMPath );
		}
	}
	stockphoto.NavIntDt.PrepNoConnectionHTMPath = "";	
	NoConnCnv.TITLE       = stockphoto.NavBar.zc.get("$$$/NoConn/title=Please connect to the Internet");
	NoConnCnv.PRIMARYFONT = stockphoto.NavExtFnc.GetFontNames()+","+stockphoto.NavBar.zc.get("$$$/NoConn/primaryfont=Arial,Helvetica,Geneva,Verdana,sans-serif");
	NoConnCnv.P101        = stockphoto.NavBar.zc.get("$$$/NoConn/p101=Adobe Stock Photos");
	NoConnCnv.P102        = stockphoto.NavBar.zc.get("$$$/NoConn/p102=is an online service");
	NoConnCnv.P201        = stockphoto.NavBar.zc.get("$$$/NoConn/p201=To browse and purchase images, you need to have a working Internet connection. Please make sure your computer is connected to the Internet and try again.");
	NoConnCnv.P301        = stockphoto.NavBar.zc.get("$$$/NoConn/p301=If you don't have a working Internet connection at the moment, you can still access");
	NoConnCnv.P302        = stockphoto.NavBar.zc.get("$$$/NoConn/p302=Previous Searches");
	NoConnCnv.P303        = stockphoto.NavBar.zc.get("$$$/NoConn/p303=Downloaded Comps");
	NoConnCnv.P304        = stockphoto.NavBar.zc.get("$$$/NoConn/p304=Purchased Images");
	NoConnCnv.P305        = stockphoto.NavBar.zc.get("$$$/NoConn/p305=offline.");
	NoConnCnv.P3COMMA     = stockphoto.NavBar.zc.get("$$$/NoConn/p3comma=,");
	NoConnCnv.P3AND       = stockphoto.NavBar.zc.get("$$$/NoConn/p3and=, and");
	NoConnCnv.PRETRY      = stockphoto.NavBar.zc.get("$$$/NoConn/pretry=Retry ");
	if( stockphoto.DL.HTMLUtil.SubLocalHTMLbyDocID( stockphoto.core.folder.getTemplateFolder() + "/noConnection.html",
						NoConnCnv, "evntNoConn.htm", doc_id ) )
	{
		stockphoto.NavIntDt.PrepNoConnectionHTMPath = stockphoto.HTMLUtil.fsOut.fsName;
	}
	return( stockphoto.NavIntDt.PrepNoConnectionHTMPath );
}

stockphoto.NavExtFnc.ProgressGIFOn=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "Wheel ON PrepareNavBar" );
	stockphoto.NavExtFnc.SpiningWheelOn( "", doc_id );
}

stockphoto.NavExtFnc.ProgressGIFOff=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id ); 
	if( stockphoto.core.log.DebugINIData.log != undefined ) 
		stockphoto.core.log.logString( 0, "Wheel OFF ProgressGIFOff()" );
	stockphoto.NavExtFnc.SpiningWheelOff( doc_id );
}


stockphoto.NavExtFnc.getTotalImageCount=function( fldw ) 
{
	var FolderObj, n, s;
	FolderObj = Folder( fldw );
	n = stockphoto.NavIntFnc.getCntValue_NEW( FolderObj, 11 );
	if( n > 0 )
	{
		return( n );
	}
	s = stockphoto.HTMLUtil.GetKeyWordFromSearchXML( fldw, "TOTALHITS VALUE", 15, "/CACHE/GrinderState.xml" );
	if( s != "" )
	{
		return( stockphoto.HTMLUtil.ConvertToInteger( s ) );
	}
	return( 0 );
}

// ===
// === Termination process
// ===
stockphoto.NavExtFnc.finalCleanUpOfSubFolder=function( Lev, OsFolderPath, bDoSubFolder ) 
{
	var j, fls, fsOsFolderPath, eachFs;
	if( OsFolderPath == undefined )
		return;
	// Do folders
	if( bDoSubFolder )
	{
		fsOsFolderPath = new Folder( OsFolderPath );
		if( fsOsFolderPath != undefined )
		{
			if( fsOsFolderPath.exists ) {
				fls = fsOsFolderPath.getFiles( "*.*" );
				if( fls != null )
				{
					for( j=0; j<fls.length; j++ ) {
						if( fls[j] instanceof File ) {
							;
						} else {
							try {
								eachFs = fls[j]; // Folder structure
								if( stockphoto.core.log.DebugINIData.log != undefined ) 
									stockphoto.core.log.logString( 0, "Cleaning Folder: "+eachFs.fsName );
								stockphoto.NavExtFnc.finalCleanUpOfSubFolder( 1, eachFs.fsName, bDoSubFolder );
							} catch(e) { ; /* ignore */ }
						}
					} /* for */
				}
			}
			delete fsOsFolderPath;
		}
	}
	// Do all - folder is empty
	fsOsFolderPath = new Folder( OsFolderPath );
	if( fsOsFolderPath != undefined )
	{
		if( fsOsFolderPath.exists ) {
			fls = fsOsFolderPath.getFiles( "*.*" );
			if( fls != null )
			{
				for( j=0; j<fls.length; j++ ) {
					try {
						eachFs = fls[j];
						if( stockphoto.core.log.DebugINIData.log != undefined ) 
							stockphoto.core.log.logString( 0, "Removing File/Folder: "+eachFs.fsName );
						eachFs.remove();
					} catch(e) { ; /* ignore */ }
				}
			}
		}
		delete fsOsFolderPath;
	}
}

stockphoto.NavExtFnc.finalCleanUp=function( bIsInit ) {
	// Clean sub folder
	var noOfSec, invalidIfBeforeThisSec, doc_id, startOsFolderPath, fsOsFolderPath, 
	    fls, j, eachFs, uFsName, verStr="";
	if( stockphoto.core.init.isInitDll )
	{
		verStr = stockphoto.impl.version + "." + stockphoto.impl.build;
	}
	if( ( bIsInit == undefined )||( ! bIsInit ) )
	{
		// Close imgDetail windows
		if( stockphoto.DL.isAlreadyLoaded( stockphoto.DL.jsx_ImgDetail ) )
		{ // image detail was loaded
			for( doc_id=0; doc_id<stockphoto.NavIntDt_t.length; doc_id++ ) 
			{
				if( ! stockphoto.NavIntDt_t[doc_id]._i )
				{
					stockphoto.gpk3.getPrice3fin( doc_id );
				}
			}
		}
		// ShoppingCart image temp.
		if( ( stockphoto.addToCart != undefined )&&
			( stockphoto.addToCart.temp != undefined ) )
		{
			for( doc_id=0; doc_id<stockphoto.NavIntDt_t.length; doc_id++ ) 
			{
				if( ! stockphoto.NavIntDt_t[doc_id]._i )
				{
					stockphoto.addToCart.DoAddGroupThumbsToCartFree( doc_id );
				}
			}
		}
		fsOsFolderPath = new Folder( stockphoto.core.folder.getMyShoppingCartFolder() );
		if( fsOsFolderPath != undefined )
		{
			if( fsOsFolderPath.exists ) {
				fls = fsOsFolderPath.getFiles( "_tmpJpg_*.jpg" );
				if( fls != null )
				{
					for( j=0; j<fls.length; j++ ) {
						eachFs  = fls[j];
						if( eachFs.exists )
						    eachFs.remove();
					}
				}
				fls = [];
			}
			delete fsOsFolderPath;
		}
		// write search result to searchCnts.txt
//		stockphoto.NavExtFnc.writeFldAndNum_nnn();
		// if the lastly closed window is "web" and BM, change the startup folder
		if( stockphoto.eventHandler.pathAnalyzer.quitBMWeb )
		{
			app.preferences.target = "stockphoto://home";
		}
	}

	// start from temp folder -> scan sub folder
	invalidIfBeforeThisSec = stockphoto.core.CurrentProcessID - 86400 /* #OfSec/day = 60sec x 60min x 24 hours */;
	startOsFolderPath = stockphoto.core.folder.getTempFolder();
	fsOsFolderPath    = new Folder( startOsFolderPath );
	if( fsOsFolderPath != undefined )
	{
		if( fsOsFolderPath.exists ) {
			fls = fsOsFolderPath.getFiles( "*" );
			if( fls != null )
			{
				for( j=0; j<fls.length; j++ ) {
					eachFs  = fls[j];
					uFsName = ( eachFs.name ).toUpperCase();
					if( uFsName == "IMAGES" ) 
					{
						stockphoto.NavExtFnc.finalCleanUpOfSubFolder( 0, startOsFolderPath+"/"+eachFs.name, true );
					} else {
						noOfSec = stockphoto.core.util.convertToInteger( eachFs.name );
						if( ( noOfSec <= invalidIfBeforeThisSec )||
							( ( ! bIsInit )&&( noOfSec == stockphoto.core.CurrentProcessID ) ) )
						{	//                             /* 0123456789 */
							// if uFsName is in the form like en_US1.0.0, it is
							// Navbar save folder so should not be deleted.
							if( verStr != "" )
							{
								if( ( uFsName.length    <  8   )||
									( uFsName.charAt(2) != "_" )||
									( uFsName.substr(5) != verStr ) )
								{
									stockphoto.NavExtFnc.finalCleanUpOfSubFolder( 0, startOsFolderPath+"/"+eachFs.name, true );
								}
							}
						}
					}
				}
			}
		}
		delete fsOsFolderPath;
	}
	stockphoto.NavExtFnc.finalCleanUpOfSubFolder( 1, startOsFolderPath, false ); 
	if( bIsInit )
	{ // resulting to create IMAGES sub folder under temp
		startOsFolderPath = stockphoto.core.folder.getTempFolder();
	}
}

// ===
// === Interface functions between external component and data managed in the NavBar
// ===
stockphoto.NavExtFnc.GetStandardVonversionTable=function()
{
	return( stockphoto.NavCnv.StandardCnvTab );
}

stockphoto.NavExtFnc.SetRecent_s_Folder=function( ik, doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[doc_id].core.RecentSFld.path = stockphoto.NavIntDt_t[doc_id].Ext.fk[ik].p;
	stockphoto.NavIntDt_t[doc_id].core.RecentSFld.name = stockphoto.NavIntDt_t[doc_id].Ext.fk[ik].n;
}

stockphoto.NavExtFnc.SetPreviousKeyIndex=function( ik, doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[doc_id].Ext.PrevKeyInd = ik;
}

stockphoto.NavExtFnc.GetStyleSheetLocale=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	return( stockphoto.NavIntDt_t[doc_id].Ext.StyleSheetLocale );
}

stockphoto.NavExtFnc.SetStyleSheetLocale=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[doc_id].Ext.StyleSheetLocale = stockphoto.core.getValidLocale();
}

stockphoto.NavExtFnc.SetAdd3Field=function( v, doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[doc_id].Ext.NavDt.add[3] = v;
}

stockphoto.NavExtFnc.SetNoMoreImgField=function( b, doc_id )
{
	var idx=stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt.FldAndNumTab[ idx ].noMoreImg = b;
}

stockphoto.NavExtFnc.Getb0Value=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	return( stockphoto.NavIntDt_t[ doc_id ].kindOfNav );
}
	
stockphoto.NavExtFnc.SetCurrTopBar=function( str, doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[doc_id].CurrTopBar = str;
}
	
stockphoto.NavExtFnc.SetFolderName=function( Nm, doc_id )
{
	var UNm = ( File( Nm ).name ).toUpperCase();
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	stockphoto.NavIntDt_t[ doc_id ].core.FolderNm = UNm;
}

stockphoto.NavExtFnc.GetFolderName=function( doc_id )
{
	stockphoto.NavExtFnc.PrepareNavBar( doc_id );
	return( stockphoto.NavIntDt_t[ doc_id ].core.FolderNm );
}

stockphoto.NavExtFnc.SetStartUpFolder=function( Nm )
{
	if( stockphoto.NavIntDt.StartUpFldr == "" )
	{
		stockphoto.NavIntDt.StartUpFldr = Nm;
	}
}

stockphoto.NavExtFnc.SetFromBuyFlag=function()
{
	stockphoto.NavIntDt.FromBuyFlag = true;
}

stockphoto.NavExtFnc.getHTMLDStatus=function( doc_id, i_W_or_F )
{
	return( stockphoto.NavIntDt_t[ doc_id ].Ext.HtmLDStatus[ i_W_or_F ] );
}

if( ( stockphoto.timeKeeperOn != undefined )&&( stockphoto.timeKeeperOn ) )
{
	stockphoto.core.util.edTime( stockphoto.DL.jsx_NavBar );
}

// Utility function to add items to string, separated by ','
// Returns: Resultant string
stockphoto.NavIntFnc.AddItemToString = function (sItem, sStr)
{
  if (sStr != '')
  {
    sStr += stockphoto.NavBar.zc.get("$$$/NavBar/Misc/COMMA=,") + ' ';
  }
  
  sStr += sItem;
  
  return sStr;
}

// Prepares the 'Changed from default:...' string from current settings
// Returns: Resultant CFD string
stockphoto.NavExtFnc.GetCFD = function ( doc_id )
{
    var oCFD = { sCFD:'' };

    if ( doc_id == undefined )
    {
        return oCFD;
    }
    
    // Retrieve current settings...
	var oSettings = stockphoto.DL.NavBar.GetDrawerSettings(doc_id);
	var oDefSettings = eval ( stockphoto.search.defaultSettings );
	
    // If we have the default settings, just return the blank CFD string...
	if (oSettings.isDefault == true)
    {
        return oCFD;
    }
		
	// Otherwise, let's start framing the string...
	
	// MediaType
	if ((oSettings.mediaType.photography != oDefSettings.mediaType.photography)
        || (oSettings.mediaType.illustration != oDefSettings.mediaType.illustration)
        || ((true == stockphoto.core.displayPhotoObjectCollectionFeatureflag) && (oSettings.mediaType.photoobject != oDefSettings.mediaType.photoobject)))
    {
        oCFD.sCFD = stockphoto.NavIntFnc.AddItemToString(stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/content=Content" ), oCFD.sCFD);
    }
	
	// Tint
	if ((oSettings.colorFormat.color != oDefSettings.colorFormat.color)
        || (oSettings.colorFormat.bw != oDefSettings.colorFormat.bw))
    {
        oCFD.sCFD = stockphoto.NavIntFnc.AddItemToString(stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/tint=Tint" ), oCFD.sCFD);
    }
  
    // Orientation
    if ((oSettings.orientation.portrait != oDefSettings.orientation.portrait)
        || (oSettings.orientation.square != oDefSettings.orientation.square)
        || (oSettings.orientation.landscape != oDefSettings.orientation.landscape)
        || (oSettings.orientation.panoramic != oDefSettings.orientation.panoramic))
    {
        oCFD.sCFD = stockphoto.NavIntFnc.AddItemToString(stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/orientation=Orientation" ), oCFD.sCFD);
    }
  	
  	// Collections
  	// (Assumption: We'll never get a 'Default' setting where few collections are selected. It'd be either 'all', or 'none'.)
    
	if ((oSettings.collectionsAll != oDefSettings.collectionsAll))
	{
        oCFD.sCFD = stockphoto.NavIntFnc.AddItemToString(stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/collections=Collections" ), oCFD.sCFD);
	}
  
    // Add Prefix
   if (oCFD.sCFD != '')
   {
        var loc = stockphoto.core.getValidLocale();
          	
    	if ((loc != undefined) && (loc == "fr_FR"))
    	{
     	   oCFD.sCFD = stockphoto.NavBar.zc.get("$$$/NavBar/Misc/LPAREN=(") + stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/changedfromdefault=Changed" ) + " : " + oCFD.sCFD + stockphoto.NavBar.zc.get("$$$/NavBar/Misc/RPAREN=)");
        }
        else
        {
        	oCFD.sCFD = stockphoto.NavBar.zc.get("$$$/NavBar/Misc/LPAREN=(") + stockphoto.NavBar.zc.get( "$$$/NavBar/AdvSearch/changedfromdefault=Changed" ) + ": " + oCFD.sCFD + stockphoto.NavBar.zc.get("$$$/NavBar/Misc/RPAREN=)");
        }
	}
	
	return oCFD;
}

// Returns: nothing
stockphoto.NavExtFnc.ToggleAdvanceDrawer=function( doc_id, sShowHide ) 
{
    if (( doc_id == undefined ) || (stockphoto.documents[ doc_id ] == undefined)
	       || (stockphoto.documents[ doc_id ].document == undefined)
           || (sShowHide == undefined) )
	{
        return;
    }
    
    var oDoc = stockphoto.documents[ doc_id ].document;
	
    if (oDoc.topNavbar == undefined)
	{
		return;
	}
	
    var oTopBar = oDoc.topNavbar;
	
	if (oTopBar.drawerVisible == undefined)
	{
        oTopBar.drawerVisible = false;
    }

    // Web or File NavBar
    //Fix for Bug ID:1254850; webOrFile is not updated in the case mentioned in the bug. So using contentPaneMode always.
    var iWorF = stockphoto.NavIntFnc.get_kwORf( ( oDoc.contentPaneMode ).charAt(0) ); //stockphoto.NavIntDt_t[ doc_id ].webORfile; // 0=web, 1=file

    // New Height
    var iNewHeight = stockphoto.NavCnv.NavCnv.HEIGHTT;
    
    // Add BARHEIGHT for Filesystem NavBar..
    if (iWorF == stockphoto.NavIntDt._kWebOrFile_filesystem)
	{
      iNewHeight = iNewHeight + stockphoto.NavCnv.NavCnv.BARHEIGHT ;
    }
      
	if (sShowHide == 'H')
	{
        // Collapse the Nav Bar
        oTopBar.height = iNewHeight;
		  
        oTopBar.drawerVisible = false;
	   	stockphoto.search.showAdvancedDrawer[ doc_id ] = false;
    }	
	else if (sShowHide == 'S')
	{
	    	   
        // expand the Nav Bar
        //AK:added to adjust NAV bar height. 
      if (false == stockphoto.core.displayValueCollectionFeatureflag)
	    {
			iNewHeight = iNewHeight + stockphoto.NavCnv.NavCnv.	BARDRAWEREXPANSION_BC4;
	    }
	    else
      {       
			iNewHeight = iNewHeight + stockphoto.NavCnv.NavCnv.BARDRAWEREXPANSION;
      }  
        //AK:end of added
  		oTopBar.height = iNewHeight;
  		
        oTopBar.drawerVisible = true;
  		stockphoto.search.showAdvancedDrawer[ doc_id ] = true;
	}
	
	stockphoto.NavBar.heightUpdateScheduled = false;
}


stockphoto.NavExtFnc.searchLangDisplay = function()
{
	var code;
	if (stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_Preference )) //just to make sure that Preferences is loaded.
	{
		code = stockphoto.prefs.GetLanguage();
	}
	if (stockphoto.DL.demandJsxLoading( stockphoto.DL.jsx_LangCountry )) //just to make sure that LangCountry file is loaded.
	{
		if ( code == $.locale)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	return false;
}

// oXmlParsedObj: Object containing SearchRequest[0] (output from AnalyzeXml functions...)
// oInitSettings: Initial settings object (which will be used as a template for result...)
stockphoto.NavExtFnc.ParseAdvSettingsFromXmlObj = function ( oXmlParsedObj, oInitSettings )
{
  // Create a copy of the settings object
  var oSettings = eval(oInitSettings.toSource());
  
  if ((oXmlParsedObj == undefined) || (oXmlParsedObj.SearchRequest == undefined) || (oXmlParsedObj.SearchRequest[0] == undefined))
  {
    return oSettings;
  }
  
  // Obtain the SearchRequest object, which contails all filter settings from SearchRequest.xml
  var oSR = oXmlParsedObj.SearchRequest[0];
  
  if ((oSR.Orientation != undefined) && (oSR.Orientation.Value != undefined)  && (oSR.Orientation.Value != ""))
  {
    var sVal = oSR.Orientation.Value;
    oSettings.orientation.portrait = (sVal.indexOf("Portrait") != -1);
    oSettings.orientation.square = (sVal.indexOf("Square") != -1);
    oSettings.orientation.landscape = (sVal.indexOf("Landscape") != -1);
    oSettings.orientation.panoramic = (sVal.indexOf("Panoramic") != -1);
  }
  
  if ((oSR.ColorFormat != undefined) && (oSR.ColorFormat.Value != undefined) && (oSR.ColorFormat.Value != ""))
  {
    var sVal = oSR.ColorFormat.Value;
    oSettings.colorFormat.color = (sVal.indexOf("Color") != -1);
    oSettings.colorFormat.bw = (sVal.indexOf("BlackWhite") != -1);
  }
  
  if ((oSR.MediaTypes != undefined) && (oSR.MediaTypes.Value != undefined)  && (oSR.MediaTypes.Value != ""))
  {
    var sVal = oSR.MediaTypes.Value;
    oSettings.mediaType.photography = (sVal.indexOf("Photography") != -1);
    oSettings.mediaType.illustration = (sVal.indexOf("Illustration") != -1);
    oSettings.mediaType.photoobject = false;
  }
  
  return oSettings;
}

stockphoto.NavExtFnc.ParseAdvCollectionsFromFSObj = function ( oFSObj, oInitSettings )
{
  // Create a copy of the settings object  
  var oSettings = eval(oInitSettings.toSource());
  
  if ((oFSObj == undefined) || (oFSObj.exists == false))
  {
    return oSettings;
  }
  
  //AK:Added by aman
  
  var isMaskedImageCheckBoxSelected = stockphoto.DL.search.LoadSearchInfoFromFS(oFSObj, '[MaskedImageSelected]')
  	  
  if(undefined != typeof isMaskedImageCheckBoxSelected)
  {
  	if ("notSelected" == isMaskedImageCheckBoxSelected)
  	{
		oSettings.mediaType.photoobject = false;  	
  	}
  	else
  	{
  		oSettings.mediaType.photoobject = true;
	}
  
	if ("OnlyMISelected" == isMaskedImageCheckBoxSelected)
	{
		oSettings.mediaType.photography = false;
		oSettings.mediaType.illustration = false;
	}
	else if ("AllSelected" == isMaskedImageCheckBoxSelected)
	{
		oSettings.mediaType.photography = true;
		oSettings.mediaType.illustration = true;
	}
  }
   
  //AK:end of added by aman
  
  var arProvidersList = stockphoto.DL.search.LoadSearchInfoFromFS(oFSObj, '[ProviderCollections]')
  
  if (arProvidersList.length < 1)
  {
    return oSettings;
  }
  
  var bAllCollSelected = true;
  var bAnyCollSelected = false;
  oSettings.collectionDisplayNames = '';
  oSettings.collectionNames = '';
  
  for (var iCollIter in stockphoto.providers.collections)
  {
    var oCollectionItem = stockphoto.providers.collections[iCollIter];
    var bFound = false;
    
    for (var iProvider in arProvidersList)
    {
      if ((oCollectionItem != undefined) && (oCollectionItem.CollectionName.Value == arProvidersList[iProvider]))
      {
        oSettings.collectionSelected[iCollIter] = true;
        if (bAnyCollSelected == true) { oSettings.collectionNames += ","; } // must NOT be localized
        oSettings.collectionNames += oCollectionItem.CollectionName.Value;
        if (bAnyCollSelected == true) { oSettings.collectionDisplayNames += ","; } // must NOT be localized
        oSettings.collectionDisplayNames += oCollectionItem.CollectionDisplayName.Value;
        bAnyCollSelected = true;
        
        bFound = true;
        break;
      }
    }
    
    if (bFound == false)
    {
        oSettings.collectionSelected[iCollIter] = false;
        bAllCollSelected = false;
    }
    
    oSettings.collectionsAll = oSettings.collectionsAll & bAllCollSelected;  
        
  }
  
  return oSettings;

}

stockphoto.NavExtFnc.GetDrawerSettings = function( doc_id )
{
    if (doc_id == undefined)
    {
        return;
    }

    // Check if showPreviousSettings[doc_id] has been set to true.
    // This would be set to true in eventHandler if we are viewing a
    // Previous Search folder right now.
    if ((stockphoto.search.showPreviousSettings[doc_id] == true)
        && (stockphoto.search.previousSettings[doc_id] != undefined))
    {
        return stockphoto.search.previousSettings[doc_id];
    }
    
    if (stockphoto.search.settings[doc_id] == undefined)
    {
        if ((stockphoto.core.lastActiveDocumentID != 0) && (stockphoto.core.lastActiveDocumentID != doc_id))
        {
            stockphoto.search.settings[doc_id] = eval(stockphoto.search.settings[stockphoto.core.lastActiveDocumentID].toSource());
        }
        else
        {
            stockphoto.search.settings[doc_id] = eval(stockphoto.search.defaultSettings.toSource());
        }
    }
    
    return stockphoto.search.settings[doc_id];
}

stockphoto.NavExtFnc.GetNavType = function( doc_id )
{
	return stockphoto.NavIntDt_t[doc_id].navType; // 0 => homepage and 11 => shopping cart
}

stockphoto.NavExtFnc.GetNavHeightType = function( doc_id )
{
    var iNavType = stockphoto.NavExtFnc.GetNavType(doc_id);
    var iNavHeight;
    
    if (iNavType != undefined)
    {
        iNavHeight = stockphoto.NavIntDt.processTable[iNavType].navHeight;
    }
    
    return iNavHeight;
}

stockphoto.NavExtFnc.GetNavWorFType = function( doc_id )
{
    var iNavType = stockphoto.NavExtFnc.GetNavType(doc_id);
    var iNavWorFType;
    
    if (iNavType != undefined)
    {
        iNavWorFType = stockphoto.NavIntDt.processTable[iNavType].webORfile;
    }
    
    return iNavWorFType;
}

stockphoto.NavExtFnc.getCNavProcessingStatus = function ( doc_id, iWorF )
{
  if (stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus == undefined)
  {
    stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus = [ ];
  }
  
  if (stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus[iWorF] == undefined)
  {
    stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus[iWorF] = false;
  }
  
  return stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus[iWorF];
}

stockphoto.NavExtFnc.setCNavProcessingStatus = function ( doc_id, iWorF, status )
{
  if (stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus == undefined)
  {
    stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus = [ ];
  }
  
  stockphoto.NavIntDt_t[doc_id].CNavProcessingStatus[iWorF] = status;
}


stockphoto.NavExtFnc.setIsDefault = function ( docID, oSettings )
{
  var settings;
  
  if (oSettings != undefined)
  {
    settings = eval(oSettings);
  }
  else
  {
    settings = eval(stockphoto.search.settings[docID]);
  }
  
  var isDefault = true;
  if (settings.orientation.portrait != stockphoto.search.defaultSettings.orientation.portrait) { isDefault = false; }
  if (settings.orientation.square != stockphoto.search.defaultSettings.orientation.square) { isDefault = false; }
  if (settings.orientation.landscape != stockphoto.search.defaultSettings.orientation.landscape) { isDefault = false; }
  if (settings.orientation.panoramic != stockphoto.search.defaultSettings.orientation.panoramic) { isDefault = false; }
  if (settings.colorFormat.color != stockphoto.search.defaultSettings.colorFormat.color) { isDefault = false; }
  if (settings.colorFormat.bw != stockphoto.search.defaultSettings.colorFormat.bw) { isDefault = false; }
  if (settings.mediaType.photography != stockphoto.search.defaultSettings.mediaType.photography) { isDefault = false; }
  if (settings.mediaType.illustration != stockphoto.search.defaultSettings.mediaType.illustration) { isDefault = false; }
  if (settings.mediaType.photoobject != stockphoto.search.defaultSettings.mediaType.photoobject) { isDefault = false; }
  if (settings.collectionsAll != stockphoto.search.defaultSettings.collectionsAll) { isDefault = false; }
  if (settings.CollectionValue != stockphoto.search.defaultSettings.CollectionValue) { isDefault = false; }
  if (settings.CollectionSelect != stockphoto.search.defaultSettings.CollectionSelect) { isDefault = false; }
   
  
  settings.isDefault = isDefault;
  
  return settings;
}

stockphoto.NavExtFnc.changeMediaTypeFocus = function(doc_id)
{
   if ((stockphoto.documents[doc_id] != undefined)
    && (stockphoto.documents[doc_id].document != undefined)
    && (stockphoto.documents[doc_id].document.topNavbar != undefined)
    && (stockphoto.DL.NavBar.GetNavHeightType(doc_id) == stockphoto.NavIntDt._kNavHeight_high)
    && (stockphoto.NavExtFnc.IsExecJSSafe(doc_id) == true))
    {
        var iSavedLevel = $.level;
	   	$.level = 0;
        stockphoto.documents[doc_id].document.topNavbar.execJS('ChangeFocus()');
        // Restore
	   	$.level = iSavedLevel;
        return true;
    }
    else
    {
        return false;
    }
}
