function win(sirka,vyska,url)
{
  msg=window.open(url,'max',"toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no,status=no,width="+sirka+",height="+vyska+",top=50,left=50");
  return true;
}

function writeCookie() 
{
  var today = new Date();
  var the_date = new Date("December 31, 2099");
  var the_cookie_date = the_date.toGMTString();
  var the_cookie = "myWidth="+ window.screen.availWidth;
  var the_cookie = the_cookie + ";expires=" + the_cookie_date;
  document.cookie=the_cookie
}

function showHide(ID,PID)
{
  if ($(ID).visible() == false)
    new Effect.Appear(ID);
  else
    new Effect.Fade(ID);
}

function checkEnter(e)
{
  var characterCode;

  if (e && e.which)
    characterCode = e.which;
  else
    characterCode = event.keyCode;

  return characterCode == 13;
}

function changeField()
{
  document.getElementById("passwordbox").innerHTML = "<input class=\"text\" id=\"password\" type=\"password\" name=\"password\" value=\"\" onfocus=\"this.value=''\">";
  setTimeout("document.getElementById(\"password\").focus();", 10);
}

function showTooltip(text)
{
  if (!$("tooltip")) {
    var div = document.createElement("div");
    div.setAttribute("id", "tooltip");
    div.style.display = "none";
    document.getElementsByTagName("body")[0].appendChild(div);
  }

  if (text > "") {
    document.onmousemove = followMouse;
    $("tooltip").innerHTML = text;
    $("tooltip").show();
  }
}

function hideTooltip()
{
  $("tooltip").style.left = "-1000px";
  $("tooltip").hide();
  document.onmousemove = "";
}

function followMouse(e)
{
  if (document.all) {
    xMousePos = window.event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft);
    yMousePos = window.event.clientY + (document.documentElement.scrollTop || document.body.scrollTop);
  } else {
    xMousePos = e.pageX;
    yMousePos = e.pageY;
  }

	if (self.innerHeight) {	// all except Explorer
		if (document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else {
			windowWidth = self.innerWidth;
			windowHeight = self.windowHeight;
		}
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

  if (xMousePos + $("tooltip").offsetWidth > windowWidth + (document.documentElement.scrollLeft || document.body.scrollLeft))
    xMousePos = windowWidth + (document.documentElement.scrollLeft || document.body.scrollLeft) - $("tooltip").offsetWidth;

  if (yMousePos + 24 + $("tooltip").offsetHeight > windowHeight + (document.documentElement.scrollTop || document.body.scrollTop))
    yMousePos = yMousePos - 36 - $("tooltip").offsetHeight;

  $("tooltip").style.left = xMousePos + "px";
  $("tooltip").style.top = yMousePos + 24 + "px";
}

function addProduct(alias, count)
{
  new Ajax.Request("/shop_cart_modify.php?add_product=" + alias + "&count=" + count, {
    onSuccess: function(transport) {
	  //alert(alias);
      $('cart').innerHTML = transport.responseText;
    }
  });
}

writeCookie();