function selectSearch(originId, tagetId, no) {
	var originId = document.getElementById(originId);
	var originTxt = originId.getElementsByTagName("span")[0];
	var tagetId = document.getElementById(tagetId);
	var tagetTxt = tagetId.getElementsByTagName("li")[no].childNodes[0].nodeValue;
	originTxt.childNodes[0].nodeValue = tagetTxt;
	tagetId.className="";

if (no==0)
{
	document.inputform.ca_type.value="06";
}
else if (no==1)
{
     document.inputform.ca_type.value="07";
}
else if (no==2)
{
     document.inputform.ca_type.value="08";
}

}

function viewLayer(id) {
	var target=document.getElementById(id);
	var targetClass = target.className;
	
	if( targetClass == "") {
		target.className="layerOn";
	} else {
		target.className="";
	}
}

// content toggle
function initToggle(id,no) {
		var container1 = document.getElementById(id);
		var container2 = container1.getElementsByTagName("dd");

		if (container2[no].className=="")
		{
			container2[no].className="layerOn";
		} else {
			container2[no].className="";
		}


	/*	for (i=0; i<container2.length; i++ ){
			var faq = container2.item(i);
			var answer = container1.getElementsByTagName("dd").item(i);
				if( i == no ) {
					answer.style.display="block";
				} else {	
					answer.style.display="none";
				}
		}*/
}


// Float layer
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;
	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}


function imgOver(id) {
	var imgId = document.getElementById(id);
	var imgL = imgId.getElementsByTagName("img");

	for(i=0; i<imgL.length; i++) {
		imgL[i].onmouseover = function() {
			this.style.borderWidth = '3px';
			this.style.borderColor =  'red';
			this.style.borderStyle = 'solid';
		}
		imgL[i].onmouseout = function() {
			this.style.borderWidth = '0px';
			this.style.borderColor =  '#fff';
		}
	}
	
}

function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='';  
    return ''; 
} 

var prizeView = function (targetId) {
	var targetId = document.getElementById(targetId);

	if( targetId.className == "") {
		targetId.className="layerOn";
	} else {
		targetId.className="";
	}
}

function controlFocus(obj, toID) {
	if (toID == null) return;
	var maxLen = obj.getAttribute("maxlength"); 
	if (obj.value.length >= maxLen) {
		focusThis(toID);
	}
}

function focusThis(id) {
	if(document.getElementById(id)) {
		document.getElementById(id).focus();
	}
}



/* popup */
var chage = function(e) {
	e.value = "";
}



/* paging list */
try {
	document.execCommand("BackgroundImageCache",false,true);
} catch(ignored) {}

function $(s) { return document.getElementById(s) };
function $C(node) {return document.createElement(node)};

/* bind */
function $A(iterable)
{
	if (!iterable) return [];
	var results = [];
	for (var i = 0, length = iterable.length; i < length; i++)
	  results.push(iterable[i]);
	return results;
}

Function.prototype.bind = function()
{
	var __method = this, args = $A(arguments), object = args.shift();
	return function() {
		return __method.apply(object, args.concat($A(arguments)));
	}
}

Function.prototype.bindEvent = function()
{
	var __method = this, args = $A(arguments), object = args.shift();
	return function(event) {
		return __method.apply(object, [event || window.event].concat(args));
	}
}

//event add
function AddEvent(element, name, func)
{
	if (element.addEventListener) {
		element.addEventListener(name, func, false);
	}
	else if (element.attachEvent) {
		element.attachEvent('on' + name, func);
	}
}

Paging = function(listId,maxCount,prevBtId,nextBtId,listTag) {
	this.el = document.getElementById(listId);
	this.tag = (listTag) ? listTag : 'li';
	this.maxCount = maxCount;
	this.prevBt = (prevBtId) ? document.getElementById(prevBtId) : null;
	this.nextBt = (nextBtId) ? document.getElementById(nextBtId) : null;
	if(this.prevBt) AddEvent(this.prevBt,"click",this.prev.bind(this));
	if(this.nextBt) AddEvent(this.nextBt,"click",this.next.bind(this));
	this.init();

}

Paging.prototype = {
	init : function() {
		this.list = this.el.getElementsByTagName(this.tag);
		this.totalCount = this.list.length;
		this.totalPage = Math.ceil(this.totalCount/this.maxCount);
		this.needPaging = (this.totalCount > this.maxCount);
		if(!this.needPaging) {
			if(this.prevBt) this.prevBt.style.display = "none";
			if(this.nextBt) this.nextBt.style.display = "none";
		}
		else {
			if(this.prevBt) this.prevBt.style.display = "";
			if(this.nextBt) this.nextBt.style.display = "";
		}
		this.curPage = 1;
		this.exec(1);
	},
	prev : function() {
		this.exec(--this.curPage);
	},
	next : function() {
		this.exec(++this.curPage);
	},
	exec : function(n) {
		if(n<=0)  this.curPage = this.totalPage;
		else if(n>this.totalPage)  this.curPage = 1;

		var min = this.maxCount*(this.curPage-1), max = this.maxCount*this.curPage;
		for(var i=0;i<this.totalCount;++i) {
			if(min <= i && i < max) this.list[i].style.display = "block";
			else this.list[i].style.display = "none";
		}
	}
}

function activeflash(str, wid, hei) {

 document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+wid+"' height='"+hei+"'>")
 document.write("<param name='movie' value='"+str+"'>")
 document.write("<param name='quality' value='high'>")
 document.write("<PARAM NAME=wmode VALUE=transparent>")
 document.write(" <embed src='"+str+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+wid+"' height='"+hei+"'></embed></object>")
   
  
 }
 
 //스케줄 팝업
function popupWindow(url, w, h) {
  var posX = (screen.width - w) / 2;
  var posY = (screen.height - h) / 2;
  var option = ",resizable=no,scrollbars=no,status=no";
  window.open(url, "new_win","width="+w+",height="+h+",left="+posX +",top="+posY+option);

//win.dialog_open(url,w,h,'');     //win.dialog_open('팝업 중앙에 보여질 php or html or etc 파일','<-- 이 파일의 폭', '높이(빈칸으로 두면 170px 디폴드), '팝업 띄우고 포커스를 준다든가 하는 스크립트(빈칸이면 스크립트 실행 안함)'); 

//win.dialog_close(); 창 닫기 
//win.in_alert('알림 메세지'); 화면 좌측 상단에 2초간 보여질 내용입니다.

}




/* Layer Show/Hide */ 

var popup_req = false;//for popup ajax 
var popup_script = false;//dialog_open 네번째 인자로, 레이어 팝업창을 띄운 직후 실행할 스크립트 값 
var in_alertcount = 0; 
function new_popup() 
{ 
    this.agent_name = navigator.userAgent.toLowerCase(); 
    this.is_ie = ((this.agent_name.indexOf("msie") != -1) && (this.agent_name.indexOf("opera") == -1)); 
    this.is_gecko = navigator.product; 

    this.position_x = 0; 
    this.position_y = 0; 


    this.dlg_bg = document.getElementById('dialogbackgroundlayer'); 
    this.dlg = document.getElementById('dialoglayer'); 
    this.msg = document.getElementById('message'); 

    this.dlg_bg.style.left = '0px'; 

    this.dlg_bg.style.top = '0px'; 
    this.dlg_bg.style.width = '100%'; 
    this.dlg_bg.style.background = "#000"; 
    this.dlg_bg.style.opacity = (50/100); 
    this.dlg_bg.style.MozOpacity = (50/100); 
    this.dlg_bg.style.KhtmlOpacity = (50/100); 
    this.dlg_bg.style.filter = 'alpha(opacity=50)'; 

    this.dialog_open= function(url, w_width, w_height, run_script) 
    { 
        var height = document.body.clientHeight; 
        if(!w_height) w_height = 170; 
        if (this.is_gecko) height += 10; 

        this.dlg_bg.style.height = height + 'px'; 
        this.dlg_bg.style.display = ''; 

        //this.dlg.style.left = "50%"; 
        //this.dlg.style.top = w_height + "px"; 
		this.dlg.style.left = "650px"; 
        this.dlg.style.top = "100px"; 


        this.dlg.style.marginLeft = w_width/2*-1+"px"; 
        if (run_script) 
            popup_script = run_script; 
        else 
            popup_script = false; 

        this.load(url); 
        this.dlg.style.display = ''; 

    } 
    this.dialog_close= function() 
    { 
        this.dlg_bg.style.display = 'none'; 
        this.dlg.style.display = 'none'; 
    } 

    this.in_alert = function(message) 
    { 
        this.msg.innerHTML = message; 
        this.msg.style.display = ''; 
        window.setTimeout(this.in_alert_hidden, 2000); 
        in_alertcount++; 
    } 
    this.in_alert_hidden = function() 
    { 
        in_alertcount--; 
        if(!in_alertcount) 
            document.getElementById('message').style.display = 'none'; 
    } 

    this.load = function(url) { 
        popup_req= false; 
        // branch for native XMLHttpRequest object 
        if (window.XMLHttpRequest) { 
            try { 
                popup_req = new XMLHttpRequest(); 
            } 
            catch(e) { 
                popup_req = false; 
            } 
        } 
        // branch for IE/Windows ActiveX version 
        else if (window.ActiveXObject) { 
            try { 
                popup_req = new ActiveXObject("Msxml2.XMLHTTP"); 
            } 
            catch(e) { 
                try { 
                    this.req= new ActiveXObject("Microsoft.XMLHTTP"); 
                } 
                catch(e) { 
                    popup_req  = false; 
                } 
            } 
        } 
        if (popup_req ) { 

            popup_req.onreadystatechange = this.processPopup; 
            popup_req.open("GET", url, true); 
            popup_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); 
            popup_req.send(""); 
        } 
    } 
    this.processPopup = function() { 
        // only if req shows "loaded" 
        var obj = document.getElementById('dialoglayer'); 
        if (popup_req.readyState == 4) { 
            // only if "OK" 
            obj.innerHTML = popup_req.responseText; 
            if (popup_script) 
                eval(popup_script); 
        } 
    } 

} 

var mtickerEl = new Array();
var initmTicker = function (mtickerContainer, mtickerContent, delay) {
	var mtickerContainer = document.getElementById(mtickerContainer);
	var mtickerContent = document.getElementById(mtickerContent);
	mtickerEl[mtickerEl.length] = mtickerContainer;
	var speed = 20; //스크롤속도-작을수록빠름
	var mtickerElsum = 2; //initmTicker함수전체호출수-추가할때마다수정요함
	mtickerContainer.delay = delay/(speed/mtickerElsum); //mtickerEl.length를mtickerElsum로수정
	mtickerContainer.moveOffset = mtickerContainer.offsetHeight;//Safari만다른값.가끔될때도있음.
	mtickerContainer.count = 0;
	mtickerContainer.mtickerOver = false;
	mtickerContainer.cont = mtickerContent;
	mtickerContainer.cont.currentHeight = 0;
	mtickerContainer.move = setInterval("movemTicker()", speed);
}
function movemStop(){
	for (i=0; i<mtickerEl.length; i++) {
		mtickerEl[i].mtickerOver=true;
	}
}
function movemStart(){
	for (i=0; i<mtickerEl.length; i++) {
		mtickerEl[i].mtickerOver=false;
	}
}
function movemTicker() {
	for (i=0; i<mtickerEl.length; i++) {
		if (mtickerEl[i].cont.currentHeight % mtickerEl[i].moveOffset == 0 && mtickerEl[i].count < mtickerEl[i].delay) {
			if(!mtickerEl[i].mtickerOver) mtickerEl[i].count++;//mtickerOver가 false 일때 카운트증가시킨다
		} else {
			mtickerEl[i].count = 0;
			mtickerEl[i].cont.currentHeight -= mtickerEl[i].moveOffset;//스크롤안함
			if (mtickerEl[i].cont.currentHeight % (mtickerEl[i].cont.offsetHeight) == 0) {
				mtickerEl[i].cont.currentHeight = 0;
			}
			mtickerEl[i].cont.style.top = mtickerEl[i].cont.currentHeight + "px";
		}
	}
}
function prevmTicker(mtickerElnum) {
	var mtickerElnum = mtickerElnum-1;
	mtickerEl[mtickerElnum].count = 0;
	mtickerEl[mtickerElnum].cont.currentHeight+= mtickerEl[mtickerElnum].moveOffset;
	if (-mtickerEl[mtickerElnum].cont.currentHeight < 0) {
		mtickerEl[mtickerElnum].cont.currentHeight = mtickerEl[mtickerElnum].moveOffset-mtickerEl[mtickerElnum].cont.offsetHeight;
	}
	mtickerEl[mtickerElnum].cont.style.top = mtickerEl[mtickerElnum].cont.currentHeight + "px";
}
function nextmTicker(mtickerElnum) {
	var mtickerElnum = mtickerElnum-1;
	mtickerEl[mtickerElnum].count = 0;
	mtickerEl[mtickerElnum].cont.currentHeight-= mtickerEl[mtickerElnum].moveOffset;
	if (-mtickerEl[mtickerElnum].cont.currentHeight >= mtickerEl[mtickerElnum].cont.offsetHeight) {
		mtickerEl[mtickerElnum].cont.currentHeight = 0;
	}
	mtickerEl[mtickerElnum].cont.style.top = mtickerEl[mtickerElnum].cont.currentHeight + "px";
}


function open_newspop(k,newsurl)
{
window.open('/community/relay_news.asp?bdidx='+k+'&newsurl='+newsurl,'_blank','');
}


function openEventPopupBox(id,url,w,h,l,t) 
{ 
if ( getCookie( id ) != "done" )
	{
noticeWindow  =window.open(url,id,'left='+l+', top='+t+',width='+w+',height='+h+',intHeightoolbar=0, menubar=0, location=0, directories=0, status=0, scrollbars=no, resizable=0'); 
noticeWindow.opener = self; 
    }
}


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 Found = false 
var start, end 
var i = 0 
// cookie 문자열 전체를 검색 
while(i <= document.cookie.length) 
{ 
start = i; 
end = start + name.length; 
// name과 동일한 문자가 있다면 
if(document.cookie.substring(start, end) == name) 
{ 
Found = true;
break; 
} 
i++ 
} 
// name 문자열을 cookie에서 찾았다면 
if(Found == true) { 
start = end + 1; 
end = document.cookie.indexOf(";", start); 
// 마지막 부분이라 는 것을 의미(마지막에는 ";"가 없다) 
if(end < start) 
end = document.cookie.length; 
// name에 해당하는 value값을 추출하여 리턴한다. 
return document.cookie.substring(start, end); 
} 
// 찾지 못했다면 
return ""; 
} 


