/* #############################################################
#WEB_SITES_JS {
	--------------------------------------------
	#filename	: base.js
	#version    : 1.0;

	サイト内JavaScriptの管理ファイル
	--------------------------------------------
}

#CONTENT {
	--------------------------------------------
	+ 1: rollover function
	+ 2: accordion function
	+ 3: slide function
	+ 4: target blank function
	+ 5: following scroll function
	+ 999: CSS set
	--------------------------------------------
}

############################################################# */


$(function(){
/* ==============================================================
	
	[+1:]
	rollover function
	for jQuery

============================================================== */
$('a img.hov')
	.mouseover(function () {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_hov$2");
	})
	.mouseout(function () {
		this.src = this.src.replace(/^(.+)_hov(\.[a-z]+)$/, "$1$2");
	})
	.each(function () {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_hov$2");
});
$("input.hov")
	.mouseover(function () {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_hov$2");
	})
	.mouseout(function () {
		this.src = this.src.replace(/^(.+)_hov(\.[a-z]+)$/, "$1$2");
	})
	.each(function () {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_hov$2");
});


$('img.on')
	.each(function () {
	this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_hov$2");
});
	


/*
※jQuery is necessary. 
■ボタンのロールオーバー用ファンクション(jQuery版)

【操作手順】
[1]ロールオーバー前用の画像を適当なファイル名で用意します。 例：btn.gif
[2]ロールオーバー時用の画像のファイル名末端に"_hov"と付けます。 例：btn_hov.gif
[3]設置するimg要素に class="Hov" を指定します。
---------------------------------------------------------------
<img class="Hov" src="../../common/js/img/btn.gif" alt="test" />
---------------------------------------------------------------
*/


/* ==============================================================
	
	[+2:]
	accordion function
	for jQuery

============================================================== */
$(".accordion").each(function(){
	$("dd", this).each(function(){
		var $this = $(this);
		if(!$this.hasClass("open")){
			$this.find("ul").hide();
		}
	});
});
$(".accordion span").css("cursor", "pointer"); 
$(".accordion span").click(function(){
	if($(this).next().is(":visible")){
		$(this).next().slideUp("slow");
	}else{
		$(this).next().slideDown("slow");
		$(this).parent().siblings().children("ul:visible").slideUp("slow");
	}
	return false;
});



/* ==============================================================
	
	[+3:]
	slide function
	for jQuery

============================================================== */
$(".slideContents").each(function(){
	$(this).css("height", $(this).height() + "px");
});
$(".slideTrigger").css("cursor", "pointer"); 
$(".slideContents").hide(); 
$(".slideTrigger").click(function(){
	if($(this).next().is(":visible")){
		$(this).next().slideUp("slow");
		$(this).removeClass("active");
	}else{
		$(this).next().slideDown("slow");
		$(this).addClass("active");
	}
	return false;
});


/* ==============================================================
	
	[+4:]
	target blank function
	for jQuery

============================================================== */
$(".blank").click(function(){
	window.open(this.href,'_blank');
	return false;
});


/* ==============================================================
	
	[+5:]
	following scroll function
	for jQuery


var offset = $("#aside").offset();
var topPadding = 15;

$(window).scroll(function() {
	var asideH = $("#aside").height();
	var articleH = $("#article").height();
	
	var pOffset = $("#aside").offset();
	//alert("pOffset" + pOffset.top + " " + "offset" + offset.top);
	
	if(asideH + ($(window).scrollTop() - offset.top) < articleH){
		if($(window).scrollTop() > offset.top){
			$("#aside").stop().animate({
				marginTop: $(window).scrollTop() - offset.top + topPadding
			});
		}else{
			$("#aside").stop().animate({
				marginTop: 0
			});
		}
	}else{
		if(pOffset.top - offset.top + asideH < articleH){
			$("#aside").stop().animate({
				marginTop: articleH - asideH
			});
		}
	}
});

============================================================== */

/* ==============================================================
	
	[+5:]
	popup function
	for jQuery

============================================================== */
$(".popup").click(function(){
	window.open(this.href, "","width=1000,height=650,menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=no");
	return false;
});




});
//END "$(function()"


