// if JavaScript is enabled, hide the 'no-script' list of links, and show the ajax-driven menu
// these two lines MUST be below the elements they reference in the DOM (towards the bottom of the page)
$(".no-script").hide();
$(".sections").show();

// namespace
if (typeof HAT == "undefined" || !HAT) {
	var HAT = {};
}

HAT.Languages = {
	lang: [
		{
			intelcode:"ara",
			textdirection:"rtl",
			culture:"ar_AE",
			countryval:"/arabic/index.htm",
			countrylang:["Algeria - Arabic", "Bahrain - Arabic", "Egypt - Arabic", "Iraq - Arabic", "Jordan - Arabic", "Kuwait - Arabic", "Lebanon - Arabic", "Morocco - Arabic", "Mauritania - Arabic", "Oman - Arabic", "Qatar - Arabic", "Saudi Arabia - Arabic", "Tunisia - Arabic", "UAE - Arabic", "Yemen - Arabic"],
			fonttype:"HAT-font2"
		},
		{
			intelcode:"ara",
			textdirection:"rtl",
			culture:"ar_AR",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font2"
		},
		{
			intelcode:"aze",
			textdirection:"ltr",
			culture:"az_AZ",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font6"
		},
		{
			intelcode:"ces",
			textdirection:"ltr",
			culture:"cs_CZ",
			countryval:"/cd/corporate/europe/emea/ces/index.htm",
			countrylang:["Czech Republic - Czech"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"deu",
			textdirection:"ltr",
			culture:"de_DE",
			countryval:"GlobalGateway_Germany_German",
			countrylang:["Austria - German", "Europe - German", "Germany - German", "Liechtenstein - German", "Switzerland - German"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"eng",
			textdirection:"ltr",
			culture:"en_AP",
			countryval:"GlobalGateway_APAC_English",
			countrylang:["Asia Pacific - English", "Hong Kong - English", "Indonesia - English", "Malaysia - English", "New Zealand - English", "Pakistan - English", "Philippines - English", "Singapore - English", "Vietnam - English"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"eng",
			textdirection:"ltr",
			culture:"en_AU",
			countryval:"GlobalGateway_Australia_English",
			countrylang:["Australia - English"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"eng",
			textdirection:"ltr",
			culture:"en_IN",
			countryval:"GlobalGateway_India_English",
			countrylang:["India - English"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"sin",
			textdirection:"ltr",
			culture:"en_SG",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"eng",
			textdirection:"ltr",
			culture:"en_UK",
			countryval:"GlobalGateway_UnitedKingdom_English",
			countrylang:["Africa - English", "Belgium - English", "Czech Republic - English", "Denmark - English", "Estonia - English", "Europe - English", "Finland - English", "Gambia - English", "Greece - English", "Hungary - English", "Iceland - English", "Ireland - English", "Kenya - English", "Latvia - English", "Lithuania - English", "Luxembourg - English", "Nigeria - English", "Norway - English", "Romania - English", "Rwanda - English", "Tanzania - English", "United Kingdom - English", "Zimbabwe - English"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"eng",
			textdirection:"ltr",
			culture:"en_US",
			countryval:"GlobalGateway_UnitedStates_English",
			countrylang:["United States - English", "Canada - English"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"spa",
			textdirection:"ltr",
			culture:"es_ES",
			countryval:"GlobalGateway_Spain_Spanish",
			countrylang:["Spain - Spanish"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"esla",
			textdirection:"ltr",
			culture:"es_LA",
			countryval:"GlobalGateway_LatinAmerica_Spanish",
			countrylang:["Argentina - Spanish", "Chile - Spanish", "Colombia - Spanish", "Costa Rica - Spanish", "Latin America - Spanish", "Mexico - Spanish", "Venezuela - Spanish"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"espanol",
			textdirection:"ltr",
			culture:"es_MX",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"fra",
			textdirection:"ltr",
			culture:"fr_FR",
			countryval:"GlobalGateway_France_French",
			countrylang:["Canada - French", "France - French", "Belgium – French"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"heb",
			textdirection:"rtl",
			culture:"he_IL",
			countryval:"/cd/corporate/europe/emea/heb/287256.htm",
			countrylang:["Israel - Hebrew"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"hun",
			textdirection:"ltr",
			culture:"hu_HU",
			countryval:"/cd/corporate/europe/emea/hun/index.htm",
			countrylang:["Hungary - Hungarian"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"bah",
			textdirection:"ltr",
			culture:"id_ID",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"ita",
			textdirection:"ltr",
			culture:"it_IT",
			countryval:"GlobalGateway_Italy_Italian",
			countrylang:["Italy - Italian"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"jpn",
			textdirection:"ltr",
			culture:"ja_JP",
			countryval:"GlobalGateway_Japan_Japanese",
			countrylang:["Japan - Japanese"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"kor",
			textdirection:"ltr",
			culture:"ko_KR",
			countryval:"GlobalGateway_Korea_Korean",
			countrylang:["Korea - Korean"],
			fonttype:"HAT-font5"
		},
		{
			intelcode:"nla",
			textdirection:"ltr",
			culture:"nl_NL",
			countryval:"GlobalGateway_Netherlands_Dutch",
			countrylang:["Netherlands - Dutch", "Belgium – Netherlands"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"pol",
			textdirection:"ltr",
			culture:"pl_PL",
			countryval:"GlobalGateway_Poland_Polish",
			countrylang:["Poland - Polish"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"portugues",
			textdirection:"ltr",
			culture:"pt_BR",
			countryval:"GlobalGateway_Brazil_Portuguese",
			countrylang:["Brazil - Portuguese"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"rom",
			textdirection:"ltr",
			culture:"ro_RO",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"rus",
			textdirection:"ltr",
			culture:"ru_RU",
			countryval:"GlobalGateway_Russia_Russian",
			countrylang:["Russia - Russian"],
			fonttype:"HAT-font4"
		},
		{
			intelcode:"swe",
			textdirection:"ltr",
			culture:"sv_SE",
			countryval:"GlobalGateway_Sweden_Swedish",
			countrylang:["Sweden - Swedish"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"tur",
			textdirection:"ltr",
			culture:"tr_TR",
			countryval:"GlobalGateway_Turkey_Turkish",
			countrylang:["Turkey - Turkish"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"tha",
			textdirection:"ltr",
			culture:"th_TH",
			countryval:"GlobalGateway_Thailand_Thai",
			countrylang:["Thailand - Thai"],
			fonttype:"GG-Thai-font"
		},
		{
			intelcode:"vie",
			textdirection:"ltr",
			culture:"vi_VN",
			countryval:"",
			countrylang:[],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"zho",
			textdirection:"ltr",
			culture:"zh_CN",
			countryval:"GlobalGateway_China_SimplifiedChinese",
			countrylang:["China - Simplified Chinese"],
			fonttype:"HAT-font3"
		},
		{
			intelcode:"ukr",
			textdirection:"ltr",
			culture:"uk_UA",
			countryval:"/cd/corporate/europe/emea/rus/ukraine/index.htm",
			countrylang:["Ukraine - Ukrainian"],
			fonttype:"HAT-font1"
		},
		{
			intelcode:"zht",
			textdirection:"ltr",
			culture:"zh_TW",
			countryval:"GlobalGateway_Taiwan_TraditionalChinese",
			countrylang:["Taiwan - Traditional Chinese"],
			//fonttype:"HAT-font3"
			fonttype:"GG-Taiwan-font"
		}
	]
}

HAT.Countries = [
	{
		deeplink: 'en_US_01',
		name: 'United States - English',
		menu: '/homepage/xml/GlobalGateway_UnitedStates_English.xml',
		image: '/homepage/pix/bg/landing_10pix2-en_US.jpg'
	},
	{
		deeplink: 'en_UK_01',
		name: 'Africa - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_01',
		name: 'Latin America - Spanish',
		localizedName: 'América Latina - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_06',
		name: 'Argentina - Spanish',
		localizedName: 'Argentina - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_00',
		name: 'Asia Pacific - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AU_01',
		name: 'Australia - English',
		menu: '/homepage/xml/GlobalGateway_Australia_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_BE_01',
		name: 'Belgium - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'fr_BE_01',
		name: 'Belgium – French',
		localizedName: 'Belgium – Fran?ais',
		menu: '/homepage/xml/GlobalGateway_France_French.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'nl_BE_01',
		name: 'Belgium – Netherlands',
		localizedName: 'Belgium – Nederlands',
		menu: '/homepage/xml/GlobalGateway_Netherlands_Dutch.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'pt_BR_01',
		name: 'Brazil - Portuguese',
		localizedName: 'Brasil - Português',
		menu: '/homepage/xml/GlobalGateway_Brazil_Portuguese.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_CA_01',
		name: 'Canada - English',
		menu: '/homepage/xml/GlobalGateway_UnitedStates_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'fr_CA_01',
		name: 'Canada - French',
		localizedName: 'Canada - Fran?ais',
		menu: '/homepage/xml/GlobalGateway_France_French.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_02',
		name: 'Chile - Spanish',
		localizedName: 'Chile - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_03',
		name: 'Colombia - Spanish',
		localizedName: 'Colombia - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_CR_01',
		name: 'Costa Rica - Spanish',
		localizedName: 'Costa Rica - Espa?ol',
		link: '/costarica/index.htm'
	},
	{
		deeplink: 'cz_CZ_01',
		name: 'Czech Republic - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
//		name: 'Czech Republic - Czech', // site redirects back to UK home page
//		localizedName: '?eská republika - Czech', // site redirects back to UK home page
//		link: '/cd/corporate/europe/emea/ces/index.htm'
	},
	{
		deeplink: 'en_UK_09',
		name: 'Denmark - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'de_DE_03',
		name: 'Germany - German',
		localizedName: 'Deutschland - Deutsch',
		menu: '/homepage/xml/GlobalGateway_Germany_German.xml',
		image: '/homepage/pix/bg/landing_10pix2-de_DE.jpg'
	},
	{
		deeplink: 'es_ES_01',
		name: 'Spain - Spanish',
		localizedName: 'Espa?a - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_Spain_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_10',
		name: 'Estonia - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'de_DE_02',
		name: 'Europe - German',
		localizedName: 'Europa - Deutsch',
		menu: '/homepage/xml/GlobalGateway_Germany_German.xml',
		image: '/homepage/pix/bg/landing_10pix2-de_DE.jpg'
	},
	{
		deeplink: 'en_UK_11',
		name: 'Europe - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_12',
		name: 'Finland - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'fr_FR_01',
		name: 'France - French',
		localizedName: 'France - Fran?ais',
		menu: '/homepage/xml/GlobalGateway_France_French.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_02',
		name: 'Gambia - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_13',
		name: 'Greece - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_01',
		name: 'Hong Kong - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'hu_HU_01',
		name: 'Hungary - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
//		name: 'Hungary - Hungarian', // site redirects back to UK home page
//		localizedName: 'Magyarország - Magyar', // site redirects back to UK home page
//		link: '/cd/corporate/europe/emea/hun/index.htm'
	},
	{
		deeplink: 'en_UK_14',
		name: 'Iceland - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_IN_01',
		name: 'India - English',
		menu: '/homepage/xml/GlobalGateway_India_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_02',
		name: 'Indonesia - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_16',
		name: 'Ireland - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'it_IT_01',
		name: 'Italy - Italian',
		localizedName: 'Italia - Italiano',
		menu: '/homepage/xml/GlobalGateway_Italy_Italian.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_03',
		name: 'Kenya - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_17',
		name: 'Latvia - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'de_DE_04',
		name: 'Liechtenstein - German',
		localizedName: 'Liechtenstein - Deutsch',
		menu: '/homepage/xml/GlobalGateway_Germany_German.xml',
		image: '/homepage/pix/bg/landing_10pix2-de_DE.jpg'
	},
	{
		deeplink: 'en_UK_18',
		name: 'Lithuania - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_19',
		name: 'Luxembourg - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_03',
		name: 'Malaysia - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_04',
		name: 'Mexico - Spanish',
		localizedName: 'Mexico - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'nl_NL_01',
		name: 'Netherlands - Dutch',
		localizedName: 'Netherland - Nederlands',
		menu: '/homepage/xml/GlobalGateway_Netherlands_Dutch.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_04',
		name: 'New Zealand - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_04',
		name: 'Nigeria - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_21',
		name: 'Norway - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'de_DE_01',
		name: 'Austria - German',
		localizedName: '?sterreich - Deutsch',
		menu: '/homepage/xml/GlobalGateway_Germany_German.xml',
		image: '/homepage/pix/bg/landing_10pix2-de_DE.jpg'
	},
	{
		deeplink: 'en_AP_05',
		name: 'Pakistan - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_06',
		name: 'Philippines - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'pl_PL_01',
		name: 'Poland - Polish',
		localizedName: 'Polska - Polski',
		menu: '/homepage/xml/GlobalGateway_Poland_Polish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_22',
		name: 'Romania - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_05',
		name: 'Rwanda - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_07',
		name: 'Singapore - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_ZA_01',
		name: 'South Africa - English',
		link: '/cd/corporate/africa/emea/eng/za/index.htm'
	},
	{
		deeplink: 'de_DE_05',
		name: 'Switzerland - German',
		localizedName: 'Schweiz - Deutsch',
		menu: '/homepage/xml/GlobalGateway_Germany_German.xml',
		image: '/homepage/pix/bg/landing_10pix2-de_DE.jpg'
	},
	{
		deeplink: 'sv_SE_01',
		name: 'Sweden - Swedish',
		localizedName: 'Sverige - Svenska',
		menu: '/homepage/xml/GlobalGateway_Sweden_Swedish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_06',
		name: 'Tanzania - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'tr_TR_01',
		name: 'Turkey - Turkish',
		localizedName: 'Türkiye - Türk?e',
		menu: '/homepage/xml/GlobalGateway_Turkey_Turkish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_15',
		name: 'United Kingdom - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'es_LA_05',
		name: 'Venezuela - Spanish',
		localizedName: 'Venezuela - Espa?ol',
		menu: '/homepage/xml/GlobalGateway_LatinAmerica_Spanish.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_AP_09',
		name: 'Vietnam - English',
		menu: '/homepage/xml/GlobalGateway_APAC_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'en_UK_07',
		name: 'Zimbabwe - English',
		menu: '/homepage/xml/GlobalGateway_UnitedKingdom_English.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'ru_RU_05',
		name: 'Russia - Russian',
		localizedName: 'Россия - Русский',
		menu: '/homepage/xml/GlobalGateway_Russia_Russian.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'ru_RU_09',
		name: 'Ukraine - Ukrainian',
		localizedName: 'Укра?на - Укра?нська',
		link: '/cd/corporate/europe/emea/rus/ukraine/index.htm'
	},
	{
		deeplink: 'zh_CN_01',
		name: 'China - Simplified Chinese',
		localizedName: '中国 - 简体中文',
		menu: '/homepage/xml/GlobalGateway_China_SimplifiedChinese.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'zh_TW_01',
		name: 'Taiwan - Traditional Chinese',
		localizedName: '台灣 - 繁體中文',
		menu: '/homepage/xml/GlobalGateway_Taiwan_TraditionalChinese.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'ja_JP_01',
		name: 'Japan - Japanese',
		localizedName: '日本 - 日本語',
		menu: '/homepage/xml/GlobalGateway_Japan_Japanese.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'ko_KR_01',
		name: 'Korea - Korean',
		localizedName: '?? - ???',
		menu: '/homepage/xml/GlobalGateway_Korea_Korean.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'th_TH_01',
		name: 'Thailand - Thai',
		localizedName: '????????? -???????',
		menu: '/homepage/xml/GlobalGateway_Thailand_Thai.xml',
		image: '/homepage/pix/bg/bg-global-gateway.jpg'
	},
	{
		deeplink: 'he_IL_01',
		name: 'Israel - Hebrew',
		localizedName: '????? - ?????',
		link: '/cd/corporate/europe/emea/heb/287256.htm'
	},
	{
		deeplink: 'ar_DZ_01',
		name: 'Algeria - Arabic',
		localizedName: '??????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_BH_01',
		name: 'Bahrain - Arabic',
		localizedName: '??????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_EG_01',
		name: 'Egypt - Arabic',
		localizedName: '??? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_IQ_01',
		name: 'Iraq - Arabic',
		localizedName: '?????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_JO_01',
		name: 'Jordan - Arabic',
		localizedName: '?????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_KW_01',
		name: 'Kuwait - Arabic',
		localizedName: '?????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_LB_01',
		name: 'Lebanon - Arabic',
		localizedName: '????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_MR_01',
		name: 'Mauritania - Arabic',
		localizedName: '????????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_MA_01',
		name: 'Morocco - Arabic',
		localizedName: '?????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_OM_01',
		name: 'Oman - Arabic',
		localizedName: '???? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_QA_01',
		name: 'Qatar - Arabic',
		localizedName: '??? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_SA_01',
		name: 'Saudi Arabia - Arabic',
		localizedName: '??????? ??????? ???????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_TN_01',
		name: 'Tunisia - Arabic',
		localizedName: '???? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_AE_01',
		name: 'UAE - Arabic',
		localizedName: '???? ???????? ??????? ??????? - ???????',
		link: '/arabic/index.htm'
	},
	{
		deeplink: 'ar_YE_01',
		name: 'Yemen - Arabic',
		localizedName: '????? - ???????',
		link: '/arabic/index.htm'
	}
];


// section hover behavior
$(document).ready(function() {
	var s = "fast";
	// fixes some occasional visual glitches when user moves mouse over/out of the section
	function resetHeight() { $(this).height('auto'); }
	$(".section").hover(function() {
		$(this)
			.find('h2').stop().slideUp(s, resetHeight).end()
			.find('.contents').stop().slideDown(s, resetHeight);
	}, function() {
		$(this)
			.find('h2').stop().slideDown(s, resetHeight).end()
			.find('.contents').stop().slideUp(s, resetHeight);
	});
});

var default_country_name;
var default_country;
var deeplink = location.hash.substr(2); // flash-style deeplinking: "#/country_code"
if (!deeplink) {
	default_country_name = param("country") || cookie("countrylang"); // passed-in param or cookie
}

var redirect = (!param("country") && !deeplink); // don't (initially) redirect if a country has been passed in
var initialTracking = false;
var omniture_page_name;

$.each(HAT.Countries, function(i, country) {
	// for convenience, set up a direct link the the appropriate item in HAT.Languages.lang
	$.each(HAT.Languages.lang, function(i, language) {
		if ($.inArray(country.name, language.countrylang) >= 0) {
			country.language = language;
			return false;
		}
	});
	
	// set up the default country value and an analytics tracking name
	if (deeplink == country.deeplink || default_country_name == country.name) {
		default_country = country;
		// set omniture page name, but NOT for the default (index 0, en_US) selection
		if (i && country.language) {
			omniture_page_name = country.language.countryval.replace(/_/g, ":");
		}
	}
});

$(document).ready(function() {
	// parse the country list into a select box when loaded
	$.each(HAT.Countries, function(i, n) {
		$("<option value='" + n.name + "'>")
			.html(n.localizedName || n.name)
			.attr("selected", (n == default_country ? "selected" : ""))
			.appendTo("#country-selector");
	});
	
	// show the country selector, and add a change handler
	$("#country-selector").show().change(function(e) {
		var country = HAT.Countries[this.selectedIndex];
		
		//document.cookie = "countrylang=" + country.name + ";path=/;max-age=" + (60*60*24*365);
		//IE6 Cookie Fix 2/1/2009
		var nextyear = new Date();
        nextyear.setFullYear(nextyear.getFullYear() + 1);
        var cookie_value = "countrylang=" + encodeURIComponent(country.name) + "; path=/; expires=" + nextyear.toGMTString();
        document.cookie = cookie_value;

		
		if (country.link && redirect) {
			location.href = country.link;
		} else if (country.menu && country.language) {
			location.hash = "/" + country.deeplink;
			var header = "sites/sitewide/HAT/30recode/"+ country.language.culture + "/json/global_header_gateway.js";
			var footer = "sites/sitewide/HAT/30recode/" + country.language.culture + "/" + country.language.textdirection + "_Standards_W1024_HTTP_UTF8/footer.inc";
			var languageClasses = "HAT-wide " + country.language.fonttype + (country.language.textdirection == "rtl" ? " HAT-rtl" : "");
			var styleLink = "/sites/sitewide/HAT/30recode/css/" + country.language.textdirection + "_header.css";
			
			$.get(country.menu, parseCountryXML, "xml");
			$.getJSON(header, parseHeaderJSON);
			$("#footerdiv").load(footer);
			
			$("#HAT-linkStyle").attr('href', styleLink);
			$("#HAT-globalheader, #ggw").attr('class', languageClasses);
			$("#ggw").css('background-image', (country.image ? 'url(' + country.image + ')' : ''));
			
			// track change after the language updates for better user experience
			// but only after the initial page load
			if (initialTracking) {
				var omniture_page_name = country.language.countryval.replace(/_/g, ":").toLowerCase();
				waTrackAsLink("global gateway selection: " + country.name, 'o', 'wa_prop14=cim:' + omniture_page_name);
			}
		}
	});
	
	// load the selected language if it is not the first (0th)
	// this assumes that the default language is already set up
	//if ($("#country-selector").get(0).selectedIndex) {
		//$("#country-selector").trigger('change');
	//}
	
	redirect = true; // after the initial language is set up, re-enable redirects
	initialTracking = true;
	
	function parseCountryXML(xml) {
		var $xml = $(xml);
		function update(selector, textnode, linknode) {
			$(selector).html($.trim($xml.find(textnode).text()) || "&nbsp;"); // insert a hard space even if item is empty, to preserve HTML layout
			if (linknode) { $(selector).attr('href', $xml.find(linknode).text()); }
		}
		update(".choose-location h2", "headercopy");
		update(".section.work h1 a", "worktitle", "worklink");
		update(".section.play h1 a", "playtitle", "playlink");
		update(".section.about h1 a", "abouttitle", "aboutlink");
		update(".section.work h2", "worksubtitle");
		update(".section.play h2", "playsubtitle");
		update(".section.about h2", "aboutsubtitle");
		update(".section.work .contents", "workbody");
		update(".section.play .contents", "playbody");
		update(".section.about .contents", "aboutbody");
	}
	
	function parseHeaderJSON(json) {
		$("#logo_link").attr('href', json.header.logo.href + "?iid=" + json.header.logo.iid);
		$("#logo_img")
			.attr('alt', json.header.logo.value)
			.attr('title', json.header.logo.value);
		$("#lbl_search").html(json.header.search.button.value);
		$("#culture").val(json.header.search.culture);
		$("#searchsubmit")
			.attr('alt', json.header.search.button.value)
			.attr('title', json.header.search.button.value)
			.attr('src', "/sites/sitewide/HAT/30recode/pix/searchbtn_" + json.header.search.button.language + ".gif");
	
		HAT.SearchFilterLUT.head = json.header.search.filter.filterhead;
		HAT.SearchFilterLUT.qs = $.map(json.header.search.filter.term, function(n) {
			return { filter: n.query, term: n.value };
		});

		$("#HAT-filter-menu").remove();
		setTimeout(function() {
			$("#HAT-filter-menu").remove();
			HAT.FilterMenu.BuildFilter();
			HAT.FilterMenu.AttachEvents();
		}, 50);

		$("#supportbtn_link").attr('href',json.header.support.link.href + "?iid=" + json.header.support.link.ggiid);
		$("#supportbtn").text(json.header.support.link.value);
		
	}
	function parseSupportJSON(sjson) {
		var lang = cookie("culture");
		$("#supportbtn_link").attr('href',sjson.support[lang].support.href);
		$("#supportbtn").text(sjson.support[lang].support.button.value);
	}
});

function cookie(key) {
	//return parseParams(document.cookie, /; ?/)[key];
	//IE6 Cookie Fix 2/1/2009
	return decodeURIComponent(parseParams(document.cookie, /; ?/)[key]);
}

function param(key) {
	var params = parseParams(location.search.substr(1), "&");
	return params[key] ? unescape(params[key]) : null;
}

// can be used for cookies or URL search strings
function parseParams(str, delimiter) {
	var x = {};
	$.each(str.split(delimiter), function(i, n) {
		var keyVal = n.split(/=/);
		if (keyVal[0] && keyVal[1]) { x[keyVal[0]] = keyVal[1]; }
	});
	return x;
}

// utility function to generate the 'no script' list of country links
function createNoscriptList() {
	var $div = $(".no-script").empty().show();
	var $list = $("<ul>").appendTo($div);
	$.each(HAT.Countries, function(i, n) {
		var value = n.link;
		if (n.menu) {
			$.ajax({ async: false, url: n.menu,
				success: function(countryXML) { value = $(countryXML).find("worklink").text(); }
			});
		}
		$list.append("<li><a href='" + value + "'>" + (n.localizedName || n.name) + "<\/a><\/li>");
		if ((i+1) % 16 == 0) {
			if (i+1 == HAT.Countries.length) {
				$list.css("text-align", "right");
				$div.append("<div class='clear'>");
			} else {
				$list = $("<ul>").appendTo($div);
			}
		}
	});
}
