GLOBAL_MARKER_BGCOLOR="yellow";
MarkerLogImageLongLifeObject='';
window.onload = Marker;

function Marker()
{
  if( !isCompatibleNavigator() ) return false;
  var oRange;
  try 
  { 
    oRange = document.body.createTextRange() 
  }
  catch( e )
  {
    return false;
  }
  var rfr = document.referrer;
  if( !rfr ) return false;
  var sere, sesig;
  sere = new RegExp( '([a-z0-9\-]+\.[a-z0-9\-]+)/','i' );
  if( rfr.match(sere))
    sesig = RegExp.$1.toLowerCase();
  if( !sesig ) return false;

  var seres = ''
  +'@google.com:q'
  +'@overture.com:keywords'
  +'@yahoo.com:p'
  +'@seznam.cz:w'
  +'@atlas.cz:(q|searchtext)'
  +'@centrum.cz:q'
  +'@redbox.cz:srch'
  +'@caramba.cz:Text'
  +'@quick.cz:ftxt_query'
  +'@msn.com:q'
  +'@altavista.com:q'
  +'@jyxo.cz:s'
  +'@centrum.cz:q'
  +'@uzdroje.cz:squery'
  +'@alltheweb.com:q'
  +'@hotbot.com:query'
  +'@lycos.com:query'
  +'@webcrawler.com:qkw'
  +'@looksmart.com:key'
  +'@mamma.com:query'
  +'@search.com:q'
  +'@webfast.cz:q'
  +'@excite.com:qkw'
  +'@tiscali.cz:query'
  +'@'+sesig+':search_terms'
  +'@'
  ;
  
  var re, key, pos1, pos2;
  if((pos1 = seres.indexOf(sesig))<0) return false;
  pos1 += 1 + sesig.length;
  if((pos2 = seres.indexOf('@', pos1 ))<0) pos2 = seres.length;
  key = seres.substring(pos1,pos2);
  re = new RegExp('[\?\&]'+key+'=([^\&]+)','i');
  if(!rfr.match(re)) return false;

  var sEncoded, matchString, oParentElement, iCounterLimit, sWord, aWords, i;
  sEncoded = RegExp.$1;
  matchString = decodeURIComponent( sEncoded.replace( /\+/g, ' ') ).replace(/["'-=_,:;\.]/g,' ');
  aWords = matchString.split(/\s/);
  for( i=0;i<aWords.length;i++ )
  {
    sWord = aWords[i];
	if( sWord.length > 2 )
	{
    oRange = document.body.createTextRange() 
    while( oRange.findText( sWord, 0, 0 )) 
    {
      // oRange.execCommand( 'underline' );
	  if( 'undefined' == typeof GLOBAL_MARKER_BGCOLOR ) GLOBAL_MARKER_BGCOLOR = "#80FF80";
      oRange.execCommand( 'BackColor',false, GLOBAL_MARKER_BGCOLOR );
      oRange.collapse( false );
      oRange.moveEnd('sentence', 999999 );
    }
	}
  }
}

function isCompatibleNavigator()
{
  if( notCompatible( 'Image' )) return false;
  var rfr, uric_rfr, uric_ua, uric_esctype, uric_rand, uric_compat, uric_cookie, compat, ua_name, rand_val;
  var cookie_val, cookie_pos, cookie_end, cookie_lsgn, cookie_ssgn, cookie_myval;
  rfr= document.referrer || '#';
  uric_esctype	='e=';
  uric_rfr		='r=';
  uric_ua		='a='
  uric_rand		='x=';
  uric_compat	='c=';
  uric_cookie	='k=';
  cookie_lsgn = 'helixMarker_luid';
  cookie_ssgn = 'helixMarker_suid';
  if(cookie_val = document.cookie)
  {
  	cookie_pos=cookie_val.indexOf(cookie_lsgn);
    if( cookie_pos < 0 )
	{
		cookie_pos=cookie_val.indexOf(cookie_ssgn);
		if( cookie_pos >= 0 )
		{
			cookie_pos += cookie_ssgn.length;
		}
	}
	else
	{
	  cookie_pos += cookie_lsgn.length;
	}
	cookie_pos+=1;
	if( cookie_pos )
	{
	  cookie_end = cookie_val.indexOf(';', cookie_pos );
	  if( cookie_end < 0 ) cookie_end = cookie_val.length;
	  cookie_myval = cookie_val.substring( cookie_pos, cookie_end );
	}
  }
  if( notCompatible( 'window.navigator' ))
  {
  	ua_name = '#';
  }
  else
  {
    ua_name = window.navigator.userAgent;
  }
  if( notCompatible( 'encodeURIComponent' ))
  {
  	uric_esctype	+='escp';
	uric_rfr		+=escape(rfr);
	uric_ua			+=escape(ua_name);
	uric_cookie		+=escape(cookie_val);
	rand_val		=(Math.random() * 999999) + '.' + escape((new Date()).toGMTString());
    uric_rand		+=rand_val;
	if( !cookie_myval ) cookie_myval = rand_val;
	// document.cookie =cookie_lsgn+'='+ cookie_myval +'; expires='+ (new Date((new Date()).valueOf()+365*24*60*60*1000 )).toGMTString();
	document.cookie =cookie_ssgn+'='+ cookie_myval +';';
  }
  else
  {
  	uric_esctype	+='uric';
	uric_rfr		+=encodeURIComponent(rfr);
	uric_ua			+=encodeURIComponent(ua_name);
	uric_cookie		+=encodeURIComponent(cookie_val);
	rand_val		=(Math.random() * 999999) + '.' + (new Date()).valueOf();
    uric_rand		+=rand_val;
	if( !cookie_myval ) cookie_myval = rand_val;
	document.cookie =cookie_lsgn+'='+ cookie_myval +'; expires='+ (new Date((new Date()).valueOf()+365*24*60*60*1000 )).toGMTString();
	document.cookie =cookie_ssgn+'='+ cookie_myval +';';
  }
  if( notCompatible( 'document.body document.body.createTextRange' ))
  {
  	compat = false;
  	uric_compat	+='0';
  }
  else
  {
  	compat = true;
  	uric_compat	+='1';
  }

  return compat;
}

function notCompatible( ids, types )
{
	var p1,p2,id,i,z,t,xids;
	if( !types ) types = ':function:object:';
	xids = '';
	z=9999;
	for( p1=0; (p1 >= 0) && (p1<ids.length); p1=ids.indexOf(' ',p1))
	{
		z=z-1; if( z <= 0 ) break;
		p2 = ids.indexOf(' ',p1+1);
		if( p2 < 0 ) p2 = ids.length;
		id=ids.substring( p1,p2 );
		if( id != ' ' )
		{
			t=eval('typeof '+id ).toLowerCase();
			if( -1 == types.indexOf(t))
			{
				xids = xids + ' ' + id + '('+t+')';
			}
		}
		p1=p2;
	}
	return xids;
}

