	
	function startScroller(content, handle, track, buttonUp, buttonDown){
    	new Control.Scroller(content, handle, track, {
    		up: buttonUp,
    		down: buttonDown,
    		axis:'vertical'
    	});
	}

	
	function startMorphing(arr){
		var idx = 0;
		var nextIdx = 0;
		arr.each(
			function(elem){
				elem = $(elem);
				if (elem.visible()){
					new Effect.Fade(elem);
					nextIdx = idx+1;
				}
				if (nextIdx == (arr.length)) nextIdx = 0;
				idx++;
			}
		)
		new Effect.Appear($(arr[nextIdx]));
		setTimeout(function(){startMorphing(arr)}, 5000);		
	}

	function setFooter(){
		var bottom = parseInt($('cbBottom').offsetTop) + 40;
		var position = parseInt($$('.footer')[0].offsetTop);
		if (position < bottom){
			$$('.footer')[0].setStyle('top :' + bottom  + 'px;');
		}else{
			$$('.footer')[0].setStyle('bottom :20px;');
		}
	}
	
	function setFooterEvent(){
		window.onresize = setFooter;
		setFooter();
	}
	
//OLD
	var gTimeout = '';	
	var globalSwitched = new Array();
	var currImg = '';

	function doSwitch(subject){
		var hasSlideUp = false;
		if (!globalSwitched.length){
			globalSwitched.push(subject);
			new Effect.BlindDown(subject, {duration : 0.5});
			return;
		}
		var localglobalSwitched = new Array();
		for (var i=0;i<globalSwitched.length;i++){
			if (globalSwitched[i] == subject){
				new Effect.BlindUp(subject, {duration : 0.5});
				globalSwitched.pop(i);
				hasSlideUp = true;
			}
		}
		if (!hasSlideUp){
			new Effect.BlindDown(subject, {duration : 0.5});
			globalSwitched.push(subject);
		}
	}
		
	function showLogin(){
		doSwitch('login');
	}
	
	function resizeMe(e){
		var contentTop = parseInt(234);
		var width = Try.these(
						function(){return document.body.clientWidth;},
						function(){return window.outerWidth;}
					);
		var height = Try.these(
						function(){return document.body.clientHeight;},
						function(){return window.outerHeight;}
					);
		var contentHeight = getContentSize();
		if ($('navSpacer')){
			contentHeight += parseInt($('navSpacer').style.height);
		}
		var contentBottom = (parseInt(contentTop)+parseInt(contentHeight));
		$('mainContentCell').style.height = ( ((height -contentTop ) - 23) - (40) )+  'px'; // added 40 px to allow whitespace above mainContent 
		if (parseInt(height) < parseInt(contentBottom)){
			$('mainContentCell').style.overflow = 'auto';
			$('footer').style.top = (parseInt(height));
		}else{
			$('mainContentCell').style.overflow = 'visible';
			$('footer').style.top = (parseInt(height) - 15);
		}
		resizeContent();
	}
	
	function getContentSize(){
		var table = $('contentDivider');
		var contentSize = 0;
		$A(table.getElementsByTagName('tr')).each(
			function (aRow){
				if (aRow.getElementsByTagName('td').length > 0){
					var currCell = aRow.getElementsByTagName('td').item(0);
					//currCell.style.height = 'auto';
					var x = currCell.offsetHeight ;
					currCell.style.height = x + "px";
					contentSize += parseInt(currCell.style.height);
				}
			}
		);
		return parseInt(contentSize);
	}
	
	function resizeContent(){
		var contentTable = $('contentDivider');
		$A(contentTable.getElementsByTagName('tr') ).each(
			resizeContentRow
		);
	}

	function resizeContentRow(aRow){
		return;
		var cells = aRow.getElementsByTagName('td');
		var lastCell = cells.item(cells.length -1);
		var firstCell = cells.item(0);
		if ($('mainContentCell').style.overflow == 'auto'){
			console.log('1');
			$('mainContentCell').style.width = '932px';
			$('contentDivider').style.width = '714px';				
			$('actualContent').style.width = '714px';
			if (cells.length > 1){
				firstCell.style.width = '356px';
				lastCell.style.width = '356px';
			}else{
				//firstCell.style.width = '724px'
			}
		}else{
			console.log('2');
			$('mainContentCell').style.width = '907px';
			//$('actualContent').style.width = '704px';
			$('contentDivider').style.width = '724px';		
			if (cells.length > 1){
				firstCell.style.width = '356px' /// works on IE
				lastCell.style.width = '334px';
			}else{
				firstCell.style.width = '712px'
			}
		}
	}
	
	function isIE(){
        try {
	        dingDong = new ActiveXObject('Msxml2.XMLHTTP');
	        return true;
        }catch(e){
        	return false;
        }
	}
	
	function init(bodyNode){
		var aWPS = wps.base;
		addEvent(bodyNode, 'resize', resizeMe);
		resizeMe();
	}

	function reColour(){
		var colors = [
						['#ffcd00','#fffffa'],
						['#fffffa','#000000'],
						['#66662c','#fffffa'],
						['#9b9b63','#000000'] 
					];
		$A(document.getElementsByClassName('content')).each(
			function (contentElem){
				if (contentElem.hasChildNodes()){
					var rnd = getRnd();
					var rnd = 3; 
					contentElem.style.background = colors[rnd][0];
					contentElem.style.color = colors[rnd][1];
				}
			}
		);
	}
	
	function getRnd(){
		var random = parseInt(Math.random()*10);
		if ( (random < 4)){
			return random;
		}else{
			return getRnd();
		}
	}
	
	function startImageRotator(){
		var images = $('rotatorContainer').getElementsByTagName('img');
		if (currImg !== ''){
			new Effect.Fade(images[currImg]);
			var newIndex = (currImg+1);
		}else{
			var newIndex = 0;
		}
		if (newIndex >= images.length) newIndex = 0;
		currImg = newIndex;
		new Effect.Appear(images[newIndex]);
		setTimeout(startImageRotator, 5000);
	}
