function processCorners(containingElmId,groupClass,bDirection) {
	if(!document.getElementsByClassName) return false;
	var aBlocks = document.getElementsByClassName(groupClass,containingElmId);
	var ctr = 0;
	var iRadius = 4;
	if(bDirection == null) bDirection = true;//Overlaps go down, hard to explain but is the visual stacking thing
	dbg.h('processCorners(' + containingElmId + ',' + groupClass + ',' + bDirection +')');
	dbg.p('Got ' + aBlocks.length + ' ' + groupClass);
		
	aBlocks.each(
		function(block,idx){
			var children = Element.immediateDescendants(block);
			dbg.h(groupClass + ' : ' + idx);
			children.each(
				function(child,idx){
					//	set rounding rules for each child.
					dbg.h(idx + ':' + children.length + '  [' + child.id + '] ' + child.className);
					//get my bg colour
					var myBgCol = get_current_style(child,"background-color","transparent");
					
					if(idx == 0){
						//first, always against white (round top)
						dbg.p('First');
						AddRounded(child,'#ffffff', myBgCol, iRadius, iRadius, true);
					}
					if(idx == children.length-1){
						//last one always against white (round bottom)
						dbg.p('Last');
						AddRounded(child,'#ffffff', myBgCol, iRadius, iRadius, false);
					}
					if(children.length > 1){
						//middles, we need to get the background of our next or previous sibling
						dbg.p('Round ' + bDirection);
						if(bDirection){
							if(idx != children.length-1){
								//higher divs on top (round bottom effect) : Unless we are the last
								dbg.p('Round ' + (bDirection ? 'bottom' : 'top'));
								AddRounded(child,get_current_style(children[idx+1],"background-color","transparent"), myBgCol, iRadius, iRadius, false);
							}
						}else{
							if(idx != 0){
								//lower divs on top (round top effect) : Unless we are first
								//AddRounded(child,'#ffffff', get_current_style(child,"background-color","transparent"), iRadius, iRadius, true);
								dbg.p('my bg : ' + get_current_style(child,"background-color","transparent") + ', bg prevSib : ' + get_current_style(children[idx-1],"background-color","transparent"));
								AddRounded(child,get_current_style(children[idx-1],"background-color","transparent"), myBgCol, iRadius, iRadius, true);
							}
						}
					}//if
				}//func
			);//each
		}//func
	);//each
	dbg.p('//end');
}//end func

function processPopups() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popup")) {
			//alert(i + ' : ' + links[i].href);
			//add onclick code
			links[i].onclick = function() {
				//alert('clicked');
				var sWidth = '';
				var sHeight = '';
				var sModal = '';
				if(this.getAttribute('w')) sWidth = ',width='+ this.getAttribute('w');
				if(this.getAttribute('h')) sHeight = ',height='+ this.getAttribute('h');
				if(this.getAttribute('modal')) sModal = ',modal=1,dependant=1,chrome=0,alwaysRaised=1';
				//alert('w='+w+' h='+h);
				window.open(this.href,'','toolbar=0,resizable=1,menubar=0,scrollbars=1'+sWidth+sHeight+sModal);
				return false;
			}//end func
		}//end if
	}//end if
}//end func


var currentWindowOnload =(window.onload)?window.onload:function(){};
window.onload = function(){
	currentWindowOnload();

	//top menu
	$$('#header li').each(
		function(child,idx){
			var myBgCol = get_current_style(child,"background-color","transparent");
			AddRounded(child,'#000000',myBgCol,6,6,true,true,false,false);
		}
	);
	//side menu
	$$('#sidemenu li a, #sidemenu li span').each(
		function(child,idx){
			var myBgCol = get_current_style(child,"background-color","transparent");
			AddRounded(child,'#ffffff',myBgCol,8,8,true,false,false,true);
		}
	);


	//impact blocks
	$$('#container div.impact').each(
		function(child,idx){
			var myBgCol = get_current_style(child,"background-color","transparent");
			AddRounded(child,'#ffffff',myBgCol,8,8,true,true,true,true); //all four corners
		}
	);

	//homepage section links
	$$('#sections td li a').each(
		function(child,idx){
			var myBgCol = get_current_style(child.parentNode,"background-color","transparent");
			AddRounded(child,myBgCol,'#ffffff',8,8,false,true,true,false); //just rhs corners
		}
	);

	//process links with popup class
	processPopups();

	if(	window.adminmode && window.bLoggedIn){
		//we are logged in and editing
		qp = document.location.search.toQueryParams();  //convert to struct of sorts
		elm = $('c_' + qp.uuid);  //get the object ID
		if(elm){
			Element.scrollTo(elm);  //scroll to it
		}
	}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}