/**
* °øÅë ÇÔ¼ö
*/

// ÀüÃ¼ Ã¼Å©¹Ú½º ¼±ÅÃ
function checkAllItem(theform)
{
    if(theform.p_check_all_fg.checked == true)
    {
        for(var i=0; i < theform.length; i++)
        {
            if(theform[i].name == "p_checkbox" && theform[i].checked == false)
            {
                theform[i].checked = true;
            }
        }
    }
    else
    {
        for(var i=0; i < theform.length; i++)
        {
            if(theform[i].name == "p_checkbox" && theform[i].checked == true)
            {
                theform[i].checked = false;
            }
        }
    }
}

// ¼±ÅÃµÈ Ã¼Å©¹Ú½º ¼ö ¸®ÅÏ
function getSelectedItemCount(theform)
{
    var item_count = 0;
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_count++;
        }
    }

    return item_count;
}

// ¼±ÅÃµÈ Ã¼Å©¹Ú½º ¾ÆÀÌÅÛ ¸®½ºÆ® ¸®ÅÏ
function getSelectedItemList(theform)
{
    var item_list = "";
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_list = item_list + theform[i].value + "";
        }
    }

    return item_list;
}

// ¼±ÅÃµÈ Ã¼Å©¹Ú½º ¾ÆÀÌÅÛ ¸®½ºÆ® ¸®ÅÏ delimeter ÆÄ¶ó¹ÌÅÍ
function getSelectedItemListByDeli(theform, deli)
{
    var item_list = "";
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_list = item_list + theform[i].value + deli;
        }
    }

    return item_list;
}

// À©µµ¿ì »çÀÌÁî FIT
function body_size()
{
	wid = document.body.scrollWidth+10;
	hei = document.body.scrollHeight+29;
	self.resizeTo(wid,hei);
}

// ¹ÙÀÌÆ®¼ö ¸®ÅÏ
function getTextByte(str)
{
    var wch, x, uch = "";
    var szLength = 0;

    for ( x = 0; x < str.length; x ++ )
    {
        wch = str.charCodeAt( x );
        if ( !( wch && 0xFF80 ) )
        {
            szLength ++;
        }
        else if ( !( wch & 0xF000 ) )
        {
            szLength ++;
        }
        else 
        {  
            szLength += 2;
        }
    }
    return szLength;
}

// Æ¯¼ö¹®ÀÚ Ã³¸®¾ÈµÅ´Âµí...
function GetLength(string)
{
    var ch;
    var length = 0;

    if( string == "") return 0;

    browserName = navigator.appName;
    browserVer = navigator.appVersion.indexOf("5.");
    if (browserName == "Netscape")
        return string.length;
    else
    {
        for ( k = 0; k < string.length; k++ )
        {
            ch = string.charAt(k);
            if ( ch >= '¤¡' && ch <= 'ÆR' )
            {
                length += 2;
            }
            else if ( ch > 128)
            {
                length += 2;
            }
            else
                length++;
        }
        return length;
    }
}

function getCommentLength(string)
{
    var ch;
    var length = 0;

    if( string == "") return 0;

    browserName = navigator.appName;
    browserVer = navigator.appVersion.indexOf("5.");
    if (browserName == "Netscape")
        return string.length;
    else
    {
        for ( k = 0; k < string.length; k++ )
        {
            ch = string.charAt(k);
            if ( ch >= '¤¡' && ch <= 'ÆR' )
            {
                length += 1;
            }
            else if ( ch > 128)
            {
                length += 1;
            }
            else
                length += 0.5;
        }
        return length;
    }
}

function cutString(string, len)
{
    var ch;
    var length = 0;
	var returnStr = "";

    if( string == "") return "";

    browserName = navigator.appName;
    browserVer = navigator.appVersion.indexOf("5.");
    if (browserName == "Netscape")
        return string.length;
    else
    {
        for ( k = 0; k < string.length; k++ )
        {
			if(length >= len)
			{
				break;
			}

            ch = string.charAt(k);
            if ( ch >= '¤¡' && ch <= 'ÆR' )
            {
                length += 1;
            }
            else if ( ch > 128)
            {
                length += 1;
            }
            else
                length += 0.5;

			returnStr += ch;
        }

        return returnStr;
    }
}

// ¹®ÀÚ¿­ÀÇ ¾çÂÊ(¿ÞÂÊ, ¿À¸¥ÂÊ) °ø¹éÀ» Á¦°Å ÇÔ¼ö
function trimIt(src)
{
    var search = 0;

    while ( src.charAt(search) == " ")
    {
        search = search + 1;
    }

    src = src.substring(search, (src.length))

    search = src.length - 1;

    while (src.charAt(search) ==" ")
    {
        search = search - 1;
    }

    return src.substring(0, search + 1);
}

// Å¸ÀÓ½ºÅÆÇÁ ¸®ÅÏ
function getTimeStamp()
{
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    return stemp = hours+minutes+seconds;
}

// ÆË¾÷Ã¢À» È­¸é °¡¿îµ¥ ¶ç¿î´Ù.
// url : url
// popupname : ÆË¾÷ À©µµ¿ì¸í
// x : width
// y : height
// scroll : È­¸é scroll ¿©ºÎ( 'yes','no' )
// resize : È­¸é resize ¿©ºÎ( 'yes','no' )
function popUp(url, popupname,x,y,scroll,resize)
{
    window.open(url,popupname,"toolbar=no,width="+x+",height="+y+ ",top="+ (screen.availheight- y )/2+",left="+(screen.availwidth- x)/2 +",directories=no,status=no,scrollbars="+scroll+",resize="+resize+",menubar=no");
}

// 10 ¹Ì¸¸ ¼ýÀÚ¾Õ¿¡ '0'À» ºÙÀÎ´Ù.
function addZero(s)
{
	if( s.length > 1 )
    {
		return s;
	}
    else
    {
		return ("0"+s);
	}
}

// 10¹Ì¸¸ ¼ýÀÚ¾Õ¿¡ '0' À» ¶¼¾î³½´Ù.
function removeZero(s)
{
    if( s.charAt(0) == '0' )
    {
        return s.charAt(1);
    }
    else
    {
        return s;
    }
}

// ·£´ý ¼ýÀÚ ¸®ÅÏ
function getRandomNumber(min_num, max_num)
{         
    var nr=0;                                    
    while ((nr < min_num) || (nr > max_num))
    {   
        nr = Math.round( min_num*Math.random());  
    }

    return nr;                             
}

/**
* Validation °ü·Ã ÇÔ¼ö
*/

// ¿µ¹®(´ë,¼Ò¹®ÀÚ), ¼ýÀÚ Ã¼Å©
function isAlphaNumeric(s)
{
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for (i = 0;  i < s.length;  i++)
    {
        ch = s.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length)
        {
            return (false);
            break;
        }
    }
    return (true);
}

// ¼ýÀÚ Ã¼Å©
function isNumeric(s)
{
    var ch, ch2=1;

    for ( k = 0; k < s.length; k++ )
    {
        ch = s.charAt(k);
        if ( ch < '0' || ch > '9' )
        {
            if(k==0 && ch == '-')
				continue;
			return (false);
        }
    }
    return (true);
}

// »ç¿ë°¡´ÉÇÑ id ¸¦ Ã¼Å©
function isAvailableId(s)
{
    var ch, ch2=1;

    for ( k = 0; k < s.length; k++ )
    {
        ch = s.charAt(k);
        if ( !(('0' <= ch && '9' >= ch ) ||
            ('A' <= ch && 'Z' >= ch ) ||
            ('a' <= ch && 'z' >= ch ) || ( ch == '_' )) )
        {
            if ( ch == ' ' )
                alert("°ø¹éÀº »ç¿ëÇÏ½Ç¼ö ¾ø½À´Ï´Ù.");
            else
            {
                alert("¿µ¹®, ¼ýÀÚ, '_' ¿ÜÀÇ ¹®ÀÚ´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
            }
            return (false);
        }
    }
    return (true);
}

// ½ºÆ®¸µ¿¡ °ø¹éÀÌ ÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù.
function hasWhiteSpace(s)
{
    var ch;

    for ( k = 0; k < s.length; k++ )
    {
        ch = s.charAt(k);
        if ( ch == ' ' )
        {
            alert("°ø¹éÀº »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù..");
            return (false);
        }
    }
    return (true);
}

// ½ºÆ®¸µ¿¡ ½ºÆäÀÌ½º°¡ ÀÖ´ÂÁö¸¦ Ã¼Å©ÇÑ´Ù.
function hasBlankSpace(s)
{
  var es = escape(s);

  if( es.indexOf("%20") >= 0 )
	   return true;
 
  return false;
}

// ³¯Â¥Çü½ÄÀÌ ¸Â´ÂÁö¸¦ Ã¼Å©ÇÑ´Ù. Çü½Ä : YYYYMMDD
function isDateFormat(strDate)
{
      var strMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

      if ( strDate.length != 8 ) return false;

      var YYYY  = eval(strDate.substr(0,4));
      var MM    = eval(strDate.substr(4,2));
      var DD    = eval(strDate.substr(6,2));

      if ( !isNumeric(YYYY) || !isNumeric(MM) || !isNumeric(DD) )
           return false;

      var MonthDays = (MM != 2) ? strMonth[MM-1] : (( YYYY%4==0 && YYYY%100 !=0 || YYYY%400 ==0 ) ? 29:28 );

      if( ( MM <13 && MM >0 && DD >0 && DD <= MonthDays) == false )
         return false;

      return true;
}

// ½ºÆ®¸µ¿¡ ½ºÆäÀÌ½º°¡ ÀÖ´ÂÁö¸¦ Ã¼Å©ÇÑ´Ù.
function checkQuote(s) {
  if( s.indexOf("'") >= 0 )
	   return true;
  else
	  return false;
}

/*
	ÇÊÅÍ¸µÇÒ ´Ü¾î°¡ µé¾îÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
	true : ´Ü¾î¸¦ Æ÷ÇÔÇÏ°í ÀÖÀ½.
	false : ´Ü¾î¸¦ Æ÷ÇÔÇÏÁö ¾ÊÀ½.
*/
function isAvailText(filterList, checkWord) {
	if(filterList == null || filterList.length==0)
		return false;

	if(checkWord == null)
		return false;

	for(var i=0; i < filterList.length; i++) {
		if (checkWord.indexOf(filterList[i])>-1)
			return true;
	}

	return false;
}



function errorImage(obj, size) {
	if(obj == null)
		return;

	try
	{
		var imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_60.gif";
		if(size<=65)
			imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_60.gif";
		else if(size<=80)
			imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_70.gif";
		else if(size<=110)
			imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_90.gif";
		else if(size<=235)
			imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_130.gif";
		else
			imgSrc = "http://poppop.auction.co.kr/img/front/comm/no_img_340.gif";

		obj.src = imgSrc;
	}
	catch (e) {alert(e);}
}


// È°µ¿Á¦ÇÑ 
function chkAvailableAction(limitPenalty, isPenalty) {
	if(isPenalty) {
		alert("¾û¶×Áö¼ö " + limitPenalty + " ÀÌ»óÀÌ¸é È°µ¿ÀÌ Á¦ÇÑµË´Ï´Ù.\n¸¶ÀÌÁ¸¿¡¼­ ¾û¶×Áö¼ö¸¦ È®ÀÎÇØ ÁÖ¼¼¿ä.");
		return (false);
	} else {
		return (true);
	}
}


// iframe »çÀÌÁî Á¶Á¤
function resizeIframe(name) {
	//try {
		var oBody   = document.frames(name).document.body;
		var oIFrame = document.all(name);
		var dWidth = 900;
		
		var frmWidth  = oBody.scrollWidth;
		var frmHeight = oBody.scrollHeight;

		alert(frmHeight);
		alert(oBody.scrollHeight);

		if (frmWidth < dWidth)
			frmWidth = dWidth;
			
		oIFrame.style.width = frmWidth;
		oIFrame.style.height = frmHeight;
		alert(frmHeight);
		window.status = "";
	//} catch (e) {
	//	window.status = "";
	//}
}

function parentResizeIframe(name) {
	if (parent && parent != this && parent.resizeIframe != null) {
		parent.resizeIframe(name);
	}
}

function resizeIframePage(name) {
	resizeIframe(name);
	window.status = "";
	window.setTimeout("resizeIframePage('"+name+"')",1000);
}


function stopAnimatedGIF()
{
   document.execCommand('Stop');
}
