function onWindowScroll(){
	
	scroll_top = document.documentElement.scrollTop;

}
		
function getScreenDimension(ev){

	//valeur du scroll courant / position y de la page
	scroll_top 			= document.documentElement.scrollTop;		
	//hauteur de la page visible
	//hauteur de la page visible + hauteur du scroll  
	scroll_height		=	document.documentElement.scrollHeight;     

	screen_width = 0;
	screen_height = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		screen_width = window.innerWidth;
		screen_height = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		screen_width = document.documentElement.clientWidth;
		screen_height = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		screen_width = document.body.clientWidth;
		screen_height = document.body.clientHeight;
	}

	
}

 

		
function getScreenMousePosition(ev){
	
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.documentElement.scrollTop
		//y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
	
}





function getElementPosition(el){
	
	var left = 0;
	var top  = 0;
	
	while (el.offsetParent){
		left += el.offsetLeft;
		top  += el.offsetTop;
		el    = el.offsetParent;
	}


	left += el.offsetLeft;
	top  += el.offsetTop;
	
	return {x:left, y:top};
	
}



function getOffsetMousePosition(target, ev){
	
	ev = ev || window.event;
	var docPos    = getElementPosition(target);
	var mousePos  = getScreenMousePosition(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
	
}


function removeDom(tO) { 

	var i, n; 
	
	if (!tO) { return false; }
	  
	if (!tO.nodeName) { 
	if (tO.length) 
	for (n=tO.length; n--;) removeDom(tO[n]); 
	}
	else if(tO.parentNode != null)
	tO.parentNode.removeChild(tO);
	
}



function findParentByClassName(el,className){
	
	 if(typeof(el) == "string")
    el = document.getElementById(el);
  if(el == null)
    return;
	
	while (el.parentNode){
			
		if(el.className == className){
				
			break;
				
		}	else{
					
			el    = el.parentNode;
					
		}
								
	}

	return el;
}



function findParentByTagName(el,tagName){
	
	 if(typeof(el) == "string")
    el = document.getElementById(el);
  if(el == null)
    return;
	
	while (el.parentNode){
			
		if(el.tagName == tagName){
				
			break;
				
		}	else{
					
			el    = el.parentNode;
					
		}
								
	}

	return el;
}


function getImgSize(img_src){
	
	var newImg = new Image();
	newImg.src = img_src;
	var height = newImg.height;
	var width = newImg.width;
	return {w:width ,h:height};

}


function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}


function fixPNG(myImage) 
{
  if(!document.body.filters)
    return;
  var arVersion = navigator.appVersion.split("MSIE");
  var version = parseFloat(arVersion[1]);
  if(version < 5.5 || version >= 7)
    return;

  var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
  var imgStyle = "display:inline-block;" + myImage.style.cssText
  var strNewHTML = "<span " + imgID 
              + " style=\"" + "width:" + myImage.width 
              + "px; height:" + myImage.height 
              + "px;" + imgStyle + ";"
              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
              + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
  myImage.outerHTML = strNewHTML
}


function getNextNode(el) {  
   var node = null;  
   if (el.nextSibling) {  
	   node = el;  
	   do {  
	  	 node = node.nextSibling;  
	   }  
    	while (node.nodeType !== 1 && node.nextSibling);  
    }  
   return (node.nodeType === 1) ? node : null;  
   };  
   
   
function getPreviousNode(el) {  
    var node = null;  
    if( el.previousSibling) {  
    node = el;  
    do {  
    node = node.previousSibling;  
    } while (node.nodeType !== 1 && node.previousSibling);  
    }  
    return (node.nodeType === 1) ? node : null;  
   }; 
   
   
   
  /* Change the type of a node, e.g. h3 to p */
function changeNodeType(theNode, nodeType)
{
	var theChildren = new Array();
	var theNewNode = document.createElement(nodeType);
	var theParent = theNode.parentNode;
	
	if(theNode.style != null){	
	
		theNewNode.style.cssText = theNode.style.cssText;
				
	}
	
	if (theParent != null)
	{
		for (var i = 0; i < theNode.childNodes.length; i++)
		{
			theClone = theNode.childNodes[i].cloneNode(true);
			
			if(theNode.childNodes[i].style != null){
				
				theClone.style.cssText = theNode.childNodes[i].style.cssText;
				
			}
			
			theChildren.push(theClone);
				
		}
		
		for (var i = 0; i < theChildren.length; i++)
		{
			theNewNode.appendChild(theChildren[i]);
		}
		
		theParent.replaceChild(theNewNode, theNode);
	}
	
	return true;
}
