// *******************************  Site Catalyst Code Start ************************//

function getLanguageCode() {
	var path = location.href;
	//var pattern = /(\w+):\/\/([\w.:]+)\/(\w*)/;
	var pattern = /\/([a-z]{2})\/[A-Z]{2}\//;
	var new_path = path.match(pattern);

	if (new_path && new_path[1]) {
		return new_path[1];
	} else if (path.indexOf("lCode") >= 0) {
		pattern = /lCode\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "en";
	} else if (path.indexOf("&ln=") >= 0 || path.indexOf("?ln=")) {
		pattern = /[\&\?]ln\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "en";
	}
}

function getCountryCode() {
	var path = location.href;
	//var pattern = /(\w+):\/\/([\w.:]+)\/(\w*)\/(\w*)/;
	var pattern = /\/[a-z]{2}\/([A-Z]{2})\//;
	var new_path = path.match(pattern);

	if (new_path && new_path[1]) {
		return new_path[1];
	} else if (path.indexOf("cCode") >= 0) {
		pattern = /cCode\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "US";
	} else if (path.indexOf("&ln=") >= 0 || path.indexOf("?ln=")) {
		pattern = /[\&\?]ln\=(\w{2})_(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[2] && new_path[2].length == 2) ? new_path[2] : "US";
	}
}

var localeDetails = new Array();
localeDetails[localeDetails.length] = {ccode:"US", lcode:"en", cname:"United States", region:"AMERICAS", language:"English"};
localeDetails[localeDetails.length] = {ccode:"UK", lcode:"en", cname:"United Kingdom", region:"EMEA", language:"English"};
localeDetails[localeDetails.length] = {ccode:"IT", lcode:"it", cname:"Italy", region:"EMEA", language:"Italian"};
localeDetails[localeDetails.length] = {ccode:"ES", lcode:"es", cname:"Spain", region:"EMEA", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"KR", lcode:"ko", cname:"Korea", region:"ASIA PACIFIC", language:"Korean"};
localeDetails[localeDetails.length] = {ccode:"DK", lcode:"da", cname:"Denmark", region:"EMEA", language:"Danish"};
localeDetails[localeDetails.length] = {ccode:"AT", lcode:"de", cname:"Austria", region:"EMEA", language:"German"};
localeDetails[localeDetails.length] = {ccode:"CH", lcode:"de", cname:"Switzerland", region:"EMEA", language:"German"};
localeDetails[localeDetails.length] = {ccode:"DE", lcode:"de", cname:"Germany", region:"EMEA", language:"German"};
localeDetails[localeDetails.length] = {ccode:"AU", lcode:"en", cname:"Australia", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"CA", lcode:"en", cname:"Canada", region:"AMERICAS", language:"English"};
localeDetails[localeDetails.length] = {ccode:"FI", lcode:"en", cname:"Finland", region:"EMEA", language:"English"};
localeDetails[localeDetails.length] = {ccode:"HK", lcode:"en", cname:"Hong Kong", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"ID", lcode:"en", cname:"Indonesia", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"IL", lcode:"en", cname:"Israel", region:"EMEA", language:"English"};
localeDetails[localeDetails.length] = {ccode:"IN", lcode:"en", cname:"India", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"ME", lcode:"en", cname:"Middle East", region:"EMEA", language:"English"};
localeDetails[localeDetails.length] = {ccode:"MY", lcode:"en", cname:"Malaysia", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"NZ", lcode:"en", cname:"New Zealand", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"PH", lcode:"en", cname:"Philippines", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"SG", lcode:"en", cname:"Singapore", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"SL", lcode:"en", cname:"Sri Lanka", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"TH", lcode:"en", cname:"Thailand", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"VN", lcode:"en", cname:"Vietnam", region:"ASIA PACIFIC", language:"English"};
localeDetails[localeDetails.length] = {ccode:"ZA", lcode:"en", cname:"South Africa", region:"EMEA", language:"English"};
localeDetails[localeDetails.length] = {ccode:"AR", lcode:"es", cname:"Argentina", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"BO", lcode:"es", cname:"Bolivia", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"CB", lcode:"es", cname:"Caribbean/Central America", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"CL", lcode:"es", cname:"Chile", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"CO", lcode:"es", cname:"Colombia", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"EC", lcode:"es", cname:"Ecuador", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"MX", lcode:"es", cname:"Mexico", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"PE", lcode:"es", cname:"Peru", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"UY", lcode:"es", cname:"Uruguay", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"VE", lcode:"es", cname:"Venezuela", region:"AMERICAS", language:"Spanish"};
localeDetails[localeDetails.length] = {ccode:"CA", lcode:"fr", cname:"Canada", region:"AMERICAS", language:"French"};
localeDetails[localeDetails.length] = {ccode:"FR", lcode:"fr", cname:"France", region:"EMEA", language:"French"};
localeDetails[localeDetails.length] = {ccode:"JP", lcode:"ja", cname:"Japan", region:"JAPAN", language:"Japanese"};
localeDetails[localeDetails.length] = {ccode:"NL", lcode:"nl", cname:"The Netherlands", region:"EMEA", language:"Dutch"};
localeDetails[localeDetails.length] = {ccode:"NO", lcode:"no", cname:"Norway", region:"EMEA", language:"Norwegian"};
localeDetails[localeDetails.length] = {ccode:"PL", lcode:"pl", cname:"Poland", region:"EMEA", language:"Polish"};
localeDetails[localeDetails.length] = {ccode:"BR", lcode:"pt", cname:"Brazil", region:"AMERICAS", language:"Portuguese"};
localeDetails[localeDetails.length] = {ccode:"RU", lcode:"ru", cname:"Russia", region:"EMEA", language:"Russian"};
localeDetails[localeDetails.length] = {ccode:"SE", lcode:"sv", cname:"Sweden", region:"EMEA", language:"Swedish"};
localeDetails[localeDetails.length] = {ccode:"CN", lcode:"zh", cname:"China", region:"ASIA PACIFIC", language:"Chinese"};
localeDetails[localeDetails.length] = {ccode:"TW", lcode:"zh", cname:"Taiwan", region:"ASIA PACIFIC", language:"Chinese"};

for(var i = 0; i < localeDetails.length; i++) {
	localeDetails[localeDetails[i].ccode + "_" + localeDetails[i].lcode] = localeDetails[i];
}

function getCountryName(cCode, lCode, array) {
	if(cCode != null && cCode != "" && lCode != null && lCode != "") {
		//alert("Country Name - " + array[cCode + "_" + lCode].cname);
		return array[cCode + "_" + lCode].cname;
	}
}

function getRegionName(cCode, lCode, array) {
	if(cCode != null && cCode != "" && lCode != null && lCode != "") {
		//alert("Region - " + array[cCode + "_" + lCode].region);
		return array[cCode + "_" + lCode].region
	}
}

function getLanguageName(cCode, lCode, array) {
	if(cCode != null && cCode != "" && lCode != null && lCode != "") {
		//alert("Language - " + array[cCode + "_" + lCode].language);
		return array[cCode + "_" + lCode].language;
	}
}

//get the country code
var countryCode = getCountryCode();
var languageCode = getLanguageCode();

if (location.href.indexOf("/vsupport-jp/") >= 0) {
	countryCode = "JP";
	languageCode = "ja";
}

if(countryCode == null || countryCode == "" || languageCode == null || languageCode == "") {
	countryCode = "US";
	languageCode = "en";
}

s_prop1 = getRegionName(countryCode, languageCode, localeDetails);
s_prop2 = getCountryName(countryCode, languageCode, localeDetails);
s_prop3 = getLanguageName(countryCode, languageCode, localeDetails);

if (location.href.indexOf("/press/") >= 0 || location.href.indexOf("/news/") >= 0) {
	s_channel = "Press Room";
} else if (location.href.indexOf("/partner/") >= 0 || location.href.indexOf("/PartnerNetwork/") >= 0 || location.href.indexOf("/Products/vpn") >= 0 || location.href.indexOf("/vsupport-jp/") >= 0) {
	s_channel = "Partners";
} else if (location.href.indexOf("/education/") >= 0 || location.href.indexOf("/education.veritas.com/") >= 0) {
	s_channel = "Education";
} else if (location.href.indexOf("/events/") >= 0) {
	s_channel = "Events";
} else if (location.href.indexOf("/consulting/") >= 0) {
	s_channel = "Consulting";
} else if (location.href.indexOf("/van/") >= 0 || location.href.indexOf("/Products/van") >= 0) {
	s_channel = "VAN";
} else if (location.href.indexOf("/jobs/") >= 0) {
	s_channel = "Jobs";
} else if (location.href.indexOf("/investors/") >= 0) {
	s_channel = "Investor Relations";
} else if (location.href.indexOf("/products/") >= 0 || location.href.indexOf("/Products/www") >= 0) {
	s_channel = "Products";
} else if (location.href.indexOf("/support/") >= 0) {
	s_channel = "Support";
} else if (location.href.indexOf("/aboutus/") >= 0 || location.href.indexOf("/company/") >= 0 || location.href.indexOf("/publishing/") >= 0 || location.href.indexOf("/contact/") >= 0 || location.href.indexOf("/contactus/") >= 0) {
	s_channel = "Company Information";
} else if (location.href.indexOf("/Products/media") >= 0) {
	s_channel = "Interactive";
} else if (location.href.indexOf("/buy/") >= 0) {
	s_channel = "Store";
}

// *******************************  Site Catalyst Code End ************************//