// JavaScript Document for Awards and News pages

/******* Set tabs and divs when Awards page loads ******/
function setAwdsPageState() {
	var tPos = getCookie('awdsTabPos');
	var onTab = 'ts_btnTab'+tPos;
	var listNum = getCookie('awdsListNum');
	if (!tPos == '' || !tPos == null) {
		ts_tabHilite(onTab,tPos);
		if (!listNum == '' || !listNum == null) {
			showSelectedList(tPos,listNum);
			ftrAdj();
		}
		else {
			showSelectedList(tPos,0);
			ftrAdj();
		}
	}
	else if (!listNum == '' || !listNum == null) {
		showSelectedList(0,listNum);
		showHideView(0);
	}
	else {
		showSelectedList(0,0);
		showHideView(0);
	}
}
/******* Awards page tab changer *********/
function awdsChangeTab(tabID,pos) {
	setCookie("awdsTabPos",pos);
	var awdsTab = getCookie('awdsTabPos');
	ts_tabHilite(tabID,pos);
	awdsChangeList(awdsTab,0);
}
/******* Awards page list changer ********/
function awdsChangeList(view,pos) {
	setCookie("awdsListNum",pos);
	var awdsList = getCookie('awdsListNum');
	showSelectedList(view,awdsList);
	ftrAdj();
}
/********************************************************/
/******* Set tabs and divs when News&PR page loads ******/
function setNewsPageState() {
	var tPos = getCookie('newsTabPos');
	var onTab = 'ts_btnTab'+tPos;
	var listNum = getCookie('newsListNum');
	if (!tPos == '' || !tPos == null) {
		ts_tabHilite(onTab,tPos);
		if (!listNum == '' || !listNum == null) {
			showSelectedList(tPos,listNum);
			ftrAdj();
		}
		else {
			showSelectedList(tPos,0);
			ftrAdj();
		}
	}
	else if (!listNum == '' || !listNum == null) {
		showSelectedList(0,listNum);
		showHideView(0);
	}
	else {
		showSelectedList(0,0);
		showHideView(0);
	}
		
}
/******* News&PR page tab changer *********/
function newsChangeTab(tabID,pos) {
	setCookie("newsTabPos",pos);
	var newsTab = getCookie('newsTabPos');
//	alert('changing tab to ' + newTab);
	ts_tabHilite(tabID,pos);
	newsChangeList(newsTab,0);
}
/******* News&PR page list changer ********/
function newsChangeList(view,pos) {
	setCookie("newsListNum",pos);
	var newsList = getCookie('newsListNum');
//	alert ('the list cookie is ' + newList);
	showSelectedList(view,newsList);
	ftrAdj();
}


/******* Set the tab strip highlight ********/
function ts_tabHilite(ts_thisTab,pos){
	var ts_btnWidth=(pos==0)?183:181; /* Button Width */
	var btn = $("ts_btnTabHilite");
	btn.style.display="block";
	btn.style.left=(ts_btnWidth*pos) + "px";
	btn.innerHTML = "<a href='javascript:void(0)'>" + $(ts_thisTab).innerHTML + "</a>";
	showHideView(pos); //Set the visible layer
}

/******* Show or hide two main containers ********/
function showHideView(view) {
	if (view==0){
		$("view0").style.display = "block";
		$("view1").style.display = "none";
	}
	else if (view==1) {
		$("view0").style.display = "none";
		$("view1").style.display = "block";
	}
	ftrAdj();
}

/* Display selected set of articles and Hide all others */
function showSelectedList(view,pos){
//	alert ('The view is ' + view + ' and the list number is ' + pos);
	if (view == 0) {
		for (var i = 0; i < totalDA; i++){
			if (pos==i){
//				alert ('the list to show is ' + pos);
				$("dLink"+i).className = "contxtOn";
				divOn = $("da"+i);
				divOn.style.display = "block";
			}
			else{
				$("da"+i).style.display = "none";
				$("dLink"+i).className = "contxt";
			}
		}
	}
	else if (view == 1){
		for (var i = 0; i < totalMA; i++){
			if (pos==i){
//				alert ('the list to show is ' + pos);
				$("mLink"+i).className = "contxtOn";
				divOn = $("ma"+i);
				divOn.style.display = "block";
			}
			else {
				$("ma"+i).style.display = "none";
				$("mLink"+i).className = "contxt";
			}
		}
	}
}
	
function ftrAdj() {
	footer(Array('ContentArea'),20,20);
}
