//
function FormInputCheck(){
    var flag = true;
    var product_flag = false;
    var platform_flag = false;
    var platform_other_flag = false;
    var platform_other_detail_flag = false;
    var soft_flag = false;
    var soft_other_flag = false;
    var soft_other_detail_flag = false;
    
 elements:
    for (i = 0; i < document.forms[1].elements.length; i++) {
		//alert(document.forms[1].elements[i].name);
		
		switch(document.forms[1].elements[i].name){	

		case "company":
			if (! document.forms[1].elements[i].value){
				alert("貴社名・団体名・学校名を入力してください。");
				flag = false;
				break elements;
			}
		break;

		case "name":
			if (! document.forms[1].elements[i].value){
				alert("お名前を入力してください。");
				flag = false;
				break elements;
			}
		break;

		case "tel":
			if (! document.forms[1].elements[i].value){
				alert("TELを入力してください。");
				flag = false;
				break elements;
			}
			else{
				if(!document.forms[1].elements[i].value.match(/^[\d-]+$/)) { 
				   alert("電話番号は、半角数字で入力してください。");
				   flag = false;
				   break elements;

				}
			}
		break;

		case "fax":
			if (document.forms[1].elements[i].value &&
			   (!document.forms[1].elements[i].value.match(/^[\d-]+$/))) { 
				alert("FAX番号は、半角数字で入力してください。");
				flag = false;
				break elements;
			}
		break;

		case "email":
			if (! document.forms[1].elements[i].value){
				alert("E-mailを入力してください。");
				flag = false;
				break elements;
			}
			else{
//				if(!document.forms[1].elements[i].value.match(/.+@.+\..+/)) { 
				if(!document.forms[1].elements[i].value.match(/^([0-9A-Za-z_+/.-]+)@([-0-9A-Za-z]+)(\.[-0-9A-Za-z]+)+$/)) { 
				   alert("正しいE-mailを入力してください。");
				   flag = false;
				   break elements;

				} 
			}
		break;

		case "url":
			if (document.forms[1].elements[i].value && 
			   (!document.forms[1].elements[i].value.match(/^[\w\.\$,;:&=?!\*~@#_\(\)\/-]+$/))) { 
				alert("正しいURLを入力してください。");
				flag = false;
				break elements;
			}
		break;

		case "product_1":
		case "product_2":
			if (document.forms[1].elements[i].checked){
				product_flag = true;
			}
		break;

		case "platform_1":
		case "platform_2":
		case "platform_3":
		case "platform_other":
			if (document.forms[1].elements[i].checked){
				platform_flag = true;
				if (document.forms[1].elements[i].name == "platform_other") {
					platform_other_flag = true;
				}
			}
		break;

		case "platform_other_detail":
			if (document.forms[1].elements[i].value){
				platform_other_detail_flag = true;
			}
		break;

		case "soft_1":
		case "soft_2":
		case "soft_3":
		case "soft_other":
			if (document.forms[1].elements[i].checked){
				soft_flag = true;
				if (document.forms[1].elements[i].name == "soft_other") {
					soft_other_flag = true;
				}
			}
		break;

		case "soft_other_detail":
			if (document.forms[1].elements[i].value){
				soft_other_detail_flag = true;
			}
		break;

		case "usage":
			if (! document.forms[1].elements[i].value){
				alert("製品のご利用用途を入力してください。");
				flag = false;
				break elements;
			}
		break;

		}			
    }	

    if (!flag) {
	return flag;
    }

    // 評価希望製品の入力チェック
    if (!product_flag) {	
	alert("評価希望製品を選択してください。");
	return false;
	}

    // 希望プラットフォームの入力チェック
    if (!platform_flag) {	
	alert("希望プラットフォームを選択してください。");
	return false;
    } else {
	    if (platform_other_flag && !platform_other_detail_flag) {
		alert("希望プラットフォームのその他の内容を入力してください。");
		return false;
	}
    }

    // 使用モデリングソフトウェアの入力チェック
    if (!soft_flag) {	
	alert("使用モデリングソフトウェアを選択してください。");
	return false;
    } else {
	    if (soft_other_flag && !soft_other_detail_flag) {
		alert("使用モデリングソフトウェアのその他の内容を入力してください。");
		return false;
	}
    }
}


