if(parent.frames.length!=0)parent.location.replace(location.href)
function $(i){return document.getElementById(i);}

function addfav()
{
 var msg_netscape = "Ta funkcja nie działa z Twoją przeglądarką. Dodaj nas do ulubionych ręcznie.";
 var msg_opera    = "Ta funkcja nie działa z tą wersją Opery. Dodaj nas do ulubionych ręcznie.";
 var msg_other    = "Twoja przeglądarka nie wspiera automatycznego dodawania do ulubionych. Dodaj nas do ulubionych ręcznie.";
 var agt          = navigator.userAgent.toLowerCase();
 var title        = "Ogloszenia-Towarzyskie.Net";
 var url          = "http://www.ogloszenia-towarzyskie.net/";
 if(agt.indexOf("opera") != -1)
 {
  if (window.opera && window.print)
  {
   return true;
  } else 
  {
   alert(msg_other);
  }
 }
 else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
 else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
 else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
 else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
 else alert(msg_other);
 return;
}

function startowa()
{
 var misio = false;
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 misio=true;
 @end @*/
 if(misio)
 {
  document.body.style.behavior='url(#default#homepage)';
  document.body.setHomePage('http://www.ogloszenia-towarzyskie.net/');
 }
}

onload = function()
{
 for(var i=0; i<document.links.length; i++) {
  if (document.links[i].rel == 'external') {
   document.links[i].target = '_blank';
  }
 }
 var misio = false;
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 misio=true;
 @end @*/
 if(misio)
 {
  ie6 = navigator.userAgent.indexOf("MSIE 6");
  ie5 = navigator.userAgent.indexOf("MSIE 5");
  if(ie6!=-1 || ie5!=-1)
  {
   var el = $("podstrona").getElementsByTagName("h2");
   for(var i=0; i<el.length; i++) {
    f = el[i].getAttribute("id");
    el[i].style.background = "none";
    el[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/"+f+".png',sizingMethod='crop')";
   }
  }
 }
}

function showme()
{
 if($('opcje')) $('opcje').style.visibility = 'hidden';
 n = document.getElementsByTagName('html');
 n[0].style.height = '100%';
 n[0].style.overflow = 'hidden';
 document.body.style.height = '100%';
 document.body.style.overflow = 'hidden';
 if($('warning')) $('warning').style.display = 'block';
}

function hideme()
{
 document.cookie='wiek=ok';
 n = document.getElementsByTagName('html');
 n[0].style.height = '';
 n[0].style.overflow = '';
 document.body.style.height = '';
 document.body.style.overflow = '';
 if($('warning')) $('warning').style.display = '';
 if($('opcje')) $('opcje').style.visibility = 'visible';
}

function pokaz_k(k)
{
 $('kat1').style.display = 'none';
 $('kat2').style.display = 'none';
 $('kat3').style.display = 'none';
 $('kat4').style.display = 'none';
 if(k)
 {
  if($(k).style.display == '') { $(k).style.display = 'none'; } else { $(k).style.display = ''; }
 }
}

function czytaj_ciacho(nazwa)
{
 nazwa+="="; 
 startCookie=document.cookie.indexOf(nazwa);
 if (startCookie==-1) {return ""}
 startCookie+=nazwa.length;
 if (document.cookie.indexOf(";",startCookie)==-1) {
  koniecCookie=document.cookie.length; }
   else { koniecCookie=document.cookie.indexOf(";",startCookie); }
 textCookie=document.cookie.substring(startCookie,koniecCookie);
 textCookie=unescape(textCookie);
 return textCookie;
}
var Teraz = new Date();
Teraz.setTime(Termin = (24*60*60*1000) + Teraz.getTime());
Termin = (Teraz.toGMTString());

var ajax = new sack();
var currel = null;

function notes_loaded()
{
 if(currel == null) return false;
 currel = null;
 var ni = $('ilenotes');
 if(ni)
 {
  c = parseInt(ni.innerHTML);
  c++;
  ni.innerHTML = ''+c;
 }
}
function donotesu(id)
{
 ajax.setVar("oid", id);
 ajax.requestFile = 'do_notesu.php';
 ajax.method = 'post';
 ajax.element = currel = 'not'+id;
 ajax.onCompletion = notes_loaded;
 ajax.onError = function() { currel = null; $('ustat').className = ''; alert('Błąd! Nie można dodać do notesu!'); }
 ajax.runAJAX();
 par = $(currel);
 if(!par) return false;
 par.innerHTML = 'Czekaj ...';
}

function donotesu_an(id)
{
 ajax.setVar("oid", id);
 ajax.setVar("noverb", 1);
 ajax.requestFile = 'do_notesu.php';
 ajax.method = 'post';
 ajax.element = 'donotesu';
 ajax.onCompletion = function() { var ni = $('ilenotes'); if(ni) { c = parseInt(ni.innerHTML); c++; ni.innerHTML = ''+c; } alert('Anons został dodany do notesu.\nAby przeglądać ogłoszenia znajdujące się w notesie, kliknij w zakładkę "Notes" znajdującą się w górnym menu.'); }
 ajax.onError = function() { alert('Błąd! Nie można dodać do notesu!'); }
 ajax.runAJAX();
}

function powchgkat()
{
 ajax.setVar("k", $('dzial').value);
 ajax.requestFile = 'powiad_chgkat.php';
 ajax.method = 'post';
 ajax.element = 'kategs';
 ajax.onCompletion = function() { }
 ajax.onError = function() { alert('Błąd! Nie udało się zmienić kategorii!'); }
 ajax.runAJAX();
 $('kategs').innerHTML = '<select name="kateg" id="kateg" size="8"> <option value="0">&nbsp;</option> </select>';
}

function ocen_shw()
{
 if(nr = $('nrogl').value)
 {
  ajax.setVar("ShowOnly", 1);
  ajax.setVar("l", nr);
  ajax.requestFile = 'ocena.php';
  ajax.method = 'post';
  ajax.element = 'twojaocena';
  ajax.onCompletion = function() { }
  ajax.onError = function() { alert('Wystąpił błąd skryptu !'); }
  ajax.runAJAX();
 }
}

function ocen_add(v)
{
 if(nr = $('nrogl').value)
 {
  ajax.setVar("ShowOnly", 0);
  ajax.setVar("k", v);
  ajax.setVar("l", nr);
  ajax.requestFile = 'ocena.php';
  ajax.method = 'post';
  ajax.element = 'twojaocena';
  ajax.onCompletion = function() { }
  ajax.onError = function() { alert('Błąd! Nie udało się zapisać Twojej oceny!'); }
  ajax.runAJAX();
  $('twojaocena').innerHTML = 'Zapisuję Twój głos...';
 }
}

function chk_koment()
{
 var ret = true;
 if(document.getElementById('koment').value.length < 3) { ret = false; alert('Komentarz powininen zawierać treść.'); }
 return ret;
}

function nwin(page, x, y)
{
 sx = screen.availWidth;
 sy = screen.availHeight;
 px = (sx/2)-(x/2);
 py = (sy/2)-(y/2);
 var nwi = window.open(page,'mwin','top='+py+',left='+px+',width='+x+',height='+y+',resizable=no,scrollbars=no,status=yes', true);
 nwi.focus();
 return;
}

function swin(page, x, y)
{
 sx = screen.availWidth;
 sy = screen.availHeight;
 px = (sx/2)-(x/2);
 py = (sy/2)-(y/2);
 var nwi = window.open(page,'mwin','top='+py+',left='+px+',width='+x+',height='+y+',resizable=no,scrollbars=yes,status=yes', true);
 nwi.focus();
 return;
}

function kontakt(id)
{
 sx = screen.availWidth;
 sy = screen.availHeight;
 px = (sx/2)-250;
 py = (sy/2)-280;
 window.open('dane.php?id='+id,'','scrollbars=yes,top='+py+',left='+px+',width=500,height=560,status=no');
 return;
}

function chkadd()
{
 var ret = true;
 Maile=/^[A-Za-z0-9_.-]+@(?:[a-z0-9A-Z_-]+\.)+[a-z]{2,6}$/;
 if(ret && $('imie').value.length < 2) { ret=false; alert('Podaj swoje imię bądź nick.'); }
 if(ret && !Maile.test($('email').value)) { ret=false; alert('Podany adres e-mail jest nieprawidłowy.'); }
 if(ret && $('email').value != $('email2').value) { ret=false; alert('Podane adresy e-mail nie są identyczne.'); }
 if(ret && $('rok').value < 1900) { ret=false; alert('Podaj swój rok urodzenia.'); }
 if(ret && $('miasto').value.length < 2) { ret=false; alert('Wypełnij pole `miasto`.'); }
 if(ret && $('dwojew').value < 1) { ret=false; alert('Wybierz województwo.'); }
 if(ret && (!$('kateg') || $('kateg').value < 1)) { ret=false; alert('Wybierz kategorię w której ukaże się Twój anons.'); }
 if(ret && !$('u1').checked && !$('u2').checked && !$('u3').checked && !$('u4').checked && !$('u5').checked && !$('u6').checked 
	 && !$('u7').checked && !$('u8').checked) { ret=false; alert('Zaznacz przynajmniej jedno z listy upodobań.'); }
 if(ret && $('tresc').value.length < 2) { ret=false; alert('Pole `treść` jest wymagane.'); }
 if(ret && !$('accreg').checked) { ret=false; alert('Aby dodać swój anons musisz zaakceptować regulamin.'); }
 return ret;
}