/*
Copyright (c) 2007 Lukasz Szajkowski <http://www.szajkowski.com/>

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/ 

/* Determine browser type */
//alert('Start app');

var DHTML = (document.getElementById || document.all || document.layers);
var NS6 = (!document.all && document.getElementById)? 1:0;
var NS4 = (document.layers) ? 1:0;
var IE4 = (document.all) ? 1:0;
var NS6_Safari = false;
if (NS6) {
	var detect = navigator.userAgent.toLowerCase();
	var place = detect.indexOf('safari') + 1;
	if (place) NS6_Safari = true;
}

var timeoutId = 0;
var APP_XOFFSET  = 2;
var APP_YOFFSET  = 2;
var APP_TIPBG    = "#ff11EA";
var APP_WIDTH    = 150;
var APP_TIMEIN       = 10;
var APP_TIMEOUT      = 100;
var MENU_FONT_SIZE   = 7;
var SUB_MENU_X_OFFSET= 80;
var SUB_MENU_y_OFFSET= 2;
var MENU_ROW_H = 21;

/* Mousemove event handler  */
if(NS4 || IE4 || NS6) {
  document.onmousemove = mouseMove;
  //document.onclick = mouseClick;

  if(NS4 || NS6) {
    document.captureEvents(Event.MOUSEMOVE);
    window_width = window.innerWidth;
  }
}

function mouseClick(e) {
	//allDivOff();
}

/* Mousemove event handler function */

function mouseMove(e) {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( typeof( self.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = self.innerWidth;
    myHeight =  self.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  window_width = myWidth;
  window_height = myHeight;
  
  if(NS4) {
    mx = e.pageX + APP_XOFFSET;
    my = e.pageY + APP_YOFFSET;
  } else if(NS6_Safari) {
   	mx = e.clientX + APP_XOFFSET;
  	my = e.clientY + APP_YOFFSET;
  } else if(NS6) {
    mx = e.clientX + APP_XOFFSET + scrOfX;
    my = e.clientY + APP_YOFFSET + scrOfY;
  } else if(IE4) {
    mx = event.x + APP_XOFFSET + scrOfX;
    my = event.y + APP_YOFFSET + scrOfY;
  }
}
