document.domain = 'gala.de';

// TAAZ API calls
function getUserName() {
  //taazCookie = readCookie('taaz_username');
  //if (taazCookie != null) return taazCookie;
  taazCookie = readCookie('taaz');
  if (taazCookie != null) return taazCookie.split('|')[2];
  return null;
}

function login() {
  location.href = "http://www.gala.de/beauty_fashion/beauty/50552/StarStyler-StarStyler.html?sso_action=login";
}

function logout() {
  eraseCookie('taaz');
	eraseCookie('taaz_username');
  eraseCookie('GALA_uid');
  location.href = "http://www.gala.de/beauty_fashion/beauty/50552/StarStyler-StarStyler.html?sso_action=logout";
}

// Layer utils
function startMakeover() {
  document.getElementById("makeoverlanding").style.visibility = "hidden";
}

// Cookie Utils
function getGalaUserName() {
  noNameCookie = getNoNameCookie();
  if (noNameCookie != null) return noNameCookie.split('|')[2];
  uidCookie = readCookie('GALA_uid');
  if (uidCookie != null) return uidCookie;
  return null;
}

function getNoNameCookie() {
  c = unescape(document.cookie);
  c = c.match(/ [0-9]+[\|][\w]+[\|][\w.@-]+[\|][0-1][\|]/g);
  if (c != null) c = c[0].replace(/^\s+/,'');
  return c;
}

function createCookie(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 readCookie(name) {
  var nameEQ = name + "=";
  var ca = unescape(document.cookie).split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}

