$(function(){
	$('#searchtext').keypress(function(ev) {
			if(ev.keyCode == 13) { searchJump(); }
		});
	$('#searchbutton').click(searchJump);

	function searchJump() {
		var word = $('#searchtext').val();
		var genre = $('#genreselect').val();
		if(word.match(/^\s*$/)){
			alert('検索キーワードを入力してください');
		} else {
			var url = '/search/'+encodeURIComponent(word).replace(/%2F/g, '%252F').replace(/%20/g, '+')+'/';
			location.href = url;
		}
	}
	$('.smallimage.point, #smallpackage').click(function() {
		var id = "#largeimage"+$(this).attr('rel');
		$('.largeimage').hide();
		$(id).fadeIn();
		$(window).scrollTo('#view', 800);
	});
	$('.smallvideo').click(function() {
		$(window).scrollTo('#subcontent', 800);
		var id = "#video"+$(this).attr('rel');
		$('.video').hide();
		$(id).fadeIn();
	});
	$('#nextlink').click(function() {
		var obj = $(this);
		var href = obj.attr('href');
		var params = {
				"req" : "post"
			};
		var nextstr = obj.html();
		obj.html('<img src="/images/loading.gif" />読み込み中');
		$.post(href, params, function(html, status) {
				obj.before(html)
				if($('#cont').size()) {
					obj.attr('href', $('#cont').attr('rel')).html(nextstr);
					$('#cont').remove();
				} else {
					obj.remove();
				}
			});
		return false;
	});
	$('.blanklink').click(function() {
		if(!window.confirm('この動画のリンクは外部サイトを参照しています。\nリンク先での被害、コンテンツの内容について\n当サイトは一切の責任を負いません。')) {
			return false;
		}
		
	});
});

