function translateTo(language)
{
  location.href = location.pathname + "#mstto=" + language;
  location.reload();

  return false;
}

function translated()
{
  return getCookie("mstmode") && getCookie("mstmode") != "manual" ||
         String(document.location).indexOf("#mstto=") > -1;

}

function switchCssIfTranslated(css)
{
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
    if(a.getAttribute("rel").indexOf("style") != -1 &&
       a.getAttribute("title"))
      if(a.getAttribute("title") == css) a.disabled = !translated();
}

function shiftIfTranslated(newattrs)
{
  if(translated())
  {
    //alert("i've had it with shifting");
    for(var i=0; i<newattrs.length; i+=2)
    {
      var property = newattrs[i].split(".");
      var e = document.getElementById(property[0]);
      if(!e) e = document.getElementsByTagName(property[0])[0];
      //alert(e + "." + property[1] + "=" + e.style[property[1]]);
      e.style[property[1]] = newattrs[i+1];
    }
  }
}
