//検索フォームの初期テキスト
$(function(){
	$("input#search_form").val("検索").css("color","#cccccc");
	$("input#search_form").focus(function(){
		if(this.value == "検索"){
			$(this).val("").css("color","#000");
		}
	});
	$("input#search_form").blur(function(){
		if(this.value == ""){
			$(this).val("検索").css("color","#cccccc");
		}
		if(this.value != "検索"){
			$(this).css("color","#000");
		}
	});
});

//画像ロールオーバー
$(function(){
	$("img.rollover").not('[src*="'+'_on'+'."]').mouseover(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
		}).mouseout(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
		}).each(function(){
			$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
		})
})

//ページスクロール
$(function(){
	$("a[href^=#]").click(function(){
		var Hash = $(this.hash);
		var HashOffset = $(Hash).offset().top;
		$("html,body").animate({
			scrollTop: HashOffset
		}, 200);//数字が小さいほど速い
	return false;
	});
});

//トップのテクノツリーTVのタイトルグラデーション用
$(function(){
	$(".postTxt .title").prepend("<span></span>");
});

//一覧ページのボックスリンク
$(function(){
	$(".listBox").mouseover(function(){
		$(this).css({
			background:"#fff9ca",//F1F5F5 背景
			cursor:"pointer"});
		$("p.thumb",this).css("borderColor","#ffd69c");//サムネイルの枠
		$("h3 a",this).css("color","#ff9500");//0A6C83 見出し
	}).mouseout(function(){
		$(this).css("background","#ffffff");//背景
		$("p.thumb",this).css("borderColor","#eeeeee");//サムネイルの枠
		$("h3 a",this).css("color","#2792c3");//見出し
	}).click(function(){
	window.location=$(this).find("a").attr("href");
	return false;
	});
});

//ボックスリンク
$(function(){//jqueryAutoHeight.js
	$(".listBox").autoHeight({column:2});
});

//トップのスライド
$(function(){
	var inner="#topImg_inner";//外枠
	var first=inner +" p:first";//先頭の画像
	var last=inner +" p:last";//最後の画像
	var imgWidth=960;
	var prev="#topImg .prev";//前ボタン
	var next="#topImg .next";//次ボタン
	var prevnext="#topImg .prev,#topImg .next"//ボタン2つ
	
	var timerID=setInterval(function(){//自動スクロール
		$(next).click();
	},8000);
	
	//初期設定
	$(inner).css("width",imgWidth *$(inner +" p").size()+"px");//外枠の幅
	$(last).prependTo(inner);//最後の画像を先頭に
	$(inner).css("margin-left","-"+imgWidth+"px");
	
	//戻るボタン
	$(prev).click(function(){
		$(inner).animate({
			marginLeft:parseInt($(inner).css("margin-left"))+imgWidth+"px"
		},"normal","swing",
		function(){
			$(inner).css("margin-left","-"+imgWidth+"px");
			$(last).prependTo(inner);//最後の画像を先頭に
			$(prevnext).show();
		});
	});
	
	//進むボタン
	$(next).click(function(){
		$(inner).animate({
			marginLeft:parseInt($(inner).css("margin-left"))-imgWidth+"px"
		},"normal","swing",
		function(){
			$(inner).css("margin-left","-"+imgWidth+"px");
			$(first).appendTo(inner);//先頭の画像を最後に
			$(prevnext).show();
		});
	});
	
	$(next+" img,"+prev+" img").click(function(){
		clearInterval(timerID);//自動スクロール停止
	});
});

