/*==============================================
	CSS Style Module
==============================================*/

$(function(){
	$('html,body').css('overflow','hidden');
	$('#browser').attr('height',$(document).height()-120);
});

$(window).resize(function () {
	$('#browser').attr('height',$(document).height()-120);
});

/*==============================================
	Slide view Module
==============================================*/

var index 	= 0; //番号（新しい順)
var max 	= 0; //最大数
$(document).ready(function(){

	browse('init');
	
	//next
	$('#next').click(function() {
		if (++index >= max) index = 0;
		browse('url');
	});
	
	//back
	$('#back').click(function() {
		if (--index < 0) index = max-1;
		browse('url');
	});

});

function browse(type) {
	$.getJSON(
		'next.php',
		{
			"id": index,
			"type": type
		},
		function(data, status){
			if (status == 'success') {
				$('#cursors').show();
				if (type == 'init') {
					max = data.max;
//					$('#max').html(max);
				}
				$('#browser').attr('src', data.url);
				$('#next').attr('title', data.next);
				$('#back').attr('title', data.prev);
			}
			else {
				alert('エラーが発生しました。');
			}
		}
	);
}

/*==============================================
 IE link line hidden Module
==============================================*/

window.onload=function(){
	a=document.getElementsByTagName("a");
	for(i=0;i<a.length;i++){
		a[i].onfocus=function(){this.blur();}
	}
	area=document.getElementsByTagName("area");
	for(i=0;i<area.length;i++){
		area[i].onfocus=function(){this.blur();}
	}
};
