function getLocaleCode() {
	var localeCode = "";
	if (navigator) {
		if (navigator.language) {
			localeCode = navigator.language;
		} else if (navigator.browserLanguage) {
			localeCode = navigator.browserLanguage;
		} else if (navigator.systemLanguage) {
			localeCode = navigator.systemLanguage;
		} else if (navigator.userLanguage) {
			localeCode = navigator.userLanguage;
		}
	}
	return localeCode;
}

function getCountryCode() {
	var localeCode = getLocaleCode();
	var langCode = "";
	var countryCode = "";
	re=/(\w+)-(\w+)/i
	if (localeCode.match(re)) {
		langCode = RegExp.$1;
		countryCode = RegExp.$2.toUpperCase();
	}
	return countryCode;
}

function mapRegion(in1) {
	var countriesNA = new Array("CA", "US", "UM");
	var countriesEMEA = new Array("AT", "BE", "CZ", "DK", "FI", "FR", "DE", "HU", "IE", "IT", "LU", "NL", "AN", "NO", "PL", "PT", "RU", "ES", "SE", "CH", "GB");
	var countriesLA = new Array("CL", "MX");
	var countriesAP = new Array("CN", "HK", "IN", "JP", "KP", "KR", "NZ", "AU");
	var cmJSPath = "http://www.reebok.com/coremetrics/";
	var regionCode = "";
	for (i=0; i<countriesNA.length; i++) {
		if (countriesNA[i] == in1) {
			regionCode = "NORTH_AMERICA";
		}
	}
	if (regionCode.length == 0) {
		for (i=0; i<countriesEMEA.length; i++) {
			if (countriesEMEA[i] == in1) {
				regionCode = "EMEA";
			}
		}
	}
	if (regionCode.length == 0) {
		for (i=0; i<countriesLA.length; i++) {
			if (countriesLA[i] == in1) {
				regionCode = "LATIN_AMERICA";
			}
		}
	}
	if (regionCode.length == 0) {
		for (i=0; i<countriesAP.length; i++) {
			if (countriesAP[i] == in1) {
				regionCode = "ASIA_PACIFIC";
			}
		}
	}
	if (regionCode.length == 0) {
		regionCode = "ASIA_PACIFIC"; // default
	}
	document.write('<sc'+'ript src="'+cmJSPath+regionCode+'/v40/eluminate.js" type="text/javascript"></sc'+'ript>');
	document.write('<sc'+'ript src="'+cmJSPath+regionCode+'/cmdatatagutils.js" type="text/javascript"></sc'+'ript>');
}

function setDivLocaleCode() {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById("localeCode").innerHTML=xmlHttp.responseText.toUpperCase();
		}
	}
	xmlHttp.open("GET","acceptlanguage.asp",true);
	xmlHttp.send(null);
}

function createPageViewTag(in1, in2) {
	var countryCode = document.getElementById("localeCode").innerHTML;
	//alert("cmCreatePageviewTag(\""+countryCode+": "+in1+"\", \"/"+countryCode+"/runtaikan/"+in2+"\");");
	cmCreatePageviewTag("\""+countryCode+": "+in1+"\"", "\"/"+countryCode+"/runtaikan/"+in2+"\"");
}

function createPageElementTag(in1, in2) {
	var countryCode = document.getElementById("localeCode").innerHTML;
	//alert("cmCreatePageElementTag(\""+countryCode+": "+in1+"\", \"/"+countryCode+"/runtaikan/"+in2+"\");");
	cmCreatePageElementTag("\""+countryCode+": "+in1+"\"", "\"/"+countryCode+"/runtaikan/"+in2+"\"");
}

function createConversionEventTag(in1, in2, in3, in4) {
	var countryCode = document.getElementById("localeCode").innerHTML;
	//alert("cmCreateConversionEventTag(\""+countryCode+": "+in1+"\", \""+in2+"\", \"/"+countryCode+"/runtaikan/"+in3+"\", \""+in4+"\");");
	cmCreateConversionEventTag("\""+countryCode+": "+in1+"\"", "\""+in2+"\"", "\"/"+countryCode+"/runtaikan/"+in3+"\"", "\""+in4+"\"");
}