﻿var 	browser = 0;

/* --------------------------------------------------------------------------------------------------

*/
function	browser_detect()
{
	var	ua = navigator.userAgent;
	var	opera = (ua.indexOf('Opera') != -1);
	var	ie = (ua.indexOf('MSIE') != -1);
	var	gecko = (ua.indexOf('Gecko') != -1);
	var	oldnetscape = (ua.indexOf('Mozilla') != -1);

	if( opera ) 		browser = 'opera';
	else if( gecko )	browser = 'mozilla';
	else if( ie )		browser = 'ie';
	else if( oldnsc )	browser = 'netscape';
	else				browser = 'unknown';
}

/* --------------------------------------------------------------------------------------------------

*/
function text_to_paragraph(text, max, lr)
{
	var	paragraph = new String();
	var nb = text.length;
	var	eof = 0;

	if( nb <= max )	return	text;
	
	// loop for each line
	do
	{		
		var line = text.substring(0,max);
		
		var	i = line.lastIndexOf(".") + 1;
		var	j = line.lastIndexOf(",") + 1;
		var	k = line.lastIndexOf(" ");
		
		if( i < j ) i = j;
		if( i < k ) i = k;
		
		paragraph += text.substring(0,i) + lr;
		if( i == k ) i++;
		text = text.slice(i,nb);
		
	}while( text.length > max );
	
	paragraph += text;

	return	paragraph;
}



/* --------------------------------------------------------------------------------------------------

*/
var	mouseX = 0;
var	mouseY = 0;

/* ------------------------------------------------------

*/
function mouse_init(mX,mY)
{
	mouseX = mX;
	mouseY = mY;
}

/* --------------------------------------------------------------------------------------------------

*/
function init_mouse_xy(evnt)
{
	if( !evnt )	evnt = window.event;

	mouse_init(evnt.clientX + document.body.scrollLeft,
				evnt.clientY + document.body.scrollTop
				);
}


/* --------------------------------------------------------------------------------------------------

*/
function init_scroll_xy()
{
//	document.body.scrollLeft;		document.body.scrollTop;
	if( inlineInfo ) inlineInfo.confirm_stop();
}


/* --------------------------------------------------------------------------------------------------

*/
function init_mouse_event()
{
	if( browser == 'ie' )
	{
		document.body.attachEvent("onmousemove", init_mouse_xy);
		window.attachEvent("onscroll", init_scroll_xy);	
	}else
	{
		if( browser == 'opera' )
		{
			document.body.attachEvent("onmousemove", init_mouse_xy);
			window.attachEvent("onscroll", init_scroll_xy);
		}else
		{
			document.body.addEventListener("mousemove", init_mouse_xy, false);
			window.addEventListener("scroll", init_scroll_xy, false);
		}
	}
}


browser_detect();
