	
	//=========================================================================
    // What browser?
    //=========================================================================

	var uagent    = navigator.userAgent.toLowerCase();
	var isSafari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
	var isOpera  = (uagent.indexOf('opera') != -1);
	var isWebtv  = (uagent.indexOf('webtv') != -1);
	var isIe     = ( (uagent.indexOf('msie') != -1) && (!isOpera) && (!isSafari) && (!isWebtv) );
	var isIe4    = ( (isIe) && (uagent.indexOf("msie 4.") != -1) );
	var isMoz    = ( (navigator.product == 'Gecko')  && (!isOpera) && (!isWebtv) && (!isSafari) );
	var isNs     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!isOpera) && (!isWebtv) && (!isSafari) );
	var isNs4    = ( (isNs) && (parseInt(navigator.appVersion) == 4) );
	var isKon    = (uagent.indexOf('konqueror') != -1);
	
	//=========================================================================
    // Get element by id, enchanted function
    //=========================================================================
	
	function getById( id )
	{
		obj = null;
		
		if( document.getElementById )
		{
			obj = document.getElementById( id );
		}
		else if( document.all )
		{
			obj = document.all[id];
		}
		else if( document.layers )
		{
			obj = document.layers[id];
		}
		
		return obj;
	}
	
	//=========================================================================
    // Insert text into object
    //=========================================================================
	
	function insertText( editorId, text )
	{		
		var editor = document.getElementById( editorId );
		
		if( editor == null )
		{
			return;
		}
		
		if( document.selection )
		{
			editor.focus();
		
			var selection = document.selection.createRange();
		
			selection.text = text;
		}
		else if( editor.selectionStart || editor.selectionStart == 0 )
		{
			startPos = editor.selectionStart;

			endPos = editor.selectionEnd;

			editor.value = editor.value.substring( 0, startPos ) + text + editor.value.substring( endPos, editor.value.length );
		}
		else
		{
			editor.value += text;
		}
		
		return false;
	}
	
	//=========================================================================
    // Check equals text in object
    //=========================================================================
	
	function equalsText( text, editorId )
	{
		var editor = document.getElementById( editorId );
		
		if( editor == null )
		{
			return;
		}
		
		text = RegExp.escape( text );
		
		text = new RegExp( text );
		
		if( editor.value.search( text ) != -1 )
		{
			return true;
		}
		
		return false;
	}
	
	//=========================================================================
    // Clean up reg exp string
    //=========================================================================
	
	RegExp.escape = function( text )
	{
		if( !arguments.callee.sRE )
		{
			var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '-' ];
			
			arguments.callee.sRE = new RegExp( '(\\' + specials.join('|\\') + ')', 'g' );
		}
  
		return text.replace( arguments.callee.sRE, '\\$1' );
	}
	
	//=========================================================================
    // Get object left position
    //=========================================================================
	
	function getObjLeft( obj )
	{
		var curleft = 0;

		if( obj.offsetParent )
		{
			while( obj.offsetParent )
			{
				curleft += obj.offsetLeft;
				obj      = obj.offsetParent;
			}
		}

		return curleft;
	}
	
	//=========================================================================
    // Get object top position
    //=========================================================================

	function getObjTop( obj )
	{
		var curtop = 0;

		if( obj.offsetParent )
		{
			while( obj.offsetParent )
			{ 
				curtop += obj.offsetTop;
				obj     = obj.offsetParent;
			}
		}

		return curtop;
	}
	
	//=========================================================================
    // Attach event to object
    //=========================================================================
	
	function attach( o, e, f )
	{
		if( document.addEventListener )
		{
			o.addEventListener( e, f, false );
		}
		else if( document.attachEvent )
		{
			o.attachEvent( "on" + e, f );
		}	
	}