/***************************************************************************************************/
/** 메인외부참조파일초기화
*/
function initExternalRefMain(){
	//*.css
	document.writeln('<link rel="stylesheet" type="text/css" href="/share/css/main.css?'+nowString+'">');
	//*.js
	document.writeln('<script type="text/javascript" src="/share/js/mticker.js?'+nowString+'"></'+'script>');
}
initExternalRefMain();
/***************************************************************************************************/
//메인용함수

/** 탭메뉴콘텐츠 - 공통적으로 사용
* author : myshin
* update : 2008.06.19
* desc : 이미지일때 소스 경로/이름 무관하게 수정. 앵커일때 스타일로 제어하게 수정.
* tab1m1, tab1c1 등 id 이름을 맞춰야함. 탭메뉴는 containerId+m일련번호, 탭콘텐츠는 containerId+m일련번호.
* 이전코드와의 호환을 위해 containerId 를 tab1 형태로 부여하고 tabOn(1,1); 방법으로 호출해도됨.
* 탭 개수에 맞게 루프 돌림.
* _imgtype 를 전역변수로 지정해서 내장함수(obj.src.replace)에서도 사용가능.
* ex) tabOn("탭그룹id","활성탭id"); tabOn("tab1",1);
*/
function tabOn(containerId,a) {
	var tabContainer = document.getElementById(containerId);
	var tabid = (tabContainer)? tabContainer.id : "tab"+containerId;//이전코드호환
	var tabTagAll = document.getElementById(tabid).getElementsByTagName("*");
	var tabSum = 0;//탭그룹안의 탭 개수 초기화
	for(var i=0;i<tabTagAll.length;i++){
		//if(tabTagAll[i].className=="tabcontent") tabContents++;//오류발생가능성이많아서안씀
		var where = tabTagAll[i].id.indexOf(containerId);
		if(where!=-1) tabSum++;
	}
	tabSum = tabSum/2;//루프로 찾은 수는 탭1개당 2개(메뉴와 콘텐츠)이므로 보정.
	for(var i=1;i<=tabSum;i++){//탭 개수만큼만 루트 돌린다.
		if(i<10){inn="0"+i;} else {inn=""+i;}
		tabMenu = document.getElementById(tabid+"m"+i);
		tabContent = document.getElementById(tabid+"c"+i);
		if (tabMenu) { //객체가존재하면
			if (tabMenu.tagName=="IMG") { //이미지일때
				_imgtype = tabMenu.src.substr(tabMenu.src.length-3,tabMenu.src.length-1);
				tabMenu.src = tabMenu.src.replace("on."+_imgtype, "."+_imgtype);
			}
			if (tabMenu.tagName=="A") { tabMenu.className=""; } //앵커일때
		}
		if (tabContent) { tabContent.style.display="none"; }
	}
	if(a<10){ann="0"+a;} else {ann=""+a;}
	tabMenu = document.getElementById(tabid+"m"+a);
	tabContent = document.getElementById(tabid+"c"+a);
//	alert(tabMenu.tagName);
	if (tabMenu) { //객체가존재하면
		if (tabMenu.tagName=="IMG") { //이미지일때
			_imgtype = tabMenu.src.substr(tabMenu.src.length-3,tabMenu.src.length-1);
			tabMenu.src = tabMenu.src.replace("."+_imgtype, "on."+_imgtype);
		}
		if (tabMenu.tagName=="A") { tabMenu.className="on"; } //앵커일때
	}
	if (tabContent) { tabContent.style.display="block"; }
	tabMore = document.getElementById(tabid+"more");
}

//오픈 팝업 : 오늘 하루 열지 않기 시작  쿠키
function setCookie(name,value,expiredays){
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function getCookie(name){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}
/** 팝업레이어
* author: myshin
* update: 2008.09.23
* desc: setCookie(), getCookie() 필요
* ex) popupLayer();
*/
function closePop(pop,check){
	var checkPop = document.getElementById(check);
	if(check=="checked") setCookie(pop,"done",1);// 인수1은 쿠키유지일수
	var popLayer = document.getElementById(pop);
	if(popLayer) popLayer.style.visibility="hidden";
}
function popupLayer(pop){
	if(getCookie(pop)!="done"){
		var popLayer = document.getElementById(pop);
		if(popLayer) popLayer.style.visibility="visible";
	}
}