// JavaScript Document


// check for current news items. If there isn't anything new then don display the "What's new" column
function CheckNews() {
	var items = document.getElementsByClassName("news-latest-item");
	var news = Sat_GetObj("News");
	if (news!=undefined) {
		if (items==undefined || items.length==0) {
			news.style.display="none";
		} else {
			news.style.display="";
		}
	}
}

function InitNav(){

	if (typeof(OnCellID) == 'undefined' || Sat_GetObj(OnCellID) == false){return}

	BgColor = '#F87035';

	RightCell = getRightCell(OnCellID);

	

	Sat_GetObj(OnCellID).style.backgroundColor = BgColor;

	Sat_GetObj(OnCellID).style.backgroundImage = 'none'

	

	if(RightCell){ 

		RightCell.style.backgroundImage  = 'none';

	}

}


function resizeNav(theNav, theTarget, theElements) {
	maxSize = 0;
	if (theElements!=undefined) {
		for (i in theElements) {
			elementArray = theElements[i].split(",");
			element = Sat_GetObj(elementArray[0]);
			offset = isNaN(elementArray[1])?0:Number(elementArray[1]);
			if (element!=undefined) {
				maxSize=element.clientHeight+offset>maxSize?element.clientHeight+offset:maxSize;
			}
		}
	}

	mainContent = Sat_GetObj(theTarget);
	maxSize = mainContent.clientHeight>maxSize?mainContent.clientHeight:maxSize;

	mainNav = Sat_GetObj(theNav);
	maxSize = mainNav.clientHeight>maxSize?mainNav.clientHeight:maxSize;

	mainNav.style.height=maxSize + "px";
	mainContent.style.height=(maxSize - 10) + "px"; //-10 for padding...

}


function resizeHead(theHead, theTarget, initWidth) {

	mainWidth = initWidth;

	for (i in theTarget) {
		element = Sat_GetObj(theTarget[i]);
		mainWidth += element.clientWidth;
	}

	for (j in theHead) {
	        mainHead = Sat_GetObj(theHead[j]);
		if (mainHead.clientWidth < mainWidth) {
			mainHead.style.width=mainWidth + "px";
		}
	}

}



function getRightCell(CellID){

	rightCell = 'Nav' + (parseInt(CellID.substring(3)) + 1)

	return Sat_GetObj(rightCell)

}



function Sat_GetObj(ID) {

/*abstraction layer to deal with the IE vs NN object model */



	if (typeof(ID) != 'undefined' && ID.length != 0){

		if (document.all){	

			if (typeof(eval('document.all.' + ID)) != 'undefined' ){

				return eval('document.all.' + ID)

			}

		}

		else if (document.getElementById){

			if (typeof(document.getElementById(ID))!= 'undefined' && document.getElementById(ID) != null){

				return document.getElementById(ID)

			}

		}

	}

	return false

}





function ToggleNav(Cell, direction) {

	if (!window.OnCellID){OnCellID = ""}

	if (OnCellID == Cell.id) {return;} //don't touch the current on cell

	

	RightCell = getRightCell(Cell.id);

	

	ColorOn = '#E15C22';

	ColorOff = 'transparent';

	ImgOn = 'none';

	ImgOff = 'url(fileadmin/templates/images/topnav_divider.gif)';

	

	BgImg = eval('Img' + direction);

	BgColor = eval('Color' + direction);



	if (document.all || document.getElementById){

		Cell.style.backgroundColor = BgColor;

		

		if (Cell.id != 'Nav1' && Cell != getRightCell(OnCellID)){Cell.style.backgroundImage = BgImg;}

		if(RightCell && RightCell.id != OnCellID) {

			RightCell.style.backgroundImage   = BgImg;

		}

		

	}

}

