function addListener(element, event, listener, bubble) {
  if(element.addEventListener) {
    if(typeof(bubble) == "undefined") bubble = false;
    element.addEventListener(event, listener, bubble);
  } else if(this.attachEvent) {
    element.attachEvent("on" + event, listener);
  }
}

function updateScrollHeight(){
	var dh = document.body.scrollHeight;
	var ch = document.documentElement.clientHeight;
	
	if(dh > 920) document.getElementById('scalingBackground2').style.height = (dh-920)+'px'; // scale repeating part to dowument height
	
	document.getElementById('backgroundBottom').style.top = (dh-202)+'px'; // position curve as top for IE6
	
	if(dh < ch){ // If page is smaller then viewport
		document.getElementById('backgroundWrap').style.height = ch+'px'; // resize wrap to position curve @ bottom & clip bg-image
	}
	else{
		if(document.getElementById('fullPage').clientHeight > ch || dh > ch){
			document.getElementById('backgroundWrap').style.height = ""; // set height of wrap back to auto
		}
	}

}
addListener(this, "load", function() {
	
	setInterval("updateScrollHeight()",100);
});

