﻿var firstCall = true;
function changeFontsize(fSize, increment) {
	if (firstCall) {
		firstCall = false;
		if (increment != "") {
			changeFontsize('12', '');
		}
	}
	if (document.getElementsByTagName) {
	var getElement = document.getElementsByTagName("*");
	var eachElement, currentFontSize, fontIncrease, newFontSize;
	for (i=0; i<getElement.length; i++) {
		eachElement = getElement[i];
		if (increment != "") {
			currentFontSize = parseInt(eachElement.style.fontSize);
			fontIncrease = parseInt(increment);
			newFontSize = currentFontSize + fontIncrease;
		}
		else if (fSize != "") {
			newFontSize = parseInt(fSize);
		}
		if (getElement[i].tagName == "LI") {
			eachElement.style.lineHeight = Math.round(newFontSize*1.2) + "px";
		} else {
			//eachElement.style.lineHeight = Math.round(newFontSize*1.5) + "px";
		}
		if (fSize != "") {
			switch(getElement[i].tagName) {
				case "H2": newFontSize += 3; break;
				case "H3": newFontSize += 2; break;
				case "H4": newFontSize += 1; break;
				case "H5": newFontSize += 1; break;
				case "H6": newFontSize += 1;
			}
		}
		//eachElement.style.fontSize = newFontSize + "px";
		
		if(newFontSize > 17) {
			return;
		}else if(newFontSize < 13) {
			eachElement.style.fontSize = "12px"
		}else {
			eachElement.style.fontSize = newFontSize + "px";
		}

		//setCookie('fontSize', newFontSize);
	}
}
}

//-----------------------------------------------------------------------------
// MM_findObj
//-----------------------------------------------------------------------------

function MM_findObj(n, d) { //v4.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);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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 errorMSG(str){
	alert(str);
}


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 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 moveFocus(num, fromform, toform) {
    var str = fromform.value.length;
    if(str == num)
       toform.focus();

    return;
}


function fsearch_submit(){
	var f = document.fsearch;
	if(f.search_stx.value == ""){
		alert("검색어를 입력하셔야 됩니다.");
		f.search_stx.focus();
		return false;
	}

	var ischeck = isCheckLength(f.search_stx.value, 2);
	if(!ischeck){
		alert("검색어는 2자 이상으로 입력하셔야 됩니다.");
		f.search_stx.focus();
		return false;
	}

	f.action = "/07_utility/Total_Search.php";
	f.submit();
}
function isCheckLength(val, length) {
 var length_Of_Val = 0;
 for(var i = 0; i < val.length; ++i) {
   var oneChar = escape(val.charAt(i));
        if ( oneChar.length == 1 ) {
            length_Of_Val ++;
        } else if (oneChar.indexOf("%u") != -1) {
            length_Of_Val += 2;
        } else if (oneChar.indexOf("%") != -1) {
            length_Of_Val += oneChar.length/3;
        }
    }
    if(length < length_Of_Val) {
     return true;
    }
 return false;
}
