function chkForm(f)
{ 
	if(arguments[1]) var e=arguments[1];

    var i,tempElement;

    for(i = 0; i < f.elements.length; i++){ 
        tempElement = f.elements[i]; 
        //필수 항목을 체크한다.  
        if (tempElement.getAttribute("required") != null) { 

            if(tempElement.type.toLowerCase() == "text" || 
			   tempElement.type.toLowerCase() == "hidden" ||
               tempElement.tagName.toLowerCase() == "select" || 
               tempElement.tagName.toLowerCase() == "textarea") { 
                if(!chkText(tempElement,tempElement.getAttribute("errmsg"),e)) return false; 

            } else if(tempElement.type.toLowerCase() == "password") { 
                if(!chkText(tempElement,tempElement.getAttribute("errmsg"),e)) return false; 
	
            } else if(tempElement.type.toLowerCase() == "checkbox") { 
                if(!chkCheckbox(f, tempElement,tempElement.getAttribute("errmsg"),e)) return false; 

            } else if(tempElement.type.toLowerCase() == "radio") { 
                if(!chkRadio(f, tempElement,tempElement.getAttribute("errmsg"),e)) return false; 

            }
        }
        // 입력 페턴을 체크한다.
        if(tempElement.getAttribute("option") != null && tempElement.value.length > 0){ 
            if(!chkPatten(tempElement,tempElement.option,tempElement.getAttribute("errmsg"),e)) return false; 
        }

		// 금지단어 체크.
		if(tempElement.getAttribute("xwordCheck") != null) {
            if(tempElement.type.toLowerCase() == "text" || 
			   tempElement.type.toLowerCase() == "hidden" ||
               tempElement.tagName.toLowerCase() == "select" || 
               tempElement.tagName.toLowerCase() == "textarea") { 
                if(!chkXword(tempElement,e)) return false; 
            }
		}

	}

	for(i = 0; i < f.elements.length; i++){ 
		var Obj = f.elements[i];
		if(Obj.type) {
			var ObjType = Obj.type.toLowerCase();
		
			if (ObjType == "button" || ObjType == "submit" || ObjType == "reset") {
				Obj.disabled = true; 
			}
		}
	} 


}

function chkPatten(field,patten,name,e)
{ 
    var regNum =/^[0-9]+$/; 
    var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;                     // 형식 : 033-1234-5678
    var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/; 
    var regDomain =/^[.a-zA-Z0-9-]+.[a-zA-Z]+$/; 
    var regAlpha =/^[a-zA-Z]+$/; 
    var regHost =/^[a-zA-Z-]+$/; 
    var regId = /^[a-zA-Z]{1}[a-zA-Z0-9_-]{4,15}$/; 
    var regDate =/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;                         // 형식 : 2002-08-15

    patten = eval(patten); 
    if(!patten.test(field.value)){
    	var al=new mino.alert();
    	al.message=name;
    	al.open(); 

		if(!mino.isIE) {
			e.stopPropagation=true;
			e.preventDefault();
		} else {
			event.cancleBubble=true;
			event.returnValue=false;
		}
		return false;
    } 
    return true; 
} 

function chkXword(field,e)
{
	var getX;
	var fieldvalue=field.value;
	if(xwords) {
		var xPattern=xwords.replace(/,/g,"|");
		xPattern="/"+xPattern+"/";
		xPattern=eval(xPattern);
		

		if(getX=fieldvalue.match(xPattern)) {
	    	var al=new mino.alert();
	    	al.message="'"+getX+"'는 등록 금지 단어입니다.";
	    	al.open(); 
		
			
			var fieldType=field.type.toLowerCase();
			if(field.style.display != 'none' && fieldType != "hidden") {
//				field.focus();
			}
			if(!mino.isIE) {
				e.stopPropagation=true;
				e.preventDefault();
			} else {
				event.cancleBubble=true;
				event.returnValue=false;
			}
			return false;
		}
	}
	return true;
}

function chkText(field, name,e)
{
    fieldvalue = field.value;
    fieldvalue = fieldvalue.split(" ");

    if(field.value.length + 1 == fieldvalue.length){ 
    	var al=new mino.alert();
    	al.message=name;
    	al.open(); 
    	 
        field.value = "";
		var fieldType=field.type.toLowerCase();

		if(field.style.display != 'none' && fieldType != "hidden") {
//			field.focus();
		}

		if(!mino.isIE) {

			e.stopPropagation=true;
			e.preventDefault();
		} else {
			event.cancleBubble=true;
			event.returnValue=false;
		}

        return false; 
    } 
    return true;

}

function chkCheckbox(form, field, name,e)
{
    fieldname = eval(form.name+'.'+field.name);
    if (!fieldname.checked){
    	var al=new mino.alert();
    	al.message=name;
    	al.open(); 
    	 
		if(!mino.isIE) {
			e.stopPropagation=true;
			e.preventDefault();
		} else {
			event.cancleBubble=true;
			event.returnValue=false;
		}
		return false; 
    }
    return true; 
}

function chkRadio(form, field, name,e)
{
    fieldname = eval(form.name+'.'+field.name);
    for (i=0;i<fieldname.length;i++) {
        if (fieldname[i].checked)
            return true; 
    }
    
   	var al=new mino.alert();
   	al.message=name;
   	al.open(); 

	if(!mino.isIE) {
		e.stopPropagation=true;
		e.preventDefault();
	} else {
		event.cancleBubble=true;
		event.returnValue=false;
	}
	return false; 
} 