function add_plik(f){ //dodawanie plikow
    var no = document.forms[f].elements['no'].value;
    var znacznik = document.createElement('input');
	znacznik.setAttribute('type', 'file');
	znacznik.setAttribute('name', 'attachment['+no+']');
	znacznik.className = 'upload';
	var kontener = document.getElementById('zalacznik');
	kontener.appendChild(znacznik);
	no++;
	document.forms[f].elements['no'].value=no;
}
/**
*  20 - dodawanie kategorii
*  22 - dodanie podkategorii
*/
function actionForm(f){
var name=document.getElementById(f+'_nazwa').value;
	if(name==''){
	alert("prosze wpisac nazwe !!!");
	return false;
	}
    var http = null;
    if(window.XMLHttpRequest)
	http = new XMLHttpRequest();
    else if (window.ActiveXObject)
    http = new ActiveXObject("Microsoft.XMLHTTP");
    http.onreadystatechange = function(){
        if(http.readyState == 4) 
		{ 
	    	if( http.status == 200 ) { 
	  	 		  document.getElementById(f+'_nazwa').value='';
	  	 		  var odpowiedz = http.responseText;
	  	 		  var xmldoc = http.responseXML;
            	var record = xmldoc.getElementsByTagName('record');
  				var NewOption = document.getElementById("selectkat");
	if(NewOption.length>0){
		for (var i=0;i <= NewOption.length;i++){
			var opt = NewOption.options[NewOption.selectedIndex];
			if (opt) NewOption.removeChild(opt);
		}	
	}	
            for (i = 0; i < record.length; i++) {
            	var idValue = (record[i].getElementsByTagName("id")[0].firstChild.nodeValue);
				var nameKat = (record[i].getElementsByTagName("nazwa")[0].firstChild.nodeValue);
				NewOption.options[NewOption.options.length] = new Option(nameKat,idValue);
			}
			        		
        	}
    	}
	}

    http.open("POST", "Ajaxs/actionForm.php", true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    
    http.send("nazwa="+name+"&form="+f); 
 }
 
 
 function action(action,id){
 	/**
 	*	funkcja wysylajaca i odbierajaca dane
 	*	1 - kategorie - pokaz podkategorie
 	*	2 - kategorie - edytuj
 	*	3 - kategorie - usun
 	*
 	**/
 	if(action==3){
 		var string="Czy napewno usunac ?";
 		var r=confirm(string);
  		if(r==false){
  			return false;
  		}
 	}
 	var http = null;
    if(window.XMLHttpRequest)
	http = new XMLHttpRequest();
    else if (window.ActiveXObject)
    http = new ActiveXObject("Microsoft.XMLHTTP");
    http.onreadystatechange = function(){
        if(http.readyState == 4) 
		{ 
	    	if( http.status == 200 ) { 
				var odpowiedz = http.responseText;  
				//alert(odpowiedz);
				if(action==3){
					var element = document.getElementById(id);
					while (element.firstChild) {
						element.removeChild(element.firstChild);
					}
				}
        	}
    	}
	}

    http.open("POST", "Ajaxs/action.php", true);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    
    http.send("action="+action+"&id="+id); 
 }
 
    