$(function()
{
	$(window).bind("load",function(){

		/* 小さなウィンドウの場合だけ、縦中央寄せを解除 */
		if($(window).height()<590){
			var head = document.getElementsByTagName('head')[0];
			var link = document.createElement('link');
			link.rel = 'stylesheet';
			link.type = 'text/css';
			link.href = "css/smallwindow.css";
			head.appendChild(link);
/*
			var link = document.createElement("link");
			link.rel="stylesheet";
			link.type="text/css";
			link.href="css/smallwindow.css";
			$('head:first').append(link);
*/
		}

		/* 縦書き文字列の生成 */
		$('.tate').each(
			function tate(){
				var text_in = $(this).text();
				var text_out = "";
				var in_tag = false;
				var i=0;
				for (i = 0; i < text_in.length; i++) {
					if( text_in.charAt(i).match(/[ー－-]/)){
						text_out += '｜'+'<br/>';
					}else if( text_in.charAt(i).match(/[0123456789]/)){
						text_out += String.fromCharCode(text_in.charCodeAt(i)+65248) +'<br/>';
					}else if( text_in.charAt(i).match(/[、､]/)){
						text_out +=  '<img src="images/char_kuten.gif" width="13" height="13" alt="、" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[。｡]/)){
						text_out +=  '<img src="images/char_touten.gif" width="13" height="13" alt="。" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[（]/)){
						text_out +=  '<img src="images/char_parenthesis_st.gif" width="13" height="13" alt="（" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[）]/)){
						text_out +=  '<img src="images/char_parenthesis_en.gif" width="13" height="13" alt="）" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[「『]/)){
						text_out +=  '<img src="images/char_kagikakko_st.gif" width="13" height="13" alt="「" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[」』]/)){
						text_out +=  '<img src="images/char_kagikakko_en.gif" width="13" height="13" alt="」" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[【]/)){
						text_out +=  '<img src="images/char_lenticular_bracket_st.gif" width="13" height="13" alt="【" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[】]/)){
						text_out +=  '<img src="images/char_lenticular_bracket_en.gif" width="13" height="13" alt="】" class="char_pict"/>';
					}else if( text_in.charAt(i).match(/[～~]/)){
						text_out +=  '<img src="images/char_tilde.gif" width="13" height="13" alt="～" class="char_pict"/>';
					}else{
						text_out += text_in.charAt(i)+'<br/>';
					}
				}
				$(this).html(text_out);
				$(this).show();
			}
		);
		$('.tate:last')
		
		/* 横長であることを理解してもらうため、ロード時に一度画面をスクロールしてみせる */
		$('body').stop().scrollTo( $('#dmp_top').width(), 0, {duration:1000,axis:'x'} );
	
	});
});
