function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function open_window(TITLE,URL, WIDTH, HEIGHT) { 
	
	windowprops = "left=0,top=0,width=" + WIDTH + ",height=" + HEIGHT + ",resizable=yes,scrollbars=yes"; 
	window.open(URL, TITLE , windowprops); 
}

function open_window_no_scroll(TITLE,URL, WIDTH, HEIGHT) { 
	
	windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT + ",resizable=yes,scrollbars=no"; 
	window.open(URL, TITLE , windowprops); 
}

function open_window_no_scroll_no_resize(TITLE,URL, WIDTH, HEIGHT) { 
	
	windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT + ",resizable=no,scrollbars=no"; 
	window.open(URL, TITLE , windowprops); 
}

function open_qna_window(TITLE,URL, WIDTH, HEIGHT) { 
	
	windowprops = "left=50%,top=50%,width=" + WIDTH + ",height=" + HEIGHT + ",resizable=yes,scrollbars=no"; 
	window.open(URL, TITLE , windowprops); 
}

function checkEmail(email) {
	
	var a = email.indexOf("@");

	email_account = email.substring(0,a);
	email_domain = email.substring(a+1);

	if(!checkEmailAccount(email_account))
	{
		return false;
	}
	if(!checkEmailDomain(email_domain))
	{
		return false;
	}

	return true;

}

function checkEmailAccount(email) {

	var comp="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.";
	var t = email;
	var ValidFlag = false
	var atCount = 0
	var SpecialFlag
	var atLoop
	var atChr
	var BadFlag
	var len = t.length;

	if ( t.length > 0 ) {
		atCount = 0
		SpecialFlag = false

		for( atLoop=1; atLoop<=t.length; atLoop++ ) {

			if(comp.indexOf(t.substring(atLoop,atLoop+1))<0)
			{
				return false;
				break;
			}
			atChr = t.substring( atLoop, atLoop+1 )

			if ( (atChr >= 32) && (atChr <= 44) ) SpecialFlag = true 
			if ( (atChr == 47) || (atChr == 96) || (atChr >= 123) ) SpecialFlag = true 
			if ( (atChr >= 58) && (atChr <= 63) ) SpecialFlag = true 
			if ( (atChr >= 91) && (atChr <= 94) ) SpecialFlag = true 
		}

		if ( SpecialFlag == false ) {
			BadFlag = false
			ValidFlag = true
		}

	}
	
	if ( BadFlag == true ) ValidFlag = false

	return ValidFlag
}

function checkEmailDomain(email) {

	var comp="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.";
	var t = email;
	var ValidFlag = false
	var atCount = 0
	var SpecialFlag
	var atLoop
	var atChr
	var BadFlag = true
	var len = t.length;
	
	if ( t.length > 0 && t.indexOf(".") > 0 ) {
		atCount = 0
		SpecialFlag = false

		for( atLoop=1; atLoop<=t.length; atLoop++ ) {

			if(comp.indexOf(t.substring(atLoop,atLoop+1))<0)
			{
				return false;
				break;
			}
			atChr = t.substring( atLoop, atLoop+1 )
			if ( atChr == "." ) atCount = atCount + 1

			if ( (atChr >= 32) && (atChr <= 44) ) SpecialFlag = true 
			if ( (atChr == 47) || (atChr == 96) || (atChr >= 123) ) SpecialFlag = true 
			if ( (atChr >= 58) && (atChr <= 63) ) SpecialFlag = true 
			if ( (atChr >= 91) && (atChr <= 94) ) SpecialFlag = true 
		}

		if ( ( atCount > 0 ) && (SpecialFlag == false ) ) {


			BadFlag = false

			if ( t.substring( 1, 2 ) == "." ) BadFlag = true
			if ( t.substring( t.length-1, t.length) == "." ) BadFlag = true
			ValidFlag = true
		}
	}
	if ( BadFlag == true ) ValidFlag = false

	return ValidFlag
}

function checkDigitAlpha(id) {

	var comp="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var t = id;
	var ValidFlag = false
	var atCount = 0
	var SpecialFlag
	var atLoop
	var atChr
	var BadFlag = true
	var len = t.length;
	
	if ( t.length > 0 ) {
		atCount = 0
		SpecialFlag = false

		for( atLoop=1; atLoop<=t.length; atLoop++ ) {

			if(comp.indexOf(t.substring(atLoop,atLoop+1))<0)
			{
				return false;
				break;
			}
			atChr = t.substring( atLoop, atLoop+1 )

			if ( (atChr >= 32) && (atChr <= 44) ) SpecialFlag = true 
			if ( (atChr == 47) || (atChr == 96) || (atChr >= 123) ) SpecialFlag = true 
			if ( (atChr >= 58) && (atChr <= 63) ) SpecialFlag = true 
			if ( (atChr >= 91) && (atChr <= 94) ) SpecialFlag = true 
		}

		if ( SpecialFlag == false ) {


			BadFlag = false
			ValidFlag = true
		}
	}
	if ( BadFlag == true ) ValidFlag = false

	return ValidFlag
}


function checkDigit(id) {
	
	var comp="0123456789";

	if ( id.length > 0 ) {
		
		for(var i=0;i<id.length;i++ ) {
			
			if(comp.indexOf(id.substring(i,i+1))<0)
			{
				return false;
			}
		}
		
		return true;

	} else {
		
		return false;
	}
}


function checkNumber(field, totField)
{
  if(!checkDigit(field.value))
  {
    field.value = field.value.substring(0, field.value.length - 1);
  }
}

function checkjumin(jumin)
{
	if(jumin.length != 13)
	{
		return false;
	}
	else
	{
		a = new Array(6)
		b = new Array(7)
		tot=0
		c=0
		for(i=1;i<7;i++) 
		{
				a[i]=jumin.substring(i-1,i)
				b[i]=jumin.substring(5+i,6+i)
				if(i<3) 
				{
				c=Number(b[i])*(i+7)
				}
				else if(i>=3) 
				{
				c=Number(b[i])*((i+9)%10)
				}
				tot = tot + Number(a[i])*(i+1) + c
		}
		b[7]=jumin.substring(12,13)
		if(Number(b[7]) != ((11-(tot%11))%10)) 
		{
				return false;
		}
	}
	
	return true;
}

function FormManager(form)
{
  this.form = form;
  this.essential = new Array();
  this.essentialName = new Array();
  
  this.setEssential = function(ess)
  {
    this.essential = ess.split(',');
  }

  this.setEssentialName = function(essName)
  {
    this.essentialName = essName.split(',');
  }

  this.checkForm = function()
  {
    for(var i = 0; i< this.essential.length; i++)
    {
      var length = form.elements[this.essential[i]].length;
      var type = form.elements[this.essential[i]].type;
      
      //radio³ª °°Àº ÀÌ¸§ÀÇ ÆûÅ¸ÀÔÀÌ ÀÖÀ» ¶§
      if(type != "select-one" && length != null && length > 0)
      {
        type = form.elements[this.essential[i]][0].type;
      }

      if(type == "text" || type == "textarea" || type == "password")
      {
        result = this.checkText(i, form.elements[this.essential[i]]);

        if(!result) return result;

      } else if(type == "radio")
      {
        result = this.checkRadio(i, form.elements[this.essential[i]]);

        if(!result) return result;

      } else if(type == "select-one")
      {
        result = this.checkSelect(i, form.elements[this.essential[i]]);

        if(!result) return result;

      } else if(type == "checkbox")
      {
        result = this.checkCheckBox(i, form.elements[this.essential[i]]);

        if(!result) return result;

      }  else if(type == "hidden")
      {
        result = this.checkHidden(i, form.elements[this.essential[i]]);

        if(!result) return result;
      }
    }

	return true;
  }
  
  this.checkText = function(index, element)
  {
    if(element.value.length < 1)
    {
      alert('ÀÔ·Â ´©¶ôµÈ ÇÊµå°¡ ÀÖ½À´Ï´Ù : "' + this.essentialName[index] + '"');
      element.focus();
      return false;
    }
    
    return true;
  }

  this.checkHidden = function(index, element)
  {
    if(element.value.length < 1)
    {
      alert('ÀÔ·Â ´©¶ôµÈ ÇÊµå°¡ ÀÖ½À´Ï´Ù : "' + this.essentialName[index] + '"');

      return false;
    }
    
    return true;
  }

  this.checkRadio = function(index, element)
  {
    for(var i=0; i< element.length; i++)
    {
      if(element[i].checked)
      {
        return true;
      }
    }

    alert('ÀÔ·Â ´©¶ôµÈ ÇÊµå°¡ ÀÖ½À´Ï´Ù : "' + this.essentialName[index] + '"');
    element[0].focus();

    return false;
  }
  
  this.checkSelect = function(index, element)
  {
    if(!element.value)
    {
      alert('ÀÔ·Â ´©¶ôµÈ ÇÊµå°¡ ÀÖ½À´Ï´Ù : "' + this.essentialName[index] + '"');
      element.focus();
      return false;
    }
    return true;
  }

  this.checkCheckBox = function(index, element)
  {
    if(!element.checked)
    {
      alert('ÀÔ·Â ´©¶ôµÈ ÇÊµå°¡ ÀÖ½À´Ï´Ù : "' + this.essentialName[index] + '"');
      element.focus();
      return false;
    }
    return true;
  }


}


function showTooltip(motorName){
	
    var html = 
      '<table width=125 bgcolor="#0033CC" cellspacing="1" cellpadding="0">' + 
      '  <tr>' + 
      '    <td>' + 
      '      <table width=100% bgcolor="#FFFF99" cellpadding="0">' + 
      '        <tr>' + 
      '          <td>' + motorName + '</td>' + 
      '        </tr>' + 
      '      </table>' + 
      '    </td>' + 
      '  </tr>' + 
      '</table>';

    document.all["motor"].innerHTML = html;
    document.all["motor"].style.left = event.clientX +2;
	document.all["motor"].style.top = document.body.scrollTop + event.clientY +2;
    document.all["motor"].style.visibility = 'visible';

}

function hideTooltip(motorName){
	
    document.all["motor"].style.visibility = 'hidden';
    
}

function NumObj(obj) {

	if (event.keyCode >= 48 && event.keyCode <= 57) { //¼ýÀÚÅ°¸¸ ÀÔ·Â
		return true;
	} else {
	event.returnValue = false;
	}

}

/*
ÇÔ¼ö NumOnly(event) = ÀÔ·ÂÆû¿¡ ¼ýÀÚ¸¸ ÀÔ·Â
Internet Explorer¿Í Netscape/Firefox/Opera ¸ðµÎ »ç¿ë°¡´É
»ç¿ë¿¹Á¦) <input name="phone_1" type="text" size="4" maxlength="4" style="ime-mode:disabled;" onKeyPress="NumOnly(event);"/>
*/
function NumOnly(e) {
	var keynum;

	if(window.event) // IE
	{
		keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}

	if (keynum >= 48 && keynum <= 57) { //¼ýÀÚÅ°¸¸ ÀÔ·Â
		return true;
	} else {
		if(window.event) // IE
		{
			e.returnValue = false;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			e.preventDefault();
		}
	}

}