        

    // ! form input check
    var NUM = "0123456789";	
    var SALPHA = "abcdefghijklmnopqrstuvwxyz";
    var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+SALPHA;
    var EMAIL = "!#$%&*+-./=?@^_`{}"+NUM+ALPHA;
    var SPECHAR = "!@.#,$%^*&_-";
    var BASESTR = " '/!@.#,$%^()*&_-:" + ALPHA + NUM;
    var ERRORMSG = "";
    
    var BPROCESSING = 0;


/*******************************************************************************

	Æ¯Á¤( sCompare ) Çã¿ë ¹®ÀÚ Ã¼Å©

*******************************************************************************/
    
    function IsCheckValidStringType( sSource, sCompare )
    {
    	var i ;
    	for( i=0; i< sSource.length; i++ )
    	{
    		if( sCompare.indexOf( sSource.substring( i, i+1 ) ) < 0)
    		{
    			return false ;
    		}
    	}
    	
    	return true ;
    }


/*******************************************************************************

	Æ¯Á¤( sCompare ) ºñÇã¿ë ¹®ÀÚ Ã¼Å©

*******************************************************************************/

    function IsCheckInvalidStringType( sSource, sCompare )
    {
    	var i ;
    	for( i=0; i<sSource.length; i++ )
    	{
    		if( sCompare.indexOf( sSource.substring( i, i+1 ) ) >= 0 )
    		{
    			return true ;
    		}
    	}
    	
    	return false ;
    }

/*******************************************************************************

	°ø¹éÀ¯¹« Ã¼Å©

*******************************************************************************/

	function CheckBlankStr(strOriginal, strFind, strChange){
		var position, strOri_Length;
		position = strOriginal.indexOf(strFind);  
    
		while (position != -1){
			strOriginal = strOriginal.replace(strFind, strChange);
			position    = strOriginal.indexOf(strFind);
		}
  
		strOri_Length = strOriginal.length;
		return strOri_Length;
	}

/*******************************************************************************

	¿µ¹® ¹ÙÀÌÆ®¼ö Ã¼Å©

*******************************************************************************/

function GetStringSize ( sSource )
{
	var i;
	var len = 0;
	for( i=0 ; i<sSource.length ; i++ )
	{
		if( sSource.charCodeAt(i) > 255 )
		{
			len += 2;
		}
		else
		{
			len ++;
		}
	}
	return len;
}

/*******************************************************************************

	±âº» ÀÚ¸®¼ö Ã¼Å©

*******************************************************************************/

    function IsCheckEnglishLength( sSource, sName, nMin, nMax )
    {
    	var nStrSize = GetStringSize( sSource ) ;
    	
    	if( nStrSize == 0 && nMin > 0 )
    	{
    		ERRORMSG = " Please insert "  + sName ;
    		return false ;
    	}
    	
    	if( nMin == 0 && nStrSize > nMax )
    	{
    		ERRORMSG = sName + " " + nMax +"<= up .\n Current Size : " + nStrSize ;
    		return false ;
    	}
    	if( nStrSize < nMin || nStrSize > nMax )
    	{
    		ERRORMSG = sName + " " + nMin + "<= up, " + nMax + "<= down.\n Current Size : " + nStrSize ;
    		return false ;
    	}
    	
    	return true ;
    }



	// ¾ÆÀÌµð Ã¼Å©



    function IsCheckLoginIDFormat( sLoginID ) {

    	if( !IsCheckValidStringType( sLoginID, SALPHA+NUM ) )
    	{
    		// ERRORMSG = "[È¸¿ø¾ÆÀÌµð]´Â ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ·Î ±¸¼ºµÇ¾î¾ß ÇÏ¸ç,\nÃ¹ ±ÛÀÚ´Â ²À ¿µ¹® ¼Ò¹®ÀÚ·Î ÀÛ¼ºÇØ¾ß ÇÕ´Ï´Ù." ;
    		ERRORMSG = "[User ID] sould be alphabetics or numerics, the first letter should be lower character." ;
    		
    		return false ;
    	}
   
    	if( !IsCheckEnglishLength( sLoginID, "[User ID]", 4, 20 ) )
    	{
    		return false ;
    	}

     	
    	if( NUM.indexOf( sLoginID.charAt(0)) >= 0 )
    	{
    		ERRORMSG = "[User ID] should start with English lowercase." ;
    		return false;
    	}
    
    	if( sLoginID.substring(0,5)=="admin" || sLoginID.substring(0,5)=="guest" )
    	{
    		ERRORMSG = "[User ID] cannot contain admin nor guest." ;
    		return false;
    	}
   
    	return true ;
    }


	// Æä½º¿öµå ÀÏÄ¡ ¿©ºÎ Ã¼Å©
	

    function IsCheckPasswordFormat( sPassword, sRepassword )
    {
    	if( !IsCheckValidStringType( sPassword, SPECHAR+ALPHA+NUM  ) )
    	{
    		ERRORMSG = "Password should be between 4 and 16 characters of \nalphabetics, numerics, or other special character(! @ . # , $ % ^ * & _ -)." ;
    		return false ;
    	}
    		
    	if( !IsCheckEnglishLength( sPassword, "[Password]", 4, 16, 0 ) )
    	{
    		return false ;
    	}
    	
    	if( sPassword != sRepassword )
    	{
    		ERRORMSG = "[Password] does not match." ;
    		return false ;
    	}
    	
    	return true;
    }

    function IsCheckLoginPasswordFormat( sPassword )
    {
    	if( !IsCheckValidStringType( sPassword, SPECHAR+ALPHA+NUM ) )
    	{
    		ERRORMSG = "Password should be between 4 and 16 characters of \nalphabetics, numerics, or other special character(! @ . # , $ % ^ * & _ -)." ;
    		return false ;
    	}
    		
    	if( !IsCheckEnglishLength( sPassword, "[Password]", 4, 16, 0 ) )
    	{
    		return false ;
    	}
    	
    	return true;
    }



    function IsCheckEmailFormat( sEmail )
    {
    	var i ;
    	var s ;
    	if( !IsCheckValidStringType( sEmail, EMAIL ) )
    	{
    		ERRORMSG = "There is incorrect character in your email address.";
    		return false;
    	}
    
    	if( !IsCheckEnglishLength( sEmail, "[Email address]", 7, 50 ) )
    	{
    		return false;
    	}
    	
    	i = sEmail.indexOf('@');
    	if( i<=0 || i == sEmail.length-1 )
    	{
    		ERRORMSG = "[Email address] should be inserted as like designcontents@designcontents.com." ;
    		return false;
    	}
    	
    	i = sEmail.indexOf( '.', i+1 ) ;
    	if( i<=0 || i == sEmail.length-1 )
    	{
    		ERRORMSG = "[Email address] should be inserted as like designcontents@designcontents.com." ;
    		return false;
    	}
    	
    	return true;
    }
	
	
	function IsCheckSelectBox( sSource , FiledName , Checkvalue ){
		
		if( sSource == Checkvalue ){
    		ERRORMSG ="Please select." + FiledName ;
    		return false;			
		}
		
		return true;					
	}
	
	
		
	function IsCheckBaseString( sSource , FiledName , sCompare ){

		var strcompare;

		if( sCompare == NUM ){
			strcompare = "number";
		} else if ( sCompare == ALPHA ){
			strcompare = "alphabet";			
		} else if ( sCompare == BASESTR ){
			strcompare = "alphabet and number";			
		} else if ( sCompare == NUM+SPECHAR ){
			strcompare = "special character and number";			
		}


    	if( CheckBlankStr( sSource, " ", "") == 0 )
    	{
    		ERRORMSG ="Please insert [" + FiledName + "]." ;
    		return false;
    	}

    	if( !IsCheckValidStringType( sSource, sCompare ) )
    	{
    		ERRORMSG = FiledName + " should be consisted with " + strcompare ;
    		return false;
    	}

   		return true;
	}


	function IsCheckTextarea( sSource , FiledName ){

		var strcompare;
        var mmstr;
        

    	if( CheckBlankStr( sSource, " ", "") == 0 )
    	{
    		ERRORMSG = "Please insert [" + FiledName + "]." ;
    		return false;
    	}

        for (kk=0; kk< sSource.length; kk++)
        {
           mmstr = sSource.substr(kk,1).charCodeAt(0);
           if (mmstr < 0 || mmstr > 128 )
           {
     		 ERRORMSG = FiledName + "should consist of alphabetics and numerics." ;
     		 return false;
              break;
           }
        }

   		return true;
	}

	function GetForm(frmName)
	{
		el = GetFormInDocument(document, frmName);
		
		if (el != null) return el; 

		if (document.all == null && document.getElementById == null)
			for (var i = 0; i < document.layers.length; i++) {
				el = GetFormInDocument(document.layers[i].document, frmName);
				if (el != null) return el;
			}
		return null;
	}


	function GetFormInDocument(inDoc, frmName)
	{
		var elForm = null;
		
		with (inDoc) {
			
			elForm = forms[frmName];
			if (elForm != null) return elForm;

			for (var i = 0; i < forms.length; i++) {
				if (forms[i].name == frmName)
					return forms[i];
			}
			
			if (inDoc.all == null && inDoc.getElementById == null)
				for (var i = 0; i < inDoc.layers.length; i++) {
					el = GetFormInDocument(inDoc.layers[i].document, frmName);
					if (el != null) return el;
				}
		}
		return null;
	}	
