
/* design */
var SelectBox = {
	init: function () {
		this.selectBoxContainer = FindEl.byClass(document.getElementsByTagName('div'), "SelectBox")
		if (this.selectBoxContainer) {
			for (var i=0; i < this.selectBoxContainer.length; i++) {
				this.selectBoxContainer[i].style.display = "block"

				var heading = FindEl.byClass(this.selectBoxContainer[i].getElementsByTagName('*'), "SelectHeading")[0]
				heading.style.cursor = "default"
				heading.onclick = SelectBox.headingClick

				var list = FindEl.byClass(this.selectBoxContainer[i].getElementsByTagName('*'), "SelectList")[0]
				var listItem = list.getElementsByTagName('li')

				for (var j=0; j < listItem.length; j++) {
					listItem[j].onmouseover = SelectBox.listItemEffect
					listItem[j].onmouseout = SelectBox.listItemEffect
				}
				if (document.addEventListener) {
					document.addEventListener('click', this.listInit, false)
				} else if (document.attachEvent) {
					document.attachEvent('onclick', this.listInit)
				}
			}
			this.listInit()
		}
	},
	listInit: function () {
		for (var i=0; i < SelectBox.selectBoxContainer.length; i++) {
			var list = FindEl.byClass(SelectBox.selectBoxContainer[i].getElementsByTagName('*'), "SelectList")[0]

			if (list.style.display == "block") list.style.display = "none"
		}
	},
	headingClick: function (e) {
		var list = FindEl.byClass(this.parentNode.getElementsByTagName('div'), "SelectList")[0]

		if (list.style.display == "block") {
			list.style.display = "none"
		} else {
			SelectBox.listInit()
			list.style.display = "block"
		}
		if (list.offsetHeight > 250) {
			var scrollEl = FindEl.byClass(list.getElementsByTagName('*'), "scroll")[0]
			scrollEl.style.height = "250px"
			scrollEl.style.overflow = "auto"
		}

		var evt = e || window.event
		if (evt.stopPropagation) {
			evt.stopPropagation();
		} else {
			evt.cancelBubble = true;
		}
	},
	listItemEffect: function () {
		if (this.className == "") {
			this.className = "on"
		} else {
			this.className = ""
		}
	}
}
function newWindow(href) {
	window.open(href, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, resizable=yes, scrollbars=yes, width=900, height=700");
}

function newPopup(href,width,height,top,left) {
	window.open(href, "", "toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, width="+width+", height="+height+",top="+top+",left="+left);
}

var AppendEl = {
	moveChildInto: function (el, child) {
		el.appendChild(child)
	},
	moveChildrenInto: function (el, children) {
		var a = 0;
		while (children.length > 0) {
			if (a == children.length) break;
			else {
				a = children.length;
				this.moveChildInto(el, children[0]);
			}
		}
	},
	insertNodeAt: function(node, dest, where) {
		if(where == "before") {
			dest.parentNode.insertBefore(node, dest);
		} else { // "after"
			var next = dest.nextSibling;
			if(next) {
				next.parentNode.insertBefore(node, next);
			} else {
				dest.parentNode.appendChild(node);
			}
		}
	}
}
var RemoveEl = {
	child: function (child) {
		child.parentNode.removeChild(child)
	},
	children: function (children) {
		for (var i=0; i < children.length; i++) {
			this.child(children[i])
		}
	}
}
var FindEl = {
	byClass: function (el, className, array) {
		var elements = (array) ? array : new Array()

		for (var i=0; i < el.length; i++) {
			if (el[i].className.indexOf(className) != -1 ) {
				elements.push(el[i])
			}
		}
		return elements
	},
	byNodeType: function (el, nodeType) {
		var elements = new Array()

		for (var i=0; i < el.length; i++) {
			if (el[i].nodeType == nodeType ) {
				elements.push(el[i])
			}
		}
		return elements
	},
	parentForm: function (el) {
		var tempEl = el
		var parentForm
		do { tempEl = tempEl.parentNode	}
		while (tempEl.tagName != "FORM")
		parentForm = tempEl
		return parentForm
	},
	parentNodeByClass: function (el, className) {
		var tempEl = el
		var parentEl
		do { tempEl = tempEl.parentNode }
		while (tempEl.className.indexOf(className) == -1)
		parentEl = tempEl
		return parentEl
	},
	nextSiblingByNodeName: function (el, nodeName) {
		var tempEl = el
		while (tempEl.nextSibling.nodeName != nodeName) {
			tempEl = tempEl.nextSibling;
		}
		return tempEl.nextSibling
	}
}
LabelDisplay = function (container) {
	this.container = container;
	this.containers = FindEl.byClass(this.container.getElementsByTagName('div'), "LabelDisplay");
	for (var i=0; i < this.containers.length; i++) {
		var labels = this.containers[i].getElementsByTagName('label');
		for (var j=0; j < labels.length; j++) {
			var label = labels[j];
			var input = document.getElementById(label.className);
			if (input && !input.value) {
				label.style.display = "block";
				label.style.cursor = "text";

				label.onclick = function () {
					this.style.display = "none";
				}
				input.onclick = function () {
					FindEl.byClass(document.getElementsByTagName('label'), this.id)[0].style.display = "none";
				}
				input.onfocus = function () {
					this.onclick();
				}
			}
			if (input && input.value) {
				label.style.display = "none";
			}
		}
	}
}




/* tab */
ToggleContent = function (heading, content, observer) {
	var self = this;
	this.heading = $(heading);
	this.content = $(content);
	this.observer = observer;
	this.contentShown = false;
	this.currentContent = null;

	this.heading.click(function () {
		!self.contentShown ? self.show() : self.hide();
		return false;
	}).mouseover(function () {
		$(this).parent().addClass('hover');
	}).mouseout(function () {
		$(this).parent().removeClass('hover');
	})
	this.init();
}
ToggleContent.prototype = {
	init: function () {
		this.content.hide();
	},
	show: function () {
		if (this.observer.tabMenu(this)) return;
		this.heading.parent().addClass('on');
		this.content.show();
		this.contentShown = true;
	},
	hide: function (boolTmp) {
		if (this.observer.tabMenu(this) && boolTmp != true) return;
		this.heading.parent().removeClass('on');
		this.content.hide();
		this.contentShown = false;
	}
}
ToggleContents = function (headings, contents, isTab) {
	this.headings = $(headings);
	this.contents = $(contents);
	this.isTab = isTab === 'tab' ? true : false;
	this.currentToggleContent = null;
	
	for (var i=0; i < this.headings.length; i++) {
		new ToggleContent(this.headings[i], this.contents[i], this);
	};
	this.init();
}
ToggleContents.prototype = {
	init: function () {
		if (this.isTab) $(this.headings[0]).click();
	},
	tabMenu: function (toggleContent) {
		if (this.isTab && this.currentToggleContent === toggleContent) return true;
		if (this.isTab && this.currentToggleContent != null) this.currentToggleContent.hide(true);
		
		this.currentToggleContent = toggleContent;
		return false;
	}
}

function imageOver (image) {
	image.src = image.src.replace('.gif', '_on.gif');
}
function imageOut (image) {
	image.src = image.src.replace('_on.gif', '.gif');
}

function swf_view(src,width,height,image,desc,map_name)
{
	str = "";
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/user/flash/swflash.cab#version=9,0,115,0" width="'+width+'" height="'+height+'">';
	str += '	<param name="movie" value="'+src+'" />';
	str += '	<!--[if !IE]> <-->';
	str += '	<object data="'+src+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'">';
	str += '	<!--> <![endif]-->';
	str += '		<div><img src="'+image+'" alt="'+desc+'" usemap="#'+map_name+'" /></div>';
	str += '	<!--[if !IE]> <-->';
	str += '	</object>';
	str += '	<!--> <![endif]-->';
	str += '</object>';

	document.write(str);
}

//주민등록번호체크//////////////////////////////////////////

function ChkJumin(str_jumin1, str_jumin2)
{ 
	errfound = false; 
	var str_jumin1;
	var str_jumin2;
	var checkImg=''; 
	
	var i3=0 
	for (var i=0; i < str_jumin1.length; i++)
	{ 
		var ch1 = str_jumin1.substring(i, i+1); 
		if (ch1<'0' || ch1>'9') { i3 = i3+1 } 
	} 
	if ((str_jumin1 == '') || ( i3 != 0 )) 
	    return false;
	
	var i4=0 
	for (var i=0;i<str_jumin2.length;i++)
	{ 
	    var ch1 = str_jumin2.substring(i, i+1); 
	    if (ch1<'0' || ch1>'9') { i4 = i4+1 } 
	} 
	if ((str_jumin2 == '') || ( i4 != 0 ))
	  return false;
	
	if(str_jumin1.substring(0, 1) < 4) 
	    return false;
	
	if(str_jumin2.substring(0, 1) > 2) 
	    return false;
	
	if((str_jumin1.length > 7) || (str_jumin2.length > 8)) 
	    return false;
	
	if ((str_jumin1 == '72') || ( str_jumin2 == '18')) 
	  return false;
	 
	var f1 = str_jumin1.substring(0, 1) 
	var f2 = str_jumin1.substring(1, 2) 
	var f3 = str_jumin1.substring(2, 3) 
	var f4 = str_jumin1.substring(3, 4) 
	var f5 = str_jumin1.substring(4, 5) 
	var f6 = str_jumin1.substring(5, 6) 
	var hap = f1*2+f2*3+f3*4+f4*5+f5*6+f6*7 
	var l1 = str_jumin2.substring(0, 1) 
	var l2 = str_jumin2.substring(1, 2) 
	var l3 = str_jumin2.substring(2, 3) 
	var l4 = str_jumin2.substring(3, 4) 
	var l5 = str_jumin2.substring(4, 5) 
	var l6 = str_jumin2.substring(5, 6) 
	var l7 = str_jumin2.substring(6, 7) 
	hap = hap+l1*8+l2*9+l3*2+l4*3+l5*4+l6*5 
	hap = hap%11 
	hap = 11-hap 
	hap = hap%10 

	if (hap != l7) 
	  return false;
	   
	var i9=0 
	
	if (!errfound) 
	    return true;
} 

function getCookie(name){ 
	var first 
	var str = name +"="; 
	if(document.cookie.length>0) { 
		find = document.cookie.indexOf(str); 
		if(find == -1 ) return null; 
		first = find+str.length; 
		end = document.cookie.indexOf(";", first) 
		if(end == -1 ) 
		end = document.cookie.length 
		return unescape(document.cookie.substring(first,end))    
	} 
}

function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + todayDate.toGMTString() + ';'
} 
//setCookie( 'Notice'+idx, 'done' , 1); // 1=하룻동안 공지창 열지 않음

function checkID(str) 
{
   if (/^[a-zA-Z0-9]{6,12}$/.test(str))
	   return true;
   else
	   return false;
}

