function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function licz_znaki(pole,id,limit){

	if (pole.value.length>=limit)

	{

		pole.value=pole.value.substr(0,limit);

		document.getElementById(id).innerHTML="Użyto znaków: <b><span style=\"color: red;\">"+pole.value.length+"</span></b>";

	}else{

		document.getElementById(id).innerHTML="Użyto znaków: "+pole.value.length;

	}

}



function licz_znaki_spr(pole_id,id,limit){

	if (document.getElementById(pole_id).value.length>=limit)

	{

		document.getElementById(pole_id).value=document.getElementById(pole_id).value.substr(0,limit);

		document.getElementById(id).innerHTML="Użyto znaków: <b><span style=\"color: red;\">"+document.getElementById(pole_id).value.length+"</span></b>";

	}else{

		document.getElementById(id).innerHTML="Użyto znaków: "+document.getElementById(pole_id).value.length;

	}

}



function programy_wybor_lokalizacji(){

	if (document.dodaj_forme_reklamowa.typ.value=='tekst'){

		document.dodaj_forme_reklamowa.lokalizacja.value='moj_serwer';

		document.dodaj_forme_reklamowa.lokalizacja.disabled='disabled';

		document.getElementById('link_do_zewn_odnosnik').style.display='none';

		document.getElementById('plik_serwer').style.display='none';

		document.getElementById('tekst').style.display='block';

		document.dodaj_forme_reklamowa.link_zewn_odnosnik.value='http://';

		document.dodaj_forme_reklamowa.plik.value='';

		document.dodaj_forme_reklamowa.wysokosc.value='1';

		document.dodaj_forme_reklamowa.szerokosc.value='1';

	}else{

		document.dodaj_forme_reklamowa.lokalizacja.disabled='';

		if (document.dodaj_forme_reklamowa.lokalizacja.value=='serwer_zewnetrzny'){

			document.getElementById('link_do_zewn_odnosnik').style.display='block';

			//document.dodaj_forme_reklamowa.link_zewn_odnosnik.value='http://';

			document.getElementById('plik_serwer').style.display='none';

			document.getElementById('tekst').style.display='none';

			document.dodaj_forme_reklamowa.plik.value='';

			document.dodaj_forme_reklamowa.tekst.value='';

		}else{

			document.getElementById('link_do_zewn_odnosnik').style.display='none';

			document.getElementById('plik_serwer').style.display='block';

			document.getElementById('tekst').style.display='none';

			document.dodaj_forme_reklamowa.link_zewn_odnosnik.value='http://';

			document.dodaj_forme_reklamowa.tekst.value='';

		}

	}

}



function nowy_sprawdz(){

	if (document.dodaj_program.nowy.value=='T'){

		document.getElementById('nowy_poz').style.display='block';

	}else{

		document.getElementById('nowy_poz').style.display='none';

		document.dodaj_program.nowy_poz_form.value='';

	}

}



function polecony_sprawdz(){

	if (document.dodaj_program.polecony.value=='T'){

		document.getElementById('polecony_poz').style.display='block';

	}else{

		document.getElementById('polecony_poz').style.display='none';

		document.dodaj_program.polecony_poz_form.value='';

	}

}



function metoda_platnosci_sprawdz(){

	if (document.dodaj_program.metoda_platnosci.value=='klik'){

		document.getElementById('okres_na_finalizacje').style.display='none';

		document.dodaj_program.czas_finalizacja.value='';

		document.getElementById('procent').style.display='none';

		document.dodaj_program.procent.checked=false;

	}

	if (document.dodaj_program.metoda_platnosci.value=='wypelnianie'){

		document.getElementById('okres_na_finalizacje').style.display='none';

		document.dodaj_program.czas_finalizacja.value='';

		document.getElementById('procent').style.display='none';

		document.dodaj_program.procent.checked=false;

	}

	if (document.dodaj_program.metoda_platnosci.value=='prowizja'){

		document.getElementById('okres_na_finalizacje').style.display='block';

		document.getElementById('procent').style.display='block';

	}

}



//ajax

var http_requestKP = false;



function makeRequestKP(url,div_id,metoda) {

	document.getElementById(div_id).innerHTML='<img src="img/loading.gif"> ładuje...';

	http_requestKP = false;



	if (window.XMLHttpRequest) { // Mozilla, Safari,...

		http_requestKP = new XMLHttpRequest();

		if (http_requestKP.overrideMimeType) {

			http_requestKP.overrideMimeType('text/xml');

			// Przeczytaj o tym wierszu ponizej

		}

	} else if (window.ActiveXObject) { // IE

		try {

			http_requestKP = new ActiveXObject("Msxml2.XMLHTTP");

		} catch (e) {

			try {

				http_requestKP = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (e) {}

		}

	}



	if (!http_requestKP) {

		alert('Nie mogę stworzyć instancji obiektu XMLHTTP');

		return false;

	}

	http_requestKP.onreadystatechange = function() { alertContents(http_requestKP,div_id); };

	http_requestKP.open(metoda, url, true);

	http_requestKP.send(null);



}



function alertContents(http_requestKP,div_id) {



	if (http_requestKP.readyState == 4) {

		if (http_requestKP.status == 200) {

			document.getElementById(div_id).innerHTML=http_requestKP.responseText;

		} else {

			alert('Wystąpił problem z zapytaniem.');

		}

	}



}



function validateemail(field) {

	if(field.indexOf("@")==-1 || field.indexOf(".")==-1) return false;

	return true;

}



function validatewww(field) {

	if(field.indexOf("http://")==-1 || field.indexOf(".")==-1) return false;

	return true;

}



function validate_form_zostan_partnerem_1(f)

{

  if (f.login.value == "") {

    window.alert("Wypełnij pole login!");

    return false;

  }

  if (f.login.value.length<4) {

    window.alert("Login musi się składać z minimum 4 znaków!");

    return false;

  }

  if (f.pass.value == "" || f.pass2.value == "") {

    window.alert("Wypełnij oba pola z hasłem!");

    return false;

  }

  if (f.pass.value.length<6) {

    window.alert("Hasło musi się składać z minimum 6 znaków!");

    return false;

  }

  if (f.pass.value!=f.pass2.value) {

    window.alert("Wpisane hasła różnią się!");

    return false;

  }



  return true;

}



function validate_form_zostan_partnerem_2(f)

{

  if (f.imie.value == "") {

    window.alert("Wypełnij pole imię!");

    return false;

  }

  if (f.nazwisko.value == "") {

    window.alert("Wypełnij pole nazwisko!");

    return false;

  }

  if (!validateemail(f.email.value)) {

    window.alert("Niepoprawny e-mail!");

    return false;

  }

  if (f.ulica.value == "") {

    window.alert("Wypełnij pole ulica!");

    return false;

  }

  if (f.miasto.value == "") {

    window.alert("Wypełnij pole miasto!");

    return false;

  }

  if (f.kod.value == "") {

    window.alert("Wypełnij pole kod pocztowy!");

    return false;

  }

  if (f.telefon.value == "" && f.telefon_kom.value == "") {

    window.alert("Wpisz telefon kontaktowy!");

    return false;

  }

  //if (f.firma.value == "") {

    //window.alert("Wypełnij pole nazwa firmy!");

    //return false;

  //}



  return true;

}



function validate_form_zostan_partnerem_3(f)

{

  if (!validatewww(f.www.value)) {

    window.alert("Nipoprawne dane w polu strona www (http://)!");

    return false;

  }

  if (f.www_opis.value == "") {

    window.alert("Wypełnij pole opis!");

    return false;

  }

  if (f.przetwarzanie.checked == false) {

    window.alert("Musisz zgodzić się na przetwarzanie danych osobowych i zapoznać się z Polityką Prywatności.");

    return false;

  }

  if (f.regulamin.checked == false) {

    window.alert("Musisz zaakceptować regulamin serwisu!");

    return false;

  }

  if (f.strony_porno.checked == false) {

    window.alert("Musisz oświadczyć, iż nie będziesz umieszczał reklam z serwisu Adconnect na stronach o niedozwolonych treściach.");

    return false;

  }

  if (f.kod_obrazek.value == "") {

    window.alert("Przepisz kod z obrazka!");

    return false;

  }



  return true;

}



function validate_logowanie(f)

{

  if (f.log_login.value == "") {

    window.alert("Wypełnij pole login!");

    return false;

  }

  if (f.log_haslo.value == "") {

    window.alert("Wypełnij pole hasło!");

    return false;

  } 



  return true;

}



function validate_form_przypomnij_haslo(f)

{

  if (f.login.value == "" && f.email.value == "") {

    window.alert("Wypełnij pole login lub e-mail!");

    return false;

  }

  if (f.kod_obrazek.value == "") {

    window.alert("Przepisz kod z obrazka!");

    return false;

  }



  return true;

}



function zwin_rozwin(div_id){

	if (document.getElementById(div_id).style.display=='none'){

		document.getElementById(div_id).style.display='block';

	}else{

		document.getElementById(div_id).style.display='none';

	}

}



function osoba_firma2(){

	if (document.getElementById('osoba_firma').value=='osoba_fizyczna'){

		document.getElementById('firma').value='brak';

		document.getElementById('firma').readOnly = true;

	}else{

		document.getElementById('firma').value='';

		document.getElementById('firma').readOnly = false;

	}

}



function osoba_firma3(){

	if (document.getElementById('osoba_firma').value=='osoba_fizyczna'){

		document.getElementById('firma').value='brak';

		document.getElementById('firma').readOnly = true;

	}else{

		document.getElementById('firma').readOnly = false;

	}

}



function validate_form_edytuj_ogolne(f){

  if (f.imie.value == "") {

    window.alert("Wypełnij pole imię!");

    return false;

  }

  if (f.nazwisko.value == "") {

    window.alert("Wypełnij pole nazwisko!");

    return false;

  }

  if (!validateemail(f.email.value)) {

    window.alert("Niepoprawny e-mail!");

    return false;

  }

  if (document.getElementById('osoba_firma').value=='firma'){

  	if (f.firma.value == "") {

    	window.alert("Wypełnij pole nazwa firmy!");

    	return false;

  	}

  }

  if (!validatewww(f.www.value)) {

    window.alert("Nipoprawne dane w polu strona www (http://)!");

    return false;

  }

  ////////////////////////////////////////////////////////////////

  if (f.ulica.value == "") {

    window.alert("Wypełnij pole ulica!");

    return false;

  }

  if (f.kod.value == "") {

    window.alert("Wypełnij pole kod pocztowy!");

    return false;

  }

  if (f.miasto.value == "") {

    window.alert("Wypełnij pole miejscowość!");

    return false;

  }

 

  if (f.telefon.value == "" && f.telefon_kom.value == "") {

    window.alert("Wpisz telefon kontaktowy!");

    return false;

  }

  /////////////////////////////////////////////////////////////////

  if (f.www_opis.value == "") {

    window.alert("Wypełnij pole opis!");

    return false;

  }



  return true;

}



function validate_form_edytuj_haslo(f){

  if (f.haslo_e_stare.value.length<6) {

    window.alert("Stare hasło musi się składać z minimum 6 znaków!");

    return false;

  }

  if (f.haslo_e.value == "" || f.haslo_e_powt.value == "") {

    window.alert("Wypełnij oba pola z hasłem!");

    return false;

  }

  if (f.haslo_e.value.length<6) {

    window.alert("Hasło musi się składać z minimum 6 znaków!");

    return false;

  }

  if (f.haslo_e.value!=f.haslo_e_powt.value) {

    window.alert("Wpisane hasła różnią się!");

    return false;

  }

  

  return true;

}



function validate_form_form_kontakt(f){

  if (f.temat.value=='') {

    window.alert("Określ temat!");

    return false;

  }

  if (f.tresc.value == "") {

    window.alert("Wypełnij pole treść!");

    return false;

  }

  if (f.kod_obrazek.value == "") {

    window.alert("Przepisz kod z obrazka!");

    return false;

  }

  

  return true;

}



function validate_form_kontakt(f){

  if (f.kontakt_imie.value == "") {

    window.alert("Wypełnij pole imię!");

    return false;

  }

  if (f.kontakt_nazwisko.value == "") {

    window.alert("Wypełnij pole nazwisko!");

    return false;

  }

  if (!validateemail(f.kontakt_email.value)) {

    window.alert("Niepoprawny e-mail!");

    return false;

  }

  if (f.kontakt_temat.value=='') {

    window.alert("Określ temat!");

    return false;

  }

  if (f.kontakt_tresc.value == "") {

    window.alert("Wypełnij pole treść!");

    return false;

  }

  if (f.kod_obrazek.value == "") {

    window.alert("Przepisz kod z obrazka!");

    return false;

  }

  

  return true;

}



function info(){

	return overlib('<div class="overlib_info">Kliknij aby uzyskać więcej informacji.</div>', ABOVE, RIGHT, FGCOLOR, '#B5B5B4', BGCOLOR, '#FFFFFF', TEXTSIZE, '10px', WIDTH, 150);

}



function info_szczeg(tekst, title){

	return overlib('<div class="overlib_info_szczeg">'+tekst+'</div>', ABOVE, STICKY, CAPTION, '<div class="overlib_info_szczeg_title">'+title+'</div>', FGCOLOR, '#B5B5B4', BGCOLOR, '#FFFFFF', CLOSETEXT, '<div class="overlib_info_szczeg_title">Zamknij</div>');

}



function resetuj_wyszukiwarka(){

	document.getElementById('nazwa').value='';

	document.getElementById('kategoria').selectedIndex=0;

	document.getElementById('metoda_platnosci').selectedIndex=0;

	document.getElementById('metoda_przystapienia').selectedIndex=0;

	document.getElementById('ilosc_rekordow').selectedIndex=2;

	document.getElementById('sortowanie').selectedIndex=0;

	document.forms.wyszukiwarka.submit();

}



function validate_form_zapisz_do_programu(f){

  if (!validatewww(f.www.value)) {

    window.alert("Nipoprawne dane w polu strona www (http://)!");

    return false;

  }

  if (f.regulamin.checked == false) {

    window.alert("Musisz zaakceptować regulamin serwisu!");

    return false;

  }



  return true;

}



function popraw_okno(window_width, window_height) {

	window.resizeTo(window_width + 10,window_height + 27, 'detal');

	var szerokosc = screen.width/2 - window_width/2;

	var wysokosc = screen.height/2 - window_height/2;

	window.moveTo(szerokosc,wysokosc);

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



function copy(tekst) {

	if (window.clipboardData){

		var copytext=tekst;

		window.clipboardData.setData("Text", copytext);

		return true;

	}

	window.alert('Zabezpieczenia Twojej przeglądarki uniemożliwiają skopiowanie tekstu');

	return false; 

}



function migajacy_text(id, k1, t1, k2, t2){

	if (document.getElementById){

		document.getElementById(id).style.color = k1;

		setTimeout('migajacy_text("' +  id + '","' + k2 + '",' + t2 + ',"' + k1 + '",' + t1 + ')', t1);

	}

	else if (document.all){

    	document.all[id].style.color = k1;

		setTimeout('migajacy_text("' +  id + '","' + k2 + '",' + t2 + ',"' + k1 + '",' + t1 + ')', t1);

	}

}

function e(elem)
{
	return document.getElementById(elem);	
}

function value(elem)
{
	if(elem.nodeName.toUpperCase() == 'SELECT')
		return elem.options[elem.selectedIndex].value;
	else
		return elem.value;	
}
