function agentMatches( str ) {
	return (navigator.userAgent.toLowerCase().indexOf( str.toLowerCase() )
		!= -1);
	}

function isIE( )
	{ return agentMatches( 'MSIE' ); }

function isSafari( )
	{ return agentMatches( 'Safari' ); }

function isFirefox( )
	{ return agentMatches( 'Firefox' ); }

function isOpera( )
	{ return agentMatches( 'Opera' ); }

function isMac( )
	{ return agentMatches( 'Mac' ); }
	
function getBrowserVersion( ) {
	if( isIE( ) ) {
		var p = navigator.userAgent.toLowerCase().indexOf( 'msie' );
		return parseInt( navigator.userAgent.substring( p + 'msie '.length ) );
		}
	else {
		return parseInt( navigator.userAgent );
		}
	}

function isIE6( ) {
	return ( isIE( ) && getBrowserVersion( ) == 6 );
}


function keys( o ) {
	var r = [];
	for( var k in o ) {
		r.push( k );
		}
	return r;
	}

function intrude( dst, src ) {
	for( var k in src ) {
		dst[k] = src[k];
		}
	return dst;
	}
	
function getObj( id ) {
	return document.getElementById( id );
	}

function getObjX( obj ) {
	var x = 0;

	if( obj.offsetParent ) {
		while( obj.offsetParent ) {
			x += obj.offsetLeft;
			obj = obj.offsetParent;
			}
		x += obj.offsetLeft;
		}
	else
	if( obj.x ) {
		x += obj.x;
		}
	
	return x;
	}

function getObjY( obj ) {
	var y = 0;

	if( obj.offsetParent ) {
		while( obj.offsetParent ) {
			y += obj.offsetTop;
			obj = obj.offsetParent;
			}
		y += obj.offsetTop;
		}
	else
	if( obj.y ) {
		y += obj.y;
		}
		
	return y;
	}
	
function getEventX( e ) {
	var e = getEvent( e );

	if( e && e.clientX )
		return e.clientX;
	else
		return false;
	}

function getEventY( e ) {
	var e = getEvent( e );

	if( e && e.clientY )
		return e.clientY;
	else
		return false;
	}
	
function getEvent( e ) {
	if( window.event )
		return window.event;
		
	if( isFirefox( ) && e )
		return e;
	
	return null;
	}

function chainHandlers( first, last ) {
	return f = function( e ) {
		var r = true;

		if( first ) {
			this.__t_call = first;
			r = this.__t_call( e );
			if( r === false ) {
				return r;
				}
			}

		if( last ) {
			this.__t_call = last;
			r = this.__t_call( e );
			}

		return r;
		}
	}

function abortEvent( e ) {
	if( !e ) 
		var e = window.event;

	e.cancelBubble = true;
	if( e.stopPropagation )
		e.stopPropagation();
	
	return false;
	}

function setCookie( n, v ) {
	document.cookie = n + '=' + v + '; path=/';
	}

function getCookie( n ) {
	var nameEQ = n+'=';
	var ca = document.cookie.split(';');
	for( var ii = 0; ii < ca.length; ii++ ) {
		var c = ca[ii];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0)
			return c.substring(nameEQ.length,c.length);
		}

	return null;
	}

function eraseCookie(name) {
	setCookie(name,'');
	}


function getText( obj ) {

	if( obj.innerText )
		return obj.innerText;

	if( obj.textContent )
		return obj.textContent;

	return null;
	}

function setText( obj, text ) {
	obj.innerText = obj.textContent = text;
	}

function setHTML( obj, html ) {
	obj.innerHTML = html;
	}

var _lockedObjects = null;

function adjustLockedPositions( ) {
	if( typeof( _lockedObjects ) == 'object' ) {
		var dx = getScrollOffsetX( );
		var dy = getScrollOffsetY( );
		for( var k in _lockedObjects ) {
			_lockedObjects[ k ].style.top = z = 
				(_lockedObjects[ k ]._lockBaseOffsetY + dy) + 'px';
			_lockedObjects[ k ].style.left =
				(_lockedObjects[ k ]._lockBaseOffsetX + dx) + 'px';
			}
		}
	}

function lockPosition( obj ) {
	
	if( typeof( _lockedObjects ) != 'array' ) {

		window.onscroll = chainHandlers(
			adjustLockedPositions, window.onscroll
			);

		_lockedObjects = [];
		}
	
	if( !in_array( obj, _lockedObjects ) ) {
		obj._lockBaseOffsetX = getObjX( obj.style.top );
		obj._lockBaseOffsetY = getObjY( obj.style.left );
		_lockedObjects.push( obj );
		adjustLockedPositions( );
		}
	}


function clearNode( node ) {
	if( node.removeChild ) {
		while( node.firstChild ) {
			node.removeChild( node.firstChild );
			}
		}
	return node;
	}

function removeNode( node ) {
	if( node ) {
		node.style.display = 'none';
		if( node.parentNode ) {
			if( node.parentNode.removeChild ) {
				node.parentNode.removeChild( node );
				}
			}
		}
	}

function replaceNode( node, new_node ) {
	if( node && new_node && node.parentNode ) {
		if( node.parentNode.replaceChild ) {
			node.parentNode.replaceChild( new_node, node );
		}
	}
}

var warn = function warn( ) { }


function in_array( obj, arr ) {
	for( var k in arr ) {
		if( arr[k] == obj )
			return true;
		}
	return false;
	}

function objlen( obj ) {
	var N = 0;
	for( var k in obj ) N++;
	return N;
	}

function getWindowWidth( ) {
	if( document.body ) {
		return document.body.clientWidth;
		}
	}

function getWindowHeight( ) {
	if( document.body ) {
		return document.body.clientHeight;
		}
	}

function getScrollOffsetY( ) {
	return document.body.scrollTop;
	}
function getScrollOffsetX( ) {
	return document.body.scrollLeft;
	}


function getObjWidth( obj ) {
//	alert( 1 );

//	alert( obj.clientWidth );
	return obj.clientWidth;
	}

function getObjHeight( obj ) {
	return obj.clientHeight;
	}
