/*
copyright (c)Funnypeople corp.
mman@funnypeople.co.kr
2011-02-28
*/

var tmp = new Date();
$(document).ready(function() {

//    $(document).pngFix(); 

	// 검색어 리셋
	$("#keyword").click(function() { 
		$("#old").val( $(this).val() );
		$(this).val("");
	});

	$("#keyword").bind("blur",function() { 
		if( $(this).val() == "") { $(this).val( 	$("#old").val() ); }
	});

	// 오토키업
	$(".auto_keyup").keypress(function() {
		if( $(this).val().length ==  $(this).attr("maxlength") ) {
			$(this).next().focus();		
		}
	});
	// 마지막 보더 없앰
	$("#snb li:last-child").css("border","none");


    $("select").sb();

	// 지부이동
	$("#gomap").change(function() {
		document.location.href='http://'+ $(this).val()+'.kahp.or.kr';
	});

	// 지부이동
	$("#gomap2").change(function() {
		document.location.href='http://'+ $(this).val();
	});
});

window.searchAction = function() {
	if(  $("#keyword").val().length < 2 || $("#keyword").val() == "통합검색") {
		alert('검색어는 2글자 이상 입력하셔야 합니다.');
		return false;
	}
	return true;
}

window.fnIsIETrueBody = function() {
	// 스크롤된 실제 BODY 위치 출력용
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

window.flash = function(c,d,e) {
  var flash_tag = "";
  flash_tag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
  flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,29,0" ';
  flash_tag +='width="'+c+'" height="'+d+'" >';
  flash_tag +='<param name="wmode" value="transparent">'; 
  flash_tag +='<param name="movie" value="'+e+'">';
  flash_tag +='<param name="quality" value="high">';
  flash_tag +='<embed src="'+e+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
  flash_tag +='type="application/x-shockwave-flash"  width="'+c+'" height="'+d+'" ></embed></object>'
  document.write(flash_tag);
}

window.loginAct = function() {
	// 로그인 처리
	if(  !$("#userid").val() ) {
		alert('아이디가 입력되지 않았습니다');
		$("#userid").focus()
		return false;
	}

	if(  !$("#passwd").val() ) {
		alert('비밀번호가 입력되지 않았습니다');
		$("#passwd").focus()
		return false;
	}
	
	return true;
/*
	$.ajax( {
		type	: "POST",
		url		: "https://www.kahp.or.kr/login/act.php",
		data	: "userid="+ $("#userid").val() + "&passwd=" + $("#passwd").val() + "&url=" + $("#url").val(),
		async	: true,
		success : function(data) {
			var oj = new String();
			oj = data.split("|");
			if(oj[0] == "error") {
				alert(oj[1]);
			} else {


				alert('로그인되었습니다');
				if(oj[1] ){ document.location.replace(oj[1]); }
				else { document.location.replace('/'); }
			}
		},
		error : function(data) {
			alert("로그인시스템 오류입니다.");
		}
	});
	return false;
*/
}

window.logoutAct = function() {
	// 로그아웃 처리
	$.ajax( {
		type	: "POST",
		url		: "/login/logout.php",
		data	: "tmp="+new Date(),
		async	: true,
		success : function(data) {
			var oj = new String();
			oj = data.split("|");
			alert(oj[0]);
				if(oj[1] ){ document.location.href=oj[1]; }
				else { document.location.href='/'; }
		},
		error : function(data) {
			alert("로그인시스템 오류입니다.");
		}
	});
}

window.needLogin = function() {
	// 로그인 경고창 출력
	alert('로그인이 필요한 기능입니다');
}

window.forget = function() {
	// 아이디/비밀번호 찾기
	var itemPOP = window.open("about:blank", "itemPOP", "toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,width=417,height=400,scrollbars=yes"); 
	itemPOP.location.href = "/login/forget.php"; 
	itemPOP.focus();
}

window.openW = function(obj) {
	window.open(obj.value,'','_blank');
}

window.movieplay = function(year,day,sess,host) {
	document.write('<div class="movie"><EMBED pluginspage=http://www.microsoft.com/korea/windows/windowsmedia/ src=mms://media.ilovesea.co.kr/VOD/'+year+'/'+day+'/'+sess+' width=650 height=556 type=video/x-ms-asf-plugin showpositioncontrols="0" showtracker="1" showstatusbar="1" showcontrols="1" displaybackcolor="white" autostart="0" animationatstart="1"></EMBED></div>');
}

window.zipSearch = function(where) {
	var zips=window.open('/bin/zip2.php?where='+where, 'zip', 'width=450, height=300, scrollbars=auto');
}

window.Pop_ups = function(num,width,height){	
	window.open('?pop_load=on&num='+num,'pop_'+num,'width='+width+',height='+height+',scrollbars=no');
	}
window.Pop_cookie = function(num){
	if($("#pop_cookie_chk").attr("checked") == true){
		document.location.href='?pop_cookie=on&num='+num;
	} else {
		self.close();
	}
}
function Pop_url(url){
	opener.document.location.href=url;
}

