function getCoords (element) {
var coords = { x: 0, y: 0, width: element.offsetWidth, height: element.offsetHeight };
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}

function setCoords (coords, theID) {
element= document.getElementById(theID);
//while (element) {
//alert(coords.width);
element.style.width = (coords.width-0)+'px';
element.style.height = (coords.height)+'px';
element.style.left=(coords.x+0)+'px';
element.style.top=(coords.y+1)+'px';

//element = element.offsetParent;
//}
return;
}


function addLoadEvent(func) {
  var el=window;
  if (el.addEventListener){
    el.addEventListener('load', func, true);
    } else if (el.attachEvent){
    el.attachEvent('onload', func); 
  }
}

function OLDaddLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
        oldonload();
        func();
    }
  }
}


function SetBGimgs() {

//  var x =document.getElementById('TheBoundingBox1');
//  alert( x.offsetWidth );

coords = getCoords(document.getElementById('TheBoundingBox1'));
  configure=document.getElementById('TheBoundingBox1');

  setCoords(coords,'TheBackgroundImage1');
//
 // coords = getCoords(document.getElementById('TheBoundingBox1'));
 // setCoords(coords,'TheBackgroundImage1');
//
}

//   this function works better then the older addLoadEvent  (more browser)
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}


addEvent(window,'load',SetBGimgs,false);
addEvent(window,'resize',SetBGimgs,false);
addEvent(window,'mouseover',SetBGimgs,false);
//onresize="SetBGimgs();SetBGimgs();return true"
//addLoadEvent(SetBGimgs);
//addLoadEvent(func2);

