
function trimString (str) {
       str = this != window? this : str;
       return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

String.prototype.trim = trimString;

function checkWinc1(form){
	var host = form.numkey.value.trim();
	form.numkey.value = host;

	if( host == "") {
		alert("¸ð¹ÙÀÏÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.");
		form.numkey.style.backgroundImage = "";
		form.numkey.focus();
		return false;
	}
	
	var tmp = host;

	var result = checkValidWinc(1,tmp.trim(),form);
	if(result == false) return false;

	form.target="_top";
	
	return true;

}

function checkValidWinc(num, host,form)
{
	var strlength = host.length;
	var isHan = false;

	var valid_dom = /^[0-9#]+$/;
	if(!valid_dom.test(host)){
		alert("¸ð¹ÙÀÏÁÖ¼Ò Çü½ÄÀÌ ¸ÂÁö ¾Ê½À´Ï´Ù. \n\n´Ù½Ã ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
		form.numkey.focus();
		return false;
	}
	
	// ±æÀÌ°Ë»ç½Ã ÇÑ±Û¿µ¹®ÀÇ °æ¿ì ¿µ¹®À» 1±ÛÀÚ·Î °è»êÇÏ°ÔµÇ¸é ¾ÈµÊ.
	// ÇÑ±ÛÇÑ±ÛÀÚ¿¡ ´ëÇØ ¿µ¹®Àº 0.5ÀÚ·Î °è»êÇÏ¿© 17ÀÚ¸¦ °è»êÇÏµµ·ÏÇÔ.
	junkyAlphabet = "0123456789#";
	var strlength2 = 0; //ÇÑ±ÛÆ÷ÇÔÇÑ °æ¿ìÀÇ ±æÀÌ°è»êÀ» À§ÇÑ º°µµÀÇ º¯¼öÇÒ´ç.
	for ( var i = 0; i < strlength; i++ ) {
		if ( junkyAlphabet.indexOf( host.charAt(i) ) >= 0 ) {
			strlength2 = strlength2 + 1;
		} else {
			strlength2 = strlength2 + 1;
			isHan = true;
		}
	}
	
	var startLimit = 0;
	var endLimit = 0;
	if(isHan){
		startLimit = 2;
		endLimit = 63;
	}else{
		startLimit = 2;
		endLimit = 31.5;
	}
	
	if( strlength2 < startLimit || strlength2 > endLimit ) {
		alert("¸ð¹ÙÀÏÁÖ¼Ò´Â ÃÖ¼Ò 2 ÀÚ¿¡¼­ ÃÖ´ë 63ÀÚ ±îÁö¸¸ µî·Ï°¡´ÉÇÕ´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
		form.numkey.focus();
		return false;
	}

	//alert(strlength2);

	if (checkLength(host) == false){
		alert("WINC ¹øÈ£´Â ´ë±Ô¸ð¹øÈ£·Î ÇöÀç µî·ÏÀÌ µÇÁö ¾Ê½À´Ï´Ù.");
		form.numkey.focus();
		return false;
	}
	
	//[1.4] "-"  À¸·Î ½ÃÀÛÇÏ´Â °Í ±ÝÁö
	if( host.indexOf("0") == 0) {
		alert("WINC ¹øÈ£´Â 0À¸·Î ½ÃÀÛÇÒ¼ö ¾ø½À´Ï´Ù.");
		form.numkey.focus();
		return false;
	}

	//[1.5] "-"  À¸·Î ³¡³ª´Â °Í ±ÝÁö
	if( host.lastIndexOf("-") == (strlength-1) ) {
		alert("ÇÏÀÌÇÂ(-)À¸·Î ³¡³ª´Â ¸ð¹ÙÀÏÁÖ¼Ò´Â µî·ÏÇÏ½Ç ¼ö ¾ø½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØÁÖ½Ê½Ã¿À.");
		form.numkey.focus();
		return false;
	}
}

function checkLength(wincnum)
{
	var tmp = wincnum.split("#");

	if (tmp[1]) {
		if (tmp[1].length < 6) {
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}

//¼ýÀÚ¿Í Back Space¸¸ Çã¿ë...
function CheckNum() {
	if (event.keyCode == 9 ) { // TAB Å° Çã¿ë (¹Ú½º ÀÌµ¿)
		event.returnValue = true;
		return;
	}
	if (event.keyCode == 8 ) { // BACK SPACE
		event.returnValue = true;
		return;
	}
	// ¿À¸¥ÂÊ ¼ýÀÚÆÇ
	if (event.keyCode >= 96 && event.keyCode <= 105) {
		event.returnValue = true;
		return;
	}
	if (event.keyCode < 45 || event.keyCode > 57) {
		event.returnValue = false;
		return;
	}
}
	
function chg_opt(elm){
	if(elm ==1) {
		document.form1.domain_type2.options[0].selected = true;
	} else if(elm ==2){
		document.form1.domain_type1.options[0].selected = true;
	}
}

 //ÇÑ±ÛÀÌ ÀÖ´ÂÁö¸¦ °Ë»çÇÑ´Ù.
function isEnglishString( aString, minLength, maxLength ) {
	var iteration = 0;
	var iteration2 = 0;
	var junkyCounter = 0;

	junkyAlphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	iteration = aString.length;

	if( iteration > maxLength || iteration < minLength ) {
	return false;
	}

	while( iteration-- > 0 ) {
	iteration2 = junkyAlphabet.length;
	while( iteration2-- > 0 ) {
	if( aString.charAt( iteration ) == junkyAlphabet.charAt( iteration2 ) ) {
			 junkyCounter++;
	} else {
	 //alert( aString.charAt( iteration ) );
	}
	}
	}

	if( junkyCounter != aString.length ) {
	return false;
	}

	return true;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

// µµ¸ÞÀÎ°ú ¸ÞÄ¡µÇ´Â ¼ýÀÚ¸¦ ÀÔ·ÂÇÏ´Â ÇÔ¼ö
function check_num(theform)	{
	var str;
	str = theform.domain_name.value;
	str = str.toLowerCase();
	var temp = "";
	var num = "";
   	for(i=0; i<str.length; i++) {
   		temp = str.charAt(i);
   		if(temp == "a" || temp == "c" || temp == "b") {
			 num  += "2";
		} else if(temp == "d" || temp == "e" || temp == "f") {
			 num  += "3";
		} else if( temp == "g" ||  temp == "h" ||  temp == "i") {
			 num  += "4";
		} else if( temp == "j" ||  temp == "k" ||  temp == "l") {
			 num  += "5";
		} else if( temp == "m" ||  temp == "n" ||  temp == "o") {
			 num  += "6";
		} else if( temp == "p" ||  temp == "r" ||  temp == "s") {
			 num += "7";
		} else if( temp == "t" ||  temp == "u" ||  temp == "v") {
			 num  += "8";
		} else if( temp == "x" ||  temp == "w" ||  temp == "y") {
			 num  += "9";
		} else if( temp == "q" ||  temp == "z" || (i==0 && temp == "0" )) {
			 num  += "1";
		} else if( temp == "-" ) {
			 num  += "";
		}else if( 0 <=  temp  &&   temp <10 ) {
			 num +=  temp;
		}
   }
   
   theform.numkey.value = num;	  
}

function check_num1(theform)	{
	var str;
	str = theform.domain_name.value;
	str = str.toLowerCase();
	var temp = "";
	var num = "";
   	for(i=0; i<str.length; i++) {
   		temp = str.charAt(i);
   		if(temp == "a" || temp == "c" || temp == "b") {
			 num  += "2";
		} else if(temp == "d" || temp == "e" || temp == "f") {
			 num  += "3";
		} else if( temp == "g" ||  temp == "h" ||  temp == "i") {
			 num  += "4";
		} else if( temp == "j" ||  temp == "k" ||  temp == "l") {
			 num  += "5";
		} else if( temp == "m" ||  temp == "n" ||  temp == "o") {
			 num  += "6";
		} else if( temp == "p" ||  temp == "r" ||  temp == "s") {
			 num += "7";
		} else if( temp == "t" ||  temp == "u" ||  temp == "v") {
			 num  += "8";
		} else if( temp == "x" ||  temp == "w" ||  temp == "y") {
			 num  += "9";
		} else if( temp == "q" ||  temp == "z" || (i==0 && temp == "0" )) {
			 num  += "1";
		} else if( temp == "-" ) {
			 num  += "";
		}else if( 0 <=  temp  &&   temp <10 ) {
			 num +=  temp;
		}
   }
   
   theform.numkey1.value = num;	  
}

