(function()
{
/* -------------------------------------------

	gNavi current

------------------------------------------- */
var gNaviCurrentFunc = {
	getURL : function()
	{
		var url = document.URL,
		gNavi = $('#gNavi'),
		
		link01 = gNavi.find('.link01 a'),
		link02 = gNavi.find('.link02 a'),
		link03 = gNavi.find('.link03 a'),
		link04 = gNavi.find('.link04 a'),
		link05 = gNavi.find('.link05 a'),
		link06 = gNavi.find('.link06 a'),
		link07 = gNavi.find('.link07 a');
		
		var sideNavi1Link = $('#sideNavi1').find('a'),
		sideNavi2Link = $('#sideNavi2').find('a'),
		sideNavi3Link = $('#sideNavi3').find('a'),
		sideNavi4Link = $('#sideNavi4').find('a');
		
		
		// url と 適用するCSSの値をセットしている
		// ============
		// GALLERY
		// ============
		if( url.indexOf('/gl_studio.php') > -1 ){ this.changeNavi( link01, '0 100%' ); }
		// 下層
		if( url.indexOf('/gl_studio.php') > -1 ){ this.changeNavi( $(sideNavi1Link[0]), '100% 0' ); this.changeNavi( link01, '0 100%' ); return false; }
		if( url.indexOf('/gl_photo.php') > -1 ){ this.changeNavi( $(sideNavi1Link[1]), '100% -35px' ); this.changeNavi( link01, '0 100%' ); return false; }
		if( url.indexOf('/gl_party.php') > -1 ){ this.changeNavi( $(sideNavi1Link[2]), '100% -70px' ); this.changeNavi( link01, '0 100%' ); return false; }
		if( url.indexOf('/gl_baby.php') > -1 ){ this.changeNavi( $(sideNavi1Link[3]), '100% -105px' ); this.changeNavi( link01, '0 100%' ); return false; }
		// ============
		// PLAN
		// ============
		if( url.indexOf('/policy.php') > -1 ){ this.changeNavi( $(sideNavi2Link[0]), '100% 0' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_garnet.php') > -1 ){ this.changeNavi( $(sideNavi2Link[1]), '100% -35px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_amethyst.php') > -1 ){ this.changeNavi( $(sideNavi2Link[2]), '100% -70px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_aquamarine.php') > -1 ){ this.changeNavi( $(sideNavi2Link[3]), '100% -105px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_diamond.php') > -1 ){ this.changeNavi( $(sideNavi2Link[4]), '100% -140px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_option.php') > -1 ){ this.changeNavi( $(sideNavi2Link[5]), '100% -175px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		if( url.indexOf('/photo_setplan.php') > -1 ){ this.changeNavi( $(sideNavi2Link[6]), '100% -210px' ); this.changeNavi( link02, '-113px 100%' ); return false; }
		// ============
		// Bridal Party Plan
		// ============
		if( url.indexOf('/party_jasmin.php') > -1 ){ this.changeNavi( $(sideNavi3Link[0]), '100% 0' ); this.changeNavi( link03, '-257px 100%' ); return false; }
		if( url.indexOf('/party_rose.php') > -1 ){ this.changeNavi( $(sideNavi3Link[1]), '100% -35px' ); this.changeNavi( link03, '-257px 100%' ); return false; }
		if( url.indexOf('/party_option.php') > -1 ){ this.changeNavi( $(sideNavi3Link[2]), '100% -70px' ); this.changeNavi( link03, '-257px 100%' ); return false; }
		
		// 
		if( url.indexOf('/baby_maternity.php') > -1 ){ this.changeNavi( link04, '-401px 100%' ); }
		if( url.indexOf('/album.php') > -1 ){ this.changeNavi( link05, '-545px 100%' ); }
		if( url.indexOf('/dress.php') > -1 ){ this.changeNavi( link06, '-659px 100%' ); }
		// ============
		// DVD
		// ============
		if( url.indexOf('/o_dvd.php') > -1 ){ this.changeNavi( $(sideNavi4Link[0]), '100% 0' ); this.changeNavi( link07, '-779px 100%' ); return false; }
		if( url.indexOf('/o_flower.php') > -1 ){ this.changeNavi( $(sideNavi4Link[1]), '100% -35px' ); this.changeNavi( link07, '-779px 100%' ); return false; }
		if( url.indexOf('/o_paper.php') > -1 ){ this.changeNavi( $(sideNavi4Link[2]), '100% -70px' ); this.changeNavi( link07, '-779px 100%' ); return false; }
	},
	changeNavi : function( val, position )
	{
		val.css({ backgroundPosition : position });
	}
};
/* -------------------------------------------

	gNavi for IE
	
	// hideFocus

------------------------------------------- */
var hideForcusForIE = {
	manager : function()
	{
		var UA = navigator.userAgent;
		if( UA.indexOf('MSIE') > -1 ) this.get();
	},
	get : function()
	{
		$('#gNavi a, #flashAreaNavi a, #sideNavi1 a, #sideNavi2 a, #linkList a').attr( 'hideFocus', 'true' );
	}
};
/* -------------------------------------------

	fire!

------------------------------------------- */
$(function()
{
	gNaviCurrentFunc.getURL();
	hideForcusForIE.manager();
	
	var gNavi = $('#gNavi');
	/* ---------
	
	gNaviPopup
	
	--------- */
	gNavi.children('li.link01, li.link02, li.link03, li.link07').mouseenter(function()
	{
		/* ---------------------------
		
			CLICK EVENT CANCEL 
		
		--------------------------- */
		$( this ).children('a').click(function( e )
		{
			e.preventDefault();
		});
		/*
		
		POPUP
		
		*/
		$(this)
		.children('ul').slideDown(200)
		.end().children('a').addClass('current');
	})
	.mouseleave(function()
	{
		$(this)
		.height(21)
		.children('ul').hide()
		.end().children('a').removeClass('current');
	});
	/* ---------
	
	smoooth scroll
	
	--------- */
	$('.pageTop a').smoothScroll();
	/* ---------
	
	CALENDARの画像のずれ対応。(IE6)

	--------- */
	$('#Right .calendar a').click(function( e )
	{
		e.preventDefault();
		window.open( this.href, 'new', 'width=1000, height=900, scrollbars=1, toolbar=1, location=1, status=1, resizable=1, menubar=1');
	});
});
})();// capsule
/*!
 * jQuery Smooth Scroll Plugin v1.4
 *
 * Date: Mon Apr 25 00:02:30 2011 EDT
 * Requires: jQuery v1.3+
 *
 * Copyright 2010, Karl Swedberg
 * Dual licensed under the MIT and GPL licenses (just like jQuery):
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 *
 *
 *
*/

(function($) {

var version = '1.4',
    defaults = {
      exclude: [],
      excludeWithin:[],
      offset: 0,
      direction: 'top', // one of 'top' or 'left'
      scrollElement: null, // jQuery set of elements you wish to scroll (for $.smoothScroll).
                          //  if null (default), $('html, body').firstScrollable() is used.
      scrollTarget: null, // only use if you want to override default behavior
      afterScroll: null,   // function to be called after window is scrolled. "this" is the triggering element
      easing: 'swing',
      speed: 400
    },
    locationPath = filterPath(location.pathname),
    getScrollable = function(opts) {
      var scrollable = [],
          scrolled = false,
          dir = opts.dir && opts.dir == 'left' ? 'scrollLeft' : 'scrollTop';

      this.each(function() {

        if (this == document || this == window) { return; }
        var el = $(this);
        if ( el[dir]() > 0 ) {
          scrollable.push(this);
          return;
        }

        el[dir](1);
        scrolled  = el[dir]() > 0;
        el[dir](0);
        if ( scrolled ) {
          scrollable.push(this);
          return;
        }

      });

      if ( opts.el === 'first' && scrollable.length ) {
        scrollable = [ scrollable.shift() ];
      }

      return scrollable;
    };

$.fn.extend({
  scrollable: function(dir) {
    var scrl = getScrollable.call(this, {dir: dir});
    return this.pushStack(scrl);
  },
  firstScrollable: function(dir) {
    var scrl = getScrollable.call(this, {el: 'first', dir: dir});
    return this.pushStack(scrl);
  },

  smoothScroll: function(options) {
    options = options || {};
    var opts = $.extend({}, $.fn.smoothScroll.defaults, options);
    this.die('click.smoothscroll').live('click.smoothscroll', function(event) {

      var link = this, $link = $(this),
          hostMatch = ((location.hostname === link.hostname) || !link.hostname),
          pathMatch = opts.scrollTarget || (filterPath(link.pathname) || locationPath) === locationPath,
          thisHash = link.hash,
          include = true;


      if ( !opts.scrollTarget && (!hostMatch || !pathMatch || !thisHash) ) {
        include = false;
      } else {
        var exclude = opts.exclude, elCounter = 0, el = exclude.length;
        while (include && elCounter < el) {
          if ($link.is(exclude[elCounter++])) {
            include = false;
          }
        }

        var excludeWithin = opts.excludeWithin, ewlCounter = 0, ewl = excludeWithin.length;
        while ( include && ewlCounter < ewl ) {
          if ($link.closest(excludeWithin[ewlCounter++]).length) {
            include = false;
          }
        }
      }

      if ( include ) {
        opts.scrollTarget = options.scrollTarget || thisHash;
        opts.link = link;
        event.preventDefault();
        $.smoothScroll(opts);
      }
    });

    return this;

  }

});

$.smoothScroll = function(options, px) {
  var opts, $scroller, scrollTargetOffset,
      scrollerOffset = 0,
      offPos = 'offset',
      scrollDir = 'scrollTop',
      aniprops = {};

  if ( typeof options === 'number') {
    opts = $.fn.smoothScroll.defaults;
    scrollTargetOffset = options;
  } else {
    opts = $.extend({}, $.fn.smoothScroll.defaults, options || {});
    if (opts.scrollElement) {
      offPos = 'position';
      if (opts.scrollElement.css('position') == 'static') {
        opts.scrollElement.css('position', 'relative');
      }
    }

    scrollTargetOffset = px ||
                        ( $(opts.scrollTarget)[offPos]() &&
                        $(opts.scrollTarget)[offPos]()[opts.direction] ) ||
                        0;
  }
  opts = $.extend({link: null}, opts);
  scrollDir = opts.direction == 'left' ? 'scrollLeft' : scrollDir;

  if ( opts.scrollElement ) {
    $scroller = opts.scrollElement;
    scrollerOffset = $scroller[scrollDir]();
  } else {
    $scroller = $('html, body').firstScrollable();
  }

  aniprops[scrollDir] = scrollTargetOffset + scrollerOffset + opts.offset;

  $scroller.animate(aniprops,
  {
    duration: opts.speed,
    easing: opts.easing,
    complete: function() {
      if ( opts.afterScroll && $.isFunction(opts.afterScroll) ) {
        opts.afterScroll.call(opts.link, opts);
      }
    }
  });

};

$.smoothScroll.version = version;

// default options
$.fn.smoothScroll.defaults = defaults;


// private function
function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
}

})(jQuery);



