function myCountryCode() {
	var set = {};
	
	if (!$.cookie("apex__country")){
		$('.footerTopLinks .countries .countryLang').each(
		   function(index,elem){
			  var cc = $(elem).attr('data-country-code');
			  set[cc]= true;
		   });
		
		
		jQuery.ajax( { 
			url: '//freegeoip.net/json/', 
			type: 'POST', 
			dataType: 'jsonp',
			success: function(location) {
				
				
				if (location.country_code && location.country_code in set )
					updateCookie('country',location.country_code);
				else
					updateCookie ('country','INT');
			}
		} );
	}
	
	updateCookie ('language', $('#languageNameCode').text());
	
	
}

function updateCookie(cookieName , cookieValue){ 
		var date = new Date();
		date.setTime(date.getTime()+(365*10*24*60*60*1000));   //set expire 10 years
		if(cookieValue){
				document.cookie = 'apex__'+cookieName+'='+cookieValue + ';' + 'path=/; expires=' +date.toGMTString(); +';'
		}			
}

myCountryCode();
