
var bPList = new Array();
bPList.push(['ETRI_sosicpopup.jpg', 'http://www.etri.re.kr/etri/web/web_0104000000.etri', '', 'ETRI 좋은e웃는소식지 신청']);
bPList.push(['popup20111115.jpg', 'http://www.gogef.kr/saveenergy/saveenergy.html', '_blank', '에너지 절약, 내복입기로 시작하세요!']);
bPList.push(['ETRI_popup1115.jpg', ' http://www.etri.re.kr/etri/not/not_0102000000.etri?type=view&b_idx=12258', '', '상용화 현장연구 지원 안내']);

var bPOut = '', bIndex = 0, bPSpeed = 5000;
function selectBannerPopup(index){
	var banner = document.getElementById('pBanner');
	banner.src = '/etri2010/images/main_img/'+bPList[index][0];
	banner.alt = bPList[index][3];
	banner.parentNode.setAttribute('href', bPList[index][1]);
	if(bPList[index][2] != ''){
		banner.parentNode.setAttribute('target', bPList[index][2]);
	}
	else{
		banner.parentNode.setAttribute('target', '');
	}

	changeBannerDisplay(index);
	return false;
}

/**
 * 배너위치가 (자동으로) 바뀌면 배너 디스플레이의 모양을 바꿔준다. 
 * @param index
 * @return
 */
function changeBannerDisplay(index){
	for(var i=0; i<bPList.length;i++){
		document.getElementById('pbindex'+(i+1)).src = '/etri2010/images/main_img/'+(i+1)+'_off.gif';
	}
	document.getElementById('pbindex'+(index+1)).src = '/etri2010/images/main_img/'+(index+1)+'_on.gif';
}

/**
 * 일정시간 후에 팝업배너의 이미지를 변경시킨다.
 */
function intervalBPopup(){
	selectBannerPopup(bIndex++);
	if(bIndex == bPList.length)
		bIndex = 0;
	bPOut = setTimeout("intervalBPopup()",bPSpeed);
}

/**
 * 배너 위치로 이동할 수 있는 영역을 디스플레이
 * @return
 */
function makePopupBannerIndex(){
	var src = '';
	for(var i=0; i<bPList.length;i++){
		if(i == 0){
			src += '<a href="#" onclick="return selectBannerPopup('+i+');"><img src="/etri2010/images/main_img/1_on.gif" alt="1" id="pbindex'+(i+1)+'"></a>&nbsp;';
		}
		else{
			src += '<a href="#" onclick="return selectBannerPopup('+i+');"><img src="/etri2010/images/main_img/'+(i+1)+'_off.gif" alt="'+(i+1)+'" id="pbindex'+(i+1)+'"></a>&nbsp;';
		}
	}
	var area = document.getElementById('popup_banner_display_area');
	
	area.innerHTML = src;
}
