//funkcje do podmiany zdjec
function fon(n){document.images[n].src='grafika/'+n+'1.gif';}
function foff(n){document.images[n].src='grafika/'+n+'.gif';}

//funkcja do wyswietlania popupu
var okno_pop='';
function popup(wi,he,uerel,alignx,aligny,scrol)
{
	// Bartosz Szczecinski
	// 20.04.2006
	// Opera 8.x nie obsluguje !okno_pop.closed
	if(okno_pop && okno_pop.closed==false) {
		okno_pop.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_pop=window.open(uerel, '_blank', 'scrollbars='+scrol+',height='+he+',width='+wi+',top='+yy+',left='+xx);
}

function popupFrame(wi, he, url, alignX, alignY, scroll) {
	popup(wi, he, 'popup.php?popupFile='+url.replace(/\?/, '&'), alignX, alignY, scroll);
}

function blurall() {
	var links = document.getElementsByTagName('a');
	for (var i=0;i<links.length;i++){
		links[i].onfocus = blurme;
	}
}

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


function printversion(id,path)
{
	var okno='';
	(okno && !okno.closed)?okno.close():'';
	he=400;
	wi=730;
	xx=(screen.availHeight-he)/2-10;
	yy=(screen.availWidth-wi)/2;
	okno=window.open('print_version.php?id='+id, '_blank', 'menubar=yes,scrollbars=yes,height='+he+',width='+wi+',top='+xx+',left='+yy);
}


/*ladowanie do casch-u zdjec
foto=new Array('pl','en');
menuA=new Array();menuB=new Array();
for(n=0;n<foto.length;n++){
menuA[n]=new Image();
menuA[n].src='grafika/'+foto[n]+'.gif';
menuB[n]=new Image();
menuB[n].src='grafika/'+foto[n]+'1.gif';
}
*/


function mainTabTo(nr) {
	document.getElementById('tab1').style.display = 'none';
	document.getElementById('tab2').style.display = 'none';
	document.getElementById('tab3').style.display = 'none';
	document.getElementById('tab'+nr).style.display = 'block';
	
	var a = document.getElementById('tabs').getElementsByTagName('A');
	for(keyVar in a) a[keyVar].className = 'notactive';
	try {
		//a[(nr-1)].className = 'active';
		document.getElementById('clicktab'+nr).className = 'active';
	}
	catch(ex) {}
}

function searchTabTo(nr) {
	document.getElementById('searchTab1').style.display = 'none';
	document.getElementById('searchTab2').style.display = 'none';
	document.getElementById('searchTab3').style.display = 'none';
	document.getElementById('searchTab'+nr).style.display = 'block';
	
	var a = document.getElementById('searchTabs').getElementsByTagName('A');
	for(keyVar in a) a[keyVar].className = '';
	//a[(nr-1)].className = 'active';
	document.getElementById('st'+nr).className = 'active';
}

function subProdukt(tab, nr) {
	var cont = document.getElementById('subProdukt'+tab);
	
	if(document.getElementById('aoptions')) {
		var a = document.getElementById('aoptions').getElementsByTagName('A');	
	}
	else var a = cont.getElementsByTagName('A');
	for(keyVar in a) {		
		try {
			if(a[keyVar].href.indexOf('#') > -1) a[keyVar].className = '';			
		}
		catch(ex) {
			/**
			 * broken A
			 */
		} 
	}
	a[(nr-1)].className = 'active';
	
	var d = cont.getElementsByTagName('DIV');		
	
	try {
		for(keyVar in d) {			
			try {				
				if(d[keyVar].className != 'clear') {
					d[keyVar].style.display = 'none';				
				}
			}
			catch(ex) {
				// the fuck ...
				// dlaczego IE zwraca mi d[0] = 4 to ja juz nie wiem ...
			}
		}
	}
	catch(ex) {
				
	}
	d[(nr-1)].style.display = 'block';
}

var mmOff = false;
var ncc = false;
/**
 * Quick & Dirty
 * hack - przekaż true jako drugi parametr żeby nie zmieniać klasy w menu głównym
 * tak to jest jak handlowcy wprowadzają zmiany po oddaniu projektu
 */
function megamenuToggle(mode, noClassChange) {
	
	mmOff = false;
	ncc = noClassChange;	
	if(mode == 'none') {
		mmOff = true;		
		setTimeout(mmOffDo, 500);
	}
	else {
		document.getElementById('megamenu').style.display = 'block';		
		document.getElementById('arrowDownMe').className = 'item1 true';
	}
}

function mmOffDo() {		
	if(mmOff == false) return;
	if(!ncc) document.getElementById('w1').className = 'w1';	
	mmOff = false;
	document.getElementById('arrowDownMe').className = 'item1';
	document.getElementById('megamenu').style.display = 'none';
}