﻿var theTarget = "_blank";



function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring;

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];}
}

//On mouse over
var message="";
function clickIE() {
    if (document.all) {(message);return false;}
    }
function clickNS(e) {
    if (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers) {
        document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{
        document.onmouseup=clickNS;document.oncontextmenu=clickIE;
		}
       document.oncontextmenu=new Function("return false")

document.onmouseover = function ( e ) {   
    if ( !e ) e = window.event;   
        var el = e.target ? e.target : e.srcElement;   
    while ( el != null && el.tagName != "A" ) el = el.parentNode;   
    if ( el == null ) return;   
    if ( e.preventDefault ) e.preventDefault();   
        else e.returnValue = true;};

/**
 *  Random한 숫자를 return해준다.
 */
function getRandom()  {
  randomKey = Math.random()+"";

  if ( (pos = randomKey.indexOf('.')) > -1 )  {  //  포함된다면
    randomKey = randomKey.substring(pos+1, randomKey.length);
  }

  return randomKey;
}


/****
*    cookieName 에 해당하는 cookie value 를 반환한다.
*    @parm cookie (recommanded)
*    cookie 가 없으면 null 을 반환한다.
****/
function getCookie(name){
    var cname = name + "=";
    var dc = document.cookie;

    if (dc.length > 0) {
     begin = dc.indexOf(cname);

        if (begin != -1) {
         begin += cname.length;
         end = dc.indexOf(";", begin);

         if (end == -1) end = dc.length;
             return unescape(dc.substring(begin, end));
        }
    }
    return "";
}


function setCookie(name, value)
{
  var argv = setCookie.arguments;
  var argc = setCookie.arguments.length;
  var expires = (2 < argc) ? argv[2] : null;
  var path = (3 < argc) ? argv[3] : null;
  var domain = (4 < argc) ? argv[4] : null;
  var secure = (5 < argc) ? argv[5] : false;

  if(expires!=null) {
    var todayDate = new Date();
    todayDate.setDate   ( todayDate.getDate()    + expires             );
    todayDate.setHours  ( todayDate.getHours  () - todayDate.getHours  () );
    todayDate.setMinutes( todayDate.getMinutes() - todayDate.getMinutes() );
    todayDate.setSeconds( todayDate.getSeconds() - todayDate.getSeconds() );
    expires = todayDate;
  }

  document.cookie = name + "=" + escape(value) +
    ((expires == null) ?  ""          : ("; expires="+expires.toGMTString())) +
    ((path == null) ?     ""          : ("; path=" + path)) +
    ((domain == null) ?   ""          : ("; domain=" + domain)) +
    ((secure == true) ?   "; secure"  : "");
}

/**
* 스크롤이 되지 않는 popup 창       (암호화 안됨)
*/
function openWindow(url, winName, sizeW, sizeH, scollflag) {
  if(scollflag==null)
    scollflag = "1";
  openWindowFunction(url, winName, sizeW, sizeH, scollflag);
  w.focus();
//  return w;
}

/**
* 스크롤을 옵션으로 주는 popup 창 (암호화 안됨)
*/
function openWindowFunction(url, winName, sizeW, sizeH,scollflag) {
  if(url.indexOf('.') == -1 && url != ''){ // appid 가 들어온 경우
    url = ACTION + url;
  }
  //openWindowClose();
  w = window.open(url, winName, getOpenWindowOption(sizeW, sizeH,scollflag));
  w.focus();
//  return w;
}

function getOpenWindowOption(sizeW, sizeH, scollflag)  {
  var nLeft  = screen.width/2 - sizeW/2 ;
  var nTop  = screen.height/2 - sizeH/2 ;
  if(scollflag == "1") {
    opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
  } else {
    opt = ",toolbar=no,menubar=no,location=no,scrollbars=yes,status=no";
  }
  return "left=" + nLeft + ",top=" +  nTop + ",width=" + sizeW + ",height=" + sizeH  + opt;
}


// 달력 팝업
var preElm;
var preElmName;

var oPopup;

var setYY = '';
var setMM = '';
var setDD = '';
var holichk = '';

function viewCal(cholichk)  {

  var objFrame = getFrame();              //  처리대상 frame object
  var doc = objFrame.document;            //  현재 element의 document object
  var eSrc = objFrame.event;              //  현재 발생한 window.event;
  var elm = eSrc.srcElement;              //  현재 element object

  if ( cholichk==null )
    holichk = 0;
  else
    holichk = cholichk;

  preElm = null;

  setYY = curDate.substring(0,4);
  setMM = curDate.substring(4,6);
  setDD = curDate.substring(6,8);

  var preBaseName = '';

  //  date1 
if ( cholichk==2 )  {
  for ( inx=elm.sourceIndex; inx>1; inx-- )  {
    preElm = doc.all[inx-1];
    if ( preElm.tagName == 'INPUT' && preElm.datatype == 'date' )  {
      preElmName = preElm.name;
      break;
    }
  }
}

  if(preElm!=null)  {
    selDate = preElm.value.replace(/\,|-|\/|\.| /g,'');
    setYY = selDate.substring(0,4);
    setMM = selDate.substring(4,6);
    setDD = selDate.substring(6,8)
  }

if ( cholichk==2 )  {
  qx = eSrc.x - 10;
  qy = eSrc.y + 90;


  var height = 215;
  var width = 207;
  var url = '/common/cal_popup.jsp';
}else{
	qx = eSrc.x - 110;
  qy = eSrc.y + 190;


  var height = 290;
  var width = 410;
  var url;
  if(getCookie("LA_CODE") == "KO"){
  	url = '/common/cal_ko.jsp';
  }else{
  	url = '/common/cal.jsp';
  }
}  
  

  var myObject = new Object();
    myObject.pageObject = this.window;

  var env_options = "";
  env_options = "center:yes;dialogHide:no;edge:sunken;help:no;resizable:no;scroll:no;status:no;unadorned:yes;";
  env_options += "dialogWidth:" + width + "px;dialogHeight:" + height + "px;dialogLeft:"+qx+"px;diallogTop:"+qy+"px;";

  calClosePop();


  //oPopup=window.open(url, "calWindowPopup", "left="+qx+",top="+qy+",width="+width+",height="+height+",menubar=0,status=yes");
  oPopup=window.open(url, "calWindowPopup", "left="+qx+",top="+qy+",width="+width+",height="+height+",menubar=0,statusbar=0");

}

/**
 * 달력팝업 닫기
 */
function calClosePop()  {
  try {
    oPopup.close();
  }
  catch(ex) {}
}


function getOpenWindowOption(sizeW, sizeH, scollflag)  {
  var nLeft  = screen.width/2 - sizeW/2 ;
  var nTop  = screen.height/2 - sizeH/2 ;
  if(scollflag == "1") {
    opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
  } else {
    opt = ",toolbar=no,menubar=no,location=no,scrollbars=yes,status=no";
  }
  return "left=" + nLeft + ",top=" +  nTop + ",width=" + sizeW + ",height=" + sizeH  + opt;
}



