function CalendarReset(fg)
{
	if(fg == 1)
	{
		document.getElementById("event_e").style.display = "";			
	}
	else
	{
		document.getElementById("event_s").style.display = "";			
	}
}
// 구군 검색 함수
function GroupSelect(val,TA){
	form=document.s_one;
	form.action="/event/include/CateSelect.php";
	form.target="lovehidden";
	if(val=="1"){	
		form.DanUid.value=form["si"][form.si.selectedIndex].value;		
	}else if(val=="2"){
		form.DanUid.value=form["n_pyung"][form.n_pyung.selectedIndex].value;
	}
	if(form.DanUid.value!=""){

		form.Level.value=val;
		form.T.value=TA;
		form.submit();
	}
}

function Over(evt) {
	try{
		if(event.srcElement.className == "rollover") {
			var obj = event.srcElement;
			var srcPath = obj.src;
			var overImg = obj.over;
			var outImg = obj.out;
			var newSrcPath = srcPath.replace(outImg, overImg);
			event.srcElement.src = newSrcPath;
		}
	}catch(e){
		if(evt.target.className == "rollover") {
			var obj = evt.target;
			var srcPath = obj.src;
			var newSrcPath = srcPath.replace(".gif", "_on.gif");
			evt.target.src = newSrcPath;
		}
	}
}

function Out(evt) {
	try{
		if(event.srcElement.className == "rollover") {
			var obj = event.srcElement;
			var srcPath = obj.src;
			var overImg = obj.over;
			var outImg = obj.out;
			var newSrcPath = srcPath.replace(overImg, outImg);
			event.srcElement.src = newSrcPath;
		}
	}catch(e){
		if(evt.target.className == "rollover") {
			var obj = evt.target;
			var srcPath = obj.src;
			var newSrcPath = srcPath.replace("_on.gif", ".gif");
			evt.target.src = newSrcPath;
		}
	}
}

var __mouse_x	= null;
var __mouse_y	= null;
function Move(evt){
	try{
		__mouse_x	= document.body.scrollLeft + event.clientX;
		__mouse_y	= document.body.scrollTop + event.clientY;
	}catch(e){
		__mouse_x	= evt.pageX;
		__mouse_y	= evt.pageY;
	}
}

function init() {
	try{
		document.body.attachEvent("onmouseover", Over);
		document.body.attachEvent("onmouseout", Out);
		document.body.attachEvent("onmousemove", Move);
	}catch(e){
		document.onmouseover	= Over;
		document.onmouseout	= Out;
		document.onmousemove	= Move;
	}
}

function imageOver(){
	var e = event.srcElement;
	var name = e.name;
	var over = e.over;
	var out = e.out;
	var obj = eval("document.all."+name);
	for(var i=0; i<obj.length; i++){
		obj[i].src = obj[i].src.replace(obj[i].over, obj[i].out);
	}
	e.src = e.src.replace(e.out, e.over);
}

// 팝업창
function Windows_popup(ref, Rwidth, Rheight, wname)
{
	// ref(주소), Rwidth(넓이값), Rheight(높이값), wname(창이름)
	var window_left = (screen.width-Rwidth)/2;
	var window_top = (screen.height-Rheight)/2;
	window.open(ref,wname,'width='+Rwidth+',height='+Rheight+',status=yes,scrollbars=no,top='+window_top+',left='+window_left+'');
}

function chk_same(){
	if(document.check_form.same.checked==true){
		document.check_form.hang_post1.value = document.check_form.Zip_1.value;
		document.check_form.hang_post2.value = document.check_form.Zip_2.value;
		document.check_form.hang_addr1.value = document.check_form.Addr_1.value;
		document.check_form.hang_addr2.value = document.check_form.Addr_2.value;
	}else{
		document.check_form.hang_post1.value = "";
		document.check_form.hang_post2.value = "";
		document.check_form.hang_addr1.value = "";
		document.check_form.hang_addr2.value = "";
	}
}

function chk_id(no){
	f = document.check_form;

	if(f.user_id.value==''){
		alert('검색할 아이디를 입력하세요.');
		f.user_id.focus();
		return;
	}

	if(no==2)	 f.action = "userid_search2.php";
	else	f.action = "userid_search.php";
	f.target = "lovehidden";
	f.method = "post";
	f.submit();
}

// 숫자체크 함수
function number_check(id, nums)
{
	if(nums.match(/[^0-9]/)) {
		window.alert('숫자만 입력해주세요.');
		document.getElementById(id).value='';
		return;
	}
}

// 한글만 입력 가능 함수
function hangle_chk()
{
 var form = document.check_form;
 var box = form.admin_charge;
 var str = box.value;
 for(i=0; i<str.length; i++)
 {
  if(!((str.charCodeAt(i) > 0x3130 && str.charCodeAt(i) < 0x318F) || (str.charCodeAt(i) >= 0xAC00 && str.charCodeAt(i) <= 0xD7A3)))
  {
   alert("한글만 입력하세요");
   box.value = "";
   return false;
  }
  //else; // 처리
 }
}

// 삭제여부 묻는 함수
function conf_chk(str,no) {
	if(confirm(no+' 사업장을 정말 삭제하시겠습니까?')) {
		location.href(str);
	}
}
// 삭제여부 묻는 함수
function conf_event(str,no) {
	if(confirm("'"+no+"' 이벤트를 정말 삭제하시겠습니까?")) {
		location.href(str);
	}
}

// 업체정보 팝업
function pop_company(idx){
	window.open('./company_popup.php?idx='+idx,'company_pop','width=300, height=400, scrollbars=no, resizable=yes');
}

// 이벤트 등록시 당첨자 라디오 체크
function radio_chk(no){
	if(no==1){
		document.check_form.win_date.disabled = false;
		document.check_form.win_date.style.backgroundColor = '';
		document.check_form.win_text.disabled = true;
		document.check_form.win_text.value = "";
		document.check_form.win_text.style.backgroundColor = '#c2c2c2';
		document.check_form.win_bal[0].checked = true;
		document.check_form.win_bal[1].checked = false;
	}
	else if(no==2){
		document.check_form.win_text.disabled = false;
		document.check_form.win_text.style.backgroundColor = '';
		document.check_form.win_date.disabled = true;
		document.check_form.win_date.style.backgroundColor = '#c2c2c2';
		document.check_form.win_date.value = '';
		document.check_form.win_bal[0].checked = false;
		document.check_form.win_bal[1].checked = true;
	}
}

// 이미지 갯수만큼 늘렸다 줄었다
function add_file(value){
	for(i=1;i<=5;i++){
		var img = "img"+i;

		if(i<=value){
			document.getElementById("img"+i).style.display = "";
		}
		else if(i>value){
			document.getElementById("img"+i).style.display = "none";
		}
	}
}

// 우리지역 이벤트 상태 변경 'Y' -> 'N', 'N' -> 'Y'
function change_state(code, idx, page){
	location.href('event_exe.php?go=ch_openyn&code='+code+'&idx='+idx+'&page='+page);
}

// 이벤트 상태 변경 'Y' -> 'N', 'N' -> 'Y'
function change_state2(code, idx, page){
	location.href('event_exe2.php?go=ch_openyn&code='+code+'&idx='+idx+'&page='+page);
}

// 이벤트 제목 45자 제한하기 시작
function lengthCheck(size, check_form)
{
	charValue=document.check_form.subject.value;
	charSize=charValue.length;
	len=0;
	for(i=0; i<charSize; ++i)
	{
		temp=(charValue.charCodeAt(i)>128)?2:1;
		len += temp;
		if(len > size)
		{
			alert("45자 ( "+ size + "Bytes ) 이내로 작성하세요");
			document.check_form.subject.value=charValue.substr(0,i);
			document.check_form.showSize.value=(len-temp);
			return;
		}else{
			document.check_form.showSize.value=len;
		}
	}
}

// 이벤트 제목 45자 제한하기 끝

// 업체정보 수정레이어
function popmember(id){
	document.getElementById("popmember").style.display = "";
}

