
function getSelectedRadioButton(radioButtonGroup) {
	for (var i in radioButtonGroup)	{ 
		if (radioButtonGroup[i].checked) { return radioButtonGroup[i]; } 
	}
	return false;
}




//function getX(event) { return (event.clientX) ? event.clientX : event.pageX; }
//function getY(event) { return (event.clientY) ? event.clientY : event.pageY; } 

function getX(event) { return (event.pageX) ? event.pageX : event.clientX; }
function getY(event) { return (event.pageY) ? event.pageY : event.clientY; } 

function IsChild(child,parent) {
	if ((typeof(child)=='object') && (typeof(parent)=='object')) {
		var bezpiecznik = 0;
		while (child.parentNode!=null) {
			if (child.parentNode==parent) { return true; }
			if (bezpiecznik>=100) { break; } else { bezpiecznik++; }
			child = child.parentNode;
		}		
	}
	return false;
}

function IsChildR(child,parent,level) {
	
}

function WalkGroupTags(parentItem,tagName,groupName,operation) {
	if (tagName.length==0) { return false; }
	if (groupName.length==0) { return false; }
	parentItem = (parentItem == null) ? document : parent;
	// alert(tagName);
	var items = parentItem.getElementsByTagName(tagName);	
	for(var jj in items) {
		if (typeof(items[jj])=='object') {			
			if (items[jj].getAttribute('group')==groupName) { // element należy do właściwej grupy				
				operation(items[jj]);
			}
		} else { // to nie jest obiekt
		}
	}
}

function SHGroupTags(parentItem,tagName,groupName,display,visibility) {
	if (tagName.length==0) { return false; }
	if (groupName.length==0) { return false; }
	if (display.length==0 && visibility.length==0) { return false; }	
	parentItem = (parentItem == null) ? document : parent;
	var items = parentItem.getElementsByTagName(tagName);
	for(var i in items) {
		if (typeof(items[i])=='object') {			
			if (items[i].getAttribute('group')==groupName) { // element należy do właściwej grupy
				if (display.length) { items[i].style.display=display; }
				// if ()
			}
		} else { // to nie jest obiekt
		}
	}
}

function SH_Element(element_id,sh) {
	element = document.getElementById(element_id);
	if (element) { if (sh) { element.style.display = 'block'; } else { element.style.display = 'none'; } }
}

function Show_Element(element_id) { SH_Element(element_id,true); }
function Hide_Element(element_id) { SH_Element(element_id,false); }

function SHGroup_Elements(tagname, groupname, show_id) {
	tags = document.getElementsByTagName(tagname);	
	for (tag in tags) {
		if (!(tags[tag].id)) { continue; }
		atributes = tags[tag].attributes;
		for (a in atributes) {
			if ((atributes[a]) && (atributes[a].nodeName) && (atributes[a].nodeName=='id_group')) { 				
				if (tags[tag].id==show_id) {
					tags[tag].style.display='block';
				} else {
					tags[tag].style.display='none';
				}
			}		
		}			
	}		
}

function SH_Group(tagname, groupname, show, disp_name) {
	// alert(tagname+', '+groupname+', '+show+' '+disp_name);
	tags = document.getElementsByTagName(tagname);	
	for (tag in tags) {		
		if (!(tags[tag].id)) { continue; }
		atributes = tags[tag].attributes;
		for (a in atributes) {
			if ((atributes[a]) && (atributes[a].nodeName) && (atributes[a].nodeName=='id_group') && (atributes[a].nodeValue==groupname)) {
				
				if (show) {
					if (navigator.userAgent.indexOf('MSIE')>0) { // Explorer
						tags[tag].style.display='inline';
					} else {
						tags[tag].style.display='table-cell';
					}
				} else {
					tags[tag].style.display='none';
				}
			}		
		}			
	}		
}

function ShowGroup(tagname, groupname) { SH_Group(tagname, groupname, true); }
function HideGroup(tagname, groupname) { SH_Group(tagname, groupname, false); }


function SHRow(row,show) {	
	if (typeof(row.style)=='unknown') { row.style='display: none'; } if (typeof(row.style.display)=='unknown') { row.style.display='none'; }
	if (show) {
		row.style.display = (browser.isIE) ? 'block' : 'table-row';
	} else {
		row.style.display = 'none';
	}
	row.className='';
}

function SHRowGroup(groupname,show) {
	// alert(group);
	tags = document.getElementsByTagName('tr');
	// js_dump(tags);	
	for (tag in tags) {			
		if (!((tags[tag]) && (tags[tag].attributes) && (tags[tag].attributes.length>=1))) { continue; }
		atributes = tags[tag].attributes;
		for (a in atributes) {
			if ((atributes[a]) && (atributes[a].nodeName) && (atributes[a].nodeName=='id_group') && (atributes[a].nodeValue==groupname)) {				
				SHRow(tags[tag],show);				
			}		
		}			
	}
}

function SelfHide(event) {
	event.currentTarget.style.display = 'none';
}

function ShowCreateAfterMouseClick(event,itemID,content) {		
	var containerParam = (arguments[3]) ? arguments[3] : '';
	var dx = (arguments[4]) ? arguments[4] : -250;
	var dy = (arguments[5]) ? arguments[5] : -180;
	var item = document.getElementById(itemID);
	if (item==null) { // utworz nowy element
		var item = document.createElement('div');		
		item.setAttribute('id',itemID);
		EventUtils.addEventListener(item,'click',SelfHide);
		// item.setAttribute('style','position: absolute; display: block; top: '+getY(event)+'px; left: '+getX(event)+'px;'+containerParam);		
		document.body.appendChild(item);		
	}
	if (typeof(item)=='object') {
		item.setAttribute('style','position: absolute; display: block; top: '+(getY(event)+dy)+'px; left: '+(getX(event)+dx)+'px;'+containerParam);
		item.innerHTML = content;
	} else {
		return false;
	}	
}