/* 検索結果一覧用JS */

(function() {
	hpr = window.hpr;
	hpr.coupon = {
		show: function(o) {
			o.parentNode.style.display='none';
			var nextDivNode = o.parentNode.nextSibling;
			while (nextDivNode.nodeType != 1) {
				nextDivNode = nextDivNode.nextSibling;
			}
			nextDivNode.style.display='block';
			return false;
		},
		showDetail: function(storeId) {
			location.href = "/str" + storeId + "/map/";
		},
		shrink: {
			mouseover: function(o) {
				o.parentNode.className = "showCoupon couponHover";
			},
			mouseout: function(o) {
				o.parentNode.className = "showCoupon";
			}
		},
		expand: {
			mouseover: function(o) {
				o.className = "hideCoupon couponHover";
			},
			mouseout: function(o) {
				o.className = "hideCoupon";
			}
		},
		mouseover: function(o) {
			o.className = "hover";
		},
		mouseout: function(o) {
			o.className = "";
		}
	};

	hpr.searchlist = {
		setUrl: function() {
			$.cookie('HPJ_RESULT_URL', document.URL, { expires: 10 * 365, path:'/' });
		},
		toggleMoreParameter: function() {
			var disp = $('#moreParameter').css('display');
			if (disp == 'none') {
				document.getElementById("FEFLG").value = "1";
				$('#moreParameter').css('display','block');
				$('#showParameterBtn').css('display','none');
			} else {
				document.getElementById("FEFLG").value = "0";
				$('#moreParameter').css('display','none');
				$('#showParameterBtn').css('display','block');
			}
		},

		//レイヤー領域項目選択時制御
		submitStepLayer: function(param, cd, param2){
			var stepElm = document.getElementById("step");
			var step_cnt = stepElm.length;

			for (var k = 0; k < step_cnt; k++ ) {
		    	var f = stepElm.elements[k];
				if (f.name == param) {
					f.value = cd;
				}
				if (f.name == param2) {
					f.value = '';
				}
			}

			var hiddenTag = '';
			if (typeof cd == 'string') {
				hiddenTag = hiddenTag + '<input type="hidden" name="'+param+'" value="'+cd+'" />';
			} else {
				for (var i = 0; i < cd.length; i++ ) {
					hiddenTag = hiddenTag + '<input type="hidden" name="'+param+'" value="'+cd[i]+'" />';
				}
			}

			var stepForm = $("form[id='step']");
			stepForm.html(stepForm.html()+hiddenTag);
			stepElm.target = '_self';
			stepElm.submit();
		}

	};
})();

// ハブリング抑止のためにこのメソッドは残す
$(function(){
	$('div#mainContents div.article div.hideCoupon div.switch').click(function(e) {
		$(this).parent().hide();
		$(this).parent().prev().show();
		return false;
	});
});

// hpr.searchlist.setUrlラップ
function setSearchListUrl() {
	hpr.searchlist.setUrl();
}
