// Flash Embed ½ºÅ©¸³Æ® -- »ç¿ë¿¹ : <script>swf("/images/flash/a.swf", 100, 50) 
function swf(src, w, h) {
	var src_arr = src.split("/");
	var src_file = src_arr[src_arr.length -1]
	var src_id = src_file.substr(0,src_file.length-4);
	//alert(src_id);

	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="'+src_id+'" width="'+w+'" height="'+h+'">';
	html += '<param name="movie" value="'+src+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="bgcolor" value="#ffffff">';
	html += '<param name="swliveconnect" value="true">';
	html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" width="'+w+'" height="'+h+'" swliveconnect="true" id="'+src_id+'" name="'+src_id+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	html += '<\/object>';
	document.write(html);
}

// Flash Embed ½ºÅ©¸³Æ® -- »ç¿ë¿¹ : <script>embed_flash("/images/flash/a.swf", 100, 50) 
function swf_tran(src, w, h) {
	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="param" width="'+w+'" height="'+h+'">';
	html += '<param name="movie" value="'+src+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="bgcolor" value="#ffffff">';
	html += '<param name="wmode" value="transparent">';
	html += '<param name="swliveconnect" value="true">';
	html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	html += '<\/object>';
	document.write(html);
}

// ±âº» ÆË¾÷Ã¢
function view_open(url,name,features) { 
    window.open(url,name,features);
}


// window ¶ç¿ì±â
function open_win(URL, name, width, height) 
{
    msgWindow=window.open(URL,name,'location=0,toolbar=no,width='+width+',height='+height+',directories=no,status=no,scrollbars=Yes,resizable=no,menubar=no,border=0');
    msgWindow.focus()
}

// window ¶ç¿ì±â, no scroll
function open_win1(URL, name, width, height) 
{
    msgWindow=window.open(URL,name,'location=0,toolbar=no,width='+width+',height='+height+',directories=no,status=no,scrollbars=No,resizable=no,menubar=no,border=0');
    msgWindow.focus()
}

// window ¶ç¿ì±â
function open_win_XY(URL, name, width, height) 
{
    msgWindow=window.open(URL,name,'location=0,toolbar=no,width='+width+',height='+height+',directories=no,status=no,scrollbars=Yes,resizable=Yes,menubar=no,border=0,screenX=0,screenY=0');
    msgWindow.focus()
}


// °ø¹é check(space Ã³¸®)
// null => true
function chk_null(toCheck) 
{
    for (var i = 0; i < toCheck.length; i++)
        if (toCheck.substring(i, i+1) != " ") return false;
        
    return true;
}

// °ø¹é check (°ªÀÌ ¾øÀ»°æ¿ì true)
// null => true
function chk_null2(toCheck)
{
    var chkstr = toCheck + "";
        
    if ((chkstr == "") || (chkstr == null)) 
    {
        return true;
    }

    return false;
}

// ¼ýÀÚ check
function chk_num1(toCheck) 
{
   for (j = 0; j < toCheck.length ; j++)
   {
      if ( (toCheck.substring(j,j+1) < "0") || (toCheck.substring(j,j+1) > "9") ) return false;
   }
   return true;
}


// ¼ýÀÚ, ".", "-" ¸¸ Á¸ÀçÇÏ¸é true
function chk_num2(toCheck) 
{
   for (j = 0; j < toCheck.length ; j++) 
   {
      if ( (toCheck.substring(j,j+1) < "0") || (toCheck.substring(j,j+1) > "9") ) 
      {
         if ( (toCheck.substring(j,j+1) == ".") || (toCheck.substring(j,j+1) == "-") ) continue;
         return false;
      }
   }
   
   return true;
}

// ¼ýÀÚ, "-" ¸¸ Á¸ÀçÇÏ¸é true

function chk_num3(toCheck) 
{
   for (j = 0; j < toCheck.length ; j++) 
   {
      if ( (toCheck.substring(j,j+1) < "0") || (toCheck.substring(j,j+1) > "9") ) 
      {
         if (toCheck.substring(j,j+1) == "-") continue;
         return false;
      }
   }
   
   return true;
}

// ÇÑ±Û check
function chk_hangul(toCheck) 
{
    var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890`!@#$%^&*()-=_+~[]\{}|,./<>?";
    
    for (i=0; i< toCheck.length; i++)
    {
        idcheck = toCheck.charAt(i);
        
        for ( j = 0 ;  j < str.length ; j++)
        {
        
            if (idcheck == str.charAt(j)) break;
                
            if (j+1 == str.length)
            {
                return false;
            }
        }
    }
    return true;
}

//¿µ¾î,¼ýÀÚ, _ ¸¸ °¡´É
function chk_hangul2(toCheck) 
{
    var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_";
    
    for (i=0; i< toCheck.length; i++)
    {
        idcheck = toCheck.charAt(i);
        
        for ( j = 0 ;  j < str.length ; j++)
        {
        
            if (idcheck == str.charAt(j)) break;
                
            if (j+1 == str.length)
            {
                return false;
            }
        }
    }
    return true;
}

// ÇÑ±Û, ¿µ¹®¸¸ ÀÔ·Â°¡´É
function chk_hangul3(toCheck) 
{
    var str = "1234567890`!@#$%^&*()-=_+~[]\{}|,./<>?";
    
    for (i=0; i< toCheck.length; i++)
    {
        idcheck = toCheck.charAt(i);
        
        for ( j = 0 ;  j < str.length ; j++)
        {
            if (idcheck == str.charAt(j)){
				return false;
			}                
            if (j+1 == str.length) break;
        }
    }
    return true;
}


// Email check
function chk_mail(toCheck) 
{
    // @Ç¥½Ã È®ÀÎ
    if (toCheck.indexOf('@') == -1 ) 
    { 
        return false; 
    }

    // .Ç¥½Ã È®ÀÎ
    if (toCheck.indexOf('.') == -1 ) 
    { 
        return false; 
    }
    
    // ÇÑ±Û È®ÀÎ
    if ( chk_hangul(toCheck) == false ) 
    { 
        return false; 
    }
    
    return true;
}


// ÁÖ¹Î¹øÈ£ check
function chk_juminno(obj) 
{
	if (obj.length == 14) {
        var calStr1 = "2345670892345", biVal = 0, tmpCal, restCal;

        for (i=0; i <= 12; i++) {
                if (obj.substring(i,i+1) == "-") {
                        tmpCal = 1;
                }
                else {
                        biVal = biVal + (parseFloat(obj.substring(i,i+1)) * parseFloat(calStr1.substring(i,i+1)));
                }
        }

        restCal = 11 - (biVal % 11);

        if (restCal == 11) {
                restCal = 1;
        }

        if (restCal == 10) {
                restCal = 0;
        }
        if (restCal == parseFloat(obj.substring(13,14))) {
                return true;
        }
        else {
                return false;
        }
	}
	else {
		return false;
	}
}



// form check
// <input> tag¿¡ ¾Æ·¡»çÇ×À» check
// text : ÇØ´ç column ÀÌ¸§
// notnull : null check
// check
// - number : ¼ýÀÚ check
// - date : ³¯ÀÚ check
// - mail : ¸ÞÀÏ check
// - juminno : ÁÖ¹Î¹øÈ£ check
function chk_form(form) 
{
    var inx = 0; // À§Ä¡

    for ( ; inx < form.length; inx++)
    {
        //alert(inx);
        var column = form.elements[inx];
        
        var text = column.text;

        if ( (column.type == "text") || 
             (column.type == "password") || 
             (column.type == "textarea") ||
             (column.type == "file") )
        {
            // ÇÊ¼öÇ×¸ñ check
            if ( (column.notnull == "") && (chk_null(column.value)) ) 
            {
                alert (text + "Àº(´Â) ÇÊ¼öÇ×¸ñÀÔ´Ï´Ù");
                column.focus();
                return false;
            }
            
            // nullÀÌ ¾Æ´Ï¸é check
            if( !chk_null(column.value) )
            {
                // ÇüÅÂ check
                if ( (column.check == "number") && (!chk_num1(column.value)) )
                {
                    alert (text + "À»(¸¦) ¼ýÀÚ·Î ÀÔ·ÂÇÏ¼¼¿ä");
                    column.focus();
                    return false;
                }
				
                else if ( (column.check == "date") && (!chk_date(column.value)) )
                {
                    alert (text + "À»(¸¦) ³¯ÀÚ·Î ÀÔ·ÂÇÏ¼¼¿ä");
                    column.focus();
                    return false;
                }
                else if ( (column.check == "mail") && (!chk_mail(column.value)) )
                {
                    alert ("¿Ã¹Ù¸¥ ¸ÞÀÏÁÖ¼Ò°¡ ¾Æ´Õ´Ï´Ù.");
                    column.focus();
                    return false;
                }
                else if ( (column.check == "juminno") && (!chk_juminno(column.value)) )
                {
                    alert ("¿Ã¹Ù¸¥ ÁÖ¹Î¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.");
                    column.focus();
                    return false;
                }
                else if ( (column.check == "length") && (!chk_length(column.value,column.hlength)) )
                {
                    alert (column.hlength+"ÀÚ±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
                    column.focus();
                    return false;
                }

                else if ( (column.check == "length3") && (!chk_length3(column.value,column.hlength) || !chk_num1(column.value)) )
                {
                    alert (text + "´Â(Àº) " + column.hlength + "±ÛÀÚÀÇ ¼ýÀÚ·Î ÀÔ·ÂÇÏ¼¼¿ä.");
                    column.focus();
                    return false;
                }

				else if ( (column.check == "hangul") && (!chk_hangul2(column.value)) )
                {
                    alert (text + " ´Â(Àº) ¿µ¹®,¼ýÀÚ,'_'¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
                    column.focus();
                    return false;
                }
				else if ( (column.check == "hangul2") && (!chk_hangul3(column.value)) )
                {
                    alert (text + " ´Â(Àº) ¿µ¹®,ÇÑ±Û¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
                    column.focus();
                    return false;
                }
				else if ( (column.check2 == "length2") && (!chk_length2(column.value,column.maxlen,column.minlen)) )
                {
                    alert (text + " ´Â(Àº) "+ column.minlen + " ~ " + column.maxlen +"ÀÚ±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù");
                    column.focus();
                    return false;
                }
				else if ( (column.check == "number3") && (!chk_num3(column.value)) )
                {
                    alert (text + " ´Â(Àº) ¼ýÀÚ,'-'¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
                    column.focus();
                    return false;
                }

            }
        }
    }
  
    return true;
}

// object°¡ nullÀÎÁö check
function chk_null_obj(Obj) 
{
    var check = false;
    var Radio = Obj;

    if (!Radio) return check;

    if (Radio.length) 
    {
        for ( var i=0; i<Radio.length; i++ ) 
        {
            if ( Radio[i].checked == 1 ) 
            {
                check = true;
                break;
            }
        }
    }
    else
    {
        if ( Radio.checked == 1 ) 
        {
            check = true;
        }
    }

    return check
}


// ¸ðµç object¸¦ checkÇÔ
function CheckAll(Obj) 
{
    var Radio = Obj.form.file;

    if (!Radio) return;

    if (Radio.length) 
    {
        for ( var i=0; i<Radio.length; i++ )
            Obj.form.file[i].checked=1;
    }
    else 
    {
        Obj.form.file.checked=1;
    }
}


// ¸ðµç object¸¦ uncheckÇÔ 
function UnCheckAll(Obj) 
{
    var Radio = Obj.form.file;

    if (!Radio) return;

    if (Radio.length) 
    {
        for ( var i=0; i<Radio.length; i++ )
            Obj.form.file[i].checked=0;
    }
    else 
    {
        Obj.form.file.checked=0;
    }
}

