//******************************************************************************
//*@function Enter 입력 시 함수 호출
//*@param	objId		: 이벤트가 발생할 Obejct Id
//*@param	f			: 이벤트가 발생 후 호출할  함수
//******************************************************************************
function onPressEnter(objId, f){
	$("#"+objId).keydown(function(event){
		if(event.keyCode == 13){
			event.preventDefault();
			if(f != null){	eval(f); }
		}
	});
}

/**
 * function : modal팝업창 open
 * @author bluesheep7
 * @since 2010. 08. 25
 * 
 * @param 	url		modal open할 페이지 URL
 * @param 	option		modal open되는 DIV개체의 css속성값
 * @param 	divId		modal open되는 DIV개체 ID
 * @param 	index		modal open되는 DIV개체의 zindex값
 * 
 * @return	DIV개체 Open
 */
function divModalOpen(url, option, divId, index){
	$("body").append("<div id='"+divId+"'></div>");
	$("#"+divId).load(url, option);
	$("#"+divId).css("display", "block");
	$("#"+divId).modal({containerId : divId, zindex : index});
}
/**
 * function : modal팝업창 close
 * @author bluesheep7
 * @since 2010. 08. 25
 * 
 * @param 	divId		modal open되어있는 닫힐 DIV개체 ID
 * 
 * @return	modal open되어있는 DIV개체가 닫힘
 */
function mClose(divId){
	$.modal.close();
	if(divId != null){	$("#"+divId).css("display", "none"); $("#"+divId).remove(); }
}

//******************************************************************************
//*@function 종목 검색 팝업
//******************************************************************************

function popSearch(frm){
	var wint = (screen.height-460)/2;
	var winl = (screen.width-543)/2;
	var option = "width=543,height=460,top="+wint+",left="+winl;
	
	var winOpen = window.open("", "compSearch", option);
	frm.target = "compSearch";
	frm.action = "/compinfo/popSearch.action";
	frm.method = "GET";
	frm.submit();
	winOpen.focus();
}

//******************************************************************************
//*@function 도움말 팝업
//******************************************************************************
function popHelp(){
	var wint = (screen.height-700)/2;
	var winl = (screen.width-770)/2;
	var option = "width=770,height=700,scrollbars=yes,top="+wint+",left="+winl;
	
	var winOpen = window.open("/help/help.html", "popHelp", option);
	winOpen.focus();
}

//******************************************************************************
//*@function 화면 가운데 팝업 띄우기
//******************************************************************************
function popOpen(url, width, height, opt){
	var wint = (screen.height-height)/2;
	var winl = (screen.width-width)/2;
	var option = "width="+width+",height="+height+",top="+wint+",left="+winl;
	if(opt != null) option += ","+opt;
	
	var winOpen = window.open(url, "popOpen", option);
	winOpen.focus();
}


function getLocation(no){
	switch (no){
		case "1-1" :
			location.href="/compinfo/summary/main.action";
			break;
		case "1-2" :
			location.href="/addinfo/addinfo01.action";
			break;
		case "1-3" :
			location.href="/creditinfo/credit01.action";
			break;
		default :
			location.href="/compinfo/summary/main.action";
	}
}

function insertProgress(areaId,width,height){
	var areaWidth = 0;
	var areaHeight = 0;
	if(width == null || width == 0 || width == ""){
		areaWidth =  ($('#'+areaId).width()-60)/2;
	}else{
		areaWidth =  (width-60)/2;
	}
	if(height == null || height == 0 || height == ""){
		areaHeight =  ($("#"+areaId).height()-60)/2+1;
	}else{
		areaHeight =  (height-60)/2+1;
	}
	$('#'+areaId).html("<img src='/img/img_2010/progress.gif' style='padding:"+areaHeight+"px "+areaWidth+"px;'/>");
}

function klgubnChange(gubn){
	var txt = ""
	if(gubn==1){
		txt  = "<option value=''>선택</option>";
		txt += "<option value='K'>결산</option>";
		txt += "<option value='F'>1분기</option>";
		txt += "<option value='B'>반기</option>";
		txt += "<option value='T'>3분기</option>";
		txt += "<option value='A'>전체</option>";
	}else {
		txt  = "<option value=''>선택</option>";
		txt += "<option value='F'>1분기</option>";
		txt += "<option value='X'>2분기</option>";
		txt += "<option value='Y'>3분기</option>";
		txt += "<option value='Z'>4분기</option>";
		txt += "<option value='C'>전체</option>";
	}
	
	$("#klgubn").html(txt);
}	


//20110908 유녹수 추가~
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 "";
}	

