/* ----------------------------------------
consoleLog
Safari 4 の時のみ window.console.logに値を表示
修正：2009/02/28
----------------------------------------*/

function consoleLog( logdata ){
	if(navigator.userAgent.match("Version/4.[0-9]* Safari")){
		window.console.log( logdata );
	}
}

/* end consoleLog
-------------------------------------- */



/* ----------------------------------------
backImageLord
引数のjqueryセレクター内にある img 要素を先に読み込ませる。
修正：2009/02/28
----------------------------------------*/
function backImageLord( jqSelecter ){
	consoleLog('backImageLord : [start] "' + jqSelecter + ' img"');
	
	$(jqSelecter+" img").each(function(){
		var url = $(this).attr("src");
		consoleLog('backImageLord : [loadingImage] ' + jqSelecter + ' img "' + url + '"');
		new Image().src = url;
	});
}
/* end backImageLord
-------------------------------------- */



/* ----------------------------------------
トップページ用スライドショー
修正：2009/02/27
---------------------------------------- */

/* グローバル変数 */
var slide_timerid;
var slide_nowid = 1;
var slide_no = 2;

/* タイマー動作 */
function slide_timer(){
	var sleep = 10000; //10s
	var no;
	
	if ( slide_nowid == slide_no ){
		no = 1;
	}else{
		no = slide_nowid + 1;
	}
	
	slide_timerid = setTimeout(function(){slide_change(no,1)},sleep);
}

/* ボタンを押した時の動作 */
function slide_change(no,next){
	
	if ( no != slide_nowid ){
		$("#slide .slide_change.active").fadeOut("slow",function(){
			$("#slide .slide_change.active").removeClass("active");
			$("#slide .slide_change").each(function(){
				if ( $(this).attr("rel") == 'slide_change['+no+']' ){
					$(this).hide();
					$(this).addClass("active");
					$(this).fadeIn("slow");
				}else{
					$(this).hide();
				}
			});
		});
		
		slide_nowid = no;
		if ( next == 1 ){
			slide_timer();
		}else{
			clearTimeout(slide_timerid);
		}
		slide_buttonUpdate();
	}
}

/* ボタンの表示を更新 */
function slide_buttonUpdate(){
	var i=0;
	$("#slide .slide_button ul li a").each(function(){
		i++;
		if( slide_nowid == i ){
			$(this).css("background-position","0 -14px");
		}else{
			$(this).css("background-position","0 0");
		}
	});
}

/* ページ読み込み直後の動作 */
/*$(document).ready(function(){
	if( $("#slide").length != 0 ){
		slide_buttonUpdate();
		slide_timer();
		backImageLord( "#slide" );
	}
});*/


/* end トップページ用スライドショー
-------------------------------------- */