﻿$(document).ready( function (){
	$.ajax({
		url: filename + '?' + Math.floor(Math.random()*10000000),
		type: 'GET',
		dataType: 'xml',
		timeout: 1000,
		//ロード失敗
		error: function(){
			$('ul#firstPageList').after( '<div id="errorBox">作品リストの読み込みに失敗しました。</div>' );
			$('div#illustLoadBox').hide();
		},
		//ロード完了
		success: function(xml){
			var tree = '<ul class="illustList clearfix">';
			$(xml).find('item').each( function(){
				if( $(this).find('name').text().indexOf( "'" ) != -1 ){
					tree += '<li><a href="javascript:tb_show(\'' + $(this).find('name').text().replace("'","\\'") + '\',\'image/illust/' + $(this).find('file').text() + '.jpg\',\'illust\',\'\',\'' + $(this).find('pname').text() + '\');" title="' + $(this).find('name').text() + '" rel="illust"><img src="image/thumb/' + $(this).find('file').text() + '.jpg" width="100" height="100" alt="' + $(this).find('name').text() + '" /></a></li>';
				}
				else {
					tree += '<li><a href="javascript:tb_show(\'' + $(this).find('name').text() + '\',\'image/illust/' + $(this).find('file').text() + '.jpg\',\'illust\',\'\',\'' + $(this).find('pname').text() + '\');" title="' + $(this).find('name').text() + '" rel="illust"><img src="image/thumb/' + $(this).find('file').text() + '.jpg" width="100" height="100" alt="' + $(this).find('name').text() + '" /></a></li>';
				}
			} );
			tree += '</ul>';
			
			//反映
			$('ul#firstPageList').after( tree );
			$('div#illustLoadBox').hide();
		}
	});
} );

