var nn4=(document.layers)?true:false
var ie4=(document.all)?true:false

function zaznaczWszystkie(obiekt,wartosc,ilosc,ktory){
	for(i=0; i<ilosc; i++){
		obiekt.elements[ktory].checked=wartosc
		ktory++
	}
}

function drukuj(){
	if (!window.print){
		alert("Musisz mieć NS4.x lub IE5,\naby użyć przycisku drukowania!")
	} else {
		window.print()
	}
}

function drukuj_artykul(idartykul){
	ustawienia=
	"left=0,"
	+"top=0,"
	+"screenX=0,"
	+"screenY=0,"
	+"width=500,"
	+"height=400,"
	+"innerWidth=500,"
	+"innerHeight=400,"
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=yes,"
	+"resizable=no"
	window.open('artykul_drukuj.php?idartykul='+idartykul, '', ustawienia)
}
function wyslij_artykul(idartykul){
	var e_mail=prompt("Podaj e-mail:",'')
	if (e_mail=="" || e_mail==null || (e_mail.indexOf("@",1)==-1 || e_mail.indexOf(".",1)==-1)){
		alert("Błędny e-mail")
	}else{
		ustawienia=
		"left=0,"
		+"top=0,"
		+"screenX=0,"
		+"screenY=0,"
		+"width=400,"
		+"height=20,"
		+"innerWidth=400,"
		+"innerHeight=20,"
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=no,"
		+"menubar=no,"
		+"scrollbars=yes,"
		+"resizable=no"
		window.open('artykul_wyslij.php?idartykul='+idartykul+'&e_mail='+e_mail, '', ustawienia)
	}
}


function spr_liczba(obiekt){
	if (isNaN(obiekt.value) || obiekt.value<0 || Math.floor(obiekt.value)!=obiekt.value){
		obiekt.value=''
	} else {
		obiekt.value=Math.floor(obiekt.value)
	}
}
	
function nowyRandom(zakres) {
   var los=Math.round(Math.random()*10*zakres)+zakres
   return Math.round(((los-zakres)*zakres)/los)
} //losuje od 0 do zakres

function marquee(myText){
	/*
  textlen=myText.length;         
	newText=myText.substring(2,textlen)+myText.substring(0,2);        
	window.status=newText;         
	setTimeout("marquee('"+newText+"')",300);         
	*/
}

function zamien(wartosc) {
  var pom=""
  pom=pom+wartosc
  if (isNaN(pom))
   {
     var z=pom.indexOf(",")
	 if (z!=-1) {pom=pom.substring(0,z)+"."+pom.substring(z+1,pom.length)}
   }
  if (!isNaN(pom)) {pom=Math.round(pom*100)/100}
  return pom
}

function usun(tekst) {
  var pom=tekst.indexOf("'",0)
  while (pom!=-1){
    {tekst=tekst.substring(0,pom-1)+'`'+tekst.substring(pom+1,tekst.length)}
    pom=tekst.indexOf("'",pom)  
  }
  return tekst  
}

function show(ident) { 
    if(nn4) { 
        document.layers[ident].visibility = "show";
    } else if(ie4) { 
        document.all[ident].style.visibility = "visible";
    }
}
function hide(ident) { 
    if(nn4) { 
        document.layers[ident].visibility = "hide";
    } else if(ie4) { 
        document.all[ident].style.visibility = "hidden";
    }
}

function setstart(obj) { 
	obj.style.behavior='url(#default#homepage)'
	obj.setHomePage(document.location)
}

function addbm() { 
	window.external.AddFavorite(document.location, document.title)
}

// ------------ obrazki -----------------
	function ImageArray(n) {
		this.length = n
		for (var i = 0; i<=n; i++) {
			this[i] = new Image()
		}
		return this
	}
	
	function mOver(obiekt,num) { 
		if ((over[num].src != "") ) {
			obiekt.src = over[num].src;
		}
	}
	
	function mOut(obiekt,num) {
		if ((off[num].src != "")) {
	  	obiekt.src = off[num].src;
		}
	}
// ------------ koniec obrazki -----------------

function dataSlownie(data) {
  var pomoc=""
	dzien=data.getDay()
	if (data.getDay()==0) {dzien="Niedziela"}
	if (data.getDay()==1) {dzien="Poniedziałek"}
	if (data.getDay()==2) {dzien="Wtorek"}
	if (data.getDay()==3) {dzien="Środa"}
	if (data.getDay()==4) {dzien="Czwartek"}
	if (data.getDay()==5) {dzien="Piątek"}					
	if (data.getDay()==6) {dzien="Sobota"}

	if (data.getMonth()==0) {miesiac="stycznia"}
	if (data.getMonth()==1) {miesiac="lutego"}
	if (data.getMonth()==2) {miesiac="marca"}
	if (data.getMonth()==3) {miesiac="kwietnia"}
	if (data.getMonth()==4) {miesiac="maja"}
	if (data.getMonth()==5) {miesiac="czerwca"}
	if (data.getMonth()==6) {miesiac="lipca"}
	if (data.getMonth()==7) {miesiac="sierpnia"}
	if (data.getMonth()==8) {miesiac="września"}
	if (data.getMonth()==9) {miesiac="października"}
	if (data.getMonth()==10) {miesiac="listopada"}
	if (data.getMonth()==11) {miesiac="grudnia"}

	if (data.getYear()<1900) {rok=data.getYear()+1900} 
	else {rok=data.getYear()}

	pomoc=dzien+"<BR>"+data.getDate()+" "+miesiac+" "+rok+"r."
	
	return pomoc
}

function okno_katalog(korzen,pole) {
	plik='katalog.php?korzen='+korzen+'&pole='+pole
	noweOkienko=null
	ustawienia=
	"left=0,"
	+"top=0,"
	+"screenX=0,"
	+"screenY=0,"
	+"width=420,"
	+"height=400,"
	+"innerWidth=420,"
	+"innerHeight=400,"
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=yes,"
	+"resizable=no"
	noweOkienko=window.open(plik,"katalog",ustawienia)
	noweOkienko.focus()
}

function okno_katalog_plik(korzen,pole) {
	plik='katalog_plik.php?korzen='+korzen+'&pole='+pole
	noweOkienko=null
	ustawienia=
	"left=0,"
	+"top=0,"
	+"screenX=0,"
	+"screenY=0,"
	+"width=420,"
	+"height=400,"
	+"innerWidth=420,"
	+"innerHeight=400,"
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=yes,"
	+"resizable=no"
	noweOkienko=window.open(plik,"katalog",ustawienia)
	noweOkienko.focus()
}
function okno_tresc(tresc) {
	noweOkienko=null
	ustawienia=
	"left=0,"
	+"top=0,"
	+"screenX=0,"
	+"screenY=0,"
	+"width=550,"
	+"height=400,"
	+"innerWidth=550,"
	+"innerHeight=400,"
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=yes,"
	+"resizable=no"
	noweOkienko=window.open("","tresc",ustawienia)
	noweOkienko.document.open()
	noweOkienko.document.clear()
	noweOkienko.document.write(
	'<HTML><HEAD>\n'
	+'<TITLE>Podgląd treści</TITLE>\n'
	+'<LINK HREF="../style.css" REL="stylesheet">\n'
	+'</HEAD>\n'
	+'<BODY>\n'
	+'<TABLE WIDTH="500" ALIGN="center" VALIGN="top"><TR><TD>\n'
	+'<DIV ALIGN="justify">\n'
	+tresc			
	+'</DIV>\n'
	+'</TD></TR></TABLE>\n'
	+'</BODY>\n'
	+"</HTML>\n"
	)
	noweOkienko.document.close()
	noweOkienko.focus()
}

function okno_obrazek(src,w,h,podpis) {
	noweOkienko=null
	if (window.screeen) {
		aw=screeen.availWidth
		ah=screeen.availHeight-50
	} else {
		aw=640
		ah=450-50
	}	
	if (podpis!=null && podpis!='') {
		hn=h+40
		tabela_podpis=
		'<TR><TD HEIGHT="50" ALIGN="center" VALIGN="middle">'+podpis+'</TD></TR>\n'
	} else {
		hn=h
		tabela_podpis=''
	}
	ustawienia=
//	"left="+(aw-w)/2+","
//	+"top="+(ah-h)/2+","
//	+"screenX="+(aw-w)/2+","
//	+"screenY="+(ah-h)/2+","
	"left="+0+","
	+"top="+0+","
	+"screenX="+0+","
	+"screenY="+0+","
	+"width="+w+","
	+"innerWidth="+w+","	
	+"height="+hn+","
	+"innerHeight="+hn+","
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=no,"
	+"resizable=no"
	noweOkienko=window.open("",("obrazek_"+w+"_"+h),ustawienia)
	noweOkienko.document.open()
	noweOkienko.document.clear()
	noweOkienko.document.write(
	"<HTML><HEAD>\n"
	+"<TITLE>Proszę czekać na obrazek. . . . . . . . . . . . . . . . .  . . . . . . .</TITLE>\n"
	+"<STYLE>\n"
	+"body{\n"
	+"margin-left : 0px; \n"
	+"margin-top : 0px; \n"
	+"margin-bottom : 0px; \n"
	+"margin-right : 0px; \n"
	+"font-family : Arial; \n"
	+"} \n"
	+"</STYLE>\n"
	+"</HEAD>\n"
	+"<BODY onclick='window.close()'>\n"
	+'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="100%">'
	+'<TR><TD ALIGN="center" VALIGN="top"><IMG SRC="'+src+'" WIDTH="'+w+'" HEIGHT="'+h+'" BORDER="0" ALT=""></TD></TR>'
	+tabela_podpis
	+'</TABLE>\n'
	+"</BODY>\n"
	+"</HTML>\n"
	)
	noweOkienko.document.close()
	noweOkienko.focus()
}

//-----------------------------------------------
function AltSel(frm)
	{
	var n=frm.name
	var f=frm.form.name+'.'+n
	var s=frm.form.name+'_'+n
	var s1=s+'_s1'
	var sa=s+'_sa'
	var c=frm.className
//	alert(frm.name+frm.style.width)
//	frm.clientWidth=frm.style.width
	var Ret=''
	Ret+='<INPUT type=hidden name='+n+' value="">'
	Ret+='<TABLE border=0 cellpadding=0 cellspacing=0 bgcolor="#FFFFFF" style="border:0 inset;" onmousedown="focus(this)" onfocus="SelON('+sa+')" onblur="SelOFF('+sa+')"><TR>'
	Ret+='<TD WIDTH='+frm.style.width+' style="border:2 solid #6F7F96; font-size: 10px;"><DIV class='+c+' id='+s1+' style="cursor: default; width:'+(frm.style.width-22)+'"></DIV></TD>'
	Ret+='<TD style="border:2 solid #6F7F96;">'
	Ret+='<BUTTON style="font-size:1" onfocus="blur()"><IMG vspace=2 src="img/i_select.gif" width=8 height=5></BUTTON>'
	Ret+='<DIV style="position:absolute"><DIV id='+sa+' style="Z-INDEX:3; position:absolute; visibility:hidden; width:'+(frm.style.width)+'; background-color:#FFFFFF; padding:1; border:1 solid #6F7F96;" nowrap>'
	Ret+='<TABLE cellpadding=0 cellspacing=0 width="100%" style="cursor: default;">'
	for(var i=0; i<frm.length; i++)
		{
		var t=frm[i].text; v=frm[i].value
		if(frm[i].selected) {
			var st=t,sv=v
		}
		Ret+='<TR><TD STYLE="font-size: 10px;" NOWRAP id=tx'+i+' class='+c
		Ret+=(t.charAt(t.length-1)!='-')? ' onmousedown="'+s1+'.innerHTML=\'<NOBR>&nbsp;'+t+'</NOBR>\';'+f+'.value=\''+v+'\'" onmouseover="SelOver(this)" onmouseout="SelOut(this)"' : ' style="font-weight:bold"'
		Ret+='>&nbsp;'+t+' &nbsp;</TD></TR>'
		}
	Ret+='</TABLE>'
	Ret+='</DIV></DIV>'
	Ret+='</TD>'
	Ret+='</TR></TABLE>'
	frm.parentElement.innerHTML=Ret
	var s1=eval(s1)
	s1.innerHTML='<NOBR>&nbsp;'+st+'</NOBR>'

	var f=eval(f); f.value=sv
	var sa=eval(sa); sa.style.top=19
	}
function SelOver(obj){obj.bgc=obj.bgColor;obj.fgc=obj.style.color;obj.bgColor='#000080';obj.style.color='#FFFFFF'}
function SelOut(obj){obj.bgColor=obj.bgc;obj.style.color=obj.fgc}
function SelON(obj) {obj.style.visibility='visible';obj.style.left=-obj.clientWidth}
function SelOFF(obj){obj.style.visibility='hidden'}
// -------------------------------------------------------------------------------