var nn4=(document.layers)?true:false
var ie4=(document.all)?true:false

function drukuj(){
	if (!window.print){
		alert("Musisz mieć NS4.x lub IE5,\naby użyć przycisku drukowania!")
	} else {
		window.print()
	}
}

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 przybliz(wartosc) {
  return Math.round(wartosc*100)/100
}

function usun(tekst) {
  var pom=tekst.indexOf("'",0)
  while (pom!=-1){
    {tekst=tekst.substring(0,pom)+'`'+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 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+" "+data.getDate()+" "+miesiac+" "+rok+"r."
	
	return pomoc
}

function wzor_d(b,t,w) {
//	return 2*(b/(w*t))/(90/(170*65))-1
return 2*((10*b-t)/w)/((10*90-60)/170)-1
}

function galeria(src,w,h) {
	if (window.screeen) {
		aw=screeen.availWidth
		ah=screeen.availHeight
	} else {
		aw=640
		ah=450
	}
	noweOkienko=null
//	if (noweOkienko==null || noweOkienko.closed) {
		ustawienia=
		"left="+(aw-w)/2+","
		+"top="+(ah-h)/2+","
		+"screenX="+(aw-w)/2+","
		+"screenY="+(ah-h)/2+","
		+"width="+w+","
		+"height="+h+","
		+"innerWidth="+w+","
		+"innerHeight="+h+","
		+"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>Zdjęcie . . . . . . . . . . . . . . . . .  . . . . . . .</TITLE>\n"
	+"<STYLE>body {background : #FFFFCC url("+src+") no-repeat top;}</STYLE>\n"
	+"</HEAD>\n"
	+"<BODY donclick='window.close()'><TABLE WIDTH=100% HEIGHT=100%><TR><TD ALIGN=center VALIGN=bottom>Proszę czekać . . .</TD></TR></TABLE></BODY>\n"
	)
	noweOkienko.document.close()
	noweOkienko.focus()
}

function ostatnia_modelka() {
	nr=ob.length-1
	document.write('<TABLE WIDTH="159" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD><IMG SRC="img/t_obrazek_gora.gif" WIDTH="159" HEIGHT="2" ALT="" BORDER="0"></TD></TR>')
	document.write('<TR><TD BACKGROUND="img/t_obrazek.gif" ALIGN="center"><A HREF="fotomodelka.html"><IMG SRC="http://www.e-fotomodelki.pl/_foto/m_'+ob[nr][8]+'" ALT="" BORDER="0"></A></TD></TR>')
	document.write('<TR><TD><IMG SRC="img/t_obrazek_dol.gif" WIDTH="159" HEIGHT="7" ALT="" BORDER="0"></TD></TR></TABLE>')
}

function modelka(nr) {
	data=new Date()
	document.write('<TD WIDTH="50%">')
	document.write('<TABLE><TR VALIGN="top"><TD ROWSPAN="2">')
	document.write('<TABLE WIDTH="159" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD><IMG SRC="img/t_obrazek_gora.gif" WIDTH="159" HEIGHT="2" ALT="" BORDER="0"></TD></TR>')
	document.write('<TR><TD BACKGROUND="img/t_obrazek.gif" ALIGN="center"><IMG SRC="http://www.e-fotomodelki.pl/_foto/m_'+ob[nr][8]+'" ALT="" BORDER="0"></TD></TR>')
	document.write('<TR><TD><IMG SRC="img/t_obrazek_dol.gif" WIDTH="159" HEIGHT="7" ALT="" BORDER="0"></TD></TR></TABLE>')
	document.write('</TD><TD>')
	document.write('<B>'+ob[nr][0]+'</B> lat '+(parseInt(data.getFullYear())-ob[nr][3])+'<BR>')
	document.write(ob[nr][1])
	kolor="#000000"
	if (ob[nr][4]>=100) { kolor="#339933"} 
	if (ob[nr][4]>=105) { kolor="#0000FF"} 
	if (ob[nr][4]>=110) { kolor="#FF0000"} 
	document.write('<BR><BR><B><SPAN STYLE="color:'+kolor+'">'+ob[nr][4]+'</SPAN>-'+ob[nr][5]+'-'+ob[nr][6]+'</B><BR>')
	document.write('wzrost: <B>'+ob[nr][7]+'</B><BR>')
	wsp_d=wzor_d(ob[nr][4],ob[nr][5],ob[nr][7])
	kolor="#000000"
	if (wsp_d>=1) { kolor="#339933"} 
	if (wsp_d>=1.2) { kolor="#0000FF"} 
	if (wsp_d>=1.4) { kolor="#FF0000"} 
	document.write('współczynnik D: <SPAN STYLE="color:'+kolor+'"><B>'+przybliz(wsp_d)+'</B></SPAN>')
	if (ob[nr][2]!='') {
		document.write('<BR><BR><A HREF="mailto:'+ob[nr][2]+'?subject=Oferta%20pracy%20z%20serwisu%20WWW">kontakt</A>')
	}
	document.write('</TD></TR>')
	document.write('<TR><TD VALIGN="bottom">')
	document.write('<A HREF="http://www.e-fotomodelki.pl/'+ob[nr][9]+'" TARGET="_blank">więcej >></A>') 
	document.write('<BR><BR></TD></TR></TABLE>')
	document.write('</TD>')
}

function models(kolejnosc) {
	var pomoc=0
	if (kolejnosc=='data') {
		for (nr=ob.length-1;nr>0;nr--) {
			modelka(nr)		
			pomoc++
			if (pomoc%2==0) {
				document.write('</TR><TR VALIGN="top">')
			}
		}	
	}
	if (kolejnosc=='wsp_d') {
		var tabela_kolejnosc= Array()
		pomoc=0
		for (var nr=ob.length-1;nr>0;nr--) {
			tabela_kolejnosc[nr]=Array(nr,wzor_d(ob[nr][4],ob[nr][5],ob[nr][7]))
		}
		tabela_kolejnosc=tabela_sortuj(tabela_kolejnosc,1)
		for (var nr=tabela_kolejnosc.length-1;nr>0;nr--) {
			modelka(tabela_kolejnosc[nr][0])		
			pomoc++
			if (pomoc%2==0) {
				document.write('</TR><TR VALIGN="top">')
			}
		}	
	}
	if (kolejnosc=='biust') {
		var tabela_kolejnosc= Array()
		pomoc=0
		for (var nr=ob.length-1;nr>0;nr--) {
			tabela_kolejnosc[nr]=Array(nr,ob[nr][4])
		}
		tabela_kolejnosc=tabela_sortuj(tabela_kolejnosc,1)
		for (var nr=tabela_kolejnosc.length-1;nr>0;nr--) {
			modelka(tabela_kolejnosc[nr][0])		
			pomoc++
			if (pomoc%2==0) {
				document.write('</TR><TR VALIGN="top">')
			}
		}	
	}

}

function tabela_wyswietl(tabela) {
	document.write('<hr>')
	for (var pomoc=1;pomoc<=tabela.length-1;pomoc++) {
		document.write(pomoc)
		document.write(' = ')
		document.write(tabela[pomoc][0])
		document.write(' ')
		document.write(tabela[pomoc][1])
		document.write(' ')
		document.write(tabela[pomoc][2])
		document.write(' ')
		document.write(tabela[pomoc][3])
		document.write('<BR>')
	}
	document.write('<hr>')
}

function tabela_sortuj(tabela,pole) {
	var tabela_pomoc= Array()
	var indeks_min_aktualna=1
	var min_aktualna=tabela[indeks_min_aktualna][pole]
	for (var pomoc=1;pomoc<=tabela.length-1;pomoc++) {
		for (var nr=tabela.length-1;nr>0;nr--) {
			if(tabela[nr][pole]<min_aktualna) {
				indeks_min_aktualna=nr
				min_aktualna=tabela[indeks_min_aktualna][pole]
			}
		}
		tabela_pomoc[pomoc]=Array(tabela[indeks_min_aktualna][0],tabela[indeks_min_aktualna][1])
		tabela[indeks_min_aktualna][pole]=9999999
		min_aktualna=tabela[indeks_min_aktualna][pole]
	}
	return tabela_pomoc
}

