function showNews(id){
	var div=document.getElementById(id);
	var adiv=document.getElementById('a'+id);
	var odiv=document.getElementById('open').value;
	var cdiv=document.getElementById('close').value;
	var tdiv=document.getElementById('t'+id);
	if(adiv.innerHTML==cdiv){
		tdiv.style.display="none";
		div.style.display="block";
		adiv.innerHTML=odiv;
	}else{
		tdiv.style.display="block";
		div.style.display="none";
		adiv.innerHTML=cdiv;
	}
}
function validateEmail(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function checkAddForm(){
	var error=false;
	var osoba=document.getElementById('osoba').value;
	var email=document.getElementById('email').value;
	var tel=document.getElementById('tel').value;
	if(!osoba){
		setFocus('osoba');
		alert('Musisz wpisać swoje imię i nazwisko');
		error=true;
	}
	if(!email && !tel && !error){
		setFocus('email');
		alert('Musisz wpisać pawidłwy adres emial lub numer telefonu');
		error=true;
	}else if(email && !validateEmail(email) && !error){
		setFocus('email');
		alert('Adres email ma niepoprawną strukturę');
		error=true;
	}
	if(!error){
		return true;
	}else{
		return false;
	}

}
function setFocus(item){
	document.getElementById(item).focus();
}

okienko="";
function zoom(nazwa,x,y,s,that) {
	opcje="toolbar=0,location=0,direction=0,status=0,menubar=0,scrollbars="+s+",left=" +((screen.width/2)-(x/2))+",top="+((screen.height/2)-(y/2))+",width=" + x +",height=" + y ;
	that.blur();
	if (okienko.closed == false)
		{okienko.close();okienko=window.open(nazwa,'okienko',opcje);} else
		{okienko=window.open(nazwa,'okienko',opcje);}
	okienko.focus();
}

function showAds(){
    var el=document.getElementById("topElement");
    if(el){
        var adsDiv="<div style='width:436px;height:600px;position:absolute;right:100px;top:50px;z-index:10'>"
        adsDiv+="<div style='text-align:right'><a href='javascript:closeAds()' style='color:#ccc;text-decoration:none;font-family:verdana'>x</a></div>";
        adsDiv+="<a href='/images/ulotka.pdf' target='_blank'><img src='/images/ulotka.jpg' style='border:2px solid #d18758' /></a>";
        adsDiv+="</div>";
        el.style.display='block';
        el.innerHTML=adsDiv;
    }
}

function closeAds(){
    var el=document.getElementById("topElement");
    el.style.display='none';
}