/*
@@@BUILDINFO@@@ st19LangCountry.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.st19LangCountry        = {};
	stockphoto.timeKeeper.st19LangCountry.StTime = new Date();
}

// LangCountry namespace and zstringCache instance
stockphoto.LangCountry = {};
stockphoto.LangCountry.zc = new stockphoto.zstringCache("st19LangCountry");
stockphoto.LangCountry.isSearchArrayLoaded = false;
stockphoto.LangCountry.isBillingCountryArrayLoaded = false;

// LanguageTable is a Search Language dictionary, formatted like: {{"en_US", "English (US)"}, ... }
// ISO 639 2 letter codes / http://www.w3.org/WAI/ER/IG/ert/iso639.htm
// 
stockphoto.LangCountry.LanguageTable=[
{c:"en_US",n:"$$$/LangCountry/LanguageCode/en_US=English (US)"},
{c:"nl_NL",n:"$$$/LangCountry/LanguageCode/nl_NL=Dutch"},
{c:"en_GB",n:"$$$/LangCountry/LanguageCode/en_GB=English (UK)"},
{c:"fr_FR",n:"$$$/LangCountry/LanguageCode/fr_FR=French"},
{c:"de_DE",n:"$$$/LangCountry/LanguageCode/de_DE=German"},
{c:"it_IT",n:"$$$/LangCountry/LanguageCode/it_IT=Italian"},
{c:"ja_JP",n:"$$$/LangCountry/LanguageCode/ja_JP=Japanese"},
{c:"es_ES",n:"$$$/LangCountry/LanguageCode/es_ES=Spanish"},
{c:"",n:""} ];

// CountryTable is a Billing Country dictionary, formatted like: {{"US", "USD", "United States"}, ... }
// ISO 3166 Country codes / http://www.nw.com/zone/iso-country-codes
// 
stockphoto.LangCountry.CountryTable=[
{c:"US",m:"USD",n:"$$$/LangCountry/CountryCode/US=United States"},
{c:"AU",m:"USD",n:"$$$/LangCountry/CountryCode/AU=Australia"},
{c:"AT",m:"EUR",n:"$$$/LangCountry/CountryCode/AT=Austria"},
{c:"BE",m:"EUR",n:"$$$/LangCountry/CountryCode/BE=Belgium"},
{c:"CA",m:"USD",n:"$$$/LangCountry/CountryCode/CA=Canada"},
{c:"CN",m:"USD",n:"$$$/LangCountry/CountryCode/CN=China"},
{c:"DK",m:"EUR",n:"$$$/LangCountry/CountryCode/DK=Denmark"},
{c:"FI",m:"EUR",n:"$$$/LangCountry/CountryCode/FI=Finland"},
{c:"FR",m:"EUR",n:"$$$/LangCountry/CountryCode/FR=France"},
{c:"DE",m:"EUR",n:"$$$/LangCountry/CountryCode/DE=Germany"},
{c:"GB",m:"GBP",n:"$$$/LangCountry/CountryCode/GB=Great Britain"},
{c:"HK",m:"USD",n:"$$$/LangCountry/CountryCode/HK=Hong Kong"},
{c:"IE",m:"EUR",n:"$$$/LangCountry/CountryCode/IE=Ireland"},
{c:"IT",m:"EUR",n:"$$$/LangCountry/CountryCode/IT=Italy"},
{c:"JP",m:"JPY",n:"$$$/LangCountry/CountryCode/JP=Japan"},
{c:"MX",m:"USD",n:"$$$/LangCountry/CountryCode/MX=Mexico"},
{c:"NL",m:"EUR",n:"$$$/LangCountry/CountryCode/NL=Netherlands"},
{c:"NZ",m:"USD",n:"$$$/LangCountry/CountryCode/NZ=New Zealand"},
{c:"NO",m:"EUR",n:"$$$/LangCountry/CountryCode/NO=Norway"},
{c:"PT",m:"EUR",n:"$$$/LangCountry/CountryCode/PT=Portugal"},
{c:"SG",m:"USD",n:"$$$/LangCountry/CountryCode/SG=Singapore"},
{c:"ZA",m:"USD",n:"$$$/LangCountry/CountryCode/ZA=South Africa"},
{c:"KR",m:"USD",n:"$$$/LangCountry/CountryCode/KR=South Korea"},
{c:"ES",m:"EUR",n:"$$$/LangCountry/CountryCode/ES=Spain"},
{c:"SE",m:"EUR",n:"$$$/LangCountry/CountryCode/SE=Sweden"},
{c:"CH",m:"EUR",n:"$$$/LangCountry/CountryCode/CH=Switzerland"},
{c:"TW",m:"USD",n:"$$$/LangCountry/CountryCode/TW=Taiwan"},
{c:"",m:"",n:""} ];


// LoadLanguages
// uses LanguageTable table to create "English (US)" type array with current setting
// uses global isSearchArrayLoaded to determine if array exists
// 
stockphoto.LangCountry.LoadLanguages = function()
{
	var i;
	var memTab1 = "";
	
	if( stockphoto.LangCountry.isSearchArrayLoaded == false )
	{
		memTab1 = "([";
		stockphoto.LangCountry.isSearchArrayLoaded = true;
		
		// reconstruct Language table
		for( i = 0; stockphoto.LangCountry.LanguageTable[i].c != ""; i++)
		{
			if( i != 0 )
			{
				memTab1 += "',";
			}
			
			memTab1 = memTab1 + "'" + stockphoto.LangCountry.zc.get(stockphoto.LangCountry.LanguageTable[i].n);
		}
		
		memTab1 += "'])";
	}
	
	return( memTab1 );
}

// LoadLangCountries
// uses LanguageTable table to create "en_US" type array with current setting
// 
stockphoto.LangCountry.LoadLangCountries = function()
{
	var i;
	var memTab1 = "([";
	
	// reconstruct langCountry table
	for(i = 0; stockphoto.LangCountry.LanguageTable[i].c != ""; i++)
	{
		if( i != 0 )
		{
			memTab1 += "',";
		}
		
		memTab1 = memTab1 + "'" + stockphoto.LangCountry.LanguageTable[i].c;
	}
	
	memTab1 += "'])";
	
	return( memTab1 );
}

// GetCodeFromSearchLanguageName
// returns the language code given a language name in localized format
// 
stockphoto.LangCountry.GetCodeFromSearchLanguageName = function(languageName)
{
	var i;
	var result = "en_US";
	for(i = 0; stockphoto.LangCountry.LanguageTable[i].n != ""; i++)
	{
		var tableName = stockphoto.LangCountry.zc.get(stockphoto.LangCountry.LanguageTable[i].n);
		if (languageName.toString() == tableName)
		{
			result = stockphoto.LangCountry.LanguageTable[i].c;
			break;
		}
	}
	return result;
}

// GetNameFromSearchLanguageCode
// returns the language name in localized format given a language code
// 
stockphoto.LangCountry.GetNameFromSearchLanguageCode = function(languageCode)
{
	var i;
	var result = "";
	for(i = 0; stockphoto.LangCountry.LanguageTable[i].c != ""; i++)
	{
		if (languageCode == stockphoto.LangCountry.LanguageTable[i].c)
		{
			result = stockphoto.LangCountry.zc.get(stockphoto.LangCountry.LanguageTable[i].n);
			break;
		}
	}
	return result;
}

// LoadCountries
// uses CountryTable table to create "United States" array
// uses global isBillingCountryArrayLoaded to determine if array already exists
// 
stockphoto.LangCountry.LoadCountries = function()
{
	var i;
	var result = "";
	
	if( stockphoto.LangCountry.isBillingCountryArrayLoaded == false )
	{
		result = "([";
		
		stockphoto.LangCountry.isBillingCountryArrayLoaded = true;
		
		// reconstruct Country table
		for( i = 0; stockphoto.LangCountry.CountryTable[i].c != ""; i++)
		{
			if( i != 0 )
			{
				result += "\",";
			}
			
			result = result + "\"" + stockphoto.LangCountry.zc.get(stockphoto.LangCountry.CountryTable[i].n);
		}
		
		result += "\"])";
	}
	
	return( result );
}

// StockCountry_Body
// given an index into CountryTable, confirm that a billing country entry exists
// 
stockphoto.LangCountry.StockCountry_Body = function( CountryIndex )
{
	var result = "US";
	
	if( ( CountryIndex >= 0 ) && ( CountryIndex < stockphoto.LangCountry.CountryTable.length ) )
	{
		 result = stockphoto.LangCountry.CountryTable[CountryIndex].c;
	}
	
	return( result );
}

// StockCurrency_Body
// given a country code like "US", return the proper currency type like "USD"
// 
stockphoto.LangCountry.StockCurrency_Body = function( LangCountryCd )
{
	var contCd;
	var i;
	var result = "USD";
	
	if( LangCountryCd.length == 2 )
	{
		contCd = LangCountryCd.substr( 0, 2 );
		for( i=0; i<stockphoto.LangCountry.CountryTable.length; i++ )
		{
			if( ( contCd == stockphoto.LangCountry.CountryTable[i].c ) )
			{
				result = stockphoto.LangCountry.CountryTable[i].m;
				break;
			}
		}
	}

	return( result );
}

stockphoto.LangCountry.GetCodeFromBillingCountryName = function(languageName)
{
	var i;
	var result = "US";
	for(i = 0; stockphoto.LangCountry.CountryTable[i].c != ""; i++)
	{
		var tableName = stockphoto.LangCountry.zc.get(stockphoto.LangCountry.CountryTable[i].n);
		if (languageName.toString() == tableName)
		{
			result = stockphoto.LangCountry.CountryTable[i].c;
			break;
		}
	}
	return result;
}

stockphoto.LangCountry.GetNameFromBillingCountryCode = function(code)
{
	var i;
	var result = "";
	for(i = 0; stockphoto.LangCountry.CountryTable[i].c != ""; i++)
	{
		if (code == stockphoto.LangCountry.CountryTable[i].c)
		{
			result = stockphoto.LangCountry.zc.get(stockphoto.LangCountry.CountryTable[i].n);
			break;
		}
	}
	return result;
}

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

