function gEBI(obj) {
	return document.getElementById(obj);
}

function mailing(mail) { 
 var adresik="mailto:"+mail+"@q-100.pl";
 parent.location.href=adresik;
}

function dataw_chg() {
	gEBI('dokumenty_datak').value=gEBI('dokumenty_dataw').value;
}

function gotowka() {
	if (gEBI('platnosc_rodzaj').value==1)  {
		gEBI('platnosc_dni').disabled=false; 
		gEBI('przelewy_rodzaj').disabled=false; 
	}
	else {
		gEBI('platnosc_dni').disabled=true;
		gEBI('przelewy_rodzaj').disabled=true; 
	}
}
function kopie() {
	if (document.gEBI('faktura_egzemplarz').value!=='ORYGINAŁ+KOPIA') gEBI('ilosc_kopii').value=1; else gEBI('ilosc_kopii').value=2;
}

function send_ajax(form,url) {
if (window.XMLHttpRequest)
  {
  xmlhttp1=new XMLHttpRequest();
  }
else
  {
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
		xmlDoc=xmlhttp1.responseXML;
		var txt="";
		x=xmlDoc.getElementsByTagName("ERROR");
		y=xmlDoc.getElementsByTagName("OK");
		if (x.length==0 && y.length==0){
			form.submit();
		}
		else {
			if (x.length!=0){
				for (i=0;i<x.length;i++)
				  {
				  txt=txt + x[i].childNodes[0].nodeValue + "\n";
				  }
				alert(txt);
			}
			if (y.length!=0){
				for (i=0;i<y.length;i++)
				  {
				  txt=txt + y[i].childNodes[0].nodeValue + "\n";
				  }
				alert(txt);
				window.location.reload();
			}
		}
    }
  }
var query=Post.buildQuery(form);
xmlhttp1.open("POST","http://www.q-100.pl/faktury/ajax/?"+url,true);
xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
xmlhttp1.send(query);
}

function typy(id) {
if (window.XMLHttpRequest)
  {
  xmlhttp1=new XMLHttpRequest();
  }
else
  {
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
		xmlDoc=xmlhttp1.responseXML;
		x=xmlDoc.getElementsByTagName("TYPY");
		if (x[0].childNodes[0].nodeValue==0){
			gEBI('dokumenty_vat').checked='';
			gEBI('dokumenty_vat3').style.visibility = 'hidden';
			gEBI('dokumenty_vat4').style.visibility = 'hidden';
			gEBI('dokumenty_vat5').style.visibility = 'hidden';
			gEBI('dokumenty_netto1').style.visibility = 'hidden';
			gEBI('dokumenty_netto2').style.visibility = 'hidden';
			gEBI('dokumenty_netto3').style.visibility = 'hidden';
			gEBI('dokumenty_netto4').style.visibility = 'hidden';
			gEBI('dokumenty_netto5').style.visibility = 'hidden';
		}
		else {
			gEBI('dokumenty_vat').checked='checked';
			gEBI('dokumenty_vat3').style.visibility='visible';
			gEBI('dokumenty_vat4').style.visibility='visible';
			gEBI('dokumenty_vat5').style.visibility='visible';
			gEBI('dokumenty_netto1').style.visibility='visible';
			gEBI('dokumenty_netto2').style.visibility='visible';
			gEBI('dokumenty_netto3').style.visibility='visible';
			gEBI('dokumenty_netto4').style.visibility='visible';
			gEBI('dokumenty_netto5').style.visibility='visible';
		}
	}
  }
xmlhttp1.open("GET","http://www.q-100.pl/faktury/ajax/?typy&id="+id,true);
xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
xmlhttp1.send();
}

function send_ajax1(url,div) {
if (window.XMLHttpRequest)
  {
  xmlhttp1=new XMLHttpRequest();
  }
else
  {
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
		xmlDoc=xmlhttp1.responseXML;
		var txt="";
		x=xmlDoc.getElementsByTagName("ERROR");
		y=xmlDoc.getElementsByTagName("OK");
		if (x.length!=0){
			for (i=0;i<x.length;i++)
			  {
			  txt=txt + x[i].childNodes[0].nodeValue + "\n";
			  }
			alert(txt);
		}
		if (y.length!=0){
			for (i=0;i<y.length;i++)
			  {
			  txt=txt + y[i].childNodes[0].nodeValue + "\n";
			  }
			alert(txt);
			if (div!='') get_div(div,'');
		}
	}
  }
xmlhttp1.open("GET","http://www.q-100.pl/faktury/ajax/?"+url,true);
xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
xmlhttp1.send();
}

function forum_delete(id) {
	var form=document.forms['forum_del'];
	var url;
	url='forumdel'+'&id='+id;
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}


function forum_save() {
	var form=document.forms['forum_form'];
	var url;
	url='forumsave';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}


function pass_chg() {
	var form=document.forms['passchg_form'];
	var url;
	url='chgpass';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			gEBI('pass_error').innerHTML=xmlhttp1.responseText;
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/faktury/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}

function wyj_add() {
	var form=document.forms['wyj_dod'];
	var url;
	url='wyj_dod';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
				window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}


function wyjsz_add() {
	var form=document.forms['wyjsz_dod'];
	var url;
	url='wyjsz_dod';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
				window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}


function send_all() {
	var form=document.forms['allsend'];
	var url;
	url='send_all';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
				window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}


function dni_add() {
	var form=document.forms['dni_dod'];
	var url;
	url='dni_dod';
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
				window.location.reload();
		}
	  }
	var query=Post.CreateRequestString(form);
	var method=form.method;
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send(query);
}

function zmoku_del(item,id) {
	var url;
	url='zmoku_del&id='+id+'&item='+item;
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			window.location.reload();
		}
	  }
	xmlhttp1.open('POST',"http://www.q-100.pl/zmoku/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send();
}

function numer_chg() {
	var url;
	url='numer_change&date='+gEBI('faktury_dataw').value;
	if (window.XMLHttpRequest)
	  {
	  xmlhttp1=new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp1.onreadystatechange=function()
	  {
	  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			alert('Zmiana daty spowodowała zmianę numeru faktury na: '+xmlhttp1.responseText);
			gEBI('faktury_fullnr').value=xmlhttp1.responseText;
		}
	  }
	xmlhttp1.open('GET',"http://www.q-100.pl/faktury/ajax/?"+url,true);
	xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp1.send();
}

function get_div(url,params) {
var form=document.forms[url+'_form'];
var cont=url+'_div';
if (window.XMLHttpRequest)
  {
  xmlhttp1=new XMLHttpRequest();
  }
else
  {
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
		if (xmlhttp1.getResponseHeader("Content-Type")=="text/xml") {
			xmlDoc=xmlhttp1.responseXML;
			var txt="";
			x=xmlDoc.getElementsByTagName("ERROR");
			for (i=0;i<x.length;i++)
			  {
			  txt=txt + x[i].childNodes[0].nodeValue + "\n";
			  }
			alert(txt);
		}
		else {
			gEBI(cont).innerHTML=xmlhttp1.responseText;
		}
    }
  }
if (params!='') url = url+"&"+params; 
if (form) {
	var query=Post.CreateRequestString(form);
	var method=form.method;
}
else {
	var method='GET';
}
xmlhttp1.open(method,"http://www.q-100.pl/faktury/ajax/?"+url,true);
xmlhttp1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
xmlhttp1.send(query);
}

function set_chng() {
	gEBI('change').value=1;
}

