var myAnSearchBox = new AnSearchBox();

function AnSearchBox() {
}

AnSearchBox.prototype.changerLanguage = function () {
	var params = "";
	var language_array = document.search_form.elements['language_id[]'];

	for (var i = 0; i < language_array.length; i ++) {
		if (language_array[i].checked) {
			params += "&language_id[]=" + encodeURI(language_array[i].value);
		}
	}

	return params;
};

AnSearchBox.prototype.changeCountry = function () {
	var params = "";
	var country_array = document.search_form.elements['country_of_origin[]'];

	for (var i = 0; i < country_array.length; i ++) {
		if (country_array[i].checked) {
			params += "&country_of_origin[]=" + encodeURI(country_array[i].value);
		}
	}

	return params;
};

AnSearchBox.prototype.changerCategory = function () {
	var params = "";
	var catregory_array = document.search_form.elements['course_category_id[]'];

	for (var i = 0; i < category_array.length; i ++) {
		if (category_array[i].checked) {
			params += "&course_category_id[]=" + encodeURI(category_array[i].value);
		}
	}

	return params;
};

AnSearchBox.prototype.changerPrice = function () {
	var params = "";

	if (document.search_form.min_price.value != "") {
		params += "&min_price=" + encodeURI(document.search_form.min_price.value);
	}

	return params;
};

AnSearchBox.prototype.changerAbility = function () {
	var params = "";
	var ability_array = document.search_form.elements['japanese_ability_id[]'];

	for (var i = 0; i < ability_array.length; i ++) {
		if (ability_array[i].checked) {
			params += "&japanese_ability_id[]=" + encodeURI(ability_array[i].value);
		}
	}

	return params;
};

AnSearchBox.prototype.changerSort = function () {
	var params = "";
	var sort_array = document.search_form.elements['sort'];

	for (var i = 0; i < sort_array.length; i ++) {
		if (sort_array[i].checked) {
			params += "&sort=" + encodeURI(sort_array[i].value);
		}
	}

	return params;
};

AnSearchBox.prototype.changerLimit = function () {
	var params = "";

	if (document.search_form.limit.value != "") {
		params += "&limit=" + encodeURI(document.search_form.limit.value);
	}

	return params;
};

AnSearchBox.prototype.partner2course = function () {
	/*var params = "course_search.php?"
		+ "p=0"
		+ this.changerLanguage()
		+ this.changerPrice()
		+ this.changerAbility()
		+ this.changerSort()
		+ this.changerLimit()
	;*/
	var params = "course_search.php";

	location.href = params;
};

AnSearchBox.prototype.course2partner = function () {
	/*var params = "partner_search.php?"
		+ "p=0"
		+ this.changerLanguage()
		+ this.changerPrice()
		+ this.changerAbility()
		+ this.changerSort()
		+ this.changerLimit()
	;*/
	var params = "partner_search.php";

	location.href = params;
};
