function stretchColumns(bodyId) {

	switch (bodyId) {
	
		// ------
		case 'frontPage' :
		
			var c1 = new element('contentColumn1');
			var c2 = new element('contentColumn2');
			var c1H = c1.getH();
			var c2H = c2.getH() - 6;
			
			if(c1H > c2H) {
				c2.setH(c1H + 'px');
			} else {
				c1.setH(c2H + 'px');
			}
			
			var c3 = new element('contentColumn3');
			var c4 = new element('contentColumn4');
			var c3H = c3.getH();
			var c4H = c4.getH() - 6;
			
			if(c3H > c4H) {
				c4.setH(c3H + 'px');
			} else {
				c3.setH(c4H + 'px');
			}			
			
			break;	
	
		// ------
		case 'sectionFrontPage' :
		
			var c1 = new element('contentColumn1');
			var c2 = new element('contentColumn2');			
			var c1H = c1.getH();
			var c2H = c2.getH() + 22; // Compensate for padding bottom for c1
			
			if(c1H > c2H) {
				c2.setH(c1H + 'px');
			} else {
				c1.setH(c2H - 50 + 'px');
			}
			
			break;
			
		// ------
		case 'contentPage2Columns' :
			
			var nrOfColumns = 2;
			var c1 = new element('contentColumn1');
			var c2 = new element('contentColumn2');
			var c1H = c1.getH() + 22; // Compensate for padding bottom for c2
			var c2H = c2.getH();
			
			var maxHeight = c1H;
			var h = 0;
			
			// Loop the columns
			for(var i = 2; i <= nrOfColumns; i++) {
			
				h = eval('c' + i + 'H');
			
				if(h > maxHeight) {
					maxHeight = h;
				}
			
			}

			if(maxHeight != c2H) {
			
				c2.setH((maxHeight-22) + 'px');
				
			} else {
			
				c2.setH(maxHeight + 'px');
				maxHeight += 22;
			
			}
			
			c1.setH(maxHeight + 'px');
			
			break;			
			
			
		// ------
		case 'contentPage3Columns' :
			
			var nrOfColumns = 3;
			var c1 = new element('contentColumn1');
			var c2 = new element('contentColumn2');
			var c3 = new element('contentColumn3');
			var c1H = c1.getH() + 22; // Compensate for padding bottom for c2
			var c2H = c2.getH();
			var c3H = c3.getH() + 22; // Compensate for padding bottom for c2
			
			var maxHeight = c1H;
			var h = 0;
			
			// Loop the columns
			for(var i = 2; i <= nrOfColumns; i++) {
			
				h = eval('c' + i + 'H');
			
				if(h > maxHeight) {
						
					maxHeight = h;

				}
			
			}

			if(maxHeight != c2H) {
			
				c2.setH((maxHeight-22) + 'px');
				
			} else {
			
				c2.setH(maxHeight + 'px');
				maxHeight += 22;
			
			}
			
			c1.setH(maxHeight + 'px');
			c3.setH(maxHeight + 'px');
			
			break;
			
		// -------
		case 'newsPage' : 
		case 'contentPageTypeC' : 
		
			var c1 = new element('contentColumn1');
			var c2 = new element('contentColumn2');			
			var c1H = c1.getH();
			var c2H = c2.getH();
			
			if(c1H > c2H) {
				c2.setH(c1H - 6 +  'px');
			} else {
				c1.setH(c2H - 28 + 'px');
			}
			
			break;			
						
			

			
		
	
	}

}

function scrollToRight(objRef) {

	var found = 0;
	
	// setting ref
	objTimerRef = objRef;
	
	// loop children
	for(var x = 0; x < objRef.childNodes.length;x++) {
	
		// do we have an object
		if(objRef.childNodes[x].tagName == 'SPAN') {
			
			// find next right
			if(found == 1) {
				
				// sroll to next
				scrollSmoothTo(objRef.childNodes[x].offsetLeft,0,25,0,1);
			
				return;
			
			}
			
			if(objRef.scrollLeft == objRef.childNodes[x].offsetLeft) {
				
				found = 1;
					
			}
		
		}
	
	}

	scrollSmoothTo(0,0,-50,0,1);

}

function scrollToLeft(objRef) {

	var found = 0;
	
	// setting ref
	objTimerRef = objRef;
	
	// loop children from last
	var tmpArr = new Array();

	
	// loop children
	for(var x = 0; x < objRef.childNodes.length;x++) {
	
		// do we have an object
		if(objRef.childNodes[x].tagName == 'SPAN') {
			
			tmpArr.unshift(objRef.childNodes[x]);

		}
	}
	
	for(var x = 0; x < tmpArr.length;x++) {
	
		// find next left
		if(found == 1) {
			
			// sroll to next
			scrollSmoothTo(tmpArr[x].offsetLeft,0,-25,0,1);
			
			return;
			
		}
		
		
		if(objRef.scrollLeft == tmpArr[x].offsetLeft) {
				
			found = 1;
			
					
		}
	
	}
		
	scrollSmoothTo(objRef.scrollWidth,0,50,0,1);

}

var objTimerRef;
var timerLeft;
var timerTop;

function scrollSmoothTo(nextLeft,nextTop,stepLeft,stepTop,speed) {

	
	// calc diff
	var diffLeft 	= Math.abs(objTimerRef.scrollLeft - nextLeft);
	var diffTop 	= Math.abs(objTimerRef.scrollTop - nextTop);
	speed+=2;
	
	
	// where to scroll left
	if(diffLeft > Math.abs(stepLeft)) {
	
		// do scroll left or rigth
		objTimerRef.scrollLeft += stepLeft;
	
		clearTimeout(timerLeft);
		
		timerLeft = setTimeout('scrollSmoothTo(' + nextLeft + ',' + nextTop + ',' + stepLeft + ',' + stepTop + ',' + speed + ')', speed);
		
	} else {
	
		clearTimeout(timerLeft);
	
		// do scroll left or rigth
		objTimerRef.scrollLeft = nextLeft;
	
	}
	
	// where to scroll right
	if(diffTop > stepTop) {
	
		// do scroll up or down
		objTimerRef.scrollTop += stepTop;
	
		clearTimeout(timerTop);
		
		timerTop = setTimeout('scrollSmoothTo(' + nextLeft + ',' + nextTop + ',' + stepLeft + ',' + stepTop + ',' + speed + ')', speed);
		
	} else {
	
		clearTimeout(timerTop);
	
		// do scroll up or down
		objTimerRef.scrollTop = nextTop;

	}	

}



function ImageBox(id) {
	
	this.id = id
	this.images = 3;
	this.timeout = new Array();
	this.interval;
	this.activeIndex = 1;
	
	this.start = function () {

		clearInterval(this.interval);
		
		// start new interval
		this.interval = setInterval(this.id +".next()",5000);

	}
	
	this.stop = function () {

		clearInterval(this.interval);

	}

	this.next = function () {
	
		this.select(this.activeIndex);
		
		this.activeIndex = (this.activeIndex+1)%3;
		
	}

	this.select = function (index) {
		
		for(var x = 0; x < this.images; x++) {
		
			clearInterval(this.timeout[x]);
			
			// select active
			if(x == index) {
			
				// deselect
				document.getElementById(this.id + '__' + x).className = 'imageBoxImgSmallOver';
				
				// fading in
				this.timeout[x] = setInterval(this.id +".fadeIn("+ x +")",50);
				
			} else {
			
				// deselect
				document.getElementById(this.id + '__' + x).className = 'imageBoxImgSmall';
				
				// fade out
				this.timeout[x] = setInterval(this.id +".fadeOut("+ x +")",50);
			}
 			
		
		}
		
			
	}
	
	this.fadeIn = function (index) {
	
		var objRef = document.getElementById(this.id + '_' + index);
 	
 		var opacity = objRef.style.opacity * 100;
 		
 		if(document.all && typeof(objRef.style.filter) != 'undefined') {
 			
 			var patt1 = /([0-9]+)/g;
 			opacity = objRef.style.filter.match(patt1);
 			opacity = opacity==null?0:parseInt(opacity);
 		}
 		
 		// if opacity is 100% kill interval
		if(opacity >= 100) {
			clearInterval(this.timeout[index]);
		} else {
			
			objRef.style.opacity = (opacity + 10)/100;
			
			if(document.all) {
				
				objRef.style.filter = 'alpha(opacity=' + (opacity + 10) + ')';
				
			}
			
		}
	
		
	
	}
	
	this.fadeOut = function (index) {
	
		var objRef = document.getElementById(this.id + '_' + index);
 	
 		var opacity = objRef.style.opacity * 100;
 		
 		if(document.all && typeof(objRef.style.filter) != 'undefined') {
 			
 			var patt1 = /([0-9]+)/g;
 			opacity = objRef.style.filter.match(patt1);
 			opacity = opacity==null?0:parseInt(opacity);
 		}
 		
 		// if opacity is 0% kill interval
		if(opacity <= 0) {
			clearInterval(this.timeout[index]);
		} else {
			
			objRef.style.opacity = (opacity - 10)/100;
			if(document.all) {
				objRef.style.filter = 'alpha(opacity=' + (opacity - 10) + ')';
			}
		}
	
	}
	
	return this;
}



