
function popup(foto,szer,wys,nazwa)
{

config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+szer+',height='+wys+' ,scrollbars=no,resizable=no';
var okno = window.open ("",nazwa,config);

okno.document.write('<html><head></head><body onClick="window.close()" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0"><a href="#"><img src="'+foto+'" border=0  > </a></body></html>');

okno.document.close();
}

function setUrl()
{
var Qid=new Number(document.getElementById('QueryId').value);
if(isNaN(Qid))
alert('Proszę wprowadzić prawidłowy numer pytania');
else
window.location=Qid+',pytanie_szczegoly.html';
}

function akceptuj(f)
{

if(!f.accept.checked)
{
alert('Aby móc się zarejestrować prosimy zaakceptować regulamin!');
return false;
}
else
return true;
}


function tabelka(id)
{


  if(document.getElementById('tab'+id).style.display=='none')
  {
    document.getElementById('tab'+id).style.display='block';

  }
  else
  {
    document.getElementById('tab'+id).style.display='none';

  }


}


function blink(id)
{
var ob=document.getElementById('blink'+id);
if(ob)
{
if(ob.style.visibility=='hidden')
ob.style.visibility='visible';
else if(ob.style.visibility=='visible')
ob.style.visibility='hidden';
else
ob.style.visibility='hidden';

setTimeout("blink("+id+")",1000);
}
}








function prepareObject()
{
		if(window.XMLHttpRequest)
		{
		  req=new XMLHttpRequest();	
		}
		else if(window.ActiveXObject)
		{
		  req=new ActiveXObject("Msxml2.XMLHTTP");
		  
		  if(!req)
		  req=new ActiveXObject("Microsoft.XMLHTTP");
		}


}

function sendNewsletterRequest(formularz,url,asynch)
{
  prepareObject();
  if(!req)
  {    
    alert('Przeglądarka nie obsługuje wymaganych narzędzi do obsługi tego żądania');
    return;
   }
var form=document.forms[formularz];

try
{
  req.onreadystatechange=newsletterResponse;
  req.open(form.method,url,asynch);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
req.send('email='+encodeURIComponent(form.email.value)+'&kod='+encodeURIComponent(form.kod.value));
  
}
catch(e)
{
  alert('Wystąpił problem z komunikacją z serwerem');
}
  
}


function newsletterResponse()
{
try
{
  if(req.readyState==4 )
  {
    
    	if(req.status==200)
    	{
	
		     document.getElementById('newsletter_div').innerHTML=req.responseText;
		     document.getElementById('newsletter_div').style.display='block';
		
		  
		}
		else
		{
		   alert('Wystąpił problem z komunikacją z serwerem');
		}
    
	}
}
catch(e)
{
 alert('Wystąpił problem z komunikacją z serwerem');
} 
 
}

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

function OpenQueryRequest()
{

  prepareObject();
  if(!req)
  {    
    alert('Przeglądarka nie obsługuje wymaganych narzędzi do obsługi tego żądania');
    return;
   }


try
{

  req.onreadystatechange=OpenQueryResponse;
  req.open('GET',file,true);
	req.send(null);
  document.getElementById('open_query_content').innerHTML='Pobieranie danych....';

}
catch(e)
{
  alert('Wystąpił problem z komunikacją z serwerem');
}
  
}


function OpenQueryResponse()
{
try
{
  if(req.readyState==4 )
  {
    
    	if(req.status==200)
    	{
	
		     document.getElementById('open_query_content').innerHTML=req.responseText;
		    // document.getElementById('newsletter_div').style.display='block';
		setTimeout("OpenQueryRequest()",500000);
		  
		}
		else
		{
		   alert('Wystąpił problem z komunikacją z serwerem');
		}
    
	}
}
catch(e)
{
 alert('Wystąpił problem z komunikacją z serwerem');
} 
 
}



function drukuj()
{
config='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no';
var pop = window.open ("","pop",config);
pop.document.write('<html><head></head><body  leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0"><table  ><tr><td>');


  var txt='';
  txt+=document.getElementById('reg').innerHTML;
   pop.document.write(txt);
  pop.document.write('</td></tr></body></html>');
pop.document.close();

pop.print();
  
}




function nowe_pytanie(f)
{

	if(f.pytanie.value=='' || f.tresc.value=='')
	{
	alert('Proszę podać temat i treść pytania');
	return false;
	}
	else
	{
		if(f.forma_odp[0].checked && f.stawka.value<30)
		{
			
			return confirm('Czy na pewno chcesz obstawić swoje pytanie tą kwotą? Nieodpowiednia kwota zmniejsza szansę na otrzymanie odpowiedzi.');
		
		
		}
		else
		return true;
	}

}


 function txt_length(pole,max)
{


if(max-(pole.value.length)<0)
{
 alert('Maksymalna ilość znaków wynosi '+max);
pole.value=pole.value.substr(0,max)

}

}
 
 
 
 
 function round_stawka(f)
 {
	var value=parseFloat(f.value);
	if(isNaN(value))
	f.value='';
	else	
	 f.value=Math.round(value);

 }
 
 function wycena(f,kwota)
 {
	
	f.stawka.value=kwota;
	var pole=document.createElement('input');
	pole.setAttribute('type','hidden');
	pole.setAttribute('name','wycena');
	pole.setAttribute('value','1');
	f.appendChild(pole);
	 f.submit();
	 
 }
 

