// JavaScript Document

function onLoadFunc()
{
	getcookie();
}


function submitFunc()
{
	if(	Mcheck()==true )
		{
		setcookie();
		return true;
		}
	else
		{
		return false;
		}
}


function Mcheck(){

// ラジオボタン未選択チェック
	var i;
	var errflg = 1;
	if (document.DOWNLOAD.file.length) {

		for (i = 0; i < document.DOWNLOAD.file.length; i++) {

			// チェックが入っている
			if (document.DOWNLOAD.file[i].checked == true) {
				errflg = 0;
				break;
			}
		}

	} else {

		// チェックが入っている
		if (document.DOWNLOAD.file.checked == true) {
			errflg = 0;
		}
	}

	if (errflg == 1) {
		window.alert("Please put the check in the downloaded item.");
		return false;

	} else {

		if (document.DOWNLOAD.name.value == ""){
			window.alert("Enter your name.");
			return false }
		if (document.DOWNLOAD.company.value == ""){
			window.alert("Enter your company name.");
			return false }
		if (document.DOWNLOAD.pref.value == ""){
			window.alert("Enter your country.");
			return false }
		//if (document.DOWNLOAD.dl_syu01.value == "02"){
			if (document.DOWNLOAD.address.value == ""){
				window.alert("Enter your address.");
				return false }
		//}
		if (document.DOWNLOAD.tel.value == ""){
			window.alert("Enter your telephone number.");
			return false }
		if (document.DOWNLOAD.mail.value == ""){
			window.alert("Enter your E-mail address.");
			return false }
		return checkEmail(document.DOWNLOAD.mail.value);
	}
}


function checkEmail(i_email){

	var n = i_email;

	if (n != '') {
		okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.@ ';
		err = 0;
		for (i = 0; i < n.length; i ++) {
			if (okstr.indexOf(n.charAt(i)) == -1) err ++;
		}
		if (err != 0) {
			return false;
		}
		if (n.match(/@/)) return true;
		else {
			window.alert ("Enter your e-mail address accurately.");
			return false;
		}

	} else {
		return true;
	}
}

