
//ÇÃ·ÎÆÃ ¹è³Ê -- ½ÃÀÛ
var pdivMenu					
var pdocumentbody				
var pfirstscrollTop				

function CheckUIElements(){

	var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

	yMenuFrom   = parseInt (pdivMenu.style.top, 10);
	yMenuTo     = pdocumentbody.scrollTop + pfirstscrollTop;

	timeoutNextCheck = 500;

	if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom ) {
			setTimeout ("CheckUIElements()", timeoutNextCheck);
			return;
	}

	if ( yButtonFrom != yButtonTo ) {
			yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
			if ( yButtonTo < yButtonFrom )
					yOffset = -yOffset;

			timeoutNextCheck = 10;
	}
	if ( yMenuFrom != yMenuTo ) {
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
			if ( yMenuTo < yMenuFrom )
					yOffset = -yOffset;
			
			if (parseInt (pdivMenu.style.top, 10) + yOffset > 110) {
				pdivMenu.style.top = parseInt (pdivMenu.style.top, 10) + yOffset;
			}
			timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}
function OnLoad(divMenu, documentbody, firstscrollTop)
{
	pdivMenu = divMenu;
	pdocumentbody = documentbody;
	pfirstscrollTop = firstscrollTop;
	
	var y;
	if ( top.frames.length )
	
	//pdivMenu.style.top = pdocumentbody.scrollTop + 120;
	pdivMenu.style.visibility = "visible";
	CheckUIElements();
	return true;
}
//ÇÃ·ÎÆÃ ¹è³Ê -- ³¡

//Äü¸Þ´º ÀÌ¹ÌÁö ¹Ù²Ù±â
function CS_ImageChange_QuickMenu(obj, paimg1) {
	obj.src='../images/'+ paimg1 ;
	//obj.src='images/'+ paimg1 ;
}

//·Î±×ÀÎÃ¼Å©
function CS_PleaseLogin() {
	alert('·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
}
			
//µµ¿ò¸» : ¸ÞÀÎ¿¡¼­ ÄÝ
function CS_OpenHelp(OpenNodeID) {
	//window.open("Help/Help.aspx?paNodeID="+OpenNodeID,"Help","toolbar=no,status=no,titlebar=no,directories=yes,dependent=yes,resizable=yes,width=832,height=580,top=94,left=178");
	window.open("Help/Help.aspx?paNodeID="+OpenNodeID,"Help","toolbar=no,status=no,titlebar=no,resizable=yes,width=832,height=580,top=94,left=178");
}

//³¯Â¥ Ã¼Å© ÇÔ¼ö
function ValidDate(datein){
	var indate=datein;
	if (indate.indexOf("-")!=-1){
		var sdate = indate.split("-");
	}
	else {
		var sdate = indate.split("/");
	}
	var tmpdatein = sdate[1]+"/"+sdate[2]+"/"+sdate[0];
	var chkDate=new Date(Date.parse(tmpdatein));
	var cmpDate=(chkDate.getFullYear())+"/"+ (chkDate.getMonth()+1)+"/"+(chkDate.getDate());
	var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]));
	if (indate2!=cmpDate){
		return false;
	}
	else {
		if (cmpDate=="NaN/NaN/NaN"){
			return false;
		}
		else {
			return true;
		}	
	}
}

function fn_isKorean(chk_str) {			//ÇÑ±ÛÀÌ¸é TRUE·Î ¸®ÅÏÇÑ´Ù.
	for (i=0; i< chk_str.length; i++) {
		if ((chk_str.charCodeAt(i) > 0x3130 && chk_str.charCodeAt(i) < 0x318F) || (chk_str.charCodeAt(i) >= 0xAC00 && chk_str.charCodeAt(i) <= 0xD7A3)) {
			return true;
		}
	}
	return false;
}

//ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
function ID_Check(myObj){
	 myStr = myObj.value	
     str1 = myStr.substring(1,6)
     str2 = myStr.substring(7,7)
     var li_lastid,li_mod,li_minus,li_last;
     var value0,value1,value2,value3,value4,value5,value6;
     var value7,value8,value9,value10,value11,value12;

     if (IsInteger(str1) &&  IsInteger(str2)) {
          li_lastid    = parseFloat(str2.substring(6,7));
          value0  = parseFloat(str1.substring(0,1))  * 2;
          value1  = parseFloat(str1.substring(1,2))  * 3;
          value2  = parseFloat(str1.substring(2,3))  * 4;
          value3  = parseFloat(str1.substring(3,4))  * 5;
          value4  = parseFloat(str1.substring(4,5))  * 6;
          value5  = parseFloat(str1.substring(5,6))  * 7;
          value6  = parseFloat(str2.substring(0,1))  * 8;
          value7  = parseFloat(str2.substring(1,2))  * 9;
          value8  = parseFloat(str2.substring(2,3))  * 2;
          value9  = parseFloat(str2.substring(3,4))  * 3;
          value10 = parseFloat(str2.substring(4,5))  * 4;
          value11 = parseFloat(str2.substring(5,6))  * 5;
          value12 = 0;
          
          value12 = value0+value1+value2+value3+value4+value5+value6+value7+value8+value9+value10+value11+value12 ;
          
          li_mod = value12 %11;
          li_minus = 11 - li_mod;
          li_last = li_minus % 10;
          if (li_last != li_lastid)
          {
               myObj.select();
               myObj.focus();
               return false;
          } 
          else
          {
               return true;
          }
     } 
     else
     {
          myObj.select();
          myObj.focus();
     }
     return false;
} 

function RemoveStr(cString,cCondition) {
	var ii;
	var myReturn = "";
	
	if (cString.length <= 0) {
		return myReturn;
	}
	
	for (ii=1;cString.legnth;ii++) {
		if (substring(cString,ii,1) != cCondition) {
			myReturn = myReturn & substring(cString,ii,1);
		}
		
	}	
	return myReturn;
}

function TelNoReturn(myTelNo){
	//»ç¾÷ÀÚµî·Ï¹øÈ£¿Í ÁÖ¹Î¹øÈ£ Ã¼Å©(IdÀÇ Length°¡ 12ÀÚ¸®ÀÌ¸é »ç¾÷ÀÚ¹øÈ£, 14ÀÚ¸®ÀÌ¸é ÁÖ¹Î¹øÈ£)
	var TNo = myTelNo;
	var TNo1;
	var TNo2;
	var TelNo = ["02","032","042","051","052","053","062","064","031","033", "041","043","054","055","061","063","011","016","017","018","019","010","080","0505"];
	             
	var myReturn = ""
	
	for (ii=0;23;ii++) {
		if (TNo.substring(TelNo(ii).length) == TelNo(ii)) {
			TNo1 = TelNo(ii);
			TNo2 = TNo.substring(TelNo(ii).length + 1, TNo.length);
		}
	}
	
	if (TNo2.length == 7) {
		if (TNo1 != "") {
			myReturn = TNo1;
		}
		myReturn = myReturn & TNo2.substring(1,3) & "-" & TNo2.substring(4,7);
	}
	else if (TNo2.length == 8) {
		if (TNo1 != "") {
			myReturn = TNo1;
		}
		myReturn = myReturn & TNo2.substring(1,4) & "-" & TNo2.substring(5,8);
	}
	else {
		myReturn = RNo;
	}
	return myReturn;
}

//Grid Å¬¸®¾î
function cs_WGridClear(objGrid) {
	var grid = igtbl_getGridById(objGrid);
	var rows = grid.Rows;
	
	for(var i=0; i<rows.length; i++){
		var row = rows.getRow(i);					
		igtbl_selectRow(grid,row,true,true);		
		//row.deleteRow(grid, row);					
		//i--;
	}
	igtbl_deleteSelRows(objGrid); 
}

//server ÄÁÆ®·Ñ·Î Æ÷Ä¿½ºÃ³¸®	
function SetNextFocus(objNext) {
	if (window.Form1.all[objNext].disabled ==false) {					
		if (window.Form1.all[objNext].type == "text") {
			window.Form1.all[objNext].select();
		}
		window.Form1.all[objNext].focus();
	}
} 

//netadvantage ÄÁÆ®·Ñ·Î Æ÷Ä¿½ºÃ³¸®
function WebEditSetNextFocus(objNext) {
	var WMEditor = igedit_getById(objNext);
	WMEditor.focus();
}

//Display Label Clear
function ClearLable(objDisp) {
	window.Form1.all[objDisp].value  ="";
}

//Display Label Clear With ID
function ClearLableID(objDisp,objID) {
	window.Form1.all[objDisp].value  ="";
	window.Form1.all[objID].value  ="";
}	

//server ÄÁÆ®·Ñ·Î Æ÷Ä¿½ºÃ³¸®	
function SetNextFocus_Modal(objNext) {
	if (document.all[objNext].disabled ==false) {					
		if (document.all[objNext].type == "text") {
			document.all[objNext].select();
		}
		document.all[objNext].focus();
	}
} 

//netadvantage ÄÁÆ®·Ñ·Î Æ÷Ä¿½ºÃ³¸®
function WebEditSetNextFocus_Modal(objNext) {
	var WMEditor = igedit_getById(objNext);
	WMEditor.focus();
}

//Display Label Clear
function ClearLable_Modal(objDisp) {
	document.all[objDisp].value  ="";
}

//Display Label Clear With ID
function ClearLableID_Modal(objDisp,objID) {
	document.all[objDisp].value  ="";
	document.all[objID].value  ="";
}	

// Number Format ¼³Á¤
function NFormat(nNumber) {	
	var ii;
	var rtnFormat ="";
	
	var nVal = nNumber.replace(",","");	
	for (ii=1;ii<=nNumber.length;ii++) {
		nVal = nVal.replace(",","");
	}
	
	var valLen = nVal.length;	
	
	if (valLen <=0 ) {
		return rtnFormat;
	}	
	var startLen = valLen % 3;	
	if (startLen==0) { 
		startLen = 3;
	}		
	rtnFormat=nVal.substr(0,startLen);	
	for (ii=startLen; ii+3<=valLen; ii=ii+3) {
		rtnFormat = rtnFormat +","+ nVal.substr(ii,3);		
	}	
	return rtnFormat;
}

function CS_PanelNoneDisplay(obj) {
	if (window.Form1.all[obj].style.display=="") {
		window.Form1.all[obj].style.display="none";		
	}
}


//·ÎµùÃ¢À» ¿©´Â function
//¿¢¼¿ÆÄÀÏ - ¾îµå¹Î : È¸¿øÁ¶È¸ ¿¡¼­ »ç¿ë
function OpenLoadingPage(){
	win1=window.open("../ADPopup/loading.htm","loading","toolbar=no,status=no, titlebar=no,directories=no,scrollbars=no,menubar=no, resizable=no, width=330,height=120 ,top=180,left=350");		            
}

//·ÎµùÃ¢À» ´Ý´Â funciton
function CloseLoadingPage(){
	win1.close();
}
	
//----µðÀÚÀÎÂÊ¿¡¼­ ÁØ JS ½ÃÀÛ
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);	

//----µðÀÚÀÎÂÊ¿¡¼­ ÁØ JS ³¡

// Á¦Ç°¼Ò°³ Áß »çÁøº¸±â

function photodisplay_1() {
	photo1.style.display = 'block';
	photo2.style.display = 'none';
	photo3.style.display = 'none';

	tab1.style.display = 'block';
	tab2.style.display = 'none';
	tab3.style.display = 'none';
}

function photodisplay_2() {
	photo1.style.display = 'none';
	photo2.style.display = 'block';
	photo3.style.display = 'none';
	
	tab1.style.display = 'none';
	tab2.style.display = 'block';
	tab3.style.display = 'none';
}

function photodisplay_3() {
	photo1.style.display = 'none';
	photo2.style.display = 'none';
	photo3.style.display = 'block';
	
	tab1.style.display = 'none';
	tab2.style.display = 'none';
	tab3.style.display = 'block';
}

// Á¦Ç°¼Ò°³ Áß ³»¿ëº¸±â

function detaildisplay_1() {
	detail1.style.display = 'block';
	detail2.style.display = 'none';
	detail3.style.display = 'none';
	detail4.style.display = 'none';
	detail5.style.display = 'none';

	body1.style.display = 'block';
	body2.style.display = 'none';
	body3.style.display = 'none';
	body4.style.display = 'none';
	body5.style.display = 'none';
}

function detaildisplay_2() {
	detail1.style.display = 'none';
	detail2.style.display = 'block';
	detail3.style.display = 'none';
	detail4.style.display = 'none';
	detail5.style.display = 'none';

	body1.style.display = 'none';
	body2.style.display = 'block';
	body3.style.display = 'none';
	body4.style.display = 'none';
	body5.style.display = 'none';
}

function detaildisplay_3() {
	detail1.style.display = 'none';
	detail2.style.display = 'none';
	detail3.style.display = 'block';
	detail4.style.display = 'none';
	detail5.style.display = 'none';

	body1.style.display = 'none';
	body2.style.display = 'none';
	body3.style.display = 'block';
	body4.style.display = 'none';
	body5.style.display = 'none';
}

function detaildisplay_4() {
	detail1.style.display = 'none';
	detail2.style.display = 'none';
	detail3.style.display = 'none';
	detail4.style.display = 'block';
	detail5.style.display = 'none';

	body1.style.display = 'none';
	body2.style.display = 'none';
	body3.style.display = 'none';
	body4.style.display = 'block';
	body5.style.display = 'none';
}

function detaildisplay_5() {
	detail1.style.display = 'none';
	detail2.style.display = 'none';
	detail3.style.display = 'none';
	detail4.style.display = 'none';
	detail5.style.display = 'block';

	body1.style.display = 'none';
	body2.style.display = 'none';
	body3.style.display = 'none';
	body4.style.display = 'none';
	body5.style.display = 'block';
}

//-------------------
// Set Focus
//-------------------
// Set Focus at Server Control
function SetFocus(Gubn, objNext) {
	if (Gubn=="1") {
		if (window.Form1.all[objNext].disabled ==false) {					
			if (window.Form1.all[objNext].type == "text") {
				window.Form1.all[objNext].select();
			}
			window.Form1.all[objNext].focus();
		}
	} else if (Gubn=="2") {
		var WMEditor = igedit_getById(objNext);
		WMEditor.focus();
	}
} 
// Set Focus at Server Control in Modal
function SetFocus_Modal(Gubn, objNext) {
	if (Gubn=="1") {
		if (document.all[objNext].disabled ==false) {					
			if (document.all[objNext].type == "text") {
				document.all[objNext].select();
			}
			document.all[objNext].focus();
		}
	} else if (Gubn=="2") {
		var WMEditor = igedit_getById(objNext);
		WMEditor.focus();
	}
} 

//-------------------
// Popup : ÆË¾÷±¸µ¿ & ÄÚµå¿Í ÀÌ¸§ ¼¼ÆÃÇÏ°í ´ÙÀ½Æ÷Ä¿½º·Î Ä¿¼­ÀÌµ¿
//-------------------
// PopUp
function PopUp(objCD,objNM,objID,objNext,objNextKind,paPage) {
	var aParam ;				
	var	aResult	= new Array();
	var PPage = paPage;
	
	var sPos = "dialogWidth:415px;dialogHeight:425px;dialogLeft:window.screen.width/2; dialogtop:window.screen.height/2;status:no"
	aResult	= window.showModalDialog(PPage,aParam,sPos);
	
	if (aResult != null) {
		sbSetCode(objCD, objNM,objID,objNext,aResult[0],aResult[1],aResult[2],objNextKind);
	}
	else {
		window.Form1.all[objNM].value = "";
		window.Form1.all[objCD].select();
		window.Form1.all[objCD].focus();
	} 
}
// ZipPopUp
function ZipPopUp(objCD,objNM,objID,objNext,objNextKind,paPage) {
	var aParam ;				
	var	aResult	= new Array();
	var PPage = paPage;
	
	var sPos = "dialogWidth:480px;dialogHeight:475px;dialogLeft:window.screen.width/2; dialogtop:window.screen.height/2;status:no"
	aResult	= window.showModalDialog(PPage,aParam,sPos);
	
	if (aResult != null) {
		sbSetCode(objCD, objNM,objID,objNext,aResult[0],aResult[1],aResult[2],objNextKind);
	}
	else {
		window.Form1.all[objNM].value = "";
		window.Form1.all[objCD].select();
		window.Form1.all[objCD].focus();
	} 
}		
// ItemPopUp
function ItemPopUp(objCD,objNM,objID,objNext,objNextKind,paPage) {
	var aParam ;				
	var	aResult	= new Array();
	var PPage = paPage;
	
	var sPos = "dialogWidth:480px;dialogHeight:475px;dialogLeft:window.screen.width/2; dialogtop:window.screen.height/2;status:no"
	aResult	= window.showModalDialog(PPage,aParam,sPos);
	
	if (aResult != null) {
		sbSetCode(objCD, objNM,objID,objNext,aResult[0],aResult[1],aResult[2],objNextKind);
	}
	else {
		window.Form1.all[objNM].value = "";
		window.Form1.all[objCD].select();
		window.Form1.all[objCD].focus();
	} 
}	
//¸®ÅÏ°ª¼³Á¤
function sbSetCode(objCD,objNM,objID,objNext,pdate1,pdate2,pdate3,objNextKind) {
	window.Form1.all[objCD].value = pdate1;
	window.Form1.all[objNM].value = pdate2;
	if (objID != null) {						
		window.Form1.all[objID].value = pdate3;
	}
	SetFocus(objNextKind, objNext);
}