﻿// JScript 파일


// 테두리 라운드

function roundTable(objID) 
{
   var obj = document.getElementById(objID);
   var Parent, objTmp, Table, TBody, TR, TD;
   var bdcolor, bgcolor, Space;
   var trIDX, tdIDX, MAX;
   var styleWidth, styleHeight;

   Parent = obj.parentNode;
   objTmp = document.createElement('SPAN');
   Parent.insertBefore(objTmp, obj);
   Parent.removeChild(obj);

   bdcolor = obj.getAttribute('rborder');
   bgcolor = obj.getAttribute('rbgcolor');
   radius = parseInt(obj.getAttribute('radius'));
   if (radius == null || radius < 1) radius = 1;
   else if (radius > 6) radius = 6;

   MAX = radius * 2 + 1;

   Table = document.createElement('TABLE');
   TBody = document.createElement('TBODY');

   Table.cellSpacing = 0;
   Table.cellPadding = 0;

   for (trIDX=0; trIDX < MAX; trIDX++) {
          TR = document.createElement('TR');
          Space = Math.abs(trIDX - parseInt(radius));
          for (tdIDX=0; tdIDX < MAX; tdIDX++) {
                 TD = document.createElement('TD');
                 
                 styleWidth = '1px'; styleHeight = '1px';
                 if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
                 else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
                 else if (radius > 2) {
                        if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
                        if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
                 }

                 if (styleWidth != null) TD.style.width = styleWidth;
                 if (styleHeight != null) TD.style.height = styleHeight;

                 if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
                 else if (tdIDX > Space && Space < MAX - tdIDX - 1)  TD.style.backgroundColor = bgcolor;
                 
                 if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
                 TR.appendChild(TD);
          }
          TBody.appendChild(TR);
   }
   Table.appendChild(TBody);
   Parent.insertBefore(Table, objTmp);
}

// 삭제 확인
function del_chk()
{
    if(confirm('정말로 삭제하시겠습니까?'))
        return true;
    else
        return false;  
}

// 수정 확인
function modify_chk()
{
    if(confirm('정말로 수정하시겠습니까?'))
        return true;
    else
        return false;     
        
}

// confirm
function IsConfirm(msg)
{
    if(confirm(msg))
        return true;
    else
        return false;     
        
}

// 이미지 리사이즈
function imgThumbResize(img)
{
    if(img.width > img.height)
        img.width = 100;
    else
        img.height= 68;
}


//이미지 사이즈 재조정
function imgOpen(img)
{    
    var sUrl = img.src.split('=');
    var b = sUrl[1];
    if(sUrl.length == 2)
        window.open("http://file.walkpc.com/ImageView/frmImageBigView.aspx?kind=1&imgPath="+sUrl[1],'img','left=10,top=10,width=464,height=450,scrollbar=no,status=no');
    else
        window.open("http://file.walkpc.com/ImageView/frmImageBigView.aspx?kind=2&imgPath="+img.src,'img','left=10,top=10,width=464,height=450,scrollbar=no,status=no');
}

// 이미지 리사이즈
function imgResize(img)
{
    if (img.width>660)
        img.width = 660;
}

// 팝업창 오픈
function OpenPop(sUrl, iWidth, iHeight, iTop , iLeft)
{   
	window.open(sUrl, "OpenForm", "scrollbars=no,toolbar=no,location=no,directories=no,statusbar=no,width="+iWidth +",height=" + iHeight + ",top=" +iTop +",left=" + iLeft + ",resizable=no,menubar=no");
}

// 팝업창 오픈
function OpenPop2(sUrl, iWidth, iHeight, iTop , iLeft)
{   
    window.open(sUrl, "OpenForm", "scrollbars=yes,width="+iWidth +",height=" + iHeight + ",top=" +iTop +",left=" + iLeft);
}

// 태그검색
function tag_form(tag)
{  
    location.href = '/board/board_list.aspx?sec=forum&type=sTag&key=' + escape(tag)
}

// 특수문자 확인
function IsSpecialChar(sValue)
{
    var invalid=["`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "("
			    , ")", "-", "_", "=", "+", "\\", "|", "[", "{", "]", "}"
			    , ";", ":", "'", "\"", "<", ">", "/", "?", ","];				   					
    var sReturn;
    //var invalid=["%", "[", "]", "-", "_", "'"];
	
    for(i=0; i<invalid.length;i++){
	    if(sValue.indexOf(invalid[i]) > -1){ // 각 특수문자 중 하나라도 포함되면 true 리턴 후 종료
		    //alert(i + " : " + invalid[i]);
		    return true;
	    }
    }        
}
 

//// 메뉴 숨김/ 보이기

// 플래쉬 삽입
function FlashEmbed(sFilename,iWidth,iHeight)
{
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
	document.write(" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' ");
	document.write(" width='"+ iWidth +"' height='"+ iHeight +"' VIEWASTEXT>");
	document.write("<param name='movie' value='"+ sFilename +"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<embed src='"+ sFilename +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ iWidth +"' height='"+ iHeight +"'></embed></object>");
}

//길이계산
			
function cal_byte2(value)
{

	var aquery = value;
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount = 0;
	var limit;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);
		if (escape(onechar) =='%0D')
		{ 
		}
		else if(escape(onechar).length > 4)
		{ 
			tcount += 2; 
		}
		else
		{ 
			tcount++; 
		}
	}
			
	
	return tcount;
}

function getKey(keyStroke) {
    if ((event.srcElement.tagName != 'INPUT') && (event.srcElement.tagName != 'TEXTAREA')){
        isNetscape=(document.layers);
        eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
        which = String.fromCharCode(eventChooser).toLowerCase();
        for (var i in key)
            if (which == i) window.location = key[i];
    }
}
document.onkeypress = getKey;

function SetCookie(name, value, expiredays) {
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + expiredays);
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function GetCookie(name) {
    var nameOfCookie = name + "=";
    var x = 0;
    while (x <= document.cookie.length) {
        var y = (x + nameOfCookie.length);
        if (document.cookie.substring(x, y) == nameOfCookie) {
            if ((endOfCookie = document.cookie.indexOf(";", y)) == -1) endOfCookie = document.cookie.length;
            return unescape(document.cookie.substring(y, endOfCookie));
        }
        x = document.cookie.indexOf(" ", x) + 1;
        if (x == 0) break;
    }
    return "";
}
