//--------------------------------------------------------------------
// v1.0
	function zaokraglij( liczba )
	{
		return Math.round( liczba * 100 ) / 100 ;
	}
//-----------------------------------------------------------------------
// v1.0
function odwrotnyVAT( vat )
{
	return zaokraglij1( vat / ( 1 + vat) , 4) ;
}
//--------------------------------------------------------------------
// v1.0
	function zaokraglij1( liczba , miejsce )
	{   // miejsce - do ktorego miejsca po przecinku zaokraglic
      // zak�adam, �e miejsce jest liczb� ca�kowit�

		var mnoznik = 1 ;

		for( var i = 0 ; i < miejsce ; i++)
		{                // 10 ^ miejsce
			mnoznik *= 10 ;
		}

		return Math.round( liczba * mnoznik ) / mnoznik ;
	}
//-----------------------------------------------------------
// v1.0
function kwota( liczba )
{

	var tekst_kwoty  = Math.floor( liczba ) + '.'  ;  // obetnij cz�� po przecinku

	liczba      = zaokraglij(liczba * 100)          ;
	var reszta   = liczba % 100 ;     // reszta z dzielenia

	if( reszta == 0)
	    return tekst_kwoty + '00'  ;

 	if( reszta >= 10)
		return tekst_kwoty + reszta ;

  if( reszta < 10 )
		return tekst_kwoty + '0' + reszta ;

	return '' ;

}

//-------------------------------------------------------------------
// v1.0
function formatuj(tekst , szerokosc , wyrownanie)
{
	tekst = tekst + '' ;
	if( tekst.length >= szerokosc)
	{
		return tekst.substring(0 , szerokosc ) ;
	}

	if( wyrownanie == 'do_lewej' )
		return tekst + spacje( szerokosc - tekst.length ) ;

	if( wyrownanie == 'do_prawej' )
		return spacje( szerokosc - tekst.length) + tekst ;

	if( wyrownanie == 'wysrodkuj' )
	{
		if( ((szerokosc - tekst.length) % 2) == 0 )
			return spacje( (szerokosc - tekst.length) / 2 )
				+ tekst
				+ spacje( (szerokosc - tekst.length) / 2 )  ;
    else
			return spacje( (szerokosc - tekst.length) / 2 )
				+ tekst
				+ spacje( ((szerokosc - tekst.length) / 2) + 1 )   ;

	}

		return tekst ;    // nieprawidlowe wyr�wnanie
}
//----------------------------------------------------------------
// v1.0
function spacje( ile )
{
    var odstep = '' ;

    for( var i = 1 ; i <= ile ; i++ )
	odstep += ' ' ;

    return odstep ;
}

function kontekstStart()
{
	if( (self != top) || (document.location.href.substring(0,22) != "http://www.zabawki.pl/"))
//	if(self != top) 
		return ;
	else
		document.location.href = '/' ;
		
}

//-------------------------------------------------------------------
function kontekst( startowa , document , ramka )
{
// v. 1.2

	if( (self != top) || (document.location.href.substring(0,22) != "http://www.zabawki.pl/"))
		return ;



	var poz ;
	var search = document.location.search ;
	var pytanie ;

	if((poz = search.indexOf('&all')) != -1) 
		pytanie = search.substring(0 , poz) + search.substring(poz + 4 , search.length) ;
	else
		pytanie = search ;
	
	document.location.href = startowa + '?url=' 
		+ escape(document.location.pathname + pytanie) 
		+ '&ramka=' + ramka ;

}

/*
    Funkcje zwi�zane z cookie
    Piotr Ptak 
    28.05.2006
*/

function getCookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}

function setCookie(name,value,expires,path,domain,secure) {
    var cookieString = name + "=" +escape(value) +
       ( (expires) ? ";expires=" + expires.toGMTString() : "") +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ( (secure) ? ";secure" : "");
    document.cookie = cookieString;
}

function deleteCookie(name,path,domain) {
   if (Get_Cookie(name)) document.cookie = name + "=" +
      ( (path) ? ";path=" + path : "") +
      ( (domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}


function przewijaj(doc,id,do_przodu)
{
  div = doc.getElementById('div' + id) ;
  img = doc.getElementById('lupa' + id) ;
  
  if(div.max > -1)
  {
    if(do_przodu)
    {
      if(div.aktualny + 1 > div.max)
	div.aktualny = 0 ;
      else
	div.aktualny += 1;
    }
    else
    {
      if(div.aktualny - 1 < 0)
	div.aktualny = div.max ;
      else
	div.aktualny -= 1 ;
    }
    
    div.style.backgroundImage = "url('" + div.tla[div.aktualny] + "')" ;
    img.style.display = div.maxy[div.aktualny] ? "inline" : "none" ;
  }  
  else
  {
    img.style.display = "none" ;
  }
  
  
  
    
  
//  alert(div.style.backgroundImage) ;
}

function otworzObr(doc,id)
{
  var div = doc.getElementById('div' + id) ;

//  alert('' + div.aktualny) ;
  
  window.open('obrazekMax.jsp?kod=' + div.kod + '&nr=' + div.aktualny , '' + id , 'menubar=no,toolbar=no,status=yes,titlebar=no,scrollbars=no');
}