
// shortcut for 'document.getElementById()'
	function $(element) 
	{
		element = document.getElementById(element);
		return element;
	}


/* autocheck/uncheck all checkboxes in given form */
	function setCheckbox( container, checked )
	{
		var oContainer = document.getElementById(container);
		var aElement  = oContainer.getElementsByTagName('input');
		for( var i = 0; i < aElement.length; i++ )
		{
			if( 'checkbox' == aElement[i].type )
			{
				aElement[i].checked = checked;
			}
	    }

		return true;
	}

	// create basename from given string
	function getBaseName(str)
	{
		if(str.length>0)
		{
			var corect_str = str.replace(/\s+/gi, '-');
			corect_str = corect_str.replace(/[^\w\-]+/gi, '');
			return corect_str;
		}
		else
			return '';
	}

	function hideBlock(id)
	{
		var el = document.getElementById(id);

		if(el.style.display == 'none')
		{
			el.style.display = 'block';
		}
		else
		{
			el.style.display = 'none';
		}
	}


// clone an simple object ( without any other objects inside )
	function simplecloneObject( obj )
	{
    	for (i in obj)
		{
           	this[i] = obj[i];
	    }
	}


// clone the object and all the objects contains in it
	function cloneObject( obj )
	{
    	for (i in obj)
		{
        	if ( 'object' == typeof obj[i] )
        	{
            	this[i] = new cloneObject( obj[i]);
            }
        	else
            	this[i] = obj[i];
	    }
	}

// create element with name ( this is problem with IE )
	function createNamedElement( type, name )
	{
		var element;
		try
		{
			element = document.createElement('<'+type+' name="'+name+'">');
		}catch(e){}
		if (!element || !element.name) // Cool, this is not IE !!
		{
			element = document.createElement(type)
			element.name = name;
		}
		return element;
	}


// asinc serwer query. Gets responce text and pass it to callback function
	function serverQuery( callback_function, url, responseType )
	{
		//alert('cb-> ' + callback_function + ' url-> ' + url);
		//alert(' url-> ' + url);
		var XMLHttpRequestObject = false;
	    if( window.XMLHttpRequest )
	    {
			XMLHttpRequestObject = new XMLHttpRequest();
		}
		else if( window.ActiveXObject )
		{
			XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
		}

		if( XMLHttpRequestObject )
	    {
//			XMLHttpRequestObject.open( "GET", url );
			XMLHttpRequestObject.open( "POST", url );
			XMLHttpRequestObject.onreadystatechange = function()
			{
				if ( XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 )
		    	{

					if ( '' != callback_function )
					{
						if ( 'xml' == responseType )
							answer = XMLHttpRequestObject.responseXML;
						else
							answer = XMLHttpRequestObject.responseText;

						callback_function(answer);
					}

					delete XMLHttpRequestObject;
					XMLHttpRequestObject = null;

				}
		    }
			XMLHttpRequestObject.send( null );
		}

		return true;
	}

	function showTitle( event, text )
	{

		if ( !event )
			event = window.event;

		container = document.getElementById('asynchelp_container');

		container.style.display='block';

		var scroll_x = 0, scroll_y = 0;
		if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) )
		{
			scroll_x = document.body.scrollLeft; scroll_y = document.body.scrollTop;
		}
		else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) )
		{
			scroll_x = document.documentElement.scrollLeft; scroll_y = document.documentElement.scrollTop;
		}

		container.style.left = event.clientX + scroll_x - container.parentNode.offsetLeft - container.offsetWidth/2 + 'px';
		container.style.top = event.clientY + scroll_y - container.parentNode.offsetTop + 20 + 'px';

		container.innerHTML = text;

	}
	
	function hideTitle()
	{
		container = document.getElementById('asynchelp_container');
		container.style.display = 'none';
	}	
	
	function getAsyncHelp( event, url )
	{

		container = document.getElementById('asynchelp_container');

		container.style.display='block';

		var scroll_x = 0, scroll_y = 0;
		if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) )
		{
			scroll_x = document.body.scrollLeft; scroll_y = document.body.scrollTop;
		}
		else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) )
		{
			scroll_x = document.documentElement.scrollLeft; scroll_y = document.documentElement.scrollTop;
		}

		container.style.left = event.clientX + scroll_x - container.parentNode.offsetLeft - container.offsetWidth/2 + 'px';
		container.style.top = event.clientY + scroll_y - container.parentNode.offsetTop + 20 + 'px';

		container.innerHTML = 'loading ...';

		serverQuery( setAsyncHelp, url );

	}

	function setAsyncHelp( sText )
	{
		container = document.getElementById('asynchelp_container');
		container.innerHTML = sText;
	}

	function hideAsyncHelp()
	{
		container = document.getElementById('asynchelp_container');
		container.style.display = 'none';
	}


	function initAsyncHelp( event, url )
	{

		if ( !event )
			event = window.event;

 		getAsyncHelp( event, url)

		return true;

	}

/*
*	rss feeds func
*/
	function getRss(container,url)
	{
		container = document.getElementById(container);
		serverQuery(drawRss, url);

		function drawRss(data)
		{
			container.innerHTML = data;
			return true;
		}

		return true;
	}
/*
*	END of rss feeds func
*/