document.write('<link rel="stylesheet" type="text/css" href="/common/styles/forJS.css" media="all" />');

if(!ist) { var ist = []; }
/*----------------------------------------
	SUB LINKS
----------------------------------------*/
(function($){
$(function(){
	ist.flashObject = swfobject.getObjectById('flashObject');
	$('#topLinks > li').each(function(index, item){
		var _this = $(this);
		var _linkWrap = _this.find('div.linkWrap');
		_this.mouseenter(function(){
			if(ist.flashObject && ist.flashObject.btnOff){
				ist.flashObject.btnOff();
			}
			_linkWrap.stop();
			var _inner = _linkWrap.find('div.subLinks');
			_linkWrap.animate({ height : _inner.height() }, 400, 'easeOutCirc', function(){
				$(this).css({ height : 'auto', overflow : 'visible' });
	
			});
			_this.mouseleave(function(){
				if(ist.flashObject && ist.flashObject.btnOn){
					ist.flashObject.btnOn();
				}
				_linkWrap.stop();
				_linkWrap.css({ overflow : 'hidden' }).animate({ height :0 }, 400, 'easeOutCirc');
			});
	
		});
	});

	$('div.subLinks li').has('div.lowerLinks').each(function(index, item){
		var _this = $(this);
		var _lowerLinks = _this.find('div.lowerLinks');
		_this.mouseenter(function(){
			_this.css('z-index', 11);
			if(ist.flashObject && ist.flashObject.btnOff){
				ist.flashObject.btnOff();
			}
			_lowerLinks.show();
			_this.mouseleave(function(){
				_this.css('z-index', 10);
				if(ist.flashObject && ist.flashObject.btnOn){
					ist.flashObject.btnOn();
				}
				_lowerLinks.hide();
			});
		});
	});

});
})(jQuery);

/*----------------------------------------
	SCROLL BAR
----------------------------------------*/
$.fn.extend({
	jScrollAnchor : function() {
		var setting = $.extend({
			event : 'click',
			panel : '.scroll'
		}, $.makeArray(arguments).shift());
		var _panel = $(setting.panel);
		return this.each(function() {
			var _href = $(this).attr('href');
			$(this).bind(setting.event, function(){
				this.blur();
				_panel[0].scrollTo(_href);
				return false;
			});
		});
	}
});

ist.scrollSettings = {
	scrollbarWidth : 15,
	scrollbarMargin : 8,
	animateTo : true,
	animateInterval : 50
};
$(function() {
	$('.scroll').jScrollPane(ist.scrollSettings).css({'visibility' : 'visible'});
	$('a.anchorLink').jScrollAnchor({ panel : '#anchorArea' });
});

/*----------------------------------------
	Switch Panel
----------------------------------------*/
$.fn.extend({
	switchPanel : function() {
		var setting = $.extend({
			event : 'click',
			stayClass : 'stay',
			defaultNum : 0,
			resetLink : '.resetLink',
			panel : '.switchPanel'
		}, $.makeArray(arguments).shift());
		var _link = this;
		var _panel = $(setting.panel);
		_panel.hide().eq(setting.defaultNum).show().css({'visibility' : 'visible'});

		$(setting.resetLink).bind(setting.event, function(){
			_link.removeClass(setting.stayClass);
			_panel.hide().eq(setting.defaultNum).show().css({'visibility' : 'visible'});
			return false;
		})
		var _this = $(this);

		return this.each(function() {
			var _anchor = $(this);
			_anchor.bind(setting.event, function(){
				_link.removeClass(setting.stayClass);
				_this.filter('[href='+$(this).attr('href')+']').addClass(setting.stayClass);
				this.blur();
				_panel.hide();
				_panel.filter($(this).attr('href')).show().css({'visibility' : 'visible'});
				return false;
			});
		});
	}
});

$(function() {
	$('a.switchLink').switchPanel();
});


/*----------------------------------------
	Escape SSL
----------------------------------------*/
$.fn.extend({
	leaveSSL : function() {
		var _url = location.href;
		var _pathname = location.pathname;
		var _protocol = location.protocol;
		var _pathList = _pathname.substr(1).split('/');
		_pathList.length = _pathList.length -1;

		if(_protocol == 'https:'){
			var _domain = 'http://' + location.host;

			this.each(function(index, item){
				var $this = $(this);
				var _href = $this.attr('href');
				var _newHref = _domain + _href;
				$this.attr('href', _newHref);
			});
		}
		return this;
	},
	enterSSL : function(){
		var _url = location.href;
		var _pathname = location.pathname;
		var _protocol = location.protocol;
		var _pathList = _pathname.substr(1).split('/');
		_pathList.length = _pathList.length -1;

		if(_protocol == 'http:'){
			var _domain = 'https://' + location.host;

			this.each(function(index, item){
				var $this = $(this);
				var _href = $this.attr('href');
				var _newHref = _domain + _href;
				$this.attr('href', _newHref);
			});
		}
		return this;
	}
});
$(function() {
	$('#headerSegment a,#menuSegment a,#footerSegment a').not('a.secureLink').leaveSSL();
	$('a.secureLink').enterSSL();
});


/*----------------------------------------
	Form Error
----------------------------------------*/
(function($){
$(function(){
	$('.offContext').bind('contextmenu', function(e){
		e.preventDefault();
	});
});
})(jQuery);

/*----------------------------------------
	Form Error
----------------------------------------*/
(function($){
$(function(){
	$('.btnConfirm a').click(function(e){
		var _error = false;
		var _musts = $('.must');
		_musts.each(function(){
			var _this = $(this);
			if(_this.val().length != 0){
				_this.removeClass('noVal');
			} else {
				_error = true;
				_this.addClass('noVal');
			}
		});
		if(_error){
			e.preventDefault();
			alert('必須項目を入力してください。');
		}
	});
});
})(jQuery);


/*----------------------------------------
	Centering
----------------------------------------*/
(function($){
$(function(){
	var $container = $("#container");
	$(window).resize(setCeterFunc);
	setCeterFunc();
	
	function setCeterFunc(){
		var obj = getScreenSize();
		if(obj.x < $container.width()){
			obj.mx = "50%";
		}
		if(obj.y < $container.height()){
			obj.my = "50%";
		}
		$container.css({ left : obj.mx, top : obj.my });
	}
});
})(jQuery);


/*----------------------------------------
	getScreenSize
----------------------------------------*/
function getScreenSize() {
	var obj = new Object();
	if (!(navigator.appVersion.toLowerCase().indexOf('safari')+1?1:0) && !(navigator.userAgent.toLowerCase().indexOf('opera')+1?1:0)) {
		obj.x = document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth;
		obj.y = document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight;
	} else {
		obj.x = window.innerWidth;
		obj.y = window.innerHeight;
	}
	obj.mx = parseInt((obj.x)/2);
	obj.my = parseInt((obj.y)/2);
	return obj;
}
