function GetLanguage() {
	var language = GetCountry();
	var fromArray = new Array("UK","IE","BE"   ,"CH",   "ND",   "CE");
	var toArray   = new Array("EN","IE","BE-NL","CH-DE","ND-SE","CE-PL");
		for (i = 0; i < fromArray.length; i++) {
			if (fromArray[i] == language) {
				language=toArray[i];
			}
		}
	return language.toLowerCase();
}



function GetCountry() {
	var country = "UK";
	var url = document.location.toString();

	var genericArray = new Array(
		/^https?:\/\/(.{2})\./, /toshiba-(.{2})\./, /toshibacsg-(.{2})\./,
		/comp(.{2})\.stage/
	);

	for (i = 0; i < genericArray.length; i++) {
		var results = genericArray[i].exec(url);
		if (results != null && results.length == 2)
			return results[1].toUpperCase();
	}

	var testArray = new Array(
		new Array("ae", /^https?:\/\/gulf\./, /compgulf\.stage/),
		new Array("nd", /^https?:\/\/nordic\./, /compnordic\.stage/),
		new Array("ce", /^https?:\/\/ce\./, /compce\.stage/),
		new Array("se", /^https?:\/\/se\./, /compse\.stage/),
		new Array("il", /^https?:\/\/il\./, /compil\.stage/)
	);

	for (i=0; i<testArray.length; i++) {
		for (j=1; j<testArray[i].length; j++) {
			if (testArray[i][j].exec(url) != null)
				return testArray[i][0].toUpperCase();
		}
	}

	return country.toUpperCase();
}

function GetCountryList() {
	var country = GetCountry();
	
	var testArray = new Array(
		new Array("ch", new Array("CH-DE", "CH-FR")),
		new Array("be", new Array("BE-NL", "BE-FR")),
        new Array("nd", new Array("ND-SE", "ND-FI", "ND-NO", "ND-DK")),
        new Array("ce", new Array("CE-PL", "CE-CS", "CE-SK", "CE-HU")),
        new Array("se", new Array("SE-TR", "SE-BG", "SE-RO", "SE-GR")),
        new Array("bl", new Array("BL-SI", "BL-HR", "BL-RS")),
        new Array("ae", new Array("AE-EN", "AE-AR")), 
        new Array("il", new Array("IL-EN", "IL-HE"))
	);
	
	for (i = 0; i < testArray.length; i++) {
		if (country == testArray[i][0].toUpperCase())
			return testArray[i][1];
	}
	
	return new Array(country);
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Mon, 01-Jan-2001 00:00:01 GMT";
}


function isCookieEnabled() {
	Set_Cookie('temp','temp');
	var temp = Get_Cookie('temp');
	if (!temp) {      
		return false;
	}
	else {
		return true;
	}
}

function isOutdatedBrowser() {
	var agent = navigator.userAgent.toLowerCase();
	
	var isOpera = (agent.indexOf("opera") != -1);
	var isGecko = (!isOpera) && (agent.indexOf("gecko/") != -1);
	var isNS = (!isOpera && !isGecko) && ((agent.indexOf("mozilla") != -1) && (agent.indexOf("spoofer") == -1) && (agent.indexOf("compatible") == -1));
	var isIE = (agent.indexOf('msie') != -1 && !isOpera && (agent.indexOf('webtv') == -1) ); 

	var versionMinor = parseFloat(navigator.appVersion); 
	var ieVersion = -1;
	if (isIE && versionMinor >= 4) {
      		ieVersion = parseInt( agent.substring( agent.indexOf('msie ') + 5 ) );
	}

	
	if (isNS && (parseFloat(navigator.appVersion) < 5))
		return true;
	else if (isIE && (ieVersion < 5)) {
		return true;
	}
	else
		return false;
}

