j$(function(){
	j$(document).ready(function() {
		adjustWidth()
	});
	
	var resizeTimer = null;
		j$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(adjustWidth, 10);
	});
	function adjustWidth() {
		var bodyWidth = document.documentElement.clientWidth || document.body.clientWidth;	

		var divWidth = jQuery(".inner").width();
		
		if(navigator.userAgent.indexOf("MSIE") != -1){
			j$(".inner").css('padding-left', '0');
		}
		else {
			j$(".inner").css('padding-left', (bodyWidth-divWidth)*0.5);
		}
		j$("#tobira").width(bodyWidth);
		j$("#wrapper").width(bodyWidth);
		
		var tobiraHeight = jQuery("#wrapper").height();
		j$("#tobira").height(tobiraHeight);
		
	};
	var visited2 = cookie("visited2") && cookie("visited2")!=null ? false : true;
	if(visited2){
		
		j$(".ja").click(function(){
			setTimeout(function(){j$("#tobira").animate({opacity: 'hide'},{duration: 2200,easing: 'swing'} );}, 300);
			setTimeout(function(){j$(".btn").animate({opacity: 'hide'},{duration: 500,easing: 'swing'} );}, 100);			
			
			j$('#slides').slides({
				preload: true,
				play: 5300,
				pause: 100,
				fadeSpeed : 1000,
				fadeEasing : "easeOutQuad",				
				slideSpeed : 900,
				slideEasing: "easeOutQuad",
				hoverPause: true
			});
			clearTimeout(stoptimer);
		});
		
		stoptimer = setTimeout(function(){
			setTimeout(function(){	j$("#tobira").animate({opacity: 'hide'},{duration: 2200,easing: 'swing'} );}, 300);
			setTimeout(function(){j$(".btn").animate({opacity: 'hide'},{duration: 500,easing: 'swing'} );}, 100);			
			
			j$('#slides').slides({
				preload: true,
				play: 5300,
				pause: 100,
				fadeSpeed : 1000,
				fadeEasing : "easeOutQuad",				
				slideSpeed : 900,
				slideEasing: "easeOutQuad",
				hoverPause: true
			});
		}, 6000);

		cookie("visited2","visited2");
	}
	else {
		j$(function(){
			j$("#tobira").css("display","none");
			j$('#slides').slides({
				preload: true,
				play: 5300,
				pause: 100,
				fadeSpeed : 1000,
				fadeEasing : "easeOutQuad",				
				slideSpeed : 900,
				slideEasing: "easeOutQuad",
				hoverPause: true
			});
		});
	}
});
