var pop_up = window;
function windowOpen(windowWidth,windowHeight,src,titles,scrollbars,resizables)
{
  screenWidth = screen.availWidth;
  screenHeight= screen.availHeight;
  x=(screenWidth-windowWidth)/2;
  y=(screenHeight-windowHeight)/2;
  //pop_up = window.open(src, titles, "top='+y+', left='+x+', width='+windowWidth+', height='+windowHeight+', titlebar=no, menubar=no, location=no, status=no, toolbar=no, resizable='+resizable+', scrollbars='+scrollbars");
  description = "top="+y+", left="+x+", width="+windowWidth+"px, height="+windowHeight+"px, titlebar=no, menubar=no, location=no, status=no, toolbar=no, resizable="+resizables+", scrollbars="+scrollbars
  pop_up = window.open(src,titles,description);
    
  pop_up.focus();
}

function isdigit(v) {
    var filter = /[^0-9]/

    if (filter.test(v) == true) { return false; }
    return true;
}

function isdigit2nd(element) 
{
  var v = element.value;
  while (v.indexOf(",")>0)
    v = v.replace(",","");

  var filter = /[^0-9]/
  if (filter.test(v) == true) 
  { 
    alert('숫자만 입력 가능합니다.');
    element.value="";
    element.focus();
  }
  else
  return true;
}

function insertComma(element)
{
  var orignalString = element.value;
  var anotherString = "";
  
  while (orignalString.substring(0,1) == "0" && orignalString.length > 1) orignalString = orignalString.substring(1,orignalString.length);
  while (orignalString.indexOf(",")>0)         orignalString = orignalString.replace(",","");
 
  var remakeString = "";
  var length = orignalString.length;
  var j=0;
  for(var i = length;i>0;i--)
  {
    if (j % 3 == 0 && j !=0)
      remakeString = orignalString.substring(i-1,i) + "," + remakeString;
    else
      remakeString = orignalString.substring(i-1,i) + remakeString;
    j=j+1;
  }
  
  element.value = remakeString;
}

function playflash(file,width,height,bgcolor,quality,name)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'" id="'+name+'">');  //플래쉬플레이어 버전이 이전버전일경우 버전 8을 변경
  document.write('<param name="movie" value="'+file+'" />');
  document.write('<param name="quality" value="'+quality+'" />');
  
  //투명플래쉬가 아닐경우 이 라인을 삭제/////////////////////////
  document.write('<param name="wmode" value="transparent" />');  
  /////////////////////////////////////////////////////////////////
   
  document.write('<param name="bgcolor" value="'+bgcolor+'" />');
  document.write('<embed src="'+file+'" quality="'+quality+'" wmode="transparent" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  document.write('</object>')
}

function playflex(file,width,height,bgcolor,quality,name,userID,imageCode,deviceCode,siteURL)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" width="'+width+'" height="'+height+'" id="'+name+'">');  //플래쉬플레이어 버전이 이전버전일경우 버전 8을 변경
  document.write('<param name="movie" value="'+file+'" />');
  document.write('<param name="quality" value="'+quality+'" />');
  //document.write('<param name="flashVars" value="userID='+userID+'&deviceID='+deviceCode+'&imageID='+imageCode+'" />');
  document.write('<param name="flashVars" value="userID='+userID+'&deviceID='+deviceCode+'&imageID='+imageCode+'&siteURL='+siteURL+'" />');
  
  //투명플래쉬가 아닐경우 이 라인을 삭제/////////////////////////
  document.write('<param name="wmode" value="transparent" />');  
  /////////////////////////////////////////////////////////////////
   
  document.write('<param name="bgcolor" value="'+bgcolor+'" />');
  document.write('<param name="allowScriptAccess" value="sameDomain" />');
    
  document.write('<embed src="'+file+'" quality="'+quality+'" wmode="transparent" bgcolor="'+bgcolor+'" play="true" loop="false" width="'+width+'" height="'+height+'" name="'+name+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  document.write('</object>')
}

function playmedia(Filename,width,height,name,AutoStart,AutoSize,ClickToPlay,EnableFullScreenControls,EnableTracker,ShowControls,ShowPositionControls,ShowDisplay,ShowTracker,SendKeyboardEvents,SendMouseClickEvents,SendMouseMoveEvents,Volume)
{
  document.write('<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ');
  document.write('id="'+name+'" border="0" width="'+width+'" height='+height+'>');
  document.write('<param name="AutoStart" value="'+AutoStart+'">');
  document.write('<param name="AutoSize" value="'+AutoSize+'">');
  document.write('<param name="ClickToPlay" value="'+ClickToPlay+'">');
  document.write('<param name="EnableFullScreenControls" value="'+EnableFullScreenControls+'">');
  document.write('<param name="EnableTracker" value="'+EnableTracker+'">');
  document.write('<param name="Filename" value="'+Filename+'">');
  document.write('<param name="ShowControls" value="'+ShowControls+'">');
  document.write('<param name="ShowPositionControls" value="'+ShowPositionControls+'">');
  document.write('<param name="ShowDisplay" value="'+ShowDisplay+'">');
  document.write('<param name="ShowTracker" value="'+ShowTracker+'">');
  document.write('<param name="SendKeyboardEvents" value="'+SendKeyboardEvents+'">');
  document.write('<param name="SendMouseClickEvents" value="'+SendMouseClickEvents+'">');
  document.write('<param name="SendMouseMoveEvents" value="'+SendMouseMoveEvents+'">');
  document.write('<param name="Volume" value="'+Volume+'">');
  document.write('<param name="loop" value="true">');
  
  document.write('</object>');
}

function checkBoxControl(elementName,index)
{
  if (document.all[elementName][index].checked==true) 
    document.all[elementName][index].checked=false;
  else 
    document.all[elementName][index].checked=true;
}

function checkBoxControlSingle(elementName)
{
  if (document.all[elementName].checked==true) 
    document.all[elementName].checked=false;
  else
    document.all[elementName].checked=true;
}

var isDisplayCalc = true;

function ShowDialogCalc(element,viewHour)
{
  var temp = element.value
  var rvalue = showModalDialog('/common/calc.asp?selectdate='+temp+'&viewHour='+viewHour, 100, 'resizable: no; help: no; status: no; scroll: no; dialogWidth:226px; dialogHeight:280px');
  if (rvalue != null)
  {
    if (viewHour)
      element.value = rvalue[0] + " " + rvalue[1];
    else
      element.value = rvalue[0];
    
    return true;
  }
  else
    return false;
}

function clearDate(element)
{
  element.value = "";
}

function ShowDialogCalc_form(element,viewHour)
{
  if (isDisplayCalc)
  {
    var temp = element.value
    var rvalue = showModalDialog('/common/calc.asp?selectdate='+temp+'&viewHour='+viewHour, 100, 'resizable: no; help: no; status: no; scroll: no; dialogWidth:226px; dialogHeight:350px');
    if (rvalue != null)
    {
      if (viewHour)
        element.value = rvalue[0] + " " + rvalue[1];
      else
        element.value = rvalue[0];
      
      return true;
    }
    else
      return false;
  }
}

function ShowDialogCalcDetail(element)
{
  var temp = element.value;
  var nowDateTime = element.nowDateTime;
  var rvalue = showModalDialog('/common/calc.asp?selectdate='+temp+'&viewTime=true&nowAllowPresent=true&nowDateTime='+nowDateTime, 100, 'resizable: no; help: no; status: no; scroll: no; dialogWidth:226px; dialogHeight:350px');
  if (rvalue != null)
  {
    element.value = rvalue[0] + " " + rvalue[1];
    return true;
  }
  else
    return false;
}

function ShowDialogCalcView30Min(element,nowAllowPresent)
{
  var temp = element.value;
  var nowDateTime = element.nowDateTime;
  var rvalue = showModalDialog('/common/calc.asp?selectdate='+temp+'&view30Min=true&nowAllowPresent='+nowAllowPresent+'&nowDateTime='+nowDateTime, 100, 'resizable: no; help: no; status: no; scroll: no; dialogWidth:226px; dialogHeight:350px');
  if (rvalue != null)
  {
    element.value = rvalue[0] + " " + rvalue[1];
    return true;
  }
  else
    return false;
}



function playFlash2(file,name)
{
  try
  {
  
  
  
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" id="'+name+'">');  //플래쉬플레이어 버전이 이전버전일경우 버전 8을 변경
  document.write('<param name="movie" value="'+file+'" />');
  document.write('<param name="quality" value="high" />');
  
  //투명플래쉬가 아닐경우 이 라인을 삭제/////////////////////////
  document.write('<param name="wmode" value="transparent" />');  
  /////////////////////////////////////////////////////////////////
   
  document.write('<param name="bgcolor" value="white" />');
  document.write('<embed src="'+file+'" quality="high" wmode="transparent" bgcolor="white" name="'+name+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  document.write('</object>')
  }
  catch(e)
  {}
}

function playMedia2(file,name)
{
  try
  {
  document.write('<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ');
  document.write('id="'+name+'" border="0">');
  document.write('<param name="AutoStart" value="1">');
  document.write('<param name="AutoSize" value="0">');
  document.write('<param name="ClickToPlay" value="-1">');
  document.write('<param name="EnableFullScreenControls" value="-1">');
  document.write('<param name="EnableTracker" value="1">');
  document.write('<param name="Filename" value="'+file+'">');
  document.write('<param name="ShowControls" value="1">');
  document.write('<param name="ShowPositionControls" value="1">');
  document.write('<param name="ShowDisplay" value="0">');
  document.write('<param name="ShowTracker" value="1">');
  document.write('<param name="SendKeyboardEvents" value="-1">');
  document.write('<param name="SendMouseClickEvents" value="-1">');
  document.write('<param name="SendMouseMoveEvents" value="-1">');
  document.write('<param name="Volume" value="-320">');
  document.write('</object>');
  }
  catch(e)
  {}
}

//같은 프레임을 쓸때
function changeTab(element,noCookie)
{
  if (element.nowState == "down")
  {
    imgURL = element.id.substring(3,element.id.length);
    element.nowState = "up";
    document.all[element.otherGroup].nowState = "down";

    element.src = "/images/"+imgURL+"_"+element.nowState+".jpg";
    document.all[element.otherGroup].src = "/images/"+element.otherGroup.substring(3,element.otherGroup.length)+"_"+document.all[element.otherGroup].nowState+".jpg";
    
    document.all[element.frameName].src = "/blank.asp";
    document.all[element.frameName].src = element.frameSrc+element.id;
    
    if (noCookie)
    {
      document.all.fieldName.value  = "menuValue";
      document.all.fieldValue.value = element.id;
      document.CookieForm.submit();
    }
  }
}

//다른 Div를 쓸때
function changeTab2(element, noCookie)
{
  if (element.nowState == "down")
  {
    imgURL = element.id.substring(3,element.id.length);
    element.nowState = "up";
    document.all[element.otherGroup].nowState = "down";

    element.src = "/images/"+imgURL+"_"+element.nowState+".jpg";
    document.all[element.otherGroup].src = "/images/"+element.otherGroup.substring(3,element.otherGroup.length)+"_"+document.all[element.otherGroup].nowState+".jpg";

    document.all[element.otherTarget].style.display = "none";
    document.all[element.targetDiv].style.display   = "";
    
    if (noCookie)
    {
      document.all.fieldName.value  = element.fieldName;
      document.all.fieldValue.value = element.id;
      document.CookieForm.submit();
    }
  }
}

function dellist(from,to) 
{
//	var from = document.all.employee_list;
//	var to   = document.all.group_list;
	movelist(to, from, "d");
}

function addlist(to,from) 
{
//	var from = document.all.group_list;
//	var to   = document.all.employee_list;
	movelist(to, from, "a");
}

function existCheck(values, targetList)
{
  var isExists = false;
  
  
  for (j = 1 ; j < targetList.length; j++)
  {
    var targetText = targetList.options[j].text;
    
    if (targetText == values)
    {
      isExists = true;
      break;
    }
  }
    
  return isExists;
}

function movelist(tgz1, tgz2, mode) 
{
  var isExists;
  
	for (i = 1 ; i < tgz1.length; i++) 
	{
	  isExists = false;
	  
		if (tgz1.options[i].selected) 
		{
		  
			if (mode=="a")
			{
			
			  isExists = existCheck(tgz1.options[i].text, tgz2);
		  
			  if ( isExists == false)
			  {
    		  tgz2[tgz2.length] = new Option(tgz1.options[i].text, tgz1.options[i].value);
  				tgz1.options[i] = null;
  				i -= 1;
  			}
  			else
  			{
  			  tgz1.options[i].selected = false;
  			}
  			
			}
      else if (mode=="d")
			{
				tgz2[tgz2.length] = new Option(tgz1.options[i].text, tgz1.options[i].value);
        tgz1.options[i] = null;
				i -= 1;
			}
		}
	}
}

function MOver(element)
{
  element.bgColor="EEEEEE";
  element.style.backgroundColor="EEEEEE";
}

function MOut(element)
{
  element.bgColor="";
  element.style.backgroundColor="";
}

function MOver2(element)
{
  element.style.color = "tomato"
  element.style.textDecoration="underline";
}

function MOut2(element)
{
  element.style.color="";
  element.style.textDecoration="";
}

function isSpecialChar(element) 
{
  var v = element.value;
  if ( element.value.indexOf("\\") >= 0 ||
       element.value.indexOf(",") >= 0 ||
       element.value.indexOf("..") >= 0 ||
       element.value.indexOf("/") >= 0 ||
       element.value.indexOf(":") >= 0 ||
       element.value.indexOf("*") >= 0 ||
       element.value.indexOf("?") >= 0 ||
       element.value.indexOf("\"") >= 0 ||
       element.value.indexOf("<") >= 0 ||
       element.value.indexOf(">") >= 0 ||
       element.value.indexOf("|") >= 0 
  )
  {
    alert("다음과 같은 특수 기호를\n사용할 수 없습니다!!! \n(\\ , .. / : * ? \" < > |) ");
    element.value="";
    element.focus();
  }
  else
  return true;
}

function resizeMedia(media_Hide, media, flash_Hide, flash)
{

  if (media_Hide == "[object]")
  {
    
    if (media_Hide.length == null)
    { 
      media.style.height = media_Hide.style.height;
      media.style.width  = media_Hide.style.width;
    }
    else
    {
      for (i=0;i<=media_Hide.length-1;i++)
      {
        media[i].style.height = media_Hide[i].style.height;
        media[i].style.width  = media_Hide[i].style.width;
      }
    }
  }

  if (flash_Hide == "[object]")
  {
  
    if (flash_Hide.length == null)
    {
      flash.style.height = flash_Hide.style.height;
      flash.style.width  = flash_Hide.style.width;
    }
    else
    {
      for (i=0;i<=flash_Hide.length-1;i++)
      {
        flash[i].style.height = flash_Hide[i].style.height;
        flash[i].style.width  = flash_Hide[i].style.width;
      }
    }
  }
  
}