








function getX(event) {	return (event.clientX) ? event.clientX : event.layerX; }
function getY(event) { return (event.clientY) ? event.clientY : event.layerY; } 


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); }

