
		
/*   UTILS   */		
		
function getObj(name)
{
  if (document.getElementById)
  {
  	return document.getElementById(name);
  }
  else if (document.all)
  {
	  return document.all[name];
	}
  else if (document.layers)
  {
   	return document.layers[name];
  }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function hide(id)
{
  getStyleObject(id).display = 'none';
}
function show(id)
{
  getStyleObject(id).display = 'block';
}


function switchDisplay(id)
{
  getStyleObject(id).display = (getStyleObject(id).display == 'block') ? 'none' : 'block';
}

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

function popupMe(imgObj) {
  var pp = window.open(imgObj.src);
}
/*
function popupUrl(url, w, h){
  var pp = window.open(url, null, "height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no");
}
*/

var isLoaded = false;
function popupUrl(e, url, w, h) {
	var targ;
	if (e.target) { targ = e.target;}
	else if (e.srcElement) { targ = e.srcElement;}

x = (e.clientX + document.body.scrollLeft)/2;
y = (e.clientY + document.body.scrollTop)/4;
getStyleObject("imageDiv").left= x+"px";
getStyleObject("imageDiv").top= y+"px";
/*
getStyleObject("imageDiv").height= h+"px";
getStyleObject("imageDiv").width= w+"px";
*/
getObj("imageDiv").innerHTML= "<img src=\""+url+"\" alt=\"img\" />";
show("imageDiv");
isLoaded=true;
}

function hideAll()
{
	if(isLoaded) {
		hide("imageDiv");
		isLoaded=false;
	}

}


// global request and XML document objects
var req;

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadRemoteDoc(url) {

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
    return req;
}

// handle onreadystatechange event of req object
function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			endReqProcess();
         } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
         }
    }
}

function endReqProcess()
{
	alert("endReqProcess...");
}

// Retrieve text of an XML document element, including elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
  var result = "";
  if (prefix && isIE) {
    // IE/Windows way of handling namespaces
    result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
  } 
  else {
    // the namespace versions of this method 
    // (getElementsByTagNameNS()) operate
    // differently in Safari and Mozilla, but both
    // return value with just local name, provided 
    // there aren't conflicts with non-namespace element
    // names
    result = parentElem.getElementsByTagName(local)[index];
  }
  if (result) {
    // get text, accounting for possible
    // whitespace (carriage return) text nodes 
    if (result.childNodes.length > 1) {
        return result.childNodes[1].nodeValue;
    } else {
    	if (result.firstChild == null) return ''; 
        return result.firstChild.nodeValue;    		
    }
  } 
  else {
    return "n/a";
  }
}


function serialize(node,level) {
	    if (node == null || typeof node != 'object') {
	      return node
	    };
	    if (window.ActiveXObject) {
	      //pour IE
	      return node.xml;
	    }
	    else if (window.XMLSerializer) {
	      //pour FF
	      return new XMLSerializer().serializeToString(node);
	    }else {
	      //pour les autres
	      return node;
	    }
	}