$(function(){
   // #で始まるアンカーをクリックした場合に処理
   $('a[href^=#]').click(function() {
      // スクロールの速度
      var speed = 400;// ミリ秒
      // アンカーの値取得
      var href= $(this).attr("href");
      // 移動先を取得
      var target = $(href == "#" || href == "" ? 'html' : href);
      // 移動先を数値で取得
      var position = target.offset().top;
      // スムーススクロール
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
});


$(document).ready(function() {
	$(".navi dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".navi dd").css("display","none");
	$(".navi dt").click(function(){
		$(this).next().slideToggle("slow");
		});
});

/*
//画像ロールオーバー
jQuery(function($) {
	var postfix = '_on';
	$('#header a img').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function() {
			img.attr('src', src_on);
		}, function() {
			img.attr('src', src);
		});
	});
});

*/

//lightbox
		$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$(".group1").colorbox({rel:'group1'});
			$(".group2").colorbox({rel:'group2', transition:"fade"});
			$(".group3").colorbox({rel:'group3', transition:"none", width:"75%", height:"75%"});
			$(".group4").colorbox({rel:'group4', slideshow:true});
			$(".ajax").colorbox();
			$(".youtube").colorbox({iframe:true, innerWidth:425, innerHeight:344});
			$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
			$(".inline").colorbox({inline:true, width:"50%"});
			$(".callbacks").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});



//fadein
var i = 0;
var int = 0;
$(window).bind("load", function() {
	$('#InVisual').fadeIn(1000); // box1のフェードインの実行
	var int=setInterval("sFade(i)",1000);  // 1000ミリ秒ごとにフェードインの処理の実行
});
function sFade() {
	if (i >= 1) {
		clearInterval(int); // setIntervalの解除
	}
	if (i == 0) {
		$('#MainVisual2').fadeIn(1000); // box2のフェードインの実行
	}
	if (i == 1) {
		$('#box3').fadeIn(1000); // box3のフェードインの実行
	}
    i++;
}


//マウスオーバーフェード
(function ($) {
              $.fn.cross = function (options) {
                  return this.each(function (i) { 
                      // cache the copy of jQuery(this) - the start image
                      var $$ = $(this);
                      
                      // get the target from the backgroundImage + regexp
                      var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');

                      // nice long chain: wrap img element in span
                      $$.wrap('<span style="position: relative;"></span>')
                          // change selector to parent - i.e. newly created span
                          .parent()
                          // prepend a new image inside the span
                          .prepend('<img>')
                          // change the selector to the newly created image
                          .find(':first-child')
                          // set the image to the target
                          .attr('src', target);

                      // the CSS styling of the start image needs to be handled
                      // differently for different browsers
                      if ($.browser.msie || $.browser.mozilla) {
                          $$.css({
                              'position' : 'absolute', 
                              'left' : 0,
                              'background' : '',
                              'top' : this.offsetTop
                          });
                      } else if ($.browser.opera && $.browser.version < 9.5) {
                          // Browser sniffing is bad - however opera < 9.5 has a render bug 
                          // so this is required to get around it we can't apply the 'top' : 0 
                          // separately because Mozilla strips the style set originally somehow...                    
                          $$.css({
                              'position' : 'absolute', 
                              'left' : 0,
                              'background' : '',
                              'top' : "0"
                          });
                      } else { // Safari
                          $$.css({
                              'position' : 'absolute', 
                              'left' : 0,
                              'background' : ''
                          });
                      }

                      // similar effect as single image technique, except using .animate 
                      // which will handle the fading up from the right opacity for us
                      $$.hover(function () {
                          $$.stop().animate({
                              opacity: 0
                          }, 250);
                      }, function () {
                          $$.stop().animate({
                              opacity: 1
                          }, 250);
                      });
                  });
              };
              
          })(jQuery);
          
          // note that this uses the .bind('load') on the window object, rather than $(document).ready() 
          // because .ready() fires before the images have loaded, but we need to fire *after* because
          // our code relies on the dimensions of the images already in place.
          $(window).bind('load', function () {
              $('img.fade').cross();
          });


//スマホ振り分け用
// iPhoneまたは、Androidの場合は振り分けを判断 
if (document.referrer.indexOf('192.168.11.25/takagyo719.com/root/') == -1 && ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0)) {     if(confirm('東京都行政書士アカデミーへようこそ。\nこのサイトにはスマートフォン用のサイトがあります。\n表示しますか？')) {         location.href = 'http://192.168.11.25/takagyo719.com/root/light/';     } }




//レンタルオフィス ギャラリー用
  $(function() {
    //$('img.image14').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
    //$('img.image1').data('ad-title', 'Title through $.data');
    //$('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
    //$('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');
    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
    $('#toggle-description').click(
      function() {
        if(!galleries[0].settings.description_wrapper) {
          galleries[0].settings.description_wrapper = $('#descriptions');
        } else {
          galleries[0].settings.description_wrapper = false;
        }
        return false;
      }
    );
  });

