var IEVersion = parseFloat( navigator.appVersion.split('MSIE')[1] );
if ( navigator.userAgent.indexOf('Mac')        >= 0 ) { IEVersion = 6; }
if ( navigator.userAgent.indexOf('Windows CE') >= 0 ) { IEVersion = 6; }
if ( navigator.userAgent.indexOf('Opera')      >= 0 ) { IEVersion = 6; }
if ( navigator.userAgent.indexOf('Firefox')      >= 0 ) { IEVersion = 6; }
	
//funkcje do podmiany zdjec
function fon(n){document.images[n].src='grafika/'+n+'.gif';}
function foff(n){document.images[n].src='grafika/'+n+'1.gif';}

//funkcja do wyswietlania popupu
var okno='';
function popup(wi,he,uerel,alignx,aligny,scrol)
{
	if(okno &&!okno.closed){okno.close()}
	if(wi=='100%'){wi=screen.availWidth-30}
	if(he=='100%'){he=screen.availHeight-0}
	if(alignx=='left'){xx=0}
	else if(alignx=='right'){xx=(screen.availWidth-wi)-10}
	else{xx=(screen.availWidth-wi)/2}
	if(aligny=='top'){yy=0}
	else if(aligny=='bottom'){yy=(screen.availHeight-he)}
	else{yy=(screen.availHeight-he)/2}
	okno=window.open(uerel, '_blank', 'scrollbars='+scrol+',height='+he+',width='+wi+',top='+yy+',left='+xx);
}

/* (c) Konrad */
function show(co, wi, he)
{
  wii = wi + 40;
  hee = he + 20;
	
  if ( screen.availHeight - 50 < hee )
	  hee = screen.availHeight - 50;
	
  if ( screen.availWidth < wii )
	{
	  wii = screen.availWidth - 30;
		hee += 10;
	}
	
  if ( okno && !okno.closed )
	  okno.close();
	
  xx = ( screen.availHeight - hee ) / 2 - 10;
  yy = ( screen.availWidth - wii ) / 2;
  okno = window.open( 'about:blank', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,fullscreen=no,channelmode=no,height=' + hee + ',width=' + wii + ',top=' + xx + ',left=' + yy );
  okno.document.write( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><META CONTENT="text/html; charset=iso-8859-2" HTTP-EQUIV=Content-Type><META NAME="Author" CONTENT="www.venti.com.pl"><TITLE>QUEST</TITLE></HEAD><BODY style="background: #fff; margin: 0px; padding: 0px"><TABLE WIDTH="100%" height="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0"><tr><td style="padding:5px 10px; text-align: center; vertical-align: middle"><a onfocus="blur()" href="javascript:self.close()"><img src="'+co+'" width="'+wi+'" height="'+he+'" style="border: 1px solid #ddd"></a></td></tr></TABLE></BODY></HTML>' );
}

function ScrollToElement( theElement )
{
	e = document.getElementById( theElement );
	
	var selectedPosX = 0;
	var selectedPosY = 0;
	          
	while ( e != null )
	{
		selectedPosX += e.offsetLeft;
		selectedPosY += e.offsetTop;
		e = e.offsetParent;
	} // END while ( e != null )
	                    		      
	window.scrollTo( selectedPosX, selectedPosY );
} // END function ScrollToElement( theElement )

/* (c) Bartek */
function BlurAll()
{
	var links = document.getElementsByTagName('a');
	for ( var i = 0; i < links.length; i++ )
	{
  	links[i].onfocus = BlurMe;
  }
}

function BlurMe()
{
	this.blur();
}

function InitMenu()
{
	var ML = document.getElementsByName('ML');
	var IL = document.getElementsByName('IL');
	
	for ( var i = 0; i < ML.length; i++ )
	{
		if ( ML[i].parentNode.className.indexOf( 'Active' ) < 0 )
		{
			var P = ML[i].parentNode;
			
			P.onmouseover = BGOn;
			P.onmouseout = BGOff;
			
			var P = IL[i].parentNode;
			
			P.onmouseover = BGOn;
			P.onmouseout = BGOff;
		}
	}
	
	var MB = document.getElementsByName('MB');
	
	for ( var i = 0; i < MB.length; i++ )
	{
		var P = MB[i].parentNode.parentNode;
		
		if ( P.className.indexOf( 'Active' ) < 0 )
		{
			P.onmouseover = BGOn2;
			P.onmouseout = BGOff2;
		}
	}
}

function BGOn()
{
	C = this.firstChild;	// powinno wskazywać na <a></a>
	C.style.color = '#9c002d';
	
	this.parentNode.style.backgroundColor = '#e7e7e7';
	
	if ( !self.IEVersion )
		self.IEVersion = 6;

	this.style.cursor = ( self.IEVersion < 6 ) ? 'hand' : 'pointer'; // IE starsze od 6 nie rozpoznają cursor: pointer
	
	this.parentNode.onclick = function()
	{
		window.location.href = C.href;
	}
	
	if ( this.nextSibling )
	{
		SC = this.nextSibling.firstChild; // powinno wskazywać na <a></a>
		SC.style.color = '#9c002d';
	}
}

function BGOff()
{
	C = this.firstChild;	// powinno wskazywać na <a></a>
	C.style.color = '#6f6d6f';
	
	this.parentNode.style.backgroundColor = '#f6f6f6';
	this.parentNode.style.cursor = 'default';
	
	if ( this.nextSibling )
	{
		SC = this.nextSibling.firstChild; // powinno wskazywać na <a></a>
		SC.style.color = '#6f6d6f';
	}
}

function BGOn2()
{
	var C = this.firstChild.firstChild; // powinno wskazywać na <a></a>
	//C.style.textDecoration = 'underline';
	
	this.style.backgroundColor = '#d60027';
	
	if ( !self.IEVersion )
		self.IEVersion = 6;
	
	this.style.cursor = ( self.IEVersion < 6 ) ? 'hand' : 'pointer'; // IE starsze od 6 nie rozpoznają cursor: pointer
	
	this.onclick = function()
	{
		window.location.href = C.href;
	}
}

function BGOff2()
{
	var C = this.firstChild.firstChild; // powinno wskazywać na <a></a>
	//C.style.textDecoration = 'none';
	
	this.style.backgroundColor = '#007f3a';	
	this.style.cursor = 'default';
}

function Init()
{
	BlurAll();
	//InitMenu();
	return true;
}

function ChangeStyle( E, BGColor, BorderBottom, Cursor )
{
	E.parentNode.style.backgroundColor = BGColor;
	E.style.borderBottom = BorderBottom
	E.style.cursor = 'pointer';
	
	Prev = E.previousSibling;
	Next = E.nextSibling;
 
	if ( Prev )
	{
		 Prev.style.borderBottom = BorderBottom;
	}
	
	if ( Next )
	{
		 Next.style.borderBottom = BorderBottom;
	}
}

function Show( n )
{
	var E = document.getElementById( n );
	
	E.style.display = 'block';
}

function Hide( n )
{
	var E = document.getElementById( n );
	
	E.style.display = 'none';
}
