PageSourceSearch

https://www.claris.com/interactive/themes/beacon/localization-gr/js/gr.js?v=7.7

js claris.com collected 2026-10-09 21:51:14 UTC 49,886 bytes, 1,396 lines download raw bytes

1// GLOBAL VARIABLES
2var geneFM, ralphFM;
3// DEPENDENCIES JQUERY, JQUERY COOKIE
4
5// RALPH ----------------------------------------------------------------
6function Ralph(countryJSON) {
7	this.country = '';
8	this.countryJSON = countryJSON;
9	this.init();
10	
11	// BUY AND TRIAL JSON
12	this.buyLink;
13	this.tryLink;
14	
15	// USER COOKIES
16	this.cookie = { 
17			country: '', glCountry: '', local: ''
18	};
19	
20	this.wwwLocale ={};
21	
22	// CONTENT SWAP 
23	this.defaultContent;
24	this.defaultContentSelection; // DEFAULT COUNTRY, FOR EXAMPLE: EN -> US, DE -> DE, ES -> ES
25		
26}
27Ralph.prototype = {
28	// do init, check what is avaiable on page (i.e. subnav)
29	init: function() {
30		var ralph = this;
31						
32	},
33	
34	// SET WWW LOCALE
35	setWWWLocale: function(wwwLocale) {
36		var ralph = this;
37		
38		ralph.wwwLocale = wwwLocale;
39	},
40	
41	// SET THE CLASS IN THE BODY
42	setCountryToBody: function() {
43		 var ralph = this;
44		 $('body').addClass('gr-country-'+ralph.wwwLocale.country);
45			$('body').attr('gr-locale', ralph.wwwLocale.language + '-' + ralph.wwwLocale.country)
46	},
47	
48	// SETS LANGUAGE SITE ICON TO SELECTOR
49	setLanguageToLanguageSelector: function() {
50		 var ralph = this;
51			if(!$('#language-icon-selection').length) {
52			 $('<span id="language-icon-selection"></span>').insertAfter('#language-country-selector .language-icon');
53				$('#language-icon-selection').html(ralph.wwwLocale.language.toUpperCase());
54			}
55			if($('.cs-gfoot-ccrl-text').length > 0) {
56				$('.cs-gfoot-ccrl-text').text(ralph.countryJSON['content-selector'][ralph.wwwLocale.country]['name'])
57			}
58	},
59	
60	// BUY LINKS
61	buyLinks: function() {
62		//console.log('buyLinks function');
63		var ralph = this,
64				country = ralph.wwwLocale.country;
65	// Subnav, Global-Nav, Dropdown Global-Nav, Subnav-Store
66		if($('#subnav-buy-now a').length > 0 || $('.gr-buy-link').length > 0 || $('#gnav-purchase a:first').length > 0 || $('#gnav-purchase li:first a:first').length > 0 || $('#subnav-store a').length > 0 || $('#g-top-nav-buy a').length > 0 || $('#subnav-buy a').length > 0 || $('#buy-box a[buy=buy-sidebar]').length > 0 || $('#buy-box a[buy=buy-buy-box]').length > 0 ) {
67			//console.log('buy link ajax');
68			$.ajax({
69				url: "/site/ralph/buy_links_json.txt",
70				method: "GET",
71				cache: false,
72				dataType: "json",
73				success: function(buyLinks) { 
74					//console.log(buyLinks);
75					if(buyLinks['buy links']['lang'][ralph.wwwLocale.language] && buyLinks['buy links']['lang'][ralph.wwwLocale.language]['country'][country]) {
76						$('#subnav-buy-now a, .gr-buy-link, #gnav-purchase a:first, #gnav-purchase li:first a:first, #subnav-store a, #g-top-nav-buy a, #subnav-buy a, #buy-box a[buy=buy-sidebar], #buy-box a[buy=buy-buy-box]').attr('href', buyLinks['buy links']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
77					} else {
78						//console.log('no buy link available');
79					}
80				}
81			});
82		}
83	},
84	
85	// TRIAL LINKS
86	trialLinks: function() {
87		var ralph = this,
88				country = ralph.wwwLocale.country;
89		
90		// #subnav-try-now a - LEGACY
91		// #g-top-nav-trial a - BIRCH
92		// #subnav-try a - BIRCH
93		
94		if($('#subnav-try-now a').length > 0 || $('.gr-trial-link').length > 0 || $('#global-util-free-trial').length > 0 || $('#g-top-nav-trial a').length > 0 || $('#subnav-try a').length > 0 || $('#buy-box a[buy=try-buy-box]').length > 0 ) {
95			$.ajax({
96				url: "/site/ralph/trial_links_json.txt",
97				method: "GET",
98				cache: false,
99				dataType: "json",
100				success: function(trialLinks) { 
101					//console.log(trialLinks);
102					if(trialLinks['trial links']['lang'][ralph.wwwLocale.language] && trialLinks['trial links']['lang'][ralph.wwwLocale.language]['country'][country]) {
103						$('#subnav-try-now a, .gr-trial-link, #global-util-free-trial, #g-top-nav-trial a, #subnav-try a, #buy-box a[buy=try-buy-box]').attr('href', trialLinks['trial links']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
104					} else {
105						//console.log('no trial link available');
106					}
107				}
108			});
109		}
110	},
111	
112	// PRICING (FILEMAKER/CONNECT)
113	pricing: function() {
114		var ralph = this,
115				country = ralph.wwwLocale.country,
116				language = ralph.wwwLocale.language,
117				// languageOverride = { 'en-SE': 'sv-SE' }
118				wwwLocale = language+'-'+country
119				// console.log('locale: '+wwwLocale)
120				// if(wwwLocale in languageOverride) { wwwLocale = overrideMap[wwwLocale] }
121		
122		function programTierPrice(productsArray, program, tier, selectedSKU, selectedVersion, priceType, offering, duration) {
123			var version = ''
124			var sku = ''
125			// RADD = expansion
126			// R19 = product
127			if(offering === 'expansion') {
128				version = 'RADD'
129			} else if(offering === 'product' && selectedVersion != '' && selectedSKU != '') {
130				version = selectedVersion
131				sku = selectedSKU
132			} else if(offering === 'product') {
133				version = 'R19'
134				sku = ''
135			} else {
136				return 'offering input error'
137			}
138
139			var priceDuration = 0
140			if(duration === 'monthly') {
141				priceDuration = 12
142			} else if(duration === 'yearly') {
143				priceDuration = 1
144			} else {
145				return 'duration input error'
146			}
147
148			for(var i=0; i<productsArray.length;i++) {
149				if(productsArray[i]['program'] === program) {
150					for(var j=0; j<productsArray[i]['tiers'].length;j++) {
151						if(productsArray[i]['tiers'][j]['tier'] === tier) {
152							for(var k=0;
152 k<productsArray[i]['tiers'][j]['product'].length;k++) {
153								if(productsArray[i]['tiers'][j]['product'][k]['version'] === version && (sku === '' ? '' : productsArray[i]['tiers'][j]['product'][k]['sku']) === sku) {
154									return parseFloat(productsArray[i]['tiers'][j]['product'][k][priceType]) / priceDuration
155								}
156							}
157						}
158					}
159				}
160			}
161		}
162		
163		function numberWithCommas(x) {
164				return 
165		}
166		
167		function formatPrice(price, currencyDetail) {
168			var formattedPrice;
169			var groupingSize = currencyDetail['groupingSize']
170			var groupingUsed = currencyDetail['groupingUsed']
171			var groupingSeparatorSymbol = String(currencyDetail['groupingSeparatorSymbol'])
172			var decimalSeparatorSymbol = String(currencyDetail['decimalSeparatorSymbol'])
173			var maxFractionDigits = currencyDetail['maxFractionDigits']
174			
175			var priceArray = String(price).split('.')
176			// console.log(priceArray)
177			
178			if(groupingUsed === true) {
179				// console.log('grouping USED')
180				var replace = "\\B(?=(\\d{"+groupingSize+"})+(?!\\d))"
181				// console.log(replace)
182				var re = new RegExp(replace,"g")
183				priceArray[0] = priceArray[0].toString().replace(re, groupingSeparatorSymbol);
184				// console.log(priceArray)
185			}
186			
187			if(priceArray[1] !== undefined) {
188				priceArray[1] = priceArray[1].slice(0,2)
189				if(priceArray[1].length < 2) {
190					priceArray[1] = priceArray[1]+'0'
191				}
192			}
193			
194			// console.log(decimalSeparatorSymbol)
195			price = priceArray.join(decimalSeparatorSymbol)
196			// console.log(price)
197			
198			var symbol = currencyDetail['positivePrefix']
199			if(symbol !== ''){ 
200				formattedPrice = symbol+price
201			} else {
202				symbol = currencyDetail['positiveSuffix']
203				formattedPrice = price+symbol
204			}
205			
206			return formattedPrice
207		}
208		
209		function formatToPriceHTML(price, currencyDetail) {
210			var decimalSeparatorSymbol = String(currencyDetail['decimalSeparatorSymbol'])
211			var formattedPriceHTML
212			var priceArray = price.split(decimalSeparatorSymbol)
213			var integerAmount = priceArray[0]
214			var decimalAmount = priceArray[1]
215			
216			if(decimalAmount === undefined) {
217				decimalAmount = ''
218			} else {
219				decimalAmount = decimalSeparatorSymbol + decimalAmount
220			}
221			
222			return integerAmount + "<sup>" + decimalAmount + "</sup>"
223		}
224		
225		
226		
227		$.ajax({
228			type: 'get',
229			dataType: 'json',
230			cache: false,
231			url: '/site/includes/pricing/pricing_backup.txt',
232			success: function(data) {
233				// console.log(data[wwwLocale])
234
235				var overrideMap = { "fr-LU": "en-LU", "de-LU": "en-LU", "en-SE": "sv-SE", "en-KR": "ko-KR", "en-NL": "nl-NL", "en-BE": "nl-BE", "en-BR": "pt-BR", "en-CN": "zh-CN"} // { www: store }
236				if(wwwLocale in overrideMap) { wwwLocale = overrideMap[wwwLocale] }
237				
238				var wwwLocalePrice = data[wwwLocale]
239				var currencyDetail = wwwLocalePrice['currency-details']
240				var priceDominant = wwwLocalePrice['price_dominant']
241				var priceType = ''
242				if(priceDominant == 2) {
243					priceType = 'incPrice'
244				} else {
245					priceType = 'exPrice'
246				}
247
248				// function programTierPrice(productsArray, program, tier, selectedSKU, selectedVersion, priceType, offering, duration)
249				var connectTier0 = programTierPrice(wwwLocalePrice['products'], 'STA', '0', '','',priceType, 'product', 'monthly') // Essentials
250				var connectTier0Exp = programTierPrice(wwwLocalePrice['products'], 'STA', '0', '','',priceType, 'expansion', 'monthly') // Essentials expansion
251				var connectTier1 = programTierPrice(wwwLocalePrice['products'], 'STA', '1', '','',priceType, 'product', 'monthly') // Standard
252				var connectTier1Exp = programTierPrice(wwwLocalePrice['products'], 'STA', '1', '','',priceType, 'expansion', 'monthly') // Standard expansion
253				var connectTier5 = programTierPrice(wwwLocalePrice['products'], 'STA', '5', '','',priceType, 'product', 'monthly') // FM Plus
254				var connectTier5Exp = programTierPrice(wwwLocalePrice['products'], 'STA', '5', '','',priceType, 'expansion', 'monthly') // FM Plus expansion
255				var connectTier6 = programTierPrice(wwwLocalePrice['products'], 'STA', '6', '','',priceType, 'product', 'monthly') // Developer
256				var filemakerTier0 = programTierPrice(wwwLocalePrice['products'], 'FCL', '0', '','',priceType, 'product', 'monthly') // Essentials
257				var filemakerTier1 = programTierPrice(wwwLocalePrice['products'], 'FCL', '1', '','',priceType, 'product', 'monthly') // 
257Standard
258				var serverTier1 = programTierPrice(wwwLocalePrice['products'], 'FLA', '1', '23FA12VL1C2426','R23',priceType, 'product', 'monthly') // On-Prem
259				var serverRB = programTierPrice(wwwLocalePrice['products'], 'CBS', null, 'CBS00001','RADD',priceType, 'expansion', 'yearly') // remote backup
260				var serverRBPerYrAdd100GB = programTierPrice(wwwLocalePrice['products'], 'CBS', null, 'CBS00006','RADD',priceType, 'expansion', 'yearly') // remote backup
261				var serverSS = programTierPrice(wwwLocalePrice['products'], 'SBS', null, 'WSS00001','RADD',priceType, 'expansion', 'yearly') // remote backup
262				
263				var filemakerPro = programTierPrice(wwwLocalePrice['products'], 'FMP', null, '', '',priceType, 'product', 'yearly') // On-Prem
264				
265
266				/*console.log(connectTier0)
267				console.log(connectTier0Exp)
268				console.log(connectTier1)
269				console.log(connectTier1Exp)
270				console.log(connectTier5)
271				console.log(connectTier5Exp)
272				console.log(connectTier6)
273				console.log(filemakerTier0)
274				console.log(filemakerTier1)
275				console.log(serverTier1)
276				console.log(filemakerPro)*/
277				
278				filemakerTier0 = formatPrice(filemakerTier0, currencyDetail)
279				filemakerTier1 = formatPrice(filemakerTier1, currencyDetail)
280				
281				connectTier6 = formatPrice(connectTier6, currencyDetail)
282				connectTier5 = formatPrice(connectTier5, currencyDetail)
283				connectTier5Exp = formatPrice(connectTier5Exp, currencyDetail)
284				connectTier0 = formatPrice(connectTier0, currencyDetail)
285				connectTier0Exp = formatPrice(connectTier0Exp, currencyDetail)
286				connectTier1 = formatPrice(connectTier1, currencyDetail)
287				connectTier1Exp = formatPrice(connectTier1Exp, currencyDetail)
288				
289				serverTier1 = formatPrice(serverTier1, currencyDetail)
290				serverRB = formatPrice(serverRB, currencyDetail)
291				serverRBPerYrAdd100GB = formatPrice(serverRBPerYrAdd100GB, currencyDetail)
292				serverSS = formatPrice(serverSS, currencyDetail)
293				
294				filemakerPro = formatPrice(filemakerPro, currencyDetail)
295				
296				// html format
297				filemakerTier0 = formatToPriceHTML(filemakerTier0, currencyDetail)
298				filemakerTier1 = formatToPriceHTML(filemakerTier1, currencyDetail)
299				
300				connectTier6 = formatToPriceHTML(connectTier6, currencyDetail)
301				connectTier5 = formatToPriceHTML(connectTier5, currencyDetail)
302				connectTier5Exp = formatToPriceHTML(connectTier5Exp, currencyDetail)
303				connectTier0 = formatToPriceHTML(connectTier0, currencyDetail)
304				connectTier0Exp = formatToPriceHTML(connectTier0Exp, currencyDetail)
305				connectTier1 = formatToPriceHTML(connectTier1, currencyDetail)
306				connectTier1Exp = formatToPriceHTML(connectTier1Exp, currencyDetail)
307				
308				serverTier1 = formatToPriceHTML(serverTier1, currencyDetail)
309				serverRB = formatToPriceHTML(serverRB, currencyDetail)
310				serverRBPerYrAdd100GB = formatToPriceHTML(serverRBPerYrAdd100GB, currencyDetail)
311				serverSS = formatToPriceHTML(serverSS, currencyDetail)
312				
313				filemakerPro = formatToPriceHTML(filemakerPro, currencyDetail)
314
315				$('.f-price-offering-1').html(filemakerTier0).css('white-space','nowrap')
316				$('.f-price-offering-2').html(filemakerTier1).css('white-space','nowrap')
317
318				// connect price-offering-1 developer
319				// connect price-offering-2 filemaker-plus
320				// connect price-offering-3 essentials
321				// connect price-offering-4 standard
322
323				$('.c-price-offering-1').html(connectTier6).css('white-space','nowrap')
324				$('.c-price-offering-2').html(connectTier5).css('white-space','nowrap')
325				$('.c-price-offering-3').html(connectTier0).css('white-space','nowrap')
326				$('.c-price-offering-4').html(connectTier1).css('white-space','nowrap')
327				$('.c-exp-price-offering-2').html(connectTier5Exp).css('white-space','nowrap')
328				$('.c-exp-price-offering-3').html(connectTier0Exp).css('white-space','nowrap')
329				$('.c-exp-price-offering-4').html(connectTier1Exp).css('white-space','nowrap')
330				
331				$('.op-price-offering-1').html(serverTier1).css('white-space','nowrap')
332				$('.op-price-offering-rb').html(serverRB).css('white-space','nowrap')
333				$('.op-price-offering-rb-peryear100gb').html(serverRBPerYrAdd100GB).css('white-space','nowrap')
334				$('.op-price-offering-ss').html(serverSS).css('white-space','nowrap')
335				
336				$('.fmp-price-offering-1').html(filemakerPro).css('white-space','nowrap')
337
338			}
339		})
340		
341	},
342	
343	// CONTENT SWAP
344	// REPLACES CONTENT BASED ON LOCALE
345	contentSwap: function() {
346		var grContent = $('.gr-content'),
347				grCountrySelection,
348				ralph = this,
349				path;
350				localizationPath = '',
351				pagePath = document.location.pathname.split('/'),
352				pagePathLast = pagePath.length-1;
353				pagePathName = pagePath[pagePathLast],
354				dropdownSelector = '<div id="pricing-selector-dropdown" class="dropdown-selector flag-display-selection"><span class="">Country</span><ul class="dropdown"></ul></div>';
355									
356				if( pagePathName === 'index.html' || pagePathName === '' ) {
357					 localizationPath = '';
358				} else {
359					 localizationPath = pagePathName.split('.')[0]+'/';
360				}
361			
362		// LOAD CONTENT FUNCTION
363		function loadContent(country) {
364			country = country.toLowerCase();
365			$.ajax({
366				url: 'localization/'+localizationPath+country+'.html',
367				method: "GET",
368				cache: false,
369				dataType: "html",
370				success: function(content) {
371				//console.log(content);
372				//console.log($(content).find('#gr-js-src'));			
373					$('#gr-content-wrapper').html(content);				
374				},
375					error: function() {
376					//console.log('error');
377					}			
378				});
379				
380				// UPDATE SELECTOR
381				$('#gr-content-selector').val(country);
382		}
383		if(grContent[0]) {
384			// Get the Dropdown styles and Ralph Dropdown style overrides
385			$('<link/>', {
386				rel: 'stylesheet',
387				type: 'text/css',
388				href: '/interactive/themes/arctic/dropdown-selector/css/dropdown-selector.css'
389			}).appendTo('head');
390			$('<link/>', {
391				rel: 'stylesheet',
392				type: 'text/css',
393				href: '/interactive/themes/beacon/localization-gr/css/dropdown.css'
394			}).appendTo('head');
395				
396			$.getScript('/interactive/themes/arctic/dropdown-selector/js/dropdown-selector.js')
397				.done(function(script, textStatus) {
398					//console.log(grContent[0]);
399				
400					ralph.defaultContentSelection = ralph.countryJSON['country-list']['lang'][ralph.wwwLocale.language]['default'];
401					
402					//console.log(grContent[0].innerHTML);
403					ralph.defaultContent = grContent[0].innerHTML;
404					grContent.children().wrapAll('<div id="gr-content-wrapper"></div>');
405								
406								
407					// ADD SELECTOR
408					grContent.prepend(dropdownSelector); // DDS
409								
410					// CHECK IF SELECTOR IS DEFINED
411					if(grContent.attr('data-country-selection')) {
412						grCountrySelection = grContent.attr('data-country-selection').split(' ');
413						//console.log(grCountrySelection);
414						
415						var itemSelected = '';
416						var contentSelectorJSON = ralph.countryJSON['content-selector']; // DDS
417						// DDS
418						// LOOK FOR DEFAULT ITEM
419						for(var j in grCountrySelection) {
420							//console.log( grCountrySelection[j].toUpperCase() );
421							if(grCountrySelection[j].toUpperCase() === ralph.countryJSON['country-list']['lang'][ralph.wwwLocale.language]['default']) {
422									itemSelected = "data-selected='true'";
423							}
424							//console.log( contentSelectorJSON[grCountrySelection[j].toUpperCase()] );
425							if(contentSelectorJSON[grCountrySelection[j].toUpperCase()]) {
426								$('#pricing-selector-dropdown ul.dropdown').append("<li><a href='#"+contentSelectorJSON[grCountrySelection[j].toUpperCase()]['value']+"' class='"+contentSelectorJSON[grCountrySelection[j].toUpperCase()]['flag']+" flag-button' data-value='"+contentSelectorJSON[grCountrySelection[j].toUpperCase()]['value']+"' data-country-code='"+grCountrySelection[j]+"' data-language='"+ralph.wwwLocale.language+"' "+itemSelected+">"+contentSelectorJSON[grCountrySelection[j].toUpperCase()]['name']+"</a></li>");
427							}
428							
429							itemSelected = '';
430						}
431										
432						// DDS
433						// INITIALIZE DROPDOWN
434						var dd = new DropdownSelector( $('#pricing-selector-dropdown'), function(text, dataValue, countryCode, lang) {
435								//console.log("OnLoad - text: "+text+", data-value:"+dataValue+", data-country-code:"+countryCode+", data-language:"+lang);
436								//FM.getJSON(countryCode,lang);
437						});
438						
439						// DDS
440						dd.itemSelected(function(text, dataValue, countryCode, lang) {
441							//console.log("text: "+text+", data-value:"+dataValue+", data-country-code:"+countryCode+", data-language:"+lang);
442							
443							var countrySelection = countryCode;
444							//console.log( countryCode );
445							//console.log( ralph.defaultContentSelection.toLowerCase() );
446							//console.log( ralph.defaultContent );
447							
448							if( countrySelection === ralph.defaultContentSelection.toLowerCase() ) {
449									$('#gr-content-wrapper').html(ralph.defaultContent);
450							} else {
451									loadContent(countrySelection);
452							}
453								
454						});
455						
456						// DDS - Remove Active State, Close Dropdown
457						$(document).click(function() {
458							$('.dropdown-selector').removeClass('active');
459						});
460						
461										
462						// LOAD COUNTRY PREF HASH
463						var countryHash = window.location.hash.substring(1);
464						if( ralph.countryJSON['content-hash-mapping'][countryHash] ) {
465							loadContent(ralph.countryJSON['content-hash-mapping'][countryHash]);
466								
467							$("#pricing-selector-dropdown ul.dropdown a[data-country-code='"+ralph.countryJSON['content-hash-mapping'][countryHash].toLowerCase()+"']").parent().trigger('click');
468							$('.dropdown-selector').removeClass('active');
469						} else if ( countryHash === 'latin-america' ) {
470							loadContent('rla');
471											
472							$("#pricing-selector-dropdown ul.dropdown a[data-country-code='rla']").parent().trigger('click');
473							$('.dropdown-selector').removeClass('active');
474						} else {
475							// LOAD COUNTRY PREF
476							if(ralph.defaultContentSelection.toUpperCase() === ralph.wwwLocale.country) {
477								//console.log('do nothing, leave as default');
478							} else {
479								//console.log('load based on country');
480								//console.log($.inArray(ralph.wwwLocale.country, grCountrySelection));
481								// CHECK IF CURRENT COUNTRY CODE IS WITHIN THE 'data-country-selection' VARAIBLE
482								if( $.inArray(ralph.wwwLocale.country.toLowerCase(), grCountrySelection) > -1){
483									loadContent(ralph.wwwLocale.country);
484									
485									$("#pricing-selector-dropdown ul.dropdown a[data-country-code='"+ralph.wwwLocale.country.toLowerCase()+"']").parent().trigger('click');
486									$('.dropdown-selector').removeClass('active');
487									
488									// LATIN AMERICA CUSTOM DROPDOWN ITEM, OCCURS WHEN COUNTRY IS NOT DECLARED ON THE TAG ATTRIBUTE 'data-country-selection' BUT COUNTRY IS WITHIN CUSTOM Latin America ARRAY
489								}	else if ( $.inArray(ralph.wwwLocale.country, ralph.countryJSON['latin-america']) > -1) {
490									loadContent('rla');
491									
492									$("#pricing-selector-dropdown ul.dropdown a[data-country-code='rla']").parent().trigger('click');
493									$('.dropdown-selector').removeClass('active');
494								}
495							}
496						}				
497					}
498				})
499				.fail(function(jqxhr,settings,exception) {
500				})
501			}	
502	},
503	
504	// DEVELOPER CONSULTANT LINK
505	consultantLinks: function() {
506		var ralph = this,
507			country = ralph.wwwLocale.country;
508	
509		if($('#gnav-solutions ul li:last-child a').attr('href') === '//developer.filemaker.com/search/') {
510			$.ajax({
511				url: "/site/ralph/consultants_json.txt",
512				method: "GET",
513				cache: false,
514				dataType: "json",
515				success: function(json) { 
516					//console.log(trialLinks);
517					if(json['consultants']['lang'][ralph.wwwLocale.language] && json['consultants']['lang'][ralph.wwwLocale.language]['country'][country]) {
518							$('#gnav-solutions ul li:last-child a').attr('href', json['consultants']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
519					} else {
520							//console.log('no trial link available');
521					}
522				}
523			});
524		}
525	},
526	
527	// TRAINERS LINK
528	trainersLinks: function() {
529		var ralph = this,
530				country = ralph.wwwLocale.country;
531	
532		if($('#section-teach a').length > 0) {
533			$.ajax({
534				url: "/site/ralph/trainers_json.txt",
535				method: "GET",
536				cache: false,
537				dataType: "json",
538				success: function(json) { 
539					//console.log(trialLinks);
540					if(json['trainers']['lang'][ralph.wwwLocale.language] && json['trainers']['lang'][ralph.wwwLocale.language]['country'][country]) {
541						 
542						$('#section-teach a').each(function() {
543							if( $(this).attr('href').trim() === '//developer.filemaker.com/trainers/' ) {	 
544								$(this).attr('href', json['trainers']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
545							}
546						});
547					} else {
548						//console.log('no trainers link available');
549					}
550				}
551			});
552		}
553	},
554	
555	// NSRO LINK
556	nsroLinks: function() {
557		var ralph = this,
558				country = ralph.wwwLocale.country;
559		// PROMOS PAGE
560		if($('#gr-nrso').length > 0 || $('.gr-nsro-link').length > 0) {
561			$.ajax({
562				url: "/site/ralph/nrso_links_json.txt",
563				method: "GET",
564				cache: false,
565				dataType: "json",
566				success: function(json) { 
567					//console.log(buyLinks);
568					if(json['nrso links']['lang'][ralph.wwwLocale.language] && json['nrso links']['lang'][ralph.wwwLocale.language]['country'][country]) {
569							$('#gr-nrso, .gr-nsro-link').attr('href', json['nrso links']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
570					} else {
571							//console.log('no nrso link available');
572					}
573				}
574			});
575		}
576	},
577	
578	// buy-idea2iPad LINK
579	buyidea2iPadLinks: function() {
580		var ralph = this,
581				country = ralph.wwwLocale.country;
582
583		if($('#gr-buy-idea2ipad').length > 0 || $('.gr-buy-idea2ipad-link').length > 0) {
584			$.ajax({
585				url: "/site/ralph/buy-idea2ipad_json.txt",
586				method: "GET",
587				cache: false,
588				dataType: "json",
589				success: function(json) { 
590					if(json['buy-idea2ipad']['lang'][ralph.wwwLocale.language] && json['buy-idea2ipad']['lang'][ralph.wwwLocale.language]['country'][country]) {
591							$('#gr-buy-idea2ipad, .gr-buy-idea2ipad-link').attr('href', json['buy-idea2ipad']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
592					} else {
593							//console.log('no buy idea2iPad link available');
594					}
595				}
596			});
597		}
598	},
599	
600	// buyed-idea2iPad (eduation) LINK
601	buyEdidea2iPadLinks: function() {
602		var ralph = this,
603				country = ralph.wwwLocale.country;
604
605		if($('#gr-buyed-idea2ipad').length > 0 || $('.gr-buyed-idea2ipad-link').length > 0) {
606			$.ajax({
607				url: "/site/ralph/buyed-idea2ipad_json.txt",
608				method: "GET",
609				cache: false,
610				dataType: "json",
611				success: function(json) { 
612					if(json['buyed-idea2ipad']['lang'][ralph.wwwLocale.language] && json['buyed-idea2ipad']['lang'][ralph.wwwLocale.language]['country'][country]) {
613							$('#gr-buyed-idea2ipad, .gr-buyed-idea2ipad-link').attr('href', json['buyed-idea2ipad']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
614					} else {
615							//console.log('no buyed idea2iPad link available');
616					}
617				}
618			});
619		}
620	},
621	
622	// PROMO PAGE (promo-appstarterpack) LINK
623	promoAppStarterPackLinks: function() {
624		var ralph = this,
625				country = ralph.wwwLocale.country;
626
627		if($('.promo-appstarterpack').length > 0) {
628			$.ajax({
629				url: "/site/ralph/promo-appstarterpack_json.txt",
630				method: "GET",
631				cache: false,
632				dataType: "json",
633				success: function(json) { 
634					if(json['promo-appstarterpack']['lang'][ralph.wwwLocale.language] && json['promo-appstarterpack']['lang'][ralph.wwwLocale.language]['country'][country]) {
635							$('.promo-appstarterpack').attr('href', json['promo-appstarterpack']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
636					} else {
637							//console.log('no promo-appstarterpack link available');
638					}
639				}
640			});
641		}
642	},
643	
644	// PROMO PAGE (promo-getontrack) LINK
645	promoGetOnTrackLinks: function() {
646		var ralph = this,
647				country = ralph.wwwLocale.country;
648
649		if($('.promo-getontrack').length > 0) {
650			$.ajax({
651				url: "/site/ralph/promo-getontrack_json.txt",
652				method: "GET",
653				cache: false,
654				dataType: "json",
655				success: function(json) { 
656					if(json['promo-getontrack']['lang'][ralph.wwwLocale.language] && json['promo-getontrack']['lang'][ralph.wwwLocale.language]['country'][country]) {
657							$('.promo-getontrack').attr('href', json['promo-getontrack']['lang'][ralph.wwwLocale.language]['country'][country]['data']);
658					} else {
659							//console.log('no promo-getontrack link available');
660					}
661				}
662			});
663		}
664	},
665	
666	pricingPage: function(pricingJSON) {
667		var ralph = this,
668				country,
669				pricingCountry;
670			
671		function checkLocale() {
672			 
673			country = ralph.wwwLocale.country;
674			pricingCountry = ralph.countryJSON['pricing-map'][country];
675			
676			if(pricingCountry !== undefined) {
677			//console.log('switchStore Yes');
678				$("#pricing-selector-dropdown ul.dropdown a[data-value='"+pricingCountry+"']").parent().trigger('click');
679				$('.dropdown-selector').removeClass('active');
680				return;
681			} else {
682				window.setTimeout(checkLocale, 100);
683			}	
684		}
685		window.setTimeout(checkLocale, 40);	
686	},
687	
688	// WINSOFT CHECK
689	winsoft: function() {
690		var ralph = this;
691		//console.log(ralph.cookie.country);
692		//console.log(ralph.countryJSON["winsoft"].indexOf(ralph.cookie.country));
693		if(ralph.countryJSON["winsoft"].indexOf(ralph.cookie.country) > -1) {
694			return true;
695		} else {
696			return false;
697		}
698	},
699	
700	// WINSOFT BUY TRY REPLACE
701	winsoftBuyTrialLinks: function() {
702		var ralph = this;
703		
704		if($('#subnav-buy-now a') || $('.gr-buy-link') || $('#g-top-nav-buy a')) {
705			$('#subnav-buy-now a, .gr-buy-link, #g-top-nav-buy a').attr('href', 'http://store.winsoft-international.com/products/product/filemaker.html');
706		}
707		if($('#subnav-try-now a') || $('.gr-trial-link') || $('#g-top-nav-trial a')) {
708			$('#subnav-try-now a, .gr-try-link, #g-top-nav-trial a').attr('href', 'http://store.winsoft-international.com/downloads/free-downloads/free-trials.html');
709		}
710	},
711	
712	isLatinAmericaCountry: function() {
713	},
714	
715	calculatePageURLEnd: function() {
716		/*var ralph = this;
717		var indexLang = window.location.pathname.split('/')[1].toLowerCase();
718		var newPath = ''
719		console.log(ralph.countryJSON['country-list']['lang']);
720		if(indexLang in ralph.countryJSON['country-list']['lang']) {
721			newPath = window.location.pathname.split('/');
722			newPath.splice(0,2);
723			newPath = newPath.join('/');
724		} else {
725			console.log(newPath = window.location.pathname)
726		}
727		
728		// Check if url exists
729		
730		$.each( $('.gr-link'), function(index, value) {
731			var href = $(this).attr('href');
732			var href = href+newPath;
733			$(this).attr('href', href);	
734		});
735		*/
736	},
737
738	calendly: function() {
739		var ralph = this,
740		country = ralph.wwwLocale.country,
741		language = ralph.wwwLocale.language,
742		// languageOverride = { 'en-SE': 'sv-SE' }
743		wwwLocale = language+'-'+country
744		// console.log('calendly locale: '+wwwLocale)
745		cookieLocale = $.cookie('locale');
746
747		// temp fix
748		if(wwwLocale == 'en-US' && cookieLocale == 'en-US') {
749			$('.calendly-section').show()
750		} else {
751			$('.non-calendly-form').show()
752		}
753	},
754
755	rbssAddons: function() {
756		var ralph = this,
757			country = ralph.wwwLocale.country,
758			language = ralph.wwwLocale.language,
759		// languageOverride = { 'en-SE': 'sv-SE' }
760			wwwLocale = language+'-'+country
761		// console.log('rbssAddons locale: '+wwwLocale)
762			cookieLocale = $.cookie('locale');
763
764		if(wwwLocale == 'en-CN' && cookieLocale == 'zh-CN') {
765			$('#rbss.section-wrapper').hide()
766			$('.op-price-offering-2').next().html('<br>')
767			$('.op-price-offering-2').next().next().html('<br>')
768			$('.op-price-offering-2').removeClass('op-price-offering-2').text('Contact us')
769			
770			// var linkCN = $('a')
771			// linkCN.each(function(index, link) {
772			// 	if($(link).attr('href') == '/company/contact/' || $(link).attr('href') == '/company/contact') {
773			// 		$(this).attr('href', '/company/contact/?cr=cn')
774			// 	}
775			// })
776		}
777	},
778
779	contactUSLinkSwap: function() {
780		var ralph = this,
781			country = ralph.wwwLocale.country,
782			language = ralph.wwwLocale.language,
783		// languageOverride = { 'en-SE': 'sv-SE' }
784			wwwLocale = language+'-'+country,
785		// console.log('rbssAddons locale: '+wwwLocale)
786			cookieLocale = $.cookie('locale'),
787			currentSite = ralph.wwwLocale.currentLangSite
788
789
790		var links = $('a')
791
792		if(currentSite == 'en') {
793			currentSite = '/en'
794		} else {
795			currentSite = `/${currentSite}`
796		}
797
798		links.each(function(index, link) {
799			if($(link).attr('href') == '/company/contact/' || $(link).attr('href') == '/company/contact') {
800				$(this).attr('href', `/company/contact/?cr=${country.toLowerCase()}`)
801			}
802		})
803	},
804	
805	run: function(wwwLocale) {
806		var ralph = this;
807		//console.log('ralph run');
808		
809		ralph.setWWWLocale(wwwLocale);
810		ralph.setCountryToBody();
811		ralph.setLanguageToLanguageSelector();
812		
813		var country = ralph.wwwLocale.country;
814		var language = ralph.wwwLocale.language;
815		var wwwLocaleString = language+'-'+country;
816		var cookieLocale = $.cookie('locale');
817
818		//ralph.contentSwap();
819		//ralph.consultantLinks();
820		//ralph.trainersLinks();
821		// ralph.nsroLinks(); // removed 5/7/2018 dl
822		//ralph.buyidea2iPadLinks();
823		//ralph.buyEdidea2iPadLinks();
824		if( $('.f-price-offering-1').length > 0 || $('.f-price-offering-2').length > 0 || $('.c-price-offering-1').length > 0 || $('.c-price-offering-2').length > 0 || $('.c-price-offering-3').length > 0 || $('.c-price-offering-4').length > 0 || $('.c-exp-price-offering-2').length > 0 || $('.c-exp-price-offering-3').length > 0 || $('.c-exp-price-offering-4').length > 0 || $('.op-price-offering-1').length > 0 || $('.op-price-offering-rb').length > 0 || $('.op-price-offering-ss').length > 0 || $('.fmp-price-offering-1').length > 0) {
825			ralph.pricing();
826		}
827		// ralph.promoAppStarterPackLinks(); // removed 5/7/2018 dl
828		// ralph.promoGetOnTrackLinks(); // removed 5/7/2018 dl
829		
830		//console.log(ralph.cookie.countryPref === 'undefined');
831		if(!$.cookie('locale')) {
832			//console.log('check for winsoft country');
833			/*if(ralph.winsoft()) {
834				//console.log('winsoft buy trial link swap');
835				// ralph.winsoftBuyTrialLinks(); // removed 5/7/2018 dl
836			} else {
837				 //console.log('do buy try links now!');
838			// ralph.buyLinks(); // removed 5/7/2018 dl
839			// ralph.trialLinks(); // removed 5/7/2018 dl
840			}*/
841		} else {
842			 //console.log('do buy try links now!');
843			//ralph.buyLinks(); // removed 5/7/2018 dl
844			//ralph.trialLinks(); // removed 5/7/2018 dl
845		}
846		
847		//Country Selector (gr-link)
848		//ralph.calculatePageURLEnd();
849
850		if( $('.calendly-section').length > 0) {
851			ralph.calendly();
852		}
853
854		if( $('#rbss.section-wrapper').length > 0) {
855			ralph.rbssAddons();
856		}
857		// console.log(wwwLocaleString)
858		// console.log(cookieLocale)
859		if(wwwLocaleString == 'en-CN' && cookieLocale == 'zh-CN') {
860			
861			if(window.location.pathname == '/pricing/') {
862				window.location.href = '/pricing/self-hosted.html'
863			}
864
865			if(window.location.pathname == '/pricing/self-hosted.html') {
866				$('.row-tertiary-nav').hide()
867				$('.row-tertiary-nav').children().first().hide()
868				$('.row-tertiary-nav').show()
869			}
870		}
871
872		ralph.contactUSLinkSwap();
873	}
874		
875};
876
877// GENE ---------------------------------------------------------------------------------
878function Gene(countryJSON) {
879		this.countryJSON = countryJSON;
880		this.init();
881		this.currentSite;
882		this.currentLocaleLanguage
883		
884		this.cookie = { 
885				country: '', glCountry: '', locale: ''
886		};
887		
888		this.wwwLocale = { language: '', country: '', currentLangSite: this.currentSite}; // Internal Gene/Ralph Use
889}
890Gene.prototype = {
891		
892		init: function() {
893				var gene = this;
894			
895				gene.currentSite = window.location.pathname.split('/')[1];
896				
897				//console.log(gene.countryJSON );
898				if( gene.countryJSON['country-list']['lang'][gene.currentSite] ) {
899				} else {
900					gene.currentSite = 'en';
901				}
902				
903				$('body').on('click', '.gr-language-selection', function(e) {
904					e.preventDefault();
905					
906					var indexLang = window.location.pathname.split('/')[1].toLowerCase();
907					var newPath = ''
908					if(indexLang in gene.countryJSON['country-list']['lang']) {
909						newPath = window.location.pathname.split('/');
910						newPath.splice(0,2);
911						newPath = newPath.join('/');
912					} else {
913						// console.log(newPath = window.location.pathname)
914					}
915					
916					// Check if url exists
917					
918					// console.log(newPath)
919					var href = $(this).attr('href');
920					// console.log(href);
921					var newHref = href+newPath;
922					// console.log(newHref);
923					newHref = newHref.replace('//','/');
924					//$(this).attr('href', href);	
925					
926					$.ajax({
927						type: 'HEAD',
928						url: newHref,
929						success: function() {
930							// console.log('page exists');
931							window.location = newHref;
932						},
933						error: function() {
934							// console.log('no page exists');
935							window.location.href = href;
936						}
937					});
938					
939				});
940				
941				$('body').on('click', '.gr-link', function(e) {
942					e.preventDefault();
943					var language, country;
944					
945					
946					//console.log('click link');
947					//console.log($(this).attr('href').split('/')[1]);
948					//console.log(gene.countryJSON['site-directory-to-language-map']);
949					
950					// Obtain Language from Site Link and adjust based on mapping
951					language = $(this).attr('href').split('/')[1];
952					if(gene.countryJSON['site-directory-to-language-map'][language]) {
953						language = gene.countryJSON['site-directory-to-language-map'][language];
954					} else {
955						language = 'en';
956					};
957					country = $(this).attr('data-gr-country').toUpperCase();
958					// console.log(language+' and '+country)
959					// Set Local Cookie
960					gene.setLocale(language, country);
961					
962					var indexLang = window.location.pathname.split('/')[1].toLowerCase();
963					var newPath = ''
964					
965					setTimeout(() => {
966						if(indexLang in gene.countryJSON['country-list']['lang']) {
967							newPath = window.location.pathname.split('/');
968							newPath.splice(0,2);
969							newPath = newPath.join('/');
970						} else {
971							newPath = window.location.pathname;
972						}
973						
974						var href = $(this).attr('href');
975						var newHref = href+newPath;
976						newHref = newHref.replace('//','/');
977						// console.log(href)
978						
979						// Check if page exists and redirect accordingly
980						$.ajax({
981							type: 'HEAD',
982							url: href,
983							success: function() {
984								window.location = href;
985							},
986							error: function() {
987								window.location.href = href;
988							}
989						});
990					}, 1000);
991					
992				});
993		},
994		
995		initEventListners: function() {
996			 var gene = this;
997		},
998		
999		// IS VALID COUNTRY
1000		// RETURN TRUE IS VALID COUNTRY, FALSE IF INVALID
1001		isValidCountry: function(country) {
1002			 var gene = this;
1003			//  console.log(gene.countryJSON['country-list']['lang'][gene.currentSite]['country'])
1004				// console.log(country)
1005				if(gene.countryJSON['country-list']['lang'][gene.currentSite]) {
1006					 //console.log(country);
1007					 //console.log( gene.countryJSON['country-list']['lang'][gene.currentSite]['country'].indexOf(country) );
1008					 if(gene.countryJSON['country-list']['lang'][gene.currentSite]['country'].indexOf(country) > -1) {
1009						  return true;
1010						} else {
1011							 return false;
1012						}
1013				} else {
1014					 //console.log('invalid site');
1015					 return false;
1016				}
1017				
1018		},
1019		
1020		// GET CURRENT LOCALE LANGUAGE
1021		currentLocaleLanguage: function() {
1022			var gene = this, 
1023			    language = gene.currentSite;
1024			if(gene.countryJSON['site-directory-to-language-map'][language]) {
1025				return language = gene.countryJSON['site-directory-to-language-map'][language];
1026			} else {
1027				return language = 'en';
1028			};
1029		},
1030		
1031		// CONVERT COOKIES AND REMOVE COOKIES FROM PREVIOUS VERSION
1032		conversion: function() {
1033			var gene = this;
1034			if($.cookie('locale') && $.cookie('locale').indexOf('-') > -1) { // NEW LOCALE COOKIE
1035				//console.log('new locale');
1036				if($.cookie('countryPref') != undefined || $.cookie('countryPref') != null) {
1037					$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1038					$.removeCookie('countryPref', { domain: 'www.claris.com', path: '/' });
1039					document.cookie = 'countryPref' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1040				}
1041			} else if($.cookie('locale') && $.cookie('locale').indexOf('_') > -1) { // OLD LOCALE COOKIE
1042				//console.log('old locale');
1043				if($.cookie('countryPref') != undefined || $.cookie('countryPref') != null) { // COUNTRYPREF DEFINED
1044					if( gene.isValidCountry($.cookie('countryPref')) ) {
1045						//console.log('jp?');
1046						gene.setLocale(gene.countryJSON['site-directory-to-language-map'][gene.currentSite], $.cookie('countryPref'));
1047						$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1048						$.removeCookie('countryPref', { domain: 'www.claris.com', path: '/' });
1049						document.cookie = 'countryPref' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1050					} else {
1051						$.removeCookie('locale', { domain: '.claris.com', path: '/' });
1052						$.removeCookie('locale', { domain: 'www.claris.com', path: '/' });
1053						document.cookie = 'locale' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1054						$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1055						$.removeCookie('countryPref', { domain: 'www.claris.com', path: '/' });
1056						document.cookie = 'countryPref' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1057					}
1058				} else { // NO COUNTRYPREF DEFINED
1059					$.removeCookie('locale', { domain: '.claris.com', path: '/' });
1060					$.removeCookie('locale', { domain: 'www.claris.com', path: '/' });
1061					document.cookie = 'locale' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1062					document.cookie = 'countryPref' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1063				}
1064			} else { // NO LOCALE COOKIE
1065				//console.log('no locale');
1066				if($.cookie('countryPref') != undefined || $.cookie('countryPref') != null) {
1067					$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1068					$.removeCookie('countryPref', { domain: 'www.claris.com', path: '/' });
1069					document.cookie = 'countryPref' + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1070				}
1071			}
1072		},
1073		
1074		getCookies: function() {
1075			 var gene = this;
1076				gene.cookie.glCountry = $.cookie('glCountry');
1077				gene.cookie.locale = $.cookie('locale');
1078		},
1079		
1080		// GEO LOCATION
1081		// RETURNS COUNTRY (TRUE) OR FALSE->NO GEO
1082		geoLocation: function() {
1083				var obj = this,
1084				    publicGeoIP = document.createElement('iframe');
1085								
1086				publicGeoIP.style.display = 'none';
1087				publicGeoIP.setAttribute('id', 'gr-machine');
1088				
1089				
1090				publicGeoIP.src = 'https://www.claris.com/public/GeoIP';
1091				publicGeoIP.width = 0;
1092				publicGeoIP.height = 0;
1093				document.body.appendChild(publicGeoIP);
1094		},
1095		
1096		// GET DEFAULT COUNTRY BASED ON CURRENT SITE
1097		getDefaultCountry: function() {
1098			return this.countryJSON['country-list']['lang'][this.currentSite]['default'];
1099		},
1100		
1101		// GET LOCALE
1102		getLocale: function() {
1103			var gene = this;
1104			gene.cookie.locale = $.cookie('locale');
1105			
1106			if( gene.cookie.locale ) {
1107				 return gene.cookie.locale;
1108			} else {
1109				 return false;
1110			}
1111		},
1112		
1113		// GET LOCALE COUNTRY
1114		getLocaleCountry: function() {
1115			var gene = this,
1116				  currentLocale = [];
1117			//console.log("test: " + ralph.cookie.locale);
1118			currentLocale = gene.cookie.locale;
1119			if(currentLocale === undefined || currentLocale === null) {
1120				//console.log('currentLocale: undefined');
1121				return '';
1122			} else {
1123			 	return currentLocale.split('-')[1];
1124			}
1125			return false;
1126		},
1127		
1128		// GET GLCOUNTRY
1129		getGLCountry: function() {
1130			var gene = this;
1131			return gene.cookie.glCountry;
1132		},
1133		
1134		// SET GLCOUNTRY
1135		setGLCountry: function(country) {
1136			$.cookie('glCountry', country, { expires: 182, domain: '.claris.com', path: '/' });
1137		},
1138		
1139		// SET LOCALE
1140		setLocale: function(language, country) {
1141			// Cookies.set('locale', language+'-'+country, { expires: 182, domain: '.claris.com', path: '/' });
1142			sitewide.setCookie('locale', language+'-'+country, 182, '.claris.com')
1143		},
1144		
1145		// SET LANGUAGE TAG
1146		setWWWLocale: function(country) {
1147			var gene = this;
1148			//console.log('set locale')
1149			//console.log(country);
1150			gene.wwwLocale.language = gene.currentSite;
1151			gene.wwwLocale.country = country;
1152			//$.cookie('locale', gene.cookie.locale, { expires: 365, domain: '.claris.com', path: '/' });
1153		},
1154		
1155		// RETURNS COUNTRY (TRUE) OR FALSE->NO OVERRIDE SET
1156		countryOverride: function() {
1157				function getQueryParams(key) {
1158						var params = window.location.search.substr(1).split('&');
1159						if (params === '') return '';
1160						var b = {};
1161						for (var i = 0; i < params.length; ++i)
1162						{
1163								var p=params[i].split('=');
1164								if (p.length != 2) continue;
1165								b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); // in the value replace '+' with blank space
1166						}
1167				
1168						if (typeof b[key] === 'undefined') {
1169								return '';
1170						} else {
1171								return b[key];
1172						}
1173				};
1174				
1175				function sanatizeParam(param) {
1176						var whitelist = /^[a-z]/i,
1177										sanatizedParam = '',
1178										i = 0;
1179										
1180						function isWhitelisted(character) {
1181								var j = 0;
1182		
1183								if(whitelist.test(character) === true) {
1184										return true;
1185								}	
1186								return false;
1187						}
1188						
1189						// Iterate through each character in the string
1190						for(i; i < param.length; i=i+1) {
1191							if( isWhitelisted(param[i]) === true ) {
1192								sanatizedParam = sanatizedParam + param[i];
1193							}
1194						}
1195						
1196						return sanatizedParam;
1197				}
1198				
1199				var countryParam = getQueryParams('c');
1200				//console.log(countryParam);
1201				countryParam = sanatizeParam(countryParam);
1202				//console.log(countryParam);
1203				if(countryParam != '') {
1204					 //console.log('return countryParam: '+countryParam);
1205				  return countryParam.toUpperCase();
1206				} else {
1207					 return false;
1208				}
1209		},
1210		
1211		// REMOVES COUNTRY PREFENCE
1212		removeCountryPref: function() {
1213			$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1214		},
1215		
1216		// REMOVES COUNTRY PREFENCE AND LOCALE COOKIE
1217		removeAllCookies: function() {
1218			$.removeCookie('countryPref', { domain: '.claris.com', path: '/' });
1219			$.removeCookie('locale', { domain: '.claris.com', path: '/' });
1220		},
1221		
1222		// CHECK FOR DUPLICATE COOKIES BY NAME
1223		removeDuplicateCookies: function() {
1224			var locale = 'locale',
1225					countryPref = 'countryPref',
1226					cleanupIterations = 0,
1227					pathnameArray = [],
1228					pathname = '',
1229					i;
1230			// IF MULTIPLE COOKIES OF THE SAME NAME ARE SET, ITERATE THROUGH EACH PATH EXPIRING IT EXLUDING THE BASE PATH (/)
1231				
1232			pathnameArray = window.location.pathname.split('/').filter(Boolean);
1233			cleanupIterations = pathnameArray.length;
1234			
1235			for(i=0; i<cleanupIterations;i=i+1) {
1236				pathname += '/'+pathnameArray[i];
1237				//console.log(pathname);
1238				//$.removeCookie('countryPref', { domain: '.claris.com', path: pathname });
1239				//$.removeCookie('locale', { domain: '.claris.com', path: pathname });
1240				//$.removeCookie('countryPref', { domain: 'www.claris.com', path: pathname });
1241				//$.removeCookie('locale', { domain: 'www.claris.com', path: pathname });
1242					
1243				//document.cookie=locale+"=; expires=Thu, 18 Dec 2013 12:00:00 UTC; path="+pathname;
1244				//document.cookie=countryPref+"=; expires=Thu, 18 Dec 2013 12:00:00 UTC; path="+pathname;
1245			}
1246		},
1247		
1248		// DEBUG DISPLAY
1249		displayCookies: function() {
1250			 var gene = this,
1251					wwwLocale = gene.wwwLocale,
1252					country = $.cookie('country');
1253								//debug = document.createElement('div');
1254								//debug.style.position = 'fixed';
1255								//debug.style.zIndex =  '99999999';
1256								//$(debug).attr('id', 'gr-debug-display');
1257								
1258				//console.log(gene.cookie);
1259				//$(debug).prepend('<p style="margin: 0px">locale: '+locale+'</p>');
1260				//$(debug).prepend('<p style="margin: 0px">countryPref: '+countryPref+'</p>');
1261				
1262				$('#sidebar .cookie-results').append('<p style="margin: 0px">locale: '+$.cookie('locale')+'</p>');
1263				$('#sidebar .cookie-results').append('<p style="margin: 0px">glCountry: '+$.cookie('glCountry')+'</p>');
1264				
1265				if(!country) {
1266					 country = 'n/a';
1267				}
1268			 //$(debug).prepend('<p style="margin: 0px">country: '+country+'</p>');
1269				$('#sidebar .cookie-results').append('<p style="margin: 0px">country: '+country+'</p>');
1270				$('#sidebar .cookie-results').append('<h2 style="margin-top:10px;">www Variables</h2>');
1271				$('#sidebar .cookie-results').append('<p style="margin: 0px">wwwLocale.language: '+wwwLocale.language+'</p>');
1272				$('#sidebar .cookie-results').append('<p style="margin: 0px">wwwLocale.country: '+wwwLocale.country+'</p>');
1273				//$('body').prepend(debug);
1274		},
1275		
1276		postRun: function(ralph, wwwLocale) {
1277			var gene = this;
1278			ralph.run(wwwLocale);
1279			
1280			//gene.displayCookies();
1281		},
1282		
1283		run: function(ralph) {
1284				var locale,
1285					gLocation,
1286					gene = this,
1287					gLocationRun = false,
1288					cOverride;
1289				
1290				gene.conversion(); // clean up cookies from old to new gene convert them from _ to -
1291				// expire old gene/ralph cookies
1292				// gene.removeDuplicateCookies(); // maybe remove
1293				gene.initEventListners(); // OKAY, REMOVED LISTENERS
1294				// CHECK IF THERE IS OVERRIDE IN PARAMETER
1295	
1296				gene.getCookies();
1297	
1298				// CHECK IF LOCALE IS SET
1299				locale = gene.getLocale(); // locale cookie or false
1300				// console.log(locale)
1301				gLocation = gene.getGLCountry(); // geolocation cookie or false
1302				cOverride = gene.countryOverride();
1303				// console.log(gene.getLocaleCountry())
1304				if (cOverride && gene.isValidCountry(cOverride)) {
1305						gene.setLocale(gene.currentLocaleLanguage(), cOverride);
1306						gene.setWWWLocale(cOverride);
1307						gene.postRun(ralph, gene.wwwLocale);
1308						return this;
1309				} else if(locale && gene.isValidCountry(gene.getLocaleCountry())) { // LOCALE IS SET, VALID COUNTRY
1310					// display country specific content
1311					gene.setWWWLocale(gene.getLocaleCountry());
1312					gene.postRun(ralph, gene.wwwLocale);
1313					return this;
1314				} else if (locale) { // LOCAL SET, NOT VALID COUNTRY
1315					// display language site default country content
1316					gene.setWWWLocale(gene.getDefaultCountry());
1317					gene.postRun(ralph, gene.wwwLocale);
1318					return this;
1319				} else if(gLocation && gene.isValidCountry(gLocation)) { // GEOLOCATION IS SET, VALID COUNTRY
1320					// Geolocation cookie is set
1321					gene.setWWWLocale(gLocation);
1322					gene.postRun(ralph, gene.wwwLocale);
1323					return this;
1324				} else {
1325					// Set to Default
1326					gene.setWWWLocale(gene.getDefaultCountry());
1327					gene.postRun(ralph, gene.wwwLocale);
1328					return this;
1329				}
1330				
1331				/*} else { // RUN GEOLOCATION
1332					// Run geolocation
1333					gene.geoLocation();
1334					gLocationRun = true;
1335				  //$('#gr-machine').load(function() {
1336					$('#gr-machine').on('load', function() {
1337							// UPDATE COOKIE ONCE IFRAME IS LOADED
1338							//$.cookie('country', 'DE', { expires: 365, domain: '.claris.com', path: '/' }); // Test Injection
1339						  gene.cookie.country = $.cookie('country');
1340							gLocation = gene.cookie.country;
1341							if(gLocation && gene.isValidCountry(gLocation)) {
1342								// Set GeoLocation Cookie
1343								gene.setGLCountry(gLocation);
1344								gene.setWWWLocale(gLocation);
1345								
1346								gene.postRun(ralph, gene.wwwLocale);
1347								return this;
1348							} else {
1349								// Set to Default
1350								gene.setWWWLocale(gene.getDefaultCountry());
1351								
1352								gene.postRun(ralph, gene.wwwLocale);
1353								return this;
1354							}
1355				  });
1356				}*/
1357//				gene.postRun(ralph, gene.wwwLocale);
1358				
1359				return this;
1360		}
1361	
1362};
1363
1364function setMaxPricing(){
1365	$.ajax({
1366		url: '/pricing/includes/data/server_pricing.json',
1367		dataType: 'json',
1368		success: function( data ) {
1369			var locale = $('body').attr('gr-locale')
1370			if(data[locale]){
1371				$('.op-price-offering-2').html(data[locale]).css('white-space','nowrap')
1372			} else {
1373				$('.op-price-offering-2').html(data['en-US']).css('white-space','nowrap')
1374			}
1375		},
1376		error: function( data ) {
1377			$('.op-price-offering-2').html(data['en-US']).css('white-space','nowrap')
1378		}
1379	});
1380}
1381
1382// INITIALIZE GENE AND RALPH
1383jQuery(function($) {
1384	 $.when(
1385		  $.getJSON('/interactive/themes/beacon/localization-gr/includes/country-list.json')
1386  ).then(function(countryJSON) {
1387				geneFM = new Gene(countryJSON, jQuery);
1388				ralphFM = new Ralph(countryJSON, jQuery);
1389				
1390				$.when( geneFM.run(ralphFM) ).done(function() {
1391					geneFM.displayCookies();
1392				});
1393				setMaxPricing();
1394		});
1395	 
1396});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.