function setLocation(uid) {
	var target = "index.php?" + uid;
	window.location.href = target;
}

var fOld = window.onload || function () {};
window.onload = function() {
	fOld();
	var aEls = document.getElementsByTagName('a');
	for (var i = 0; i < aEls.length; i++)
		aEls[i].onfocus = function(){ this.blur(); };
};

var version;

$(function () {
  
  var root = $("#language-switch")
      .css({
        "border": "1px solid #BDC0C9",
        "overflow": "hidden",
        "width": "85px",
        "height": "15px",
        "padding": "0",
        "position": "absolute",
        "background": "#FFFFFF"
      }),
      show = function () {
        root.css({
          "width": "105px",
          "top": "-1px",
          "left": "-10px",
          "height": "auto",
          "box-shadow": "0 2px 8px 0 #666666"
        }).find("li").css({
          "margin-top": "0",
          "margin-left": "0",
        });
      },
      hide = function () {
        root.css({
          "width": "85px",
          "top": "4px",
          "left": "0",
          "height": "15px",
          "box-shadow": "none"
        }).find("li").css({
          "margin-top": "-5px",
          "margin-left": "-10px",
        });
      };
  
  $("li.language-switch-current", root).prependTo(root);
  
  $("a", root).each(function () {
    var link;
    $("<span></span>")
      .text($("img", this).attr("title"))
      .appendTo(this);
    $(this).css({
      "display": "block",
      "padding": "6px 12px",
      "text-decoration": "none"
    });
    $(this).closest("li").css({
      "display": "block",
      "margin-top": "-5px",
      "margin-left": "-10px",
      "text-align": "left"
    });
    $("img", this).css("vertical-align", "-1px");
    if (window.pid) {
      link = $(this).attr("href");
      link += "&id=" + window.pid;
      $(this).attr("href", link);
    }
  });
  
  $("li", root).not(":last").css({
    "border-bottom": "1px solid #DDDDDD"
  });
  
  root.mouseenter(show);
  root.mouseleave(hide);
  // Use click event for touch screen clients
  $("li.language-switch-current a", root).click(function (event) {
    event.preventDefault();
    show();
  });
  
});
