function deleteconfirm($redirectUrl) {
	if (window.confirm("削除処理を実行してもよろしいですか？")) {
		location.href = $redirectUrl;
		return true;
	} else {
		return false;
	}
}

function contacts_select(radiobtn) {
	if (radiobtn.value == '1') {
		contacts_other();
	} else if (radiobtn.value == '2') {
		contacts_consultation();
	} else if (radiobtn.value == '3') {
		contacts_consultant();
	} else {
		contacts_none();
	}
}

function contacts_onload(radiovalue) {
	if (radiovalue == '1') {
		contacts_other();
	} else if (radiovalue == '2') {
		contacts_consultation();
	} else if (radiovalue == '3') {
		contacts_consultant();
	} else {
		contacts_none();
	}
}

function contacts_other() {
	document.getElementById('table_other').style.display = "block";
	document.getElementById('table_consultation').style.display = "none";
	document.getElementById('table_consultant').style.display = "none";
	document.getElementById('table_insurance').style.display = "none";
}
function contacts_consultation() {
	document.getElementById('table_other').style.display = "none";
	document.getElementById('table_consultation').style.display = "block";
	document.getElementById('table_consultant').style.display = "none";
	document.getElementById('table_insurance').style.display = "none";
}
function contacts_consultant() {
	document.getElementById('table_other').style.display = "none";
	document.getElementById('table_consultation').style.display = "none";
	document.getElementById('table_consultant').style.display = "block";
	document.getElementById('table_insurance').style.display = "block";
}
function contacts_none() {
	document.getElementById('table_other').style.display = "none";
	document.getElementById('table_consultation').style.display = "none";
	document.getElementById('table_consultant').style.display = "none";
	document.getElementById('table_insurance').style.display = "none";
}

function contacts_submit() {
	var agreevalue = 0;
	for ( var i = 0; i < document.contactsform.agree.length; i++) {
		if (document.contactsform.agree[i].checked == true)
			agreevalue = document.contactsform.agree[i].value;
	}
	if (agreevalue == '1') {
		document.contactsform.submit();
	} else {
		alert("同意しないと問い合わせができません");
	}
}
function search_list_submit(){
	document.searchlistform.submit();
}
function members_submit() {
	var agreevalue = 0;
	for ( var i = 0; i < document.membersform.agree.length; i++) {
		if (document.membersform.agree[i].checked == true)
			agreevalue = document.membersform.agree[i].value;
	}
	if (agreevalue == '1') {
		document.membersform.submit();
	} else {
		alert("同意しないと進めません");
	}
}

function consultants_submit() {
	var agreevalue = 0;
	for ( var i = 0; i < document.consultantsform.agree.length; i++) {
		if (document.consultantsform.agree[i].checked == true)
			agreevalue = document.consultantsform.agree[i].value;
	}
	if (agreevalue == '1') {
		document.consultantsform.submit();
	} else {
		alert("同意しないと進めません");
	}
}

function checkloginform() {



    }


function frontier_login(type) {

	var username = document.loginform.username.value;
	var password = document.loginform.password.value;
    // usernameが空の場合
    if (username == '' || password == '') {
      alert('IDまたはパスワードが入力されていません') ;
    } else{

	if (window.location.search.substring(1, window.location.search.length) == 'admin') {
		document.getElementById('AdminUsername').value = document
				.getElementById('username').value;
		document.getElementById('AdminPassword').value = document
				.getElementById('password').value;
		document.loginform.action = "/admins/login/";
	} else if (type == 'user') {
		document.getElementById('UserUsername').value = document
				.getElementById('username').value;
		document.getElementById('UserPassword').value = document
				.getElementById('password').value;
		document.loginform.action = "/users/login/";
	} else if (type == 'consultant') {
		document.getElementById('ConsultantUsername').value = document
				.getElementById('username').value;
		document.getElementById('ConsultantPassword').value = document
				.getElementById('password').value;
		document.loginform.action = "/consuls/login/";
	}
	document.loginform.submit();
    }
}

function votestar(type, stars, action) {
	if (type == 'speed') {
		if ((action != 'onload') && (document.getElementById('VoteSpeed').value == 1) && (stars == 1)) {
			stars = 0;
		}
		document.getElementById('VoteSpeed').value = stars;
		document.getElementById('speed1').src = '/images/vote_star_off.gif';
		document.getElementById('speed2').src = '/images/vote_star_off.gif';
		document.getElementById('speed3').src = '/images/vote_star_off.gif';
		document.getElementById('speed4').src = '/images/vote_star_off.gif';
		document.getElementById('speed5').src = '/images/vote_star_off.gif';
		if (stars >= 5) {
			document.getElementById('speed5').src = '/images/vote_star_on.gif';
		}
		if (stars >= 4) {
			document.getElementById('speed4').src = '/images/vote_star_on.gif';
		}
		if (stars >= 3) {
			document.getElementById('speed3').src = '/images/vote_star_on.gif';
		}
		if (stars >= 2) {
			document.getElementById('speed2').src = '/images/vote_star_on.gif';
		}
		if (stars >= 1) {
			document.getElementById('speed1').src = '/images/vote_star_on.gif';
		}
	} else if (type == 'proposal') {
		if ((action != 'onload') && (document.getElementById('VoteProposal').value == 1)
				&& (stars == 1)) {
			stars = 0;
		}
		document.getElementById('VoteProposal').value = stars;
		document.getElementById('proposal1').src = '/images/vote_star_off.gif';
		document.getElementById('proposal2').src = '/images/vote_star_off.gif';
		document.getElementById('proposal3').src = '/images/vote_star_off.gif';
		document.getElementById('proposal4').src = '/images/vote_star_off.gif';
		document.getElementById('proposal5').src = '/images/vote_star_off.gif';
		if (stars >= 5) {
			document.getElementById('proposal5').src = '/images/vote_star_on.gif';
		}
		if (stars >= 4) {
			document.getElementById('proposal4').src = '/images/vote_star_on.gif';
		}
		if (stars >= 3) {
			document.getElementById('proposal3').src = '/images/vote_star_on.gif';
		}
		if (stars >= 2) {
			document.getElementById('proposal2').src = '/images/vote_star_on.gif';
		}
		if (stars >= 1) {
			document.getElementById('proposal1').src = '/images/vote_star_on.gif';
		}
	} else if (type == 'cope') {
		if ((action != 'onload') && (document.getElementById('VoteCope').value == 1) && (stars == 1)) {
			stars = 0;
		}
		document.getElementById('VoteCope').value = stars;
		document.getElementById('cope1').src = '/images/vote_star_off.gif';
		document.getElementById('cope2').src = '/images/vote_star_off.gif';
		document.getElementById('cope3').src = '/images/vote_star_off.gif';
		document.getElementById('cope4').src = '/images/vote_star_off.gif';
		document.getElementById('cope5').src = '/images/vote_star_off.gif';
		if (stars >= 5) {
			document.getElementById('cope5').src = '/images/vote_star_on.gif';
		}
		if (stars >= 4) {
			document.getElementById('cope4').src = '/images/vote_star_on.gif';
		}
		if (stars >= 3) {
			document.getElementById('cope3').src = '/images/vote_star_on.gif';
		}
		if (stars >= 2) {
			document.getElementById('cope2').src = '/images/vote_star_on.gif';
		}
		if (stars >= 1) {
			document.getElementById('cope1').src = '/images/vote_star_on.gif';
		}
	}
}

function voteonload() {

	if (document.getElementById('VoteSpeed').value == '') {
		document.getElementById('VoteSpeed').value = 1;
	}
	if (document.getElementById('VoteProposal').value == '') {
		document.getElementById('VoteProposal').value = 1;
	}
	if (document.getElementById('VoteCope').value == '') {
		document.getElementById('VoteCope').value = 1;
	}
	votestar('speed',		document.getElementById('VoteSpeed').value, 'onload');
	votestar('proposal',	document.getElementById('VoteProposal').value, 'onload');
	votestar('cope',		document.getElementById('VoteCope').value, 'onload');
}

function consultation_submit(consultantId) {
	document.searchform.action = "/search_details/index/" + consultantId;
	document.searchform.submit();
}

