/**
 * brand functions
 */
(function() {
	brand = window.brand = {
		window: {
			// brand.window.openExternal
			openExternal: function(anchor) {
				window.open(anchor.href, "_blank");
				return false;
			}
		}, // window end

		freeword: {
			// brand.freeword.keyControl
			keyControl: function(event, form, nextPage) {
			    if (!event) {
			    	event = window.event;
				}

			    if (event.keyCode == 13) {
					var result = this.submit(form, nextPage);
					if (result == null || result == false) {
						return false;
					}
				}
				return true;
			},

			// brand.freeword.submit
			submit: function(form, nextPage) {
				var message = "";
				if (form.SW.value == "") {
					message = "キーワードを入力してください。";
				}

				if (message != "") {
					alert(message);
					return false;
				}

				if (nextPage != undefined){
			    	location = nextPage + '?SW=' + EscapeSJIS(form.SW.value);
				} else {
			    	form.submit();
				}
			}
		},// freeword end

		common: {

			// brand.common.submit
			submit: function(form, nextPage) {
				if (nextPage != undefined){
			    	location.href = nextPage;
				} else {
			    	form.submit();
				}
			},

			// brand.common.validateSA
			validateSA: function(form) {
				var message = "";
				if (form.SA.value == "") {
					message = "都道府県を選んでください。";
				}

				if (message != "") {
					alert(message);
					return false;
				}

				this.submit(form);

			}
		} // common end
	}; // brand end
})(); // function end
