/*SET LANGUAGE COOKIE FOR BRAND-REX*/
/*COPYRIGHT 2009-2010 BRAND-REX*/
/*CODING: MIKE PALMER*/

var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function deleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getLang() {
Lang = getCookie('Language');
	switch (Lang) {
	case 'EN': window.location="http://www.brand-rex.com/login_en/redirect_en.html"; break;
	case 'EN_SP': window.location="http://www.brand-rex.com/login_en/redirect_en_spec.html"; break;
	case 'ES': window.location="http://www.brand-rex.es/login_es/redirect_es.html"; break;
	case 'DE': window.location="http://www.brand-rex.de/login_de/redirect_de.html"; break;
	case 'FR': window.location="http://www.brand-rex.fr/login_fr/redirect_fr.html"; break;
	case 'RU': window.location="http://www.brand-rex.ru/login_ru/redirect_ru.html"; break;
	case 'PT': window.location="http://pt.brand-rex.com/login_pt/redirect_pt.html"; break;
	case 'NL': window.location="http://nl.brand-rex.com/login_nl/redirect_nl.html"; break;
	case 'IT': window.location="http://www.brand-rex.it/login_it/redirect_it.html"; break;
	case 'CN': window.location="http://cn.brand-rex.com/login_cn/redirect_cn.html"; break;
	case 'PL': window.location="http://pl.brand-rex.com/login_pl/redirect_pl.html"; break;
	}
}

function getBRMain() {
Main = getCookie('Language');
	switch (Main) {
	case 'EN': window.location="http://www.brand-rex.com/Home/tabid/105/language/en-GB/Default.aspx"; break;
	case 'EN_SP': window.location="http://www.brand-rex.com/MarketSolutions/SpecialityCables/tabid/1404/language/en-GB/Default.aspx"; break;
	case 'ES': window.location="http://www.brand-rex.es/Home/tabid/2353/language/es-ES/Default.aspx"; break;
	case 'DE': window.location="http://www.brand-rex.de/Home/tabid/1824/language/de-DE/Default.aspx"; break;
	case 'FR': window.location="http://www.brand-rex.fr/Home/tabid/2075/language/fr-FR/Default.aspx"; break;
	case 'RU': window.location="http://www.brand-rex.com/Home/tabid/105/language/en-GB/Default.aspx"; break;
	case 'PT': window.location="http://pt.brand-rex.com/Home/tabid/2892/language/pt-PT/Default.aspx"; break;
	case 'NL': window.location="http://nl.brand-rex.com/Home/tabid/1134/language/nl-NL/Default.aspx"; break;
	case 'IT': window.location="http://www.brand-rex.it/Home/tabid/618/language/it-IT/Default.aspx"; break;
	case 'CN': window.location="http://cn.brand-rex.com/%E4%B8%BB%E9%A1%B5/tabid/876/Default.aspx"; break;
	case 'PL': window.location="http://pl.brand-rex.com/Home/tabid/3273/Default.aspx"; break;
	}
}