isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
   // document.onmouseclick = captureMouseclick;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
    //document.onmouseclick = captureMouseclick;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
    //document.onmouseclick = captureMouseclick;
}

var xMousePos = 0;
var yMousePos = 0;

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        silnik = "NC";
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        //xMousePos = window.event.x;//+document.body.scrollLeft;
        //yMousePos = window.event.y+document.body.scrollTop;
        
        
        if (document.documentElement && document.documentElement.scrollTop)
        {
        	xMousePos=window.event.x+document.documentElement.scrollLeft;
        	yMousePos=window.event.y+document.documentElement.scrollTop;
        	xMousePosMax = document.body.clientWidth+document.documentElement.scrollLeft;
        	yMousePosMax = document.documentElement.clientHeight+document.documentElement.scrollTop;;
        	silnik = "IE";
        	
        }
        else
        {
        	xMousePos=window.event.x+document.body.scrollLeft;
        	yMousePos=window.event.y+document.body.scrollTop;
        	xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
       		yMousePosMax = document.documentElement.clientHeight;
       		silnik = "IE"; //napewno 6
        }
            
     //   xMousePos = window.event.x+document.body.scrollLeft;
     //   yMousePos = window.event.y+document.body.scrollTop;
        
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        silnik = "FF";
    }
    
    if (document.layers)
			{
			}
			else
			if (document.all)
			{
				if (document.documentElement && document.documentElement.scrollTop)
			 	{
			 		events_my = window.event;
			 	}
			 	else
			 	{
			 		events_my = window.event;
				 }
			}
			else
			if (document.getElementById)
			{
			// Netscape 6 behaves the same as Netscape 4 in this regard
			// FF
				events_my = e;
			}
			
		if(silnik == "FF")
 		{
		 	obj_click = events_my.originalTarget;
		}
		if(silnik == "IE")
		{
			obj_click = events_my.srcElement;
		}
		
		/*if(obj_click)
			alert(obj_click);*/
}

function getelement(id)
{
if (isNS4)
	{
		elm = document.layers[id];
	    //elm.document.open();
        //elm.document.write(totalprice);
        //elm.document.close();
        if (!elm)
			elm = false;
	}
	else 
		if (isIE4) 
		{
			elm = document.all[id];
			//elm.innerText = totalprice;
			if (!elm)
		        elm = false;
		}
		else 
			if (isIE5)
			{
				elm = document.getElementById(id);
				if (!elm)
		       		elm = false;
			}
			else 
				if (isNS6)
				{
					elm = document.getElementById(id);
					if (!elm)
		        		elm = false;
					
				}

	return elm;
}


function open_view(obj)
{
	var url = obj.href;
	
	var name='';
	 var args='WIDTH=520,HEIGHT=500,scrollbars=yes';
	 if (typeof(popupWin1) != "object")
	 {
	 popupWin1 = window.open(url, name, args);
	 }
	 else
	 {
	 if (!popupWin1.closed)
	 {
	 popupWin1.location.href = url;
	 }
	 else
	 {
	 popupWin1 = window.open(url, name, args);
	 }
	 }
	 popupWin1.focus();
	 return false;
}


var txt = false;
function txt_clr(obj)
{
	if(!txt)
	{
		txt = true;
		obj.value = "";
	}
}

function on_off(ob)
{
	var obj = getelement(ob);
	if(obj)
	{
		if(obj.style.display == "none")
			obj.style.display = "";
		else
			obj.style.display = "none";
	}
}

var old_dym=null;
function show_more_help(ob,link)
{
	var obj = getelement(ob);
	var linkj = getelement(link);

	if(obj)
	{
		obj.style.left = (xMousePos+10)+"px";
		obj.style.top = (yMousePos-110)+"px";
	}
	if(old_dym)
		on_off(old_dym);
	on_off(ob);
	old_dym = ob;
}

function show_more_helpCL(ob)
{
	old_dym = null;
	on_off(ob);
}


function find_parent_title(obj,name)
{
	if(obj.title == name)
		return obj;
	obj = obj.offsetParent;

	if (obj)
	{
		if(obj.title == name)
		return obj;
		var x=0;
		while (obj = obj.offsetParent)
		{
			if(obj.title == name)
			return obj;
			x++;
			if(x>20)
				break;
		}
	}
}

function find_parent_id(obj,name)
{
	if(obj.id == name)
		return obj;
	obj = obj.offsetParent;

	if (obj)
	{
		if(obj.id == name)
		return obj;
		var x=0;
		while (obj = obj.offsetParent)
		{
			if(obj.id == name)
			return obj;
			x++;
			if(x>20)
				break;
		}
	}
}

function find_parent_type(obj,name)
{
	alert(obj.tagName);
	if(obj.tagName == name)
		return obj;
	obj = obj.offsetParent;

	if (obj)
	{
		alert(obj.tagName);
		if(obj.tagName == name)
			return obj;
		var x=0;
		while (obj = obj.offsetParent)
		{
			alert(obj.tagName);
			if(obj.tagName == name)
			return obj;
			x++;
			if(x>20)
				break;
		}
	}
}

function GetParent(obj,target)
{
	var objektGlowny = obj.parentNode;
	if(objektGlowny.tagName == target)
	{
		return objektGlowny;
	}
	else
	{
		return GetParent(objektGlowny,target);
	}
	
	return 0;
}

function getelementname(id,type)
{
if (isNS4)
	{
		if(id)
			elm = id.getElementsByTagName(type);
		else
			elm = getelement(id).getElementsByTagName(type);
	    //elm.document.open();
        //elm.document.write(totalprice);
        //elm.document.close();
        if (!elm)
			elm = false;
	}
	else 
		if (isIE4) 
		{
			elm = document.all[type];
			//elm.innerText = totalprice;
			if (!elm)
		        elm = false;
		}
		else 
			if (isIE5)
			{
				if(id)
					elm = id.getElementsByTagName(type);
				else
					elm = getelement(id).getElementsByTagName(type);
				if (!elm)
		       		elm = false;
			}
			else 
				if (isNS6)
				{
					if(id)
						elm = id.getElementsByTagName(type);
					else
						elm = getelement(id).getElementsByTagName(type);
					if (!elm)
		        		elm = false;
					
				}

	return elm;
}