

/* Standard New Window */
function newWin(url,win,xv,yv) {
  var iwidth;
  var iheight;
  var str1;

  iwidth = (screen.width-xv)/2;
  iheight = (screen.height-yv)/2;

  str1 = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width="+xv+",height="+yv+",top="+iheight+",left="+iwidth;

  var popup = window.open(url, win, str1);
// 
//  if( navigator.appName.substring(0,8) == "Netscape" ) {
//    popup.location = url;
//  }
}

/* Standard New Window */
function newWinRS(url,win,xv,yv,scroll,resize) {
  var iwidth;
  var iheight;
  var str1;

  iwidth = (screen.width-xv)/2;
  iheight = (screen.height-yv)/2;

  str1 = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+scroll+",resizable="+resize+",width="+xv+",height="+yv+",top="+iheight+",left="+iwidth;

  var popup = window.open(url, win, str1);

//  if( navigator.appName.substring(0,8) == "Netscape" ) {
//    popup.location = url;
//  }
}


/* Remake New Window ( scroll option ) */
function newWinEx(url,win,xv,yv,scroll) {
  
  var iwidth;
  var iheight;
  var str1;
  
  if(win == "viewmember") {
    iwidth = 0;
    iheight = 0;
  }
  else {
    iwidth = (screen.width-xv)/2;
    iheight = (screen.height-yv)/2;
  }
  str1 = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars="+scroll+",resizable=0,width="+xv+",height="+yv+",top="+iheight+",left="+iwidth;

  var popup = window.open(url, win, str1);

//  if( navigator.appName.substring(0,8) == "Netscape" ) {
//    popup.location = url;
//  }
}


/* Trim the string */
function alltrim(str) {
  var i;
  var ch;
  var retStr = '';
  var retStr1 = '';
  if (str.length == 0) return str;
  for(i=0;i<str.length;i++) {
    ch = str.charAt(i);
    if(ch == ' ' || ch == '\r' || ch == '\n') continue;
    retStr += ch;
  }
  return retStr;
}


/* All Checkbox reset of dest form */
function resetCheckbox(f) {
  if(f.elements) {
    for(i=0;i<f.elements.length;i++) {
      var e = f.elements[i];
      if (e.type == "checkbox") {
        e.checked = true;
      }
    }
  }
  return false;
}


/* All Checkbox mark of dest form */
function clearCheckbox(f) {
  if(f.elements) {
    for(i=0;i<f.elements.length;i++) {
      var e = f.elements[i];
      if (e.type == "checkbox") {
        e.checked = false;
      }
    }
  }
  return false;
}


function modalNewWin(url, name, width, height) {  // 모달 창
  var winObj = new Object();
  winObj.win = window;

  //winurl = "/mNewWin.htm?turl=" + url;
  winurl = url;
  var sFeatures = "dialogHeight: " + height + "px;dialogWidth: " + width + "px;status:0;dialogHide:1;help: No;scroll:No;resizable:No";
  window.showModalDialog(winurl, winObj, sFeatures)
}

function over(t)
{
  var lnk = t.src;

  r = /\.gif$/g;
  t.src = lnk.replace(r, '_up.gif');
}

function out(t)
{
  var lnk = t.src;

  r = /_up\.gif$/g;
  t.src = lnk.replace(r, '.gif');
}

 
function getCookie(name) { 
  var Found = false 
  var start, end 
  var i = 0 

  while(i <= document.cookie.length) { 
    start = i 
    end = start + name.length 
    if(document.cookie.substring(start, end) == name) { 
      Found = true 
      break 
    } 
    i++ 
  } 

  if(Found == true) { 
    start = end + 1 
    end = document.cookie.indexOf(";", start) 
    if(end < start) 
      end = document.cookie.length 
    return document.cookie.substring(start, end) 
  } 
  return "" 
} 

function setCookie( name, value, expiredays ) 
{
  var today = new Date();
  today.setDate( today.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}


  function onmsg()
  {
    var f, w, h, lsize;

    f = document.getElementById('msglayer');

    lsize = f.style.width;

    w = document.body.clientWidth + document.body.scrollLeft - (parseInt(lsize) + 10);

    f.style.left = w;

    showmsg();
  }

  function showmsg()
  {
    var len = '';
    var newlen = '';
    var timerId, f, ff, s;

    f = document.getElementById('msglayer');

    len = f.style.height;

    s = parseInt(len);
    s = s + 5;
      
    newlen = s + 'px';

    f.style.height = newlen;

    h = document.body.clientHeight + document.body.scrollTop - (10 + s);
    f.style.top = h;

    timerId = setTimeout("showmsg()", 30);

    if (f.style.height == '100px')
    {
      clearTimeout(timerId);
      setTimeout("closemsg()", 5000)
      posmsg();
    }
  }

  function posmsg()
  {
    f = document.getElementById('msglayer');

    lsize = f.style.width;
    hsize = f.style.height;

    w = document.body.clientWidth + document.body.scrollLeft - (parseInt(lsize) + 10);
    h = document.body.clientHeight + document.body.scrollTop - (parseInt(hsize) + 10);

    f.style.left = w;
    f.style.top = h;

    setTimeout("posmsg()", 20);
  }

  function closemsg()
  {
    var len = '';
    var newlen = '';
    var timerId, f, s;

    f = document.getElementById('msglayer');

    len = f.style.height;

    s = parseInt(len);
    s = s - 5;
      
    newlen = s + 'px';

    f.style.height = newlen;

    h = document.body.clientHeight + document.body.scrollTop - (10 + s);
    f.style.top = h;

    timerId = setTimeout("closemsg()", 30);

    if (f.style.height == '0px')
    {
      clearTimeout(timerId);
      f.style.display = 'none';
    }
  }

  function setadmbtn()
  {
    f = document.getElementById('admbtn');
    lsize = f.width;

    w = document.body.clientWidth + document.body.scrollLeft - (parseInt(lsize) + 10);
    h = document.body.clientHeight + document.body.scrollTop - 90;

//    f.style.left = 10;
    f.style.left = w;
    f.style.top = h;

    setTimeout("setadmbtn()", 200);
  }

  function setholdbtn()
  {
    ff = document.getElementById('holdbtn');
    lsize = f.width;

    w = document.body.clientWidth + document.body.scrollLeft - (parseInt(lsize) + 10);
    h = document.body.clientHeight + document.body.scrollTop - 180;

//    f.style.left = 10;
    ff.style.left = w;
    ff.style.top = h;

    setTimeout("setholdbtn()", 200);
  }

  function urlencode (q)
  {
    return escape(q).replace(/\+/g, "%2B") ;
  }

  function gourl(t)
  {
    if (t) location.href = t;
  }

  function resize(i) 
  {
  	var f = document.getElementById(i);
    var fix_w = 520;

    if (f.width > fix_w) 
    {
      f.width = fix_w;
    }
  }

  function na_restore_img_src(name, nsdoc)
  {
	  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	  if (name == '')
		return;
	  if (img && img.altsrc) {
		img.src    = img.altsrc;
		img.altsrc = null;
	  } 
	}

	function na_preload_img()
	{ 
	  var img_list = na_preload_img.arguments;
	  if (document.preloadlist == null) 
		document.preloadlist = new Array();
	  var top = document.preloadlist.length;
	  for (var i=0; i < img_list.length-1; i++) {
		document.preloadlist[top+i] = new Image;
		document.preloadlist[top+i].src = img_list[i+1];
	  } 
	}

	function na_change_img_src(name, nsdoc, rpath, preload)
	{ 
	  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	  if (name == '')
		return;
	  if (img) {
		img.altsrc = img.src;
		img.src    = rpath;
	  } 
	}


  // var grp = document.poll_answer.ansno;
  function isSelRadio(grp)
  { 
    for(i=0; i<grp.length; i++) 
    { 
      if(grp[i].checked == true) 
      { 
        return true; 
      } 
    } 
    
    return false;
  } 

  function EmailCheck(v) {
      var mvalue = v;
      if (mvalue.search(/(\S+)@(\S+)\.(\S+)/) == -1) {
          return false;
      }
      else {
         return true;
      }
  }

  //플래쉬 패치
  function MakeFlash(Url,Width,Height){                 
    document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + Width + "\" height=\"" + Height + "\">"); 
    document.writeln("<param name=\"movie\" value=\"" + Url + "\">"); 
    document.writeln("<param name=\"quality\" value=\"high\" />");     
    document.writeln("<param name=\"wmode\" value=\"transparent\">"); 
    document.writeln("<embed src=\"" + Url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"" + Height + "\">"); 
    document.writeln("</object>");     
  } 

  // 한글파라미터 값을 urlencode 시켜준다.
  function encodeURL(userName){

     var s0, i, s, u; 
     s0 = "";                // encoded str 
     for (i = 0; i < userName.length; i++){   // scan the source
         s = userName.charAt(i);
         u = userName.charCodeAt(i);          // get unicode of the char
         if (s == " "){s0 += "+";}       // SP should be converted to "+"
         else {
             if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a)))
             {       // check for escape
                 s0 = s0 + s;            // don't escape 
             }
             else {                  // escape
                 if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
                     s = "0"+u.toString(16);
                     s0 += "%"+ s.substr(s.length-2);
                 }
                 else if (u > 0x1fffff){     // quaternary byte format (extended)
                     s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                     s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                     s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                     s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                 }
                 else if (u > 0x7ff){        // triple byte format
                     s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                     s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                     s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                 }
                 else {                      // double byte format
                     s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                     s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                 }
             }
         }
     }
     return s0;
  }

