window.onload = function () {
	initRollovers();
	
	var content2 = document.getElementById("col2-Content");
	var scrollb2 = document.getElementById("col2-Scrollbar");

	scrollbar2 = new Scrolling.Scrollbar (
		scrollb2,
		new Scrolling.Scroller (content2, 260, 363),
		new Scrolling.ScrollTween()
	);
	
	scrollbar2.onMouseDown = scrollbarPressed;
	scrollbar2.onMouseUp   = scrollbarReleased;
		
	var content3 = document.getElementById("col3-Content");
	var scrollb3 = document.getElementById("col3-Scrollbar");

	scrollbar3 = new Scrolling.Scrollbar (
		scrollb3,
		new Scrolling.Scroller (content3, 260, 363),
		new Scrolling.ScrollTween()
	);
	
	scrollbar3.onMouseDown = scrollbarPressed;
	scrollbar3.onMouseUp   = scrollbarReleased;
	
	var content4 = document.getElementById("col2Special-Content");
	var scrollb4 = document.getElementById("col2Special-Scrollbar");

	scrollbar4 = new Scrolling.Scrollbar (
		scrollb4,
		new Scrolling.Scroller (content4, 260, 363),
		new Scrolling.ScrollTween()
	);
	
	scrollbar4.onMouseDown = scrollbarPressed;
	scrollbar4.onMouseUp   = scrollbarReleased;
	
	var content5 = document.getElementById("col3Special-Content");
	var scrollb5 = document.getElementById("col3Special-Scrollbar");

	scrollbar5 = new Scrolling.Scrollbar (
		scrollb5,
		new Scrolling.Scroller (content5, 260, 363),
		new Scrolling.ScrollTween()
	);
	
	scrollbar5.onMouseDown = scrollbarPressed;
	scrollbar5.onMouseUp   = scrollbarReleased;
}

// Scrolling function brought to you by:
// http://www.n-son.com/scripts/jsScrolling/new
var scrollbar;

function scrollbarPressed (o, c, e) {
	o.className += "-Pressed";
};

function scrollbarReleased (o, c, e) {
	o.className = o.className.replace("-Pressed", "");
};

var hiddenClass = "hiddenBlock";
var visibleClass = "visibleBlock";

var currentlyActive = 1;

// TOGGLE BLOCKS
// Arguments come in in the form of element, class
function toggleBlocks(oneToStayActive){
	
	if(oneToStayActive != currentlyActive){
		
		// switch off anything that's not active
		var i = 1;
	
		while(document.getElementById("col2_"+i)){
			if(i != oneToStayActive){
				switchBlock("col2_"+i,hiddenClass);
				//switchBlock("link_"+i,"inactiveLink");
				eval("var txtColorFxlink_"+i+" = new Fx.Color('link_"+i+"', 'color', {duration: 0, wait:false})");
				eval("txtColorFxlink_"+i+".custom('000000', 'B92637')");
			}
			i++;
		}
		
		setVisibility("col2_"+oneToStayActive,"hidden");
		switchBlock("col2_"+oneToStayActive,visibleClass);
		//switchBlock("link_"+oneToStayActive,"activeLink");
		eval("var txtColorFxlink_"+oneToStayActive+" = new Fx.Color('link_"+oneToStayActive+"', 'color', {duration: 1000, wait:true})");
		eval("txtColorFxlink_"+oneToStayActive+".custom('B92637', '000000')");

		$('col2_'+oneToStayActive).effect('opacity', {duration: 800, onComplete: updateScrollBar2}).set(0).custom(0,1);
		
		currentlyActive = oneToStayActive;
	}
}

function updateScrollBar2(){	

	scrollbar2.reset();
	scrollbar2.enable();
	scrollbar2.reset();
}

function switchBlock(el,theClass){
	document.getElementById(el).className = theClass; 
}

function setVisibility(el,value){
	document.getElementById(el).style.visibility = value; 
}

var specialContentEffect;
var specialBackgroundEffect;


// TOGGLE SPECIAL BLOCKS
function toggleSpecialBlocks(oneToStayActive){
		
	// switch off anything that's not active
	var i = 1;
	
	while(document.getElementById("special_col2_"+i)){
		if(i == oneToStayActive){
			switchBlock("special_col2_"+i,visibleClass);
			switchBlock("special_col3_"+i,visibleClass);
		}else{
			switchBlock("special_col2_"+i,hiddenClass);
			switchBlock("special_col3_"+i,hiddenClass);
		}
		i++;
	}
	
	/// update scrollbars
	scrollbar4.reset();
	scrollbar4.enable();
	scrollbar4.reset();
	
	scrollbar5.reset();
	scrollbar5.enable();
	scrollbar5.reset();

	el = document.getElementById('specialContent');
	if (!el.currentStyle || !el.currentStyle.hasLayout) { 
		el.style.zoom = 1; // when no layout or cant tell 
	}
	
	specialContentEffect = new Fx.Opacity('specialContent');
	specialContentEffect.custom(0,1);

	specialBackgroundEffect = new Fx.Opacity('specialContentBackgroundImage');
	specialBackgroundEffect.custom(0,1);
}

function deActivateSpecial(){
	specialContentEffect.toggle();
	specialBackgroundEffect.toggle();
}

function turnOffDescriptions(){
	for(i = 0; i < arguments.length; i++){
		document.getElementById(arguments[i]).className = 'hiddenBlock';
	}
}

function toggleDescription(el){
	if(document.getElementById(el).className == "visibleBlock"){
		switchBlock(el,"hiddenBlock");
	}else{
		switchBlock(el,"visibleBlock");
	}
}

/* HIGHLIGHT LINKS */
function highLightLink(el){
	//switchBlock(el,"activeLink");
	eval("var txtColorFx"+el+" = new Fx.Color(el, 'color', {duration: 400, wait:false})");
	eval("txtColorFx"+el+".custom('B92637', '000000')");
	
	eval("var txtBGColorFx"+el+" = new Fx.Color(el, 'background-color', {duration: 400, wait:false})");
	eval("txtBGColorFx"+el+".custom('FFFFFF', 'EEEEEE')");
}

function reHighLightLink(el){
	//switchBlock(el,"activeLink");
	eval("var txtColorFx"+el+" = new Fx.Color(el, 'color', {duration: 0, wait:false})");
	eval("txtColorFx"+el+".custom('B92637', '000000')");
	
}

function unhighLightLink(el){
	//switchBlock(el,"inactiveLink");
	eval("var txtColorFx"+el+" = new Fx.Color(el, 'color', {duration: 400, wait:false})");
	eval("txtColorFx"+el+".custom('000000', 'B92637')");
	
	eval("var txtBGColorFx"+el+" = new Fx.Color(el, 'background-color', {duration: 400, wait:false})");
	eval("txtBGColorFx"+el+".custom('EEEEEE', 'FFFFFF')");
	
	document.getElementById(el).tempName = el
	document.getElementById(el).onmouseover=function() {
		reHighLightLink(this.tempName);
	}
	document.getElementById(el).onmouseout=function() {
		reUnhighLightLink(this.tempName);
	}
}

function reUnhighLightLink(el){
	//switchBlock(el,"inactiveLink");
	eval("var txtColorFx"+el+" = new Fx.Color(el, 'color', {duration: 0, wait:false})");
	eval("txtColorFx"+el+".custom('000000', 'B92637')");
}

// this function calls a popupWindow where
// win is the page address i.e. '../page.htm'
function popupWindow(win,winHeight,winWidth){
	newWindow = window.open(win,'mainWin','toolbar=no,location=no,scrollbars=no,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow.focus();
	
	return false;
}

