/*------------------------------------------------------------
 * basic.js (require jQuery.js v1.4.2) Version 0.1
/*------------------------------------------------------------*/

$(function (){
	initRollOver();
});



/* 1: img.btn, input.btnにロールオーバー効果を付けます。
==============================================================*/

function initRollOver(){
    $("img.btn, input.btn").mouseover(
		function (){ initMouseOver($(this)); }
	).mouseout(
		function (){ initMouseOut($(this)); }
	);
}

function initMouseOver(obj){
	obj.not("[src*='_on.']").attr("src", obj.attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
}

function initMouseOut(obj){
	obj.attr("src", obj.attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
}




/*----------------------------------------------------*/
/*
 * slideshow v0.1
 */

jQuery(function($){
	var slides = new Array;
	$('#main-image').find('a').each(function(){
		var image = $(this).find('img').attr('src');
		var link = $(this).attr('href');
		var slide = $('<img>').attr('src', image);
		if(link){
		$(slide).click(function(){ location.href = link; });
		}
		slides[slides.length] = slide;
	});
	var index = 0;
	$('#main-image').html(slides[index].clone(true));
	setInterval(function(){
		$('#main-image > img').fadeOut('slow', function(){
			$(this).remove();
		});
		index++;
		if (index >= slides.length){
			index = 0;
		}
		var image = slides[index].clone(true);
		$('#main-image').prepend(image.fadeIn(1000));
	}, 3000);
});


