// - check domain function
function wrongDomain(t_value,cmt)
{
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
	var numeric = '1234567890';
	var special = '`~!@#$%^&*()-_=+|\\{}[];:"\'<>,.?\/｢｣「」！”＃＄％＆’（）＝−＾＠；：＜＞、。＋＊';
	var nonjapan = alpha+special ;
	var alnum = alpha+numeric;
	var i ;
	if ( t_value.substring(0,1)=="-" || t_value.substring(t_value.length-1,t_value.length)=="-" )
	{
		return true;
	}
	if ( cmt == "englishdomain" )
	{
		for ( i=0; i<t_value.length; i++ )
		if ( alnum.indexOf(t_value.substring(i,i+1)) < 0 )
		{
			break;
		}
		if ( i != t_value.length ) 
			return true ;
	}
	else if ( cmt == "japandomain" )
	{
		for ( i=0; i<t_value.length; i++ )
		if ( nonjapan.indexOf(t_value.substring(i,i+1)) > 0 )
		{
			break;
		}
		if ( i != t_value.length )
			return true ;
	}
	return false;
}

// - search submit function  
function search1(theform)
{
	//alert(theform.name) ;
	if (theform.name == "formdom1")
	{
		cmt = "englishdomain" ;
	}

	if (theform.domain_name.value == "" )
	{
		alert('ドメイン名を入力してください。') ;
		theform.domain_name.focus() ;
		return false ;
	}

	if ( theform.name == "formdom1")
	{
		if ( (theform.domain_type_com.checked == 1 || theform.domain_type_net.checked == 1 || theform.domain_type_org.checked == 1 || theform.domain_type_info.checked == 1 || theform.domain_type_biz.checked == 1  || theform.domain_type_cc.checked == 1 || theform.domain_type_in.checked == 1 || theform.domain_type_tv.checked == 1 || theform.domain_type_tw.checked == 1 || theform.domain_type_eu.checked == 1 || theform.domain_type_ac.checked == 1 || theform.domain_type_me.checked == 1 || theform.domain_type_mobi.checked == 1 || theform.domain_type_name.checked == 1 || theform.domain_type_asia.checked == 1 || theform.domain_type_co.checked == 1) && theform.domain_name.value.length<3)
		{
			alert('3文字以上入力してください。') ;
			theform.domain_name.focus() ;
			return false ;
		}
	}

	if ( wrongDomain(theform.domain_name.value, cmt) )
	{
		cmt = "japandomain";

		if(wrongDomain(theform.domain_name.value, cmt) )
		{
			//alert(theform.domain_name.value);
			alert('正しいドメイン名を入力してください。');
			theform.domain_name.value = "";
			theform.domain_name.focus();
			return false ;
		}
		else
		{
			theform.domain_language.value = "japanese";
		}
	}
	else
	{
		theform.domain_language.value = "english";
	}

	var check_num=0 ;
	if (theform.name == "formdom1")
	{
		if ( theform.domain_type_com.checked == 1 ) check_num++ ;
		if ( theform.domain_type_net.checked == 1 ) check_num++ ;
		if ( theform.domain_type_org.checked == 1 ) check_num++ ;
		if ( theform.domain_type_info.checked == 1 ) check_num++ ;
		if ( theform.domain_type_biz.checked == 1 ) check_num++ ;
		if ( theform.domain_type_cc.checked == 1 ) check_num++ ;
		if ( theform.domain_type_in.checked == 1 ) check_num++ ;
		if ( theform.domain_type_tv.checked == 1 ) check_num++ ;
		if ( theform.domain_type_tw.checked == 1 ) check_num++ ;
		if ( theform.domain_type_eu.checked == 1 ) check_num++ ;
		if ( theform.domain_type_ac.checked == 1 ) check_num++ ;
		if ( theform.domain_type_me.checked == 1 ) check_num++ ;
		if ( theform.domain_type_mobi.checked == 1 ) check_num++ ;
		if ( theform.domain_type_name.checked == 1 ) check_num++ ;
		if ( theform.domain_type_asia.checked == 1 ) check_num++ ;
		if ( theform.domain_type_co.checked == 1 ) check_num++ ;
	}

	if (check_num == 0 )
	{
		alert('ドメインタイプを選択してください。') ;
		return false ;
	}
	if (check_num > 11 )
	{
		alert('同時に11個以上のドメインは検索できません。');
		return false ;
	}
	theform.action = "../domain/DomainRegist_Search_01.php" ;
	return true ;
}

// - search submit function  
function search2(theform)
{
	//alert(theform.name) ;
	if ( theform.name == "formdom2" )
	{
		cmt = "englishdomain" ;
	}

	if (theform.domain_name.value == "" )
	{
		alert('ドメイン名を入力してください。') ;
		theform.domain_name.focus() ;
		return false ;
	}

	if ( theform.name == "formdom2")
	{
		if ( (theform.domain_type_jp.checked == 1 || theform.domain_type_co_jp.checked == 1 || theform.domain_type_ne_jp.checked == 1 || theform.domain_type_or_jp.checked == 1 || theform.domain_type_ac_jp.checked == 1 || theform.domain_type_ed_jp.checked == 1  || theform.domain_type_gr_jp.checked == 1) && theform.domain_name.value.length<3)
		{
			alert('3文字以上入力してください。') ;
			theform.domain_name.focus() ;
			return false ;
		}
	}

	if ( wrongDomain(theform.domain_name.value, cmt) )
	{
		cmt = "japandomain";

		if(wrongDomain(theform.domain_name.value, cmt) )
		{
			//alert(theform.domain_name.value);
			alert('正しいドメイン名を入力してください。');
			theform.domain_name.value = "";
			theform.domain_name.focus();
			return false ;
		}
		else
		{
			theform.domain_language.value = "japanese";
		}
	}
	else
	{
		theform.domain_language.value = "english";
	}

	var check_num=0 ;
	if ( theform.name == "formdom2" )
	{
		if ( theform.domain_type_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_co_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_ne_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_or_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_ac_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_ed_jp.checked == 1 ) check_num++ ;
		if ( theform.domain_type_gr_jp.checked == 1 ) check_num++ ;
	}

	if (check_num == 0 )
	{
		alert('ドメインタイプを選択してください。') ;
		return false ;
	}
	if (check_num > 11 )
	{
		alert('同時に11個以上のドメインは検索できません。');
		return false ;
	}
	theform.action = "../domain/DomainRegist_Search_01.php" ;
	return true ;
}

// - search submit function  
function search3(theform)
{
	//alert(theform.name) ;
	if ( theform.name == "formdom3" )
	{
		cmt = "japandomain" ;
	}

	if (theform.domain_name.value == "" )
	{
		alert('ドメイン名を入力してください。') ;
		theform.domain_name.focus() ;
		return false ;
	}

	if ( theform.name == "formdom3")
	{
		if ( (theform.domain_type_jp.checked == 1) && theform.domain_name.value.length<3)
		{
			alert('3文字以上入力してください。') ;
			theform.domain_name.focus() ;
			return false ;
		}
	}

	if ( wrongDomain(theform.domain_name.value, cmt) )
	{
		cmt = "japandomain";

		if(wrongDomain(theform.domain_name.value, cmt) )
		{
			//alert(theform.domain_name.value);
			alert('正しいドメイン名を入力してください。');
			theform.domain_name.value = "";
			theform.domain_name.focus();
			return false ;
		}
		else
		{
			theform.domain_language.value = "japanese";
		}
	}
	else
	{
		theform.domain_language.value = "japanese";
	}

	var check_num=0 ;
	if ( theform.name == "formdom3" )
	{
		if ( theform.domain_type_jp.checked == 1 ) check_num++ ;
	}

	if (check_num == 0 )
	{
		alert('ドメインタイプを選択してください。') ;
		return false ;
	}
	if (check_num > 11 )
	{
		alert('同時に11個以上のドメインは検索できません。');
		return false ;
	}
	theform.action = "../domain/DomainRegist_Search_01.php" ;
	return true ;
}
