//
// jssystem.js
//
// javascript animation tools for div
//
// © nui - loic berthelot - 2009
// contact@libnui.net
//

//
// NETSCAPE / IE compatibility
//
var ISIE = true;
var ISSAFARI = false;
if (navigator.appName.indexOf("Netscape") >= 0)
ISIE = false;
if (navigator.appVersion.indexOf("Safari") >= 0)
ISSAFARI = true;


function jsGetObject (id)
{
  if (!ISIE)
     return document.getElementById(id);
 
  return document.all[id];
}


function jsGetImage (id)
{
  if (!ISIE)
     return document.images[id];

  return document.all[id];
}



function strReplace(s, r, w){
     return s.split(r).join(w);
}


function _check_post (s)
{
  s = strReplace (s, "\r\n", "<br>"); 
  s = strReplace (s, "\n", "<br>"); 
  s = strReplace (s, "&", "&amp;");  
  s = strReplace (s, "\"", "'");
  return s;
}



//////////////////////////////////////////////////////////
//
// MOUSE TOOLS
//

// Get the horizontal position of the mouse
function getMouseXPos(e) {
  if (!ISIE) 
    return parseInt(e.pageX+10)
   else 
    return (parseInt(event.clientX+10) + parseInt(document.body.scrollLeft))
}

// Get the vartical position of the mouse
function getMouseYPos(e) {
  if (!ISIE) 
    return parseInt(e.pageY)
   else 
    return (parseInt(event.clientY) + parseInt(document.body.scrollTop))
}


function js_window_getWidth ()
{

    if (window.innerWidth){
        if (document.body.offsetWidth){
            if (window.innerWidth!=document.body.offsetWidth)
                return document.body.offsetWidth;
            }
        return (window.innerWidth);                     // Mozilla
    }


    if (document.documentElement.clientWidth)
        return document.documentElement.clientWidth;    // IE6


    if (document.body.clientWidth)
        return document.body.clientWidth;               // IE DHTML-compliant any other
}

function js_window_getHeight ()
{

    if (window.innerHeight){
        if (document.body.offsetHeight){
            if (window.innerHeight!=document.body.offsetHeight)
                return document.body.offsetHeight;
            }
        return (window.innerHeight);                     // Mozilla
    }


    if (document.documentElement.clientHeight)
        return document.documentElement.clientHeight;    // IE6


    if (document.body.clientHeight)
        return document.body.clientHeight;               // IE DHTML-compliant any other
}


function js_document_getHeight()
{
  if (ISSAFARI)
    return document.body.scrollHeight;
  return document.documentElement.scrollHeight;
}

