var tooltipTimeout;

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} 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;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function closeTooltip()
{
	document.getElementById('tip').style.display = "none";
}

function showTooltip(n)
{
	
	clearTimeout(tooltipTimeout);
	
	document.getElementById('tip').style.display = "block";	
	
	var t = document.getElementById('tip');
	
	switch (n)
	{
		
		case 0:
			t.innerHTML = "Trwa dodawanie, proszę czekać...";
			t.style.display = "block";	
		break;
		
		case 1:
			t.innerHTML = "Produkt został dodany do koszyka";
			t.style.display = "block";	
		break;
		
		case 2:
			t.innerHTML = "Trwa logowanie, proszę czekać...";
			t.style.display = "block";
		break;
		
		case 3:
			t.innerHTML = "Logowanie przebiegło prawidłowo";
			t.style.display = "block";
			break;
			
		case 4:
			t.innerHTML = "Nieprawidłowy login lub hasło...";
			t.style.display = "block";
			break;
			
		case 5:
			t.innerHTML = "Podaj login i hasło do konta";
			t.style.display = "block";
			break;
			
		case 6:
			t.innerHTML = "Trwa wylogowywanie użytkownika...";
			t.style.display = "block";
			break;		
			
		case 7:
			t.innerHTML = "Użytkownik wylogowany...";
			t.style.display = "block";
			break;		
		case 8:
			t.innerHTML = "Szukana fraza musi zawierać minimum 3 znaki";
			t.style.display = "block";
			break;			
		
	}
	/*
		if(n==0)
	}
		document.getElementById('tip1').style.display = "none";	
	else
		document.getElementById('tip0').style.display = "none";
	
	/*if(n==0)
		tooltipTimeout = setTimeout(function(){
				closeTooltip(n);
				},3000);
*/
}	
	


function ruch_komunikatu(zdarzenie) {

	var arrayPageSize = getPageSize();
	var szerokosc = arrayPageSize[0];	
	
  zdarzenie = (zdarzenie)?zdarzenie:((window.event)?event:null);
  m = document.getElementById("tooltip");
  
  if (zdarzenie.clientX>szerokosc-300)
  {
  m.style.left=zdarzenie.clientX-238+document.body.scrollLeft + "px";
  }
  else
  {
  m.style.left=zdarzenie.clientX+15+document.body.scrollLeft + "px";
  }
  
 var y=0;
	if (self.pageYOffset) // all except Explorer
	{
		y = self.pageYOffset;
	}
	else 
		// Explorer 6 Strict
	{
		y = document.documentElement.scrollTop;
	}

  m.style.top=zdarzenie.clientY+10+y + "px";
}

