function setCookie(name, value)
{
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;

    var expires = argc > 2 ? argv[2] : null;
//    var path = argc > 3 ? argv[3] : null;
    var path = argc > 3 ? argv[3] : "/";
    //var domain = argc > 4 ? argv[4] : null;
    var domain = ".ec21.com";
    var secure = argc > 5 ? argv[5] : false;

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

function getCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen=document.cookie.length;
    var i=0;

    while(i< clen){
        var j = i+alen;
        if(document.cookie.substring(i,j)==arg) {
            var end = document.cookie.indexOf(";",j);
            if (end == -1) {
                end = document.cookie.length;
            }
            return unescape(document.cookie.substring(j,end));
        }
        i = document.cookie.indexOf(" ",i)+1;
        if (i==0) {
            break;
        }
    }
    return null;
}

function parse( OrgStr, Delimiter )
{
	param = new Array()
	if ( OrgStr == null || OrgStr == "")
	{
		return param;
	}
	var pos = 0;
	var i = 0;
	var Val = "";

	while ( (pos = OrgStr.indexOf(Delimiter)) > 0 )
	{
		Val = OrgStr.substring(0, pos);
		param[i] = Val;
		OrgStr = OrgStr.substring(pos+1, OrgStr.length);
		++i;
	}
	return param;
}

function getMail()
{
    //document.location.href = "http://mail1.ec21.com";
    //alert('EC21 is currently upgrading its e-mail system. (October 9, 2004, 21:00 (GMT +9:00) - October 10, 2004, 21:00 (GMT+09:00)). Sorry for any inconvenience and please try logging in after the upgrade is completed. ');
    document.location.href = "http://www.ec21.com/global/member/EC21Mail.jsp";
    return;
}
function checkLogin()
{
    if (document.dataForm.user_id.value.length == 0) {
        document.dataForm.user_id.focus();
        alert( "Please Enter Login ID.!!!" );
        return;
    } else if (document.dataForm.user_pw.value.length == 0) {
        document.dataForm.user_pw.focus();
        alert( "Please Enter Password.!!!" );
        return;
    } else {
        document.dataForm.target = '_top';
        document.dataForm.action = 'http://www.ec21.com/global/login/LoginSubmit.jsp?nextEvent=/global/basic/MyEC21.jsp';
        document.dataForm.submit();
    }

    return;
}

function EnterCheck( i )
{
    if( event.keyCode == 13 && i==1 ) {
        document.dataForm.user_pw.focus();
    }

    if( event.keyCode == 13 && i==2 ) {
        checkLogin();
    }
}
function checkQueryForm(theForm)
{
    if (theForm.query.value == "") {
        alert("Please Enter your keyword(s).");
        theForm.query.focus();
        return false;
    }
    return true;
}
function getMainImg() {
	var browserLang;
	if (navigator.appName == "Netscape") {
		browserLang = navigator.language;
	}else{
		browserLang = navigator.userLanguage;
	}
	var filenum =  Math.ceil(Math.random() * 6);
	if (filenum == 1) {
		document.write("<a href=\"http://www.s-trademart.com\" target=\"_blank\"><IMG SRC=http://www.ec21.com/images/app/ec/main_img" + filenum + ".jpg border=0></a>") ;
	} else if (filenum > 1) {
		document.write("<a href=\"http://www.ec21.com/app/jsp/ec/BannerLog.jsp?bannerId=Main&bannerURL=www.ec21.com/doc/app/content/recommend.html&browserLang="+browserLang+"\"><IMG SRC=http://www.ec21.com/images/app/ec/main_img" + filenum + ".jpg border=0></a>") ;
	} else {
		document.write("<IMG SRC=http://www.ec21.com/images/app/ec/main_img" + filenum + ".jpg border=0>") ;

	}
}
function getMainImg1() {
	var browserLang;
	if (navigator.appName == "Netscape") {
		browserLang = navigator.language;
	}else{
		browserLang = navigator.userLanguage;
	}
	var filenum =  Math.ceil(Math.random() * 6);
	if (filenum == 1) {
		document.write("<a href=\"http://www.s-trademart.com\" target=\"_blank\"><IMG SRC=http://www.ec21.com/images/app/ec/main_img" + filenum + ".jpg border=0></a>") ;
	} else {
		document.writeln("             <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"580\" height=\"113\">");
		document.writeln("                <param name=movie value=\"/images/app/ec/index/m_mov.swf\">");
		document.writeln("                <param name=quality value=high>");
		document.writeln("                <embed src=\"/images/app/ec/index/m_mov.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"580\" height=\"113\">");
		document.writeln("                </embed> ");
		document.writeln("             </object>");
	}
}

function getNMainImg() {
	var browserLang;
	if (navigator.appName == "Netscape"){
		browserLang = navigator.language;
	}else{
		browserLang = navigator.userLanguage;
	}
	var filenum =  Math.ceil(Math.random() * 7);
/*
	if (filenum == 1)
	{
		document.write("<a href=\"http://www.cybertrade-21.com\"  target=\"_new\"><img src=\"/images/app/ec/index/ban_jennam.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 2)
	{
		document.write("<a href=\"#\"><img src=\"/images/app/ec/index/nm_ban03.gif\" width=\"175\" height=\"69\" border=\"0\" onClick=\"MM_openBrWindow('http://www.ec21.com/doc/app/business/localsmes01.htm','smes','scrollbars=yes,width=476,height=500')\" ></a>") ;
	}
	else if (filenum == 3)
	{
		document.write("<a href=\"http://www.iitp.net\"  target=\"_new\"><img src=\"/images/app/ec/index/ban_incheon.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 4)
	{
		document.write("<a href=\"http://www.dctc.co.kr\"  target=\"_new\"><img src=\"/images/app/ec/index/deagu_ban.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
*/
	if (filenum == 1)
	{
		document.write("<a href=\"http://www.agrotrade.net\"  target=\"_new\"><img src=\"/images/app/ec/index/agrotrade_s.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 2)
	{
		document.write("<a href=\"http://www.asean3.net/\"  target=\"_new\"><img src=\"/images/app/ec/index/banner_asean3.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 3)
	{
		document.write("<a href=\"http://www.bestsme.com/\"  target=\"_new\"><img src=\"/images/app/ec/index/bestsme.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 4)
	{
		document.write("<a href=\"http://www.trade-india.com\"  target=\"_new\"><img src=\"/images/app/ec/index/nm_ban02.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 5)
	{
		document.write("<a href=\"http://www.biz-channel.com\"  target=\"_new\"><img src=\"/images/app/ec/index/nm_ban04.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 6)
	{
		document.write("<a href=\"http://www.thailand.com/exports/index.php\"  target=\"_new\"><img src=\"/images/app/ec/index/nm_ban05.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
	else if (filenum == 7)
	{
		document.write("<a href=\"http://www.made-in-china.com\"  target=\"_new\"><img src=\"/images/app/ec/index/nm_ban06.gif\" width=\"175\" height=\"69\" border=\"0\"></a>") ;
	}
}

/******************************** ¹è³Ê ¼øÈ¯ *********************************/

no = -1;
bimg_no = 7;

function startbn() {
no++;
if (no > (bimg_no - 1))
no = 0;
document.all.href_url.innerHTML=bnbox.children[no].children.bimg.innerHTML;
document.all.href_url.href=bnbox.children[no].children.url.innerText;
setTimeout("startbn()", 5000);
}

/******************************** ¹è³Ê ¼øÈ¯ *********************************/


function changeHomeUrlAlert()
{
    alert('This service is temporarily interrupted \n Please try again later');
	return;
}
function replaceSC(allDesc){
    var descX = allDesc.value;
    var newDescX = "";
    var post = 0;
    for (var i = 0; i < descX.length; i++)
    {
        if (descX.charCodeAt(i) == 169 || descX.charCodeAt(i) == 174 || descX.charCodeAt(i) == 176 ||
            descX.charCodeAt(i) == 177 || descX.charCodeAt(i) == 181 || descX.charCodeAt(i) == 216 ||
            descX.charCodeAt(i) == 8451 || descX.charCodeAt(i) == 8457 || descX.charCodeAt(i) == 160)
        {
            var str = descX.substring(post, i);

            switch(descX.charCodeAt(i))
            {
                case 8451 : str += '&#176;C'; break;
                case 8457 : str += '&#176;F'; break;
                case 160  : str += '&nbsp;'; break;
                default   : str += '&#' + descX.charCodeAt(i) + ';';
            }
            if (i + 1 > descX.length) break;
            post = i + 1;
            newDescX += str;
        }
        else
        {
            var str = "";
            if (i == descX.length - 1)
                str = descX.substring(post);
            else
                str = descX.substring(post, i);
            newDescX += str;
            post = i;
        }
    }
    allDesc.value = newDescX;
}


//images/app/ec/index/seoul_ban.gif

// ec21¿¡ ¹æ¹®ÇÏ¿´À½À» ¼¼ÆÃÇÑ´Ù.
// setCookie('ec21_visit','1');


//
function searchX(){

    var form = document.dataForm1;
    var keyword = form.keyword.value;

    if(keyword.length < 1) {
        alert('Please, Enter your keyword.');
        form.keyword.focus();
        return false;
    }

    if(form.srchType.value =='0')
        form.action = 'http://products.ec21.com/manufacturers/'+keyword + ".html";
    else if(form.srchType.value =='1')
        form.action = 'http://trade.ec21.com/trade_leads/TradeSearch?gubun=1&keyword='+keyword;
    else if(form.srchType.value =='2')
        form.action = 'http://suppliers.ec21.com/companies/CompanySearch?keyword='+keyword;
    else if(form.srchType.value =='3')
        form.action = 'http://www.ec21.com/global/common/SearchBuyer.jsp';
	else
	{
		alert('');
		return false;
	}

//    form.submit();
    //return true;
}



var imgObj = new Image();


function showImgWin(imgName) {
  imgObj.src = imgName;
  setTimeout("createImgWin(imgObj)", 100);
}


function createImgWin(imgObj) {
  if (! imgObj.complete) {
    setTimeout("createImgWin(imgObj)", 100);
    return;
  }
  imageWin = window.open("", "imageWin",
    "width=" + imgObj.width + ",height=" + imgObj.height);
  imageWin.document.write("<html><body style='margin:0'>");
  imageWin.document.write("<a href=javascript:window.close()><img src='" + imgObj.src + "' border=0></a>");
  imageWin.document.write("</body><html>");
  imageWin.document.title = imgObj.src;
}





function doNothing(){}

function pop(pPage,Opt) {

popUpWin = window.open(pPage,'',Opt);

}



function isNull ( ObjVal )
{
	var inValue = null;
	if ( isObject(ObjVal))
	{
		inValue = ObjVal.value;
	}
	else
		inValue = ObjVal;

   if (inValue == null || inValue == "")
      return true;

   return false;
}


function isObject ( obj )
{
   if (obj)
      return true;
   else
      return false;
}


function SelectPreOption ( SelectFormName, SelectedValue )
{
   for ( var i=0; i < SelectFormName.options.length; ++i )
   {
      if ( SelectFormName.options[i].value == SelectedValue )
      {
         SelectFormName.options[i].selected = true;
         break;
      }
   }
}


function PreRadioCheck( RadioName, preValue)
{
	for(var i=0;i<RadioName.length;i++)
	{
		if(RadioName[i].value==preValue)
		{
			RadioName[i].click();
		}
	}
}

function CheckPre ( CheckboxName )
{
   CheckboxName.click();
   CheckboxName.disabled;
}


// ÀÔ·ÂµÈ ³¯Â¥ Çü½ÄÀÌ ¿Ã¹Ù¸¥Áö¸¦ °Ë»çÇÏ°í, Á¤È®ÇÑ ³¯Â¥ÀÎÁö °Ë»çÇÑ´Ù.
// ÀÔ·Â °ª : ³¯Â¥ Çü½ÄÀÇ String
// ¸®ÅÍ °ª : boolean

function checkDate(strDate)
{
   
   var arrDate;
   var chkDate
	var Del = "/-.";

	if (IsNumeric(strDate) == true || strDate.length == 8)
	{
		arrDate = new Array(3);
		arrDate[0] = strDate.substring(0,4);
		arrDate[1] = strDate.substring(4,6);
		arrDate[2] = strDate.substring(6,8);
	}
	else
	{
		for (var i=0; i<Del.length; ++i)
		{
			if (strDate.indexOf(Del.charAt(i)) >= 0)
			{
				arrDate = strDate.split(Del.charAt(i));
			}
		}
	}
   

   if (arrDate.length != 3) {
      return false;
   }
   chkDate = new Date(arrDate[0] + "/" + arrDate[1] + "/" + arrDate[2]);
   
   if (isNaN(chkDate) == true ||
      (arrDate[1] != chkDate.getMonth() + 1 || arrDate[2] != chkDate.getDate())) {
      return false;
   }
   
   return true;
}




function replaceText ( OrgStr, Target, Change )
{
	var index, len=0;
	var fullStr = '';

	while ( (index=OrgStr.indexOf(Target)) >= 0) 
	{
		fullStr = fullStr + ''+ OrgStr.substring(0,index) + ''+Change ;

		OrgStr = OrgStr.substring(index+Target.length);
	}
	return fullStr+''+OrgStr;
}


function checkEmail(strEmail) {   
   var arrMatch = strEmail.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
   if (arrMatch == null) {
      return false;
   }

   var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
   if (arrIP != null) {
      for (var i = 1; i <= 4; i++) {
         if (arrIP[i] > 255) {
            return false;
            }
         }
   }
   return true;
}

// String ÀÇ ±æÀÌ¸¦ °è»êÇÑ´Ù. ÇÑ±ÛÀÌ¸é 2°³.
// ÀÔ·Â °ª : Object(textarea, text ...), Çã¿ëÃÖ´ë±æÀÌ, ÇÊµå (Á¦¸ñ, ³»¿ë ...etc)
// ¸®ÅÍ °ª : boolean

function CheckStrLen(obj, MaxLen, FieldName) {
   var i, len=0;

   if (!obj) {
      alert('°´Ã¼°¡ Á¤ÀÇµÇÁö ¾Ê¾Ò½À´Ï´Ù.');
      return false;
   }

   var s = obj.value;
   
    
   for(i=0;i < s.length; i++) 
      (s.charCodeAt(i) > 255)? len+=2:len++;
   
   if (MaxLen < len) {
      if (FieldName != "") alert("'"+FieldName + "' ÀÇ ÃÖ´ë ÀÔ·Â ±æÀÌ´Â " + MaxLen + "ÀÚ ÀÔ´Ï´Ù. (ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)\n      ÀÔ·ÂµÈ ±ÛÀº ["+len+"]ÀÚ ÀÔ´Ï´Ù.");
//      obj.focus();
      return false;
   }
   return true;
}


function Trim(strSrc, intMaxLen) {
   var i;
   var intLen = 0;
   
   for (i = 0; i < strSrc.length; i++) {
      (strSrc.charCodeAt(i) > 255) ? intLen += 2 : intLen++;
      
      if (intLen > intMaxLen) {
         strSrc = strSrc.substring(0, i);
         break;
      }
   }
   
   return strSrc;
}


function IsNumeric(checkStr)
{
   var checkOK = "0123456789";
     for (i = 0;  i < checkStr.length;  i++)
    {
          ch = checkStr.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 trimZero(Digit)
{
   var i = 0;

   while ( i <= Digit.length )
   {
      ch = Digit.charAt(i);
      if ( ch == "0" )
      {
         Digit = Digit.substring(1,Digit.length);
         i = 0;
         continue;
      }
      else
         break;
      ++i;
   }

   return Digit;
}


function isAnyHtmlTag ( obj, name )
{
   if ( !isObject(obj) )
   {
      return (true);
   } 

   str=obj.value;

   HtmlTag=/<script|<object|<style|\bhref|\bonload|<applet|<meta|<iframe|\bonmouseover|\bonclick|\bonunload|<link|<span|<div|javascript:|<table|<\/table|<tr|<\/tr|<td|<\/td|<form|\bwidth|\bheight|<embed|<th|<\/th|<select|<option|<button|<xmp|\bonstart|<textarea|<font|<b>|<a href/gi;

   found=str.match(HtmlTag);

   if(found != null){
      alert("["+name+"] ÇÊµå¿¡ HTML ÅÂ±×¸¦ »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
      obj.focus();
      obj.select();
      return (true);
   }   
   return (false);
}

function isWebImage ( obj )
{
   if ( !isObject(obj) )
      return false;

   ImageFile = obj.value;
 
   idx = ImageFile.lastIndexOf(".")

   if ( idx > 0 )
   {
      extension = ImageFile.substring(idx+1, ImageFile.length);
      extension = extension.toUpperCase();

      if( extension == "BMP" || extension == "GIF" || extension == "JPG" || extension == "JEPG"  )
         return true;
      else
         return false;
   }
   else
      return false;
}

function open_win ( URL )
{
   var Opt = 'toolbar=1,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=auto,width=250,height=150';
   win_name = window.open ( URL,"aa",Opt);
   if (win_name)
      win_name.focus();
}

function open_win ( URL, WIDTH, HEIGHT )
{
   var Opt = 'toolbar=1,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width='+WIDTH+',height='+HEIGHT;
   win_name = window.open ( URL,"aa",Opt);
   if (win_name)
      win_name.focus();
}

// ÀÔ·ÂÇÑ ¹®ÀÚ°¡ ¼Ò¹®ÀÚÀÌ¸é ¹«Á¶°Ç ´ë¹®ÀÚ·Î º¯È¯ÇÑ´Ù.
// ÀÔ·Â °ª : obj -ÀÔ·Â°´Ã¼, even - ¹ß»ýÀÌº¥Æ®
// ¸®ÅÏ °ª : ¹®ÀÚ


function toUpperCase(obj, e) {
	  var whichCode = (window.Event) ? e.which : e.keyCode;
	  whichChar = String.fromCharCode(whichCode).charAt(0);

	  if(whichChar.charAt(0) >= 'a' && whichChar.charAt(0) <= 'z')
		e.keyCode = e.keyCode-32;
}

// MoneyFormat ¿¡ ÇØ´çÇÏ´Â ¹®ÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. (1234567890,)
// ÀÔ·Â °ª : obj -ÀÔ·Â°´Ã¼, even - ¹ß»ýÀÌº¥Æ®
// ¸®ÅÏ °ª : ¹®ÀÚ

// ½ÇÁ¦ »ç¿ë ¿¹½Ã : onKeyPress="return MoneyFiler(this, event);" 


function MoneyFiler(obj, e) {
	  var whichCode = (window.Event) ? e.which : e.keyCode;
	  whichChar = String.fromCharCode(whichCode).charAt(0);

	  if( '0' <= whichChar.charAt(0) && whichChar.charAt(0) <= '9' || whichChar.charAt(0) == ',')
		  ;
	  else
		e.keyCode = null;
}

// »ç¾÷ÀÚ ¹øÈ£ Ã¼Å© ·ÎÁ÷
// ÀÔ·Â °ª : »ç¾÷ÀÚ ¹øÈ£ ÀÔ·ÂÇÊµå
// ¸®ÅÍ °ª : boolean 

function chkBizNo(sSerial) {
    var objstring=sSerial.replace(/D/g,"");
    
    if (objstring.length !=10) return false;
 
    var biz_value=new Array(10);
    var li_temp, li_lastid;
 

    biz_value[0] = ( parseFloat(objstring.substring(0 ,1)) * 1 ) % 10; 
    biz_value[1] = ( parseFloat(objstring.substring(1 ,2)) * 3 ) % 10; 
    biz_value[2] = ( parseFloat(objstring.substring(2 ,3)) * 7 ) % 10; 
    biz_value[3] = ( parseFloat(objstring.substring(3 ,4)) * 1 ) % 10; 
    biz_value[4] = ( parseFloat(objstring.substring(4 ,5)) * 3 ) % 10; 
    biz_value[5] = ( parseFloat(objstring.substring(5 ,6)) * 7 ) % 10; 
    biz_value[6] = ( parseFloat(objstring.substring(6 ,7)) * 1 ) % 10; 
    biz_value[7] = ( parseFloat(objstring.substring(7 ,8)) * 3 ) % 10; 
    li_temp = parseFloat(objstring.substring(8,9)) * 5 + "0"; 
    biz_value[8] = parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2)); 
    biz_value[9] = parseFloat(objstring.substring(9,10)); 
 
    li_lastid = (10 - ( ( biz_value[0] + biz_value[1] + biz_value[2] 
    + biz_value[3] + biz_value[4] + biz_value[5] + biz_value[6] 
    + biz_value[7] + biz_value[8] ) % 10 ) ) % 10; 
   
    return biz_value[9]==li_lastid ? true : false;
}

function parseString ( OrgStr, Delimiter )
{
	param = new Array()
	if ( OrgStr == null || OrgStr == "")
	{
		return param;
	}
	var pos = 0;
	var i = 0;
	var Val = "";

	while ( (pos = OrgStr.indexOf(Delimiter)) > 0 )
	{
		Val = OrgStr.substring(0, pos);
		param[i] = Val;
		OrgStr = OrgStr.substring(pos+1, OrgStr.length);
		++i;
	}
	return param;
}

function resizeMe(obj)
{ 
	try
	{
		docHeight = adver.document.body.scrollHeight
		//alert (docHeight);
		obj.style.height = docHeight+10 + 'px'
	}
	catch( e )
	{
	}
} 

// ¿µ¹®°ú Æ¯¼ö¹®ÀÚ ÀÏ¶§ true
function check(str){   
        for(i=0;i<str.length;i++){   
        if(str.charCodeAt(i)>256)
                return true;   
        }
        return false;
} 
