// JavaScript Document
(function($){
$(function()
{
	// モバイルページのロード
	$('#ranking dl dt').after('<dd><div id="ranking_detail"></div></dd>');
	$('#ranking_detail').load("jipang/tubuyaki.htm",null,function()
	{
		$('#ranking_detail img').each(function()
		{
			$(this).attr('width', $(this).attr('width') * 0.8);
			$(this).attr('height', $(this).attr('height') * 0.8);
		});
		$('.table_out th').wrapInner('<div class="th"></div>');
		$('.table_out td').wrapInner('<div class="td"></div>');
		$('.table_out table,.table_out tbody,.table_out tr,.table_out td,.table_out th').children().unwrap();
	});

	// 近日お目見え台の高さ統一
	left_height = $('.other_list:eq(0) .other_list_left .other_list_box_bottom').height();
	right_height = $('.other_list:eq(0) .other_list_right .other_list_box_bottom').height();
	if (left_height <= right_height) $('.other_list:eq(0) .other_list_left .other_list_box_bottom').css({height:right_height});
	else $('.other_list:eq(0) .other_list_right .other_list_box_bottom').css({height:left_height});
	// PICK UPの高さ統一
	left_height = $('.other_list:eq(1) .other_list_left .other_list_box_bottom').height();
	right_height = $('.other_list:eq(1) .other_list_right .other_list_box_bottom').height();
	if (left_height <= right_height) $('.other_list:eq(1) .other_list_left .other_list_box_bottom').css({height:right_height});
	else $('.other_list:eq(1) .other_list_right .other_list_box_bottom').css({height:left_height});
	// メモのアコーディオン化
	memo_intro_height = $('#memo #memo_intro').height();
	$('#memo #memo_intro').css({'display':'none'});
	memo_detail_height = $('#memo #memo_detail').height();
	$('#memo #memo_detail').css({'height':memo_intro_height});
	
	$('#memo dl dd#more_btn a#more_close').css('display', 'none');
	
	$("#memo dl dd#more_btn a#more_open img").click(function(){
		$("#memo #memo_detail").animate({height:memo_detail_height},300);
		$('#memo dl dd#more_btn a#more_open').css('display', 'none');
		$('#memo dl dd#more_btn a#more_close').css('display', 'inline');
		return false;
	});
	
	$("#memo dl dd#more_btn a#more_close img").click(function(){
		$("#memo #memo_detail").animate({height:memo_intro_height},300);
		$('#memo dl dd#more_btn a#more_open').css('display', 'inline');
		$('#memo dl dd#more_btn a#more_close').css('display', 'none');
		return false;
	});
	
	// フォームのデフォルト
	$('#regist_form input:eq(1)').after('<input type="text" value="password" />');
	$('#regist_form input:eq(1)').css("display", "none");
	
	$('#regist_form input:eq(2)').focus(resetForm);
	$('#regist_form input:eq(2)').click(resetForm);
	
	function resetForm()
	{
		$('#regist_form input:eq(1)').css({"display":"inline", "color":"#000000"});
		$('#regist_form input:eq(2)').css("display", "none");
		$('#regist_form input:eq(1)').focus();
	}
	
	idFlg = false;
	$('#regist_form input').css("color", "#b5b5b5");
	$('#regist_form input:eq(0)').attr("value","ID");
	$('#regist_form input:eq(0)').click(function()
	{
		if (!idFlg)
		{
			idFlg = true;
			$(this).attr("value", "");
			$(this).css("color", "#000000");
		}
	});
    // イベントリストの埋込
    $("#event_column").after('<div id="event_list"><div id="jipang_event_list"></div><div id="hall_event_list"></div></div>');
    // ジパングイベント
    $.get('jipang_event_list.xml', function (data)
    {
        $('event', data).each(function()
        {
            img = $('img', this).text();
            title = $('title', this).text();
            comment = $('comment', this).text();
            link = $('link', this).text();
            
            $("#jipang_event_list").append('<ul><li class="event_image"><a href="' + link + '"><img src="img/index/event/' + img + '" alt="' + title + '" /></a></li><li class="event_title"><a href="' + link + '">' + title + '</a></li><li class="event_comment">' + comment + '</li></ul>');
        });
    }, 'xml');
    // ホールイベント
    $.get('hall_event_list.xml', function (data)
    {
        $('event', data).each(function()
        {
            img = $('img', this).text();
            title = $('title', this).text();
            comment = $('comment', this).text();
            link = $('link', this).text();
            
            $("#hall_event_list").append('<ul><li class="event_image"><a href="' + link + '"><img src="img/index/event/' + img + '" alt="' + title + '" /></a></li><li class="event_title"><a href="' + link + '">' + title + '</a></li><li class="event_comment">' + comment + '</li></ul>');
        });
    }, 'xml');
    $("#event_type1_link").colorbox({width:"50%", inline:true, href:"#jipang_event_list"});
    $("#event_type2_link").colorbox({width:"50%", inline:true, href:"#hall_event_list"});
});
})(jQuery);
