//Ajax Loader v1.1 INIT SERVICES
//Permite una variable de entrada para indicar en que path relativo esta la imagen
	function getAbsoluteTop(o) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects	
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}
	
	function getAbsoluteLeft(o) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects	
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}
	
function ajxUnload(elmid) {
	elm=document.getElementById(elmid);
	cap=document.getElementById("loa_ding"+elm.id);
	cap.parentNode.removeChild(cap);
	}
		
function ajxLoading(elmid,pathimg,imagen,wc,hc) {
 var widthCargando=50;
 var heightCargando=50;
 if (wc!=undefined) {
 	widthCargando=wc;
 }
 if (hc!=undefined) {
 	heightCargando=hc;
 }
 
 elm=document.getElementById(elmid);
 
    while (elm.tagName !="DIV") {
    elm = elm.parentNode
    }
 
_width = elm.offsetWidth;
_height = elm.offsetHeight;
_top = getAbsoluteTop(elm);
_left = getAbsoluteLeft(elm);
 
var antOverlay=document.getElementById('loa_ding'+elm.id);

if (antOverlay==undefined) {	
	overlay = document.createElement("div");
	overlay.style.width = _width + "px";
	overlay.style.height = _height + "px";
	overlay.style.position = "absolute";
	overlay.style.background = "#FFFFFF";
	overlay.style.top = _top + "px";
	overlay.style.left = _left + "px";
	overlay.id='loa_ding'+elm.id;
	
	overlay.style.filter = "alpha(opacity=75)";
	overlay.style.opacity = "0.75";
	overlay.style.mozOpacity = "0.75";
	 
	imglay=document.createElement("img");
	
	if (imagen==undefined) {
		imagen="loading.gif";
	}
	if (pathimg!=undefined) {
		imglay.src=pathimg+'img/'+imagen;
	} else {
		imglay.src='/img/'+imagen;			
	}
	imglay.width=widthCargando;
	imglay.height=heightCargando;
	imglay.style.position="absolute";
	
	imglay.style.top=((_height/2)-(heightCargando/2))+"px";
	imglay.style.left=((_width/2)-(widthCargando/2))+"px";
	overlay.appendChild(imglay);
	document.getElementsByTagName("body")[0].appendChild(overlay);
	} else {
	antOverlay.style.display='block';
	}
}
