/*
* This code is Copyright (C) 2006 ALEAUR
* All Rights Reserved.
*/

// -------------- Window and Element Size and Position --------------

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
function posLeft() {return window.pageXOffset != null? window.pageXOffset: document.body.scrollLeft != null? document.body.scrollLeft:0;}
function posTop() {return window.pageYOffset != null? window.pageYOffset: document.body.scrollTop != null? document.body.scrollTop:0;}
function posRight() {return posLeft()+pageWidth();}
function posBottom() {return posTop()+pageHeight();}

// Obtient la position d'un élément sur la page
function getPos(el) {
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent) {
      var tmp = getPos(el.offsetParent);
      r.x += tmp.x;
      r.y += tmp.y;
   }
   return r;
}

// -------------- Click handling --------------

// Fonctions pour la prise en charge des clicks

var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 1;

// alert(navigator.appName);

if (document.layers || document.all) { // IE
//         document.onmouseup = hidediv;
   document.onmouseup = mousehandler;
}

if (document.addEventListener) {
//         document.addEventListener('mouseup', hidediv, true);
   document.addEventListener('mouseup', mousehandler, true);
}

//      if(isNS)
//      document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
      
function mousehandler(e){
   if (EnableRightClick==1) {
      return true;
   }
   var myevent = (isNS) ? e : event;
   var eventbutton = (isNS) ? myevent.which : myevent.button;
   if ((eventbutton==2)||(eventbutton==3)) {
      return false;
   } else {
      // Nothing
   }
}

function contexthandler(){
   if (EnableRightClick==1) {
      return true;
   } else {
      return false;
   }
}

document.oncontextmenu = contexthandler;

function NTSP_trimString(str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

String.prototype.trim = NTSP_trimString;

function NTSP_removeSpacesFromString(str) {
  str = this != window? this : str;
  return str.replace(/\s+/g, '');
}

String.prototype.removespaces = NTSP_removeSpacesFromString;

/*
var s = '  te st  ';
s = s.removespaces();
alert(s.length);
*/

function NTSP_toggleBloc(id){
	if (this.document.getElementById(id).style.display == 'none'){
		this.document.getElementById(id).style.display = '';
	} else {
		this.document.getElementById(id).style.display = 'none';
	}
}


