function byId( sId ) {
	return document.getElementById( sId );
}

function newTag(tag) {
	return document.createElement(tag);
}

function categoryList( data , dest) {
	aC = data.split(':');
	oDest = document.getElementById(dest);
	for(a=0; a<aC.length; a++) {
		if(a % 2 == 0) {
			cl='par';
		} else {
			cl='npar';
		}
		aCC=aC[a].split(';');

	}

}

function removeNode( oNode ) {
	oNode.parentNode.removeChild(oNode);
}

function removeNodeById( sId ) {
	try {
		removeNode(byId(sId));
	} catch (e) {
		;
	}
}

// funkcje do roznych formularzy....

/* Kategorie linkow */
function showCatEdit( oSpan ) {
	i=oSpan.id;
	ed = document.getElementById('ed_'+i);
	oSpan.style.display='none';
	ed.style.display='inline';

}

function hideCatEdit( id ) {
	n = document.getElementById(id);
	ed = document.getElementById('ed_'+id);
	n.style.display='inline';
	ed.style.display='none';

}

function updateCat( id , cid) {
	clearMessages(document.getElementsByTagName('form')[0]);
	n = document.getElementById(id);
	n.innerHTML=document.getElementById('in_'+id).value;
	postData='upd_cat='+cid;
	postData+='&new_val='+encodeURIComponent(document.getElementById('in_'+id).value)
	makeRequest('index.php?runEngine=1&act=links', postData);
	hideCatEdit( id );
	return false;
}

function delCat(cId) {
	postData='del_cat='+cId;
	makeRequest('index.php?runEngine=1&act=links', postData);
	return false;
}



/* kategorie notek */
function showNCatEdit( oSpan ) {
	i=oSpan.id;
	ed = document.getElementById('ed_'+i);
	oSpan.style.display='none';
	ed.style.display='inline';

}

function hideNCatEdit( id ) {
	n = document.getElementById(id);
	ed = document.getElementById('ed_'+id);
	n.style.display='inline';
	ed.style.display='none';

}

function updateNCat( id , cid) {
	clearMessages(document.getElementsByTagName('form')[0]);
	n = document.getElementById(id);
	n.innerHTML=document.getElementById('in_'+id).value;
	postData='upd_cat='+cid;
	postData+='&new_val='+encodeURIComponent(document.getElementById('in_'+id).value)
	makeRequest('index.php?runEngine=1&act=notesCat', postData);
	hideNCatEdit( id );
	return false;
}

function delNCat(cId) {
	postData='del_cat='+cId;
	makeRequest('index.php?runEngine=1&act=notesCat', postData);
	return false;
}



function getSelect(oSelect, id ) {
	if(!oSelect) {
		oSelect = document.getElementById(id);
	}
	if(oSelect) {
		return oSelect;
	} else {
		return false;
	}
	
}

function clearSelect( oSelect, id ) {
	while(oSelect.options.length>0)
	oSelect.remove(0);
}


function createOption(sValue, sText) {
	return new Option(sValue, sText);
}

function addOption(selectElement,newOption) {
	try {
		selectElement.add(newOption,null);
	}
	catch (e) {
		selectElement.add(newOption,selectElement.length);
	}
}

function addOptions(select, opts) {
	for(var l=0; l<opts.length; l++) {
		addOption(select, createOption(opts[l].val, opts[l].text));
	}
}

function hideById(sId) {
	document.getElementById(sId).style.display='none';
}

function showById(sId) {
	document.getElementById(sId).style.display='block';
}


function massAttr( aIds, sArrt, sValue ) {
	var a=0;
	for(a=0; a<aIds; a++) {
		byId(aIds[a]).setAttribute(sAttr, sValue);
	}
}