// Search

UA = (navigator.userAgent.indexOf('MSIE',0) != -1) ? 'target' : 'other';
IE6 = (navigator.userAgent.indexOf('MSIE 6',0) != -1) ? 'target' : 'other';

jQuery.noConflict();
var j$ = jQuery;

j$(function(){
// [スタイル制御]比較、マガジン配布店舗ナビゲーション
	j$('.compareTable tr:odd,#shopNavi li:even').addClass('odd');
	j$('.compareTable tr:even').addClass('even');
	j$('.compareTable tr').hover(function(){
		j$(this).addClass('hover');
	},
	function(){
		j$(this).removeClass('hover');
	});
	j$('.compareTable tr').click(function(){
		j$(this).toggleClass('ac');
	});
// [スタイル制御]RSS一覧ページ
	j$('.stripe').each(function(i){
		addId = 'a'+i;
		j$(this).attr('id',addId);
		j$('.stripe#'+addId).children('tbody').children('tr:even').addClass('odd');
	});

// ランキングのjsはseach.jsへ移行

// [高さ調整]トップページ
	var sets = [], temp = [];
	j$('.hotRanking li dl').each(function(i){
		temp.push(this);
		if(i % 2 == 1){
			sets.push(temp);
			temp = [];
		}
	});
	var sets2 = [], temp2 = [];
	j$('.eachCategory .categoryBlock').each(function(i){
		temp2.push(this);
		if(i % 2 == 1){
			sets2.push(temp2);
			temp2 = [];
		}
	});
	
	if(temp.length) sets.push(temp);
	if(temp2.length) sets2.push(temp2);
	
	j$.each(sets, function(){
		j$(this).flatHeights();
	});
	j$.each(sets2, function(){
		j$(this).flatHeights();
	});
// [高さ調整]トップページ
	j$('.hotRanking li').each(function(i){
		dlh = j$(this).children('dl').height();
		h = ( dlh > 72 ) ? dlh+6 : 72 ;
		j$(this).height(h);
	});
// [高さ調整]写真一覧
	var sets3 = [], temp3 = [];
	j$('.photoGalleryList li .photo').each(function(i){
		temp3.push(this);
		if(i % 4 == 3){
			sets3.push(temp3);
			temp3 = [];
		}
	});
	if(temp3.length) sets3.push(temp3);
	j$.each(sets3, function(){
		j$(this).flatHeights();
	});

// [高さ調整]写真一覧
	var sets4 = [], temp4 = [];
	j$('.photoGalleryList h2').each(function(i){
		temp4.push(this);
		if(i % 4 == 3){
			sets4.push(temp4);
			temp4 = [];
		}
	});
	if(temp4.length) sets4.push(temp4);
	j$.each(sets4, function(){
		j$(this).flatHeights();
	});

// [高さ調整]ランキングマガジンバックナンバー一覧
	var sets5 = [], temp5 = [];
	j$('.backnum .section').each(function(i){
		temp5.push(this);
		if(i % 4 == 3){
			sets5.push(temp5);
			temp5 = [];
		}
	});
	if(temp5.length) sets5.push(temp5);
	j$.each(sets5, function(){
		j$(this).flatHeights();
	});

// [高さ調整]ナビページ・イチ押しランキングモジュール
	var sets6 = [], temp6 = [];
	j$('#recommendRanking li:not(.topArticle)').each(function(i){
		temp6.push(this);
		if(i % 2 == 1){
			sets6.push(temp6);
			temp6 = [];
		}
	});
	if(temp6.length) sets6.push(temp6);
	j$.each(sets6, function(){
		j$(this).flatHeights();
	});

// [スタイル調整]バナー（バナーの配信が無い時、下マージンを取る）
	j$('.adbanner > noscript').each(function(i){
		j$(this).prev('script') ? false:j$(this).parent().addClass('adnone');
	});
	
// [スタイル調整]module（最下部の下線を取る）
	j$('.module02 .section01').each(function(i){
		j$(this).children('li:last').addClass('last');
	});
	
// [フォーム]フォーム部品フォーカス
// IEだけselectのフォーカスがおかしいので除外
	switch(UA){
		case 'target':
			j$('input[@type="text"],textarea').focus(function(){
					j$(this).addClass('hover');
			});
	  		j$('input[@type="text"],textarea').blur(function(){
					j$(this).removeClass('hover');
			});
		break;
		
		case 'other':
			j$('input[@type="text"],select,textarea').focus(function(){
					j$(this).addClass('hover');
					j$(this).css('outline','1px dotted #000');
			});
	  		j$('input[@type="text"],select,textarea').blur(function(){
					j$(this).removeClass('hover');
					j$(this).css('outline','none');
			});
		break;
		
		default:
			j$('input[@type="text"],select,textarea').focus(function(){
					j$(this).addClass('hover');
			});
	  		j$('input[@type="text"],select,textarea').blur(function(){
					j$(this).removeClass('hover');
			});
		break;
	}
	
	j$('input[@type="checkbox"],input[@type="radio"]').focus(function(){
		j$(this).addClass('hover');
	});
	j$('input[@type="checkbox"],input[@type="radio"]').blur(function(){
		j$(this).removeClass('hover');
	});
	j$('.useSec h2,.useSec h3,.useSec p').each(function(){
		title = j$(this).html();
		j$(this).attr('title',title);
	});
	j$('.useSec p').each(function(){
		ph = j$(this).parents('.useSec').height();
		nh = j$('.useSec:header').height();
		j$(this).height(ph - nh);
	});
	j$('.adbanner').each(function(){
	});
// [ブロック制御]グローバルナビ展開
	j$('#gnavi > ul > li > a').each(function(){
		j$(this).parent().hover(function(){
			j$(this).children().next().addClass('ac');
			j$(this).addClass('hover');
		},
		function(){
			j$(this).children().next().removeClass('ac');
			j$(this).removeClass('hover');
		});
	});
// [スタイル制御]ナビページブロック背景色
	j$('.rankingTop li dd,.rankingBottom li dd').each(function(){
		j$(this).hover(function(){
			j$(this).addClass('hover');
		},
		function(){
			j$(this).removeClass('hover');
		});
	});
// [スタイル制御]ランキングマガジンバックナンバー：過去リスト
	j$('.backnumList dl dd span').nextAll().addClass('double');
// [パラメータ付与]ランキングページ（「ランキングの使い方」「BCNランキングとは」のリンク）
	j$('#main .guide .other a').each(function(){
		var parameter = j$(this).attr('href');
		var parameter = parameter + '\?ref=products';
		j$(this).attr('href',parameter);
	});
// [パラメータ付与]ナビページ（「BCNランキングとは」のリンク）
	j$('.naviTitle .aboutBcn a').each(function(){
		var parameter = j$(this).attr('href');
		var parameter = parameter + '\?ref=navipage';
		j$(this).attr('href',parameter);
	});
// [パラメータ付与]トップページ（製品ジャンルごとの記事リスト）
	j$('.categoryBlock .more a').each(function(){
		var parameter = j$(this).attr('href');
		var parameter = parameter + '\?ref=top&mode=newsgenre';
		j$(this).attr('href',parameter);
	});
});

//------------------------------------------------------------------//
// ロールオーバー
//------------------------------------------------------------------//
function rover(name,state){
	if(state=='on'){
	document.getElementById(name).style.backgroundColor = "#f8fecc";
	}else if(state=='off'){
	document.getElementById(name).style.backgroundColor = "#fff";
	}
}

function roverimg(name,state){
	var imgsrc = "/news/images/" + name + "_" + state + ".gif";
	document[name].src = imgsrc;
}


//------------------------------------------------------------------//
// AJAX Macintosh文字化け対策
//------------------------------------------------------------------//
function changeResponseText(inText){
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( inText );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			inText = decodeURIComponent( esc );
		}
	}
	return inText;
}
/**
 *
 *
*/
function changeAccessRanking($inType){
	if($inType == 'week'){
		document.getElementById('accessRankingHour').style.display = 'none';
		document.getElementById('accessRankingWeek').style.display = 'block';
	}
	else{
		document.getElementById('accessRankingHour').style.display = 'block';
		document.getElementById('accessRankingWeek').style.display = 'none';
	}
}
/**
 *
 *
*/
function changeIchioshiRanking($inType){
	if($inType == 'cate'){
		document.getElementById('ichioshiRankingAll').style.display = 'none';
		document.getElementById('ichioshiRankingCate').style.display = 'block';
	}
	else{
		document.getElementById('ichioshiRankingAll').style.display = 'block';
		document.getElementById('ichioshiRankingCate').style.display = 'none';
	}
}
/**
 * Overture 2008-08-26 add
 */
var overture_counter = -1;
function bcn_overture_echo(j){
	if(overture_counter == -1){
		overture_counter = 6;
	}	
	for(k=0;k<j;k++){
		var descr = zSr[overture_counter++]; // listing description
		var unused1 = zSr[overture_counter++]; // (ignore)
		var clickURL = zSr[overture_counter++]; // listing link
		var title = zSr[overture_counter++]; // listing title
		var sitehost = zSr[overture_counter++]; // advertiserfs domain name
		var unused2 = zSr[overture_counter++]; // (ignore)
		document.write('<br />');
		document.write('<p>');
		document.write('<a class="title" target="_new" href="' + clickURL + '">');
		document.write(title);
		document.write('</a><br />');
		document.write('<a class="descr" target="_new" href="' + clickURL + '">');
		document.write(descr);
		document.write('</s><br />');
		document.write('<a class="host" target="_new" href="' + clickURL + '">');
		document.write('(' + sitehost + ')');
		document.write('</a>');
		document.write('</p>');
	}
	document.write('<br />');
	document.write('<div class="ads" align="left">');
	document.write('Ads by Overture');
	document.write('</div>');
	document.write('<br />');

}


function dispIntroduction(){
	j$('div.expand').toggle();
}


function trend_open(){
	j$("#TrendAll").show();
	j$("#TrendSummary").hide();
}

function trend_close(){
	j$("#TrendAll").hide();
	j$("#TrendSummary").show();
}





