if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPod') != -1 || navigator.userAgent.indexOf('iPad') != -1) {
	document.write('<script type="text/javascript" src="ipad.js"></script>');
}

/* ヘッダタブ */
$(function() {
	//ご利用ガイド
	$('#headerBar > ul > li.guide > a,  #guideList > p.close > a').click(function(){
		$('#guideList').slideToggle('fast');
		return false;
	});
	//ヘッダタブ
	$('#headerTab > ul').tabs({
		fx: { height: 'toggle',  duration: 'fast'  },
		deselectable: 'true'
	});
	//ヘッダタブ内「×」
	$('#headerTab > div.navigation > div.panel > p.close > a').click(function(){
		function callBack(){ $(this).addClass('hide'); }
		$(this).parent('p.close').parent('div.panel').slideToggle('fast', callBack),
		$('#headerTab > ul.tabnav > li').removeClass('select ui-tabs-deselectable');
		return false;
	});
});
/*
$('#headerTab').tabs({
    //Ajaxで読み込むのを阻止
    select: function(event, ui) {
        var url = $.data(ui.tab, "load.tabs");
        if (url) {
            location.href = url;
            return false;
        }
        return true;
    },
    selected: 5
});
*/

/* フッタタブ */
$(function() {
	//フッタタブ
	$(window).load(function(){
		for( i = 1; i < 4; i = i + 1){ $.cookie('win' + i, ''); } //cookie一旦全削除
	});
	$('#footerBar > ul.popupBtn').tabs({
		deselectable: 'true'
	});
	//フッタタブ内「×」
	$('div.balloon > div.#window1 > p.close > a').click(function(){
		$('#window1').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
		$('#footerBar > ul.popupBtn > li > a.bombit-ad').parent('li').removeClass('select ui-tabs-deselectable');
		$.cookie('win1', 'null');
		return false;
	});
	$('div.balloon > div.#window2 > p.close > a').click(function(){
		$('#window2').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
		$('#footerBar > ul.popupBtn > li > a.contact-list').parent('li').removeClass('select ui-tabs-deselectable');
		$.cookie('win2', 'null');
		return false;
	});
	$('div.balloon > div.#window3 > p.close > a').click(function(){
		$('#window3').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
		$('#footerBar > ul.popupBtn > li > a.social-list').parent('li').removeClass('select ui-tabs-deselectable');
		$.cookie('win3', 'null');
		return false;
	});
	$('div.balloon > div.#window4 > p.close > a').click(function(){
		$('#window4').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
		$('#footerBar > ul.popupBtn > li > a.faq').parent('li').removeClass('select ui-tabs-deselectable');
		$.cookie('win4', 'null');
		return false;
	});
		
	$('#footerBar > ul.popupBtn > li > a.bombit-ad').click(function(){
		if($.cookie('win1') == 'yes'){ 
			$('#window1').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } }); 
			$.cookie('win1', 'null'); 
		}else{ 
			$('#window1').css('display', 'block').animate({ 'top' : -($('#window1').height() + 42) + 'px' }); 
			$('#window2, #window3, #window4').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } }); 
			$.cookie('win1', 'yes'); 
			$.cookie('win2', 'null');
			$.cookie('win3', 'null');
			$.cookie('win4', 'null');
			return false;
		}
	});
	$('#footerBar > ul > li > a.contact-list').click(function(){
		if($.cookie('win2') == 'yes'){
			$('#window2').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } }); 
			$.cookie('win2', 'null');
		}else{
			$('#window2').css('display', 'block').animate({ 'top' : -($('#window2').height() + 42) + 'px' }); 
			$('#window1, #window3, #window4').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } }); 
			$.cookie('win1', 'null');
			$.cookie('win2', 'yes');
			$.cookie('win3', 'null');
			$.cookie('win4', 'null');
			return false;
		}
	});
	$('#footerBar > ul > li > a.social-list').click(function(){
		if($.cookie('win3') == 'yes'){
			$('#window3').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
			$.cookie('win3', 'null');
		}else{
			$('#window3').css('display', 'block').animate({ 'top' : -($('#window3').height() + 42) + 'px' });
			$('#window1, #window2, #window4').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
			$.cookie('win1', 'null');
			$.cookie('win2', 'null');
			$.cookie('win3', 'yes');
			$.cookie('win4', 'null');
			return false;
		}
	});
	$('#footerBar > ul > li > a.faq').click(function(){
		if($.cookie('win4') == 'yes'){
			$('#window4').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
			$.cookie('win4', 'null');
		}else{
			$('#window4').css('display', 'block').animate({ 'top' : -($('#window4').height() + 42) + 'px' });
			$('#window1, #window2, #window3').animate({ 'top' : '639px' }, { complete: function(){ $(this).css('display', 'none'); } });
			$.cookie('win1', 'null');
			$.cookie('win2', 'null');
			$.cookie('win3', 'null');
			$.cookie('win3', 'yes');
			return false;
		}
	});
});

/* メインイメージ */
$(function() {
	$('#contents > ul').tabs({
		fx: { opacity: 'toggle', duration: 'fast'  }
	}).tabs('rotate', 6000);
});

/* スライドバナー */
$(function() {	
	var speed = 5000;
	var run = setInterval('rotate()', speed);	
	var item_width = $('#slides li').outerWidth(); 
	var left_value = item_width * (-1); 
	$('#slides li:first').before($('#slides li:last'));
	$('#slides ul').css({'left' : left_value});
	$('#prev').click(function() {
		var left_indent = parseInt($('#slides ul').css('left')) + item_width;
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    
			$('#slides li:first').before($('#slides li:last'));           
			$('#slides ul').css({'left' : left_value});
		});
		return false;
	});
	$('#next').click(function() {
		var left_indent = parseInt($('#slides ul').css('left')) - item_width;
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
			$('#slides li:last').after($('#slides li:first'));                 	
			$('#slides ul').css({'left' : left_value});
		});
		return false;
	});        
	$('#slides').hover(
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('rotate()', speed);	
		}
	); 
});

function rotate() {
	$('#next').click();
}

/* ページの先頭へ戻る */
$(function() {	
	$('p.gotop > a').click(function(){
		var target;
		target = $('#wrapper');
		$('html, body').animate({scrollTop: target.offset().top});
		return false;
	});
});

/*  IE */
$(function() {
	var cautionStr = '<div id="ieCaution">'+
	'<p>当ウェブサイトは Windows Internet Explorerでは<br />'+
	'正しく表示されない可能性があります。<br />'+
	'最新の Google Chrome、FireFox、Safariのご利用をおすすめします。</p>'+
	'<ul><li><a href="http://www.google.com/chrome?hl=ja" class="chrome">Google Chrome のダウンロードはこちら</a></li>'+
	'<li><a href="http://mozilla.jp/firefox/" class="firefox">FireFox のダウンロードはこちら</a></li>'+
	'<li><a href="http://5yt2m.tk" class="ie">最新の Internet Explorer のダウンロードはこちら</a></li></ul>'+
	'<p class="button"><a href="#" onclick="closeIECaution()">閉じる</a></p>'+
	'</div>';
	if(navigator.userAgent.indexOf('MSIE 6') > -1 && $.cookie('cautionIsClosed') != 'yes'){
		$('body').prepend(cautionStr);
	}
});
function closeIECaution(){
	$('#ieCaution').hide();
	//$.cookie('cautionIsClosed', 'yes', {path: '/', expires: 7}); //7日間
	$.cookie('cautionIsClosed', 'yes'); //ブラウザ閉じる度
}

/*  ライトボックス */
$(function() {  
	$('#lb a').lightBox();  
}); 
$(function() {  
	$('#PHOTO_0 a').lightBox();  
}); 
