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();
		}
	}

}



//********************* ½ºÅ©·Ñ¸µ *************************//

TextSlider = function(className)
{
	document.write("<div id='TextSliderPLayer_"+ className +"'><div id='TextSliderLayer_"+ className +"'></div></div>");

	this.item = [];
	this.width = this.height = this.speed = this.pixel = this.interval = this.size = this.moveCount = this.X = this.Y = 0;
	this.direction = "";

	this.pLayer	= document.getElementById("TextSliderPLayer_"+ className);
	this.layer	= document.getElementById("TextSliderLayer_"+ className);
	this.align	= "left";
	this.intervalId	= null;
	this.className	= className;
	this.isPause	= false;
}

TextSlider.prototype.init = function()
{
	with (this.pLayer.style)
	{
		width		= this.width +"px";
		height		= this.height +"px";
		overflow	= "hidden";
	}

	with (this.layer.style)
	{
		width	= this.direction == 'up' || this.direction == 'down' || this.direction == 'down_eve' ? this.width +"px" : this.size * (this.item.length + 1) +"px";
		height	= this.direction == 'up' || this.direction == 'down' || this.direction == 'down_eve' ? this.size * (this.item.length + 1) +"px" : this.height +"px";
		top		= 0;
		left	= 0;
		position = "relative";
	}

	for (var i = 0; i < parseInt(this.height / this.size, 10) + 1; i++) {
		this.item[this.item.length] = this.item[i];
	}
//alert(this.item.length);
	switch (this.direction)
	{
		case "up"		: this.X = this.Y = 0;
						  break;

		case "down"		: this.X = 0;
						  this.layer.style.top = this.Y = -this.size * (this.item.length - 1);
						  break;
		case "down_eve"		: this.X = 0;
						  this.layer.style.top = this.Y = -this.size * (this.item.length - 1);
						  break;
		case "left"		: this.X = this.Y = 0;
						  break;

		case "right"	: this.Y = 0;
						  this.layer.style.left = this.X = -this.size * (this.item.length - 1);
						  break;
	}

	var __html = "<div onmouseover='"+ this.className +".pause()' onmouseout='"+ this.className +".unpause()'>";

	if (this.direction == "up" || this.direction == "down" || this.direction == "down_eve")
	{
		__html += "<table width='"+ this.layer.style.width +"' cellspacing='0' cellpadding='0' border='0'>";
		
		for (var i in this.item)
			__html += "<tr><td height='"+ this.size +"' style='overflow:hidden' align='"+ this.align +"' valign='top'>"+ this.item[i] +"</td></tr>";

		__html += "</table>";
	}
	else
	{
		__html += "<table cellspacing='0' cellpadding='0' border='0'><tr>";

		for (var i in this.item)
			__html += "<td width='"+ this.size +"' height='"+ this.layer.style.height +"' align='"+ this.align +"' valign='top' style='overflow:hidden;'>"+ this.item[i] +"</td>";

		__html += "</tr></table>";
	}

	__html += "</div>";

	this.layer.innerHTML = __html;
	this.start();
}

TextSlider.prototype.start = function()
{
	this.intervalId = setInterval(this.className +".move()", this.speed);
}

TextSlider.prototype.move = function()
{
	if (this.isPause) return;

	switch (this.direction)
	{
		case "up"		: this.Y -= this.pixel;
						break;

		case "down"		: this.Y += this.pixel;
						break;
		
		case "down_eve"		: this.Y += this.pixel;
						break;

		case "left"		: this.X -= this.pixel;
						break;

		case "right"	: this.X += this.pixel;
						break;
	}

	if (this.direction == 'up' || this.direction == 'down' || this.direction == 'down_eve')
	{
		if (Math.abs(this.Y) % this.size == 0)
			this.stop();

		this.layer.style.top = this.Y;
	}
	else
	{
		if (Math.abs(this.X) % this.size == 0)
			this.stop();

		this.layer.style.left = this.X;
	}
}

TextSlider.prototype.stop = function()
{
	clearInterval(this.intervalId);

	switch (this.direction)
	{
		case "up"	:
					if (Math.abs(this.Y) >= parseInt(this.layer.style.height, 10) - this.size) this.Y = this.layer.style.top = 0;
					break;

		case "down"	:
					if (Math.abs(this.Y) <= 0) this.Y = this.layer.style.top = -this.size * (this.item.length - 3);
					break;

		case "down_eve"	:
					if (Math.abs(this.Y) <= 0) this.Y = this.layer.style.top = -this.size * (this.item.length - 2);
					break;

		case "left"	:
					if (Math.abs(this.X) >= parseInt(this.layer.style.width, 10) - this.size)
						this.X = this.layer.style.left = 0;
					break;

		case "right":
					if (Math.abs(this.X) <= 0) 
						this.X = this.layer.style.left = -this.size * (this.item.length - 1);
					break;
	}

	setTimeout(this.className +".start()", this.interval);
}

TextSlider.prototype.pause		= function() {this.isPause = true;}
TextSlider.prototype.unpause	= function() {this.isPause = false;}

//******************************* ½ºÅ©·Ñ¸µ ³¡ *****************************//


function selectCombo(obj, val){
	for(i=0; obj.length>i; i++){
		if(obj.options[i].value == val) obj.selectedIndex = i;
	}
	
}

function selectRadio(obj, val){
	if(typeof(obj) != "object") return;

	if(isArray(obj)){
		for(var i=0; i<obj.length; i++){
			if(obj[i].value == val) obj[i].checked = true;
		}
	}
	else{
		if(obj.value == val) obj.checked = true;
	}
}

function checkboxAllCheck(obj, chkStatus){

	if(typeof(obj) != "object") return;

	if(isArray(obj)) for(var i=0; i<obj.length; i++) obj[i].checked = chkStatus;
	else obj.checked = chkStatus;
}
