﻿
// Change Peroid
function ChangePeroid(dateType,ctlBegin, ctlEnd)
{

    var todayDate = new Date();
    
    var BeginDate;
    var EndDate;
    switch(dateType)
    {
        // Today
        case 'T' : 
       {
           BeginDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) BeginDate += '0' + (todayDate.getMonth()+1)+'-';   else BeginDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         BeginDate += '0'  + (todayDate.getDate());             else BeginDate += (todayDate.getDate());
           
            EndDate = BeginDate;
            break;
       } 
       // Week
        case 'W' : 
       {
           /*End Date*/
           EndDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) EndDate += '0' + (todayDate.getMonth()+1)+'-';   else EndDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         EndDate += '0'  + (todayDate.getDate());             else EndDate += (todayDate.getDate());
           
           /* Begin Date*/
           todayDate.setDate(todayDate.getDate()-6);
           BeginDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) BeginDate += '0' + (todayDate.getMonth()+1)+'-';   else BeginDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         BeginDate += '0'  + (todayDate.getDate());             else BeginDate += (todayDate.getDate());
            break;
       } 
          // Month
        case 'M' : 
       {
           /*End Date*/
           EndDate =  todayDate.getFullYear() +'-';           
           /* Month */ if((todayDate.getMonth()+1) < 10) EndDate += '0' + (todayDate.getMonth()+1)+'-';   else EndDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         EndDate += '0'  + (todayDate.getDate());             else EndDate += (todayDate.getDate());
           
           /* Begin Date*/
           todayDate.setMonth(todayDate.getMonth()-1);
           todayDate.setDate(todayDate.getDate()+1);
           BeginDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) BeginDate += '0' + (todayDate.getMonth()+1)+'-';   else BeginDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         BeginDate += '0'  + (todayDate.getDate());             else BeginDate += (todayDate.getDate());
            break;
       } 
            // Year
        case 'Y' : 
       {
           /*End Date*/
           EndDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) EndDate += '0' + (todayDate.getMonth()+1)+'-';   else EndDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         EndDate += '0'  + (todayDate.getDate());             else EndDate += (todayDate.getDate());
           
           /* Begin Date*/
           todayDate.setFullYear(todayDate.getFullYear()-1);
           todayDate.setDate(todayDate.getDate()+1);
           BeginDate =  todayDate.getFullYear() +'-';
           /* Month */ if((todayDate.getMonth()+1) < 10) BeginDate += '0' + (todayDate.getMonth()+1)+'-';   else BeginDate += (todayDate.getMonth()+1)+'-';
           /* Day    */ if(todayDate.getDate() < 10)         BeginDate += '0'  + (todayDate.getDate());             else BeginDate += (todayDate.getDate());
            break;
       } 
    }
    document.all[ctlBegin].value = BeginDate;
    document.all[ctlEnd].value = EndDate;
}




//에러 메시지 출력
function ErrorMessageCall(errMsg)
{
	alert(errMsg);
}

// 새창 띄우기
function openFrame(url,title,width,height)
{
	//window.open(url,title,'width="+width+",height="+height+",scrollbars=yes');
	var vtop =0;
	var vleft =0;
	if(width <=600)
		vleft = 200;
	else 
		vleft = 10;
	
	if(height <=600)
		vtop = 200;
	else
		vtop = 10;
	var openOpt = "width="+width+",height="+height+",left="+vleft+", top="+vtop+", toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes";
	window.open(url,title,openOpt);
}

function openFrame2(url,title,width,height)
{
	//window.open(url,title,'width="+width+",height="+height+",scrollbars=yes');
	var vtop =0;
	var vleft =0;
	if(width <=600)
		vleft = 200;
	else 
		vleft = 10;
	
	if(height <=600)
		vtop = 200;
	else
		vtop = 10;
	var openOpt = "width="+width+",height="+height+",left="+vleft+", top="+vtop+", toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes";
	window.open(url,title,openOpt);
}

function openFrameNoScroll(url,title,width,height)
{
	//window.open(url,title,'width="+width+",height="+height+",scrollbars=yes');
	var vtop =0;
	var vleft =0;
	if(width <=600)
		vleft = 200;
	else 
		vleft = 10;
	
	if(height <=600)
		vtop = 200;
	else
		vtop = 10;
	var openOpt = "width="+width+",height="+height+",left="+vleft+", top="+vtop+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no ";
	window.open(url,title,openOpt);
}

function openFrameNoScroll(url,title,width,height,top,left)
{
	//window.open(url,title,'width="+width+",height="+height+",scrollbars=yes');

	var openOpt = "width="+width+",height="+height+",left="+left+", top="+top+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no ";
	window.open(url,title,openOpt);
}

// 도움말 띄우기
function showHelpDesk(url)
{
	var openOpt = "width=800px,height=600px,left=200, top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no";
	window.open(url,'',openOpt);
}

function showHelp(func, words)
{
	var url = "../../help/front/helpDesk.aspx?fun="+func+"&words="+words;
	showHelpDesk(url);
}

// 모달리스로 창 띄우기
function openModelessFrame(url,arg,width,height)
{
	 window.showModelessDialog(url,arg,'dialogWidth:'+width+'; dialogHeight:'+height+'; scroll:no; help:no; status:no; resizable:no; center:yes;');
}


//아이디 중복 검사
function check_id(userid)
{
	
	window.open("../Menu/ChkUserID.aspx?UserID="+userid,"","width=300, height=200, scrollbars=no, toolbar=no, resize=no");
	
}

//부서 선택창 띄우기
function RequestDept()
{
	window.open("UserMgmt_Dept.aspx","","width=200 , height=160, toolbar=no, resize=no");
}
//부서 선택 결과값 받기
function ReplyDept(deptname,deptcode)
{
	//alert("==="+deptcode);
	window.opener.form1.txtDept.value = deptname;
	window.opener.form1.txtDeptCode.value = deptcode;
	window.close();
}

//Protocol List받기
function ReplyControl(ctlText,ctlValue,rtnText,rtnValue)
{
	//alert("==="+rtnText+"\n"+rtnValue);
	window.opener.Form1.all[ctlText].value ='';
	window.opener.Form1.all[ctlValue].value = '';
	window.opener.Form1.all[ctlText].value = rtnText;
	
	window.opener.Form1.all[ctlValue].value = rtnValue;
	window.close();
}

// Left Space trim
function ltrim(para) 
{
	while(para.substring(0,1) == ' ') 
	{
		para = para.substring(1, para.length);
	}
	return para;
}

// Right Space trim
function rtrim(para) 
{
	while(para.substring(para.length-1,1) == ' ') 
	{
		para = para.substring(0, para.length-1);
	}
	return para;
}

// String Replace
function replaceString(value, from, to) 
{
	var returnValue = "";
	var splitArray = value.split(from);

	for(i = 0, j = splitArray.length; i < j; i++)
	{
		if((i + 1) == j)
		{
			returnValue += splitArray[i];
		}
		else
		{
			returnValue += splitArray[i]+to;
		}
	}

	return returnValue;
}

// String trim
function trim(para) 
{
	return rtrim(ltrim(para));
}

//달력 open
function openDateCal(dateCat,path)
{

	var dateform = null;
	document.Form1.hiddenOpenType.value = dateCat;

		// 달력이 뜨는 좌표 계산	
	
	x = screenLeft;
	y = screenTop;
	//alert(x);
	//alert(dateCat);
	var xpos=x;
	var ypos=y;
	
	if(dateCat == "ANALYSIS")
	{
		xpos = x+205;
		ypos = y+150;	
	}
	else if (dateCat == "ANALYSISEND")
	{
			xpos = x+434;
			ypos = y+150;	
	}
	else
	{
			xpos = x;
			ypos = y;	
	}
	
		
	var caldate = window.open(path+"common/ModalDateCalendar.html","caldate","scrollbars=no,resizable=no,status=no,Width=188,Height=252,left="+xpos+",top="+ypos+"");
	caldate.focus();
}

function KeyEvent()
{
	if(event.keyCode == 13)
	{
		return false;
	}
}	


// s : swf위치 w : width, h : height, m : wmode -> 필요없을 경우 '' 
function flash_view(s,w,h,m){
		var d = 'adf';
		var t = m =='' ? 'opaque' : m;
        var flash =  "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width="+w+" height="+h+" id="+d+"><param name=wmode value="+t+" /><param name=movie value="+s+" /><param name=quality value=high /><param name=allowScriptAccess value=sameDomain><embed src="+s+" quality=high allowScriptAccess=sameDomain wmode="+t+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+w+" height="+h+"></embed></object>";
		document.write(flash);
}


function openTMSServiceOrder(msgid)
{
    var openOpt = "dialogWidth=420px;dialogHeight=380px;dialogTop=250px;dialogLeft=250px;center=no;help=no;resizable=no;scroll=no;status:no";
    var rtn = window.showModalDialog('/WEB/CNM/Common/MessagePop.aspx?msgid='+msgid,window,openOpt);
}