// JavaScript Document

jQuery.noConflict();
jQuery(document).ready(function($){
	$("#commentBlock").ready(function(){
		$("#commentBlock").load("/map/gourmet/ajax_comment.php");
	});

	$("#rankingBlock").ready(function(){
		$("#rankingBlock").load("/map/gourmet/ajax_ranking.php");
	});

	$("#historyBlock").ready(function(){
		$("#historyBlock").load("/map/gourmet/ajax_history.php");
	});

	$("#osusume_table").ready(function(){
		$("#osusume_table").load("/map/gourmet/ajax_recommend.php");
	});

	$("#pickup_table").ready(function(){
		$("#pickup_table").load("/map/gourmet/ajax_pickup.php");
	});

	$("#shop_information").ready(function(){
		$('#shop_information table tr:odd').addClass('uline');
		$('#shop_information table tr:even').addClass('uline border');
	});

	$("#mainImgBlock").ready(function(){
		$("#thumbA").bind("click",function(){
			$("#mainImgCaption").html( $("#thumbA").attr("alt") );
			$("#mainImgA").show();
			$("#mainImgB").hide();
			$("#mainImgC").hide();
			$("#thumbA").hide();
			$("#thumbB").show();
			$("#thumbC").show();
		});

		$("#thumbB").bind("click",function(){
			$("#mainImgCaption").html( $("#thumbB").attr("alt") );
			$("#mainImgA").hide();
			$("#mainImgB").show();
			$("#mainImgC").hide();
			$("#thumbA").show();
			$("#thumbB").hide();
			$("#thumbC").show();
		});

		$("#thumbC").bind("click",function(){
			$("#mainImgCaption").html( $("#thumbC").attr("alt") );
			$("#mainImgA").hide();
			$("#mainImgB").hide();
			$("#mainImgC").show();
			$("#thumbA").show();
			$("#thumbB").show();
			$("#thumbC").hide();
		});
		thumbInit("#thumbA");
		thumbInit("#thumbB");
		thumbInit("#thumbC");
		$("#mainImgA").show();
		$("#mainImgB").hide();
		$("#mainImgC").hide();
		$("#thumbA").hide();
		$("#thumbB").show();
		$("#thumbC").show();
	});

	$("#checkbox_genre").ready(function(){
		$("#checkbox_genre label:eq(0)").after("<br />");
		$("#checkbox_genre label:eq(4)").after("<br />");
		$("#checkbox_genre label:eq(8)").after("<br />");
		$("#checkbox_genre label:eq(11)").after("<br />");
		$("#checkbox_genre label:eq(14)").after("<br />");
		$("#checkbox_genre label:eq(19)").after("<br />");
		$("#checkbox_genre label:eq(21)").after("<br />");
	});

	$("#checkbox_keyword").ready(function(){
		$("#checkbox_keyword label:eq(3)").after("<br />");
		$("#checkbox_keyword label:eq(7)").after("<br />");
		$("#checkbox_keyword label:eq(11)").after("<br />");
		$("#checkbox_keyword label:eq(15)").after("<br />");
		$("#checkbox_keyword label:eq(18)").after("<br />");
		$("#checkbox_keyword label:eq(21)").after("<br />");
	});

	$("#checkbox_service").ready(function(){
		$("#checkbox_service label:eq(2)").after("<br />");
	});
	
});

function thumbInit( $id ) {
	thumbImage = "/map/img.php?d=gourmet&w=150&s=jpg&f=" + jQuery($id).attr("f");
	jQuery($id).css( 'display', 'block' );
	jQuery($id).css( 'float', 'left' );
	jQuery($id).css( 'cursor', 'hand' );
	jQuery($id).css( "background-image", "url(" + thumbImage + ")" );
	jQuery($id).css( 'background-position', 'center center' );
	jQuery($id).css( 'width', 150 );
	jQuery($id).css( 'height', 90 );
}

function postFavorite( $id ) {
	new Ajax.Request('/map/gourmet/mypage_add.php', {  // ※確認※
		method: 'post',
		parameters:$( $id ).serialize(),
		onSuccess: function(transport){
			var res = transport.responseText;
			var result = res.evalJSON();
			alert(result.msg);
		},
		onFailure: function(transport){
			alert(11111);
		},
		onException: function(transport, ex){
			alert(ex);
		}
	});
}

/*
function login(nick)
{
	$('log').innerHTML = '<table cellpadding="0" cellspacing="0" id="login_t">'
					+	'<tr>'
					+	'<td colspan="3"><label>こんにちは！' + String(nick) + 'さん</label></td>'
					+	'<td colspan="2"><input type="image" alt="ログアウトする" src="/web_test/member/img/pmap_logout_btn.gif" value="submit" name="login" onclick="member_logout()"></td>'
					+	'</tr>'
					+	'<tr>'
					+	'<td><a href="/web_test/member/henko.php" class="small">プロフィール各種編集</a></td>'
					+	'<td colspan="2"><a href="/web_test/member/taikai.php" class="small">アカウント管理</a></td>'
					+	'</tr>'
					+	'</table>';
 }
*/
