/* press archive functions start here */
function showYearFilter(id) {
	var divLink = document.getElementsByTagName('div');
	var divCounter = 0;
	
	for(var no = 0; no < divLink.length; no++){
		if(divLink[no].className=='rtContainer'){
			divCounter++;
		}
	}

	for (var i = 0; i < divCounter; i++) {
		var thisSection = document.getElementById('rlCont' + i);
		
		if (i == id) {
			if (thisSection.style.display == '') {
				thisSection.style.display = 'none';
				
				// changing class for section header to show selected/unselected state
				changeClass('rlHD' + i, 'rtHD');
			} else {
				thisSection.style.display = '';
				
				// changing class for section header to show selected/unselected state
				changeClass('rlHD' + i, 'rtHDSelected');
			}
		} else {
			thisSection.style.display = 'none';
			
			// changing class for section header to show selected/unselected state
			changeClass('rlHD' + i, 'rtHD');
		}
	}
}

function buildYearFilters() {
	var filterHtml = '';
	var i = 0;
	
	if (newsType == 3) {
		var minYear = '2007';
	} else {
		var minYear = '2006';
	}

	for (y = currentYearPress; y > minYear; y--) {
		filterHtml += '<div class="rtContainer">'+
			'<a id="rlHD' + i + '" class="rtHD" href="javascript:showYearFilter(' + i + ')">' + y + '</a>'+
									
			'<div id="rlCont' + i + '" class="filterContent" style="display: none;">'+
				'<b>Filter by Month</b><br />'+
				'<select id="yearDrop' + i + '">'+
					'<option>- Select -</option>';
					//determinig month length
					if (y == thisYear) {
						var monthCount = d.getMonth() + 1;
					} else {
						var monthCount = monthArray.length;
					}
					for (m = 0; m < monthCount; m++) {
						filterHtml += '<option value="' + m + '">' + monthArray[m] + '</option>';
					}
				filterHtml += '</select>'+
				'<a href="javascript:getYearFilter(\'' + y + '\',\'' + i + '\')"><img src="/citi/press/images/red_submit.gif" alt="submit" /></a>'+
				'<a href="javascript:getYearNews(' + y + ')" class="rtLink">>>View All</a>'+
			'</div>'+
		'</div>';
		i++;
	}
	
	document.getElementById('newsFilter').innerHTML = filterHtml;
}

function getYearFilter(newsYear, filterID) {	
	var dropVal1 = document.getElementById("yearDrop" + filterID);
	passVarValue = new Array();
	passVarLabel = new Array('yearNum', 'monthNum', 'newsType');
	
	passVarValue[0] = newsYear;
	//passVarValue[1] = dropVal1.options[dropVal1.selectedIndex].value;
	passVarValue[1] = dropVal1.value;
	passVarValue[2] = getNewsType(newsType);
	
	if (getFile("xml/press" + newsYear + ".xml").indexOf('<?xml') != -1) {
		// if xml news archive exist, we will display the content
		if (passVarValue[1] != '') {
			document.getElementById('newsList').innerHTML = ' ';
			var newsList = new loadData("xml/press" + newsYear + ".xml", "xsl/news_list.xsl", "newsList", passVarLabel, passVarValue, false);
		}
	} else {
		document.getElementById('newsList').innerHTML = '<h1 class="black">None at this time for ' + currentYearPress + '.</h1>';
	}
}

function getYearNews(newsYear) {
	document.getElementById('newsList').innerHTML = ' ';
	
	passVarValue = new Array();
	passVarLabel = new Array('yearNum', 'monthNum', 'newsType');
	
	passVarValue[0] = newsYear;
	passVarValue[1] = 89;
	passVarValue[2] = getNewsType(newsType);
	
	// load right image
	showMainImage(newsType);
	
	if (getFile("xml/press" + newsYear + ".xml").indexOf('<?xml') != -1) {
		// if xml news archive exist, we will display the content
		document.getElementById('newsList').innerHTML = ' ';
		var newsList = new loadData("xml/press" + newsYear + ".xml", "xsl/news_list.xsl", "newsList", passVarLabel, passVarValue, false);
	} else {
		document.getElementById('newsList').innerHTML = '<h1 class="black">None at this time for ' + currentYearPress + '.</h1>';
	}
}

function getNewsType(newsCat) {
	switch(newsCat) {
		case "0":
			return 'Citi-Wide';
		break;
		case "1":
			return 'Business-Specific';
		break;
		case "2":
			return 'Community Affairs';
		break;
		case "3":
			return 'Features';
		break;
		default:
			return 'Citi-Wide';
	}
}

function showMainImage(newsCat) {
	var imgHtml = '';
	switch(newsCat) {
		case "0":
			imgHtml = '<img src="images/i_pr_cw.jpg" width="692px" height="140px" alt="Press Releases: Citi-Wide" />';
		break;
		case "1":
			imgHtml = '<img src="images/i_pr_bsp.jpg" width="692px" height="140px" alt="Press Releases: Business-Spefic" />';
		break;
		case "2":
			imgHtml = '<img src="images/i_pr_ca.jpg" width="692px" height="140px" alt="Press Releases: Community Affairs" />';
		break;
		case "3":
			imgHtml = '<img src="images/i_features.jpg" width="692px" height="140px" alt="Features" />';
		break;
		default:
			imgHtml = '<img src="images/i_pr_cw.jpg" width="692px" height="140px" alt="Press Releases: Citi-Wide" />';
	}
	document.getElementById('mainImage').innerHTML = '';
	document.getElementById('mainImage').innerHTML = imgHtml;
}
/* press archive functions end here */

function showAd(adID) {
	var thisAdDiv = document.getElementsByTagName('div');
	var adCounter = 0;
	
	for (var n = 0; n < thisAdDiv.length; n++) {
		if (thisAdDiv[n].className == 'adContainer') {
			adCounter++;
		}
	}
	
	for (var i = 0; i < adCounter; i++) {

		var thisAdContainer = document.getElementById('ad' + i);
		
		if (i != adID) {
			if (thisAdContainer.style.display == '') {
				new Effect.Fade('ad' + i, { queue: 'front'});
			}
		} else {
			if (thisAdContainer.style.display == '') {
				if (i != adID) {
					new Effect.Fade('ad' + i, { queue: 'front'});
				}
			} else {
				new Effect.Appear('ad' + i, { queue: 'end'});
			}
		}
	}
}