$(function(){
	var aPreLoad = new Array();
	$("img.btn, img.tab, img.push").each(function(i){
		var src = $(this).attr('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		if(!src.match(/_o./)) {
			var hsrc = src.replace(ftype, '_o'+ftype);
			var psrc = src.replace(ftype, '_on'+ftype);
			$(this).attr('hsrc', hsrc);
			$(this).attr('dsrc', src);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			if($(this).parent().attr('class') != "now"){
				$(this).mouseover(function(){
					$(this).attr('src', $(this).attr('hsrc'));
				});
				$(this).mouseout(function(){
					$(this).attr('src', $(this).attr('dsrc'));
				});
			}else{
				$(this).attr('src', src.replace(ftype, '_n'+ftype));
			}
			if($(this).attr('class') == "push"){
				$(this).mousedown(function(){
					$(this).attr('src', $(this).attr('psrc'));
				});
				$(this).mouseup(function(){
					$(this).attr('src', $(this).attr('hsrc'));
				});
			}
		}
	});
	
	
	$("#menu img").each(function(n){
		if($(this).attr('src').match(/_uc.|_n./)){
			$(this).parent().removeAttr("href");
		}
		
		//番組ページリンク隠す
		/*if(n==5) {
			$(this).parent().hide();
		}*/
	});
	
	$("img.uc").each(function(){
			$(this).fadeTo(1, 0.5)				  
	});
	
	if($.browser.msie && $.browser.version < 7) {
	$("#page").css('background-image','url(img/page_bg_png8.png)');
	}
	
	if($("#blog_header").size()){
		$("#blog_header").pngfix();
		if($("#blog_header li").size()%2 == 0){
			$("#blog_header li:last-child").css({"clear":"left","float":"right"});
		}
	}
	
	if($("#timetable").size()){
		$(".msg").each(function(n){
			$(this).css({"margin-top":0-$(this).height()/2-22});
			$(this).click(function(){
				$(this).fadeOut();
			});
			//$(this).pngfix();
		});
		$("#timetable td a").each(function(n){
			$(this).mouseover(function(){
				$(this).css({"margin-top":-2});
			});
			/*$(this).mousedown(function(){
				$(this).css({"margin-top":0});
			});*/
			$(this).mouseout(function(){
				$(this).css({"margin-top":0});
			});
			
			//$("html").mousedown(function(){msgClose(0);});
		});
	}
	
	
	if($("#top").size()){
		$("p.shinsai").corner();
	}
});

function pageScroll(o){
	if(!o) o=0;
	$.scrollTo(o,350);
}

function toiawase(o) {
	if(o){
		$("#toiawase_pane").fadeIn("fast");
	}else{
		$("#toiawase_pane").fadeOut("fast");
	}
}

function onukiMsg(o) {
	if(o){
		$("#onuki_msg").fadeIn("slow");
	}else{
		$("#onuki_msg").fadeOut("slow");
	}
}


function msg(o) {
	$(".msg").each(function(n){
		if($(this).attr('id') == "msg"+o && $(this).is(":hidden")){
			$(this).fadeIn();
		}else{
			$(this).fadeOut();
		}
	});
}
function msgClose(o) {
	$(".msg").each(function(n){
		$(this).fadeOut();				
	});
}
