/*
------------------------------------------------------------
Add "Class attribution" function for "body" tag.
This function requires 'jQuery'.
Please load jQuery library before using this function.
------------------------------------------------------------
*/

$(document).ready(function(){
	
	var $a_check = $("#main p.topicPath:first a").text();
	var $span_check = $("#main p.topicPath:first span").text();
	
	// Select type and Add bodyClass
	if(($a_check.match(/INFO/i)) || ($span_check.match(/INFO/i))){
		$("body").addClass("info");
		// if set attribution of "id", use next method
	//	$("body").attr({id: "wp_info"});
	}
	
	if(($a_check.match(/キャンペーン/)) || ($span_check.match(/キャンペーン/))){
		$("body").addClass("campaign");
	}
	
	if(($a_check.match(/レシピ/)) || ($span_check.match(/レシピ/))){
		$("body").addClass("recipe");
	}
	
	if(($a_check.match(/フルーツ/)) || ($span_check.match(/フルーツ/))){
		$("body").addClass("recipe");
	}
	
	if(($a_check.match(/洋菓子/)) || ($span_check.match(/洋菓子/))){
		$("body").addClass("recipe");
	}
	
	if(($a_check.match(/展示会/)) || ($span_check.match(/展示会/))){
		$("body").addClass("exhibition");
	}
	
	if(($a_check.match(/新商品のご案内/)) || ($span_check.match(/新商品のご案内/))){
		$("body").addClass("new");
	}
	
	if(($a_check.match(/講習会/)) || ($span_check.match(/講習会/))){
		$("body").addClass("course");
	}
	
});

$(function(){
	$('#genre').click(function(){
		$('#entryList07').slideToggle("fast");
	});
	$('#ingredient').click(function(){
		$('#entryList08').slideToggle("fast");
	});
	$('body.recipe #entryList07').css('display','block');
	$('body.recipe #entryList08').css('display','block');
	$('body.recipe #entryList07 ul').css('display','none');
	$('body.recipe #entryList08 ul').css('display','none');
	$('body.recipe p.topicPath span.current').before('レシピ > ');	
	$('a.childCategory').click(function(){
			$(this).next().slideToggle("fast");
	});
});

function checkBrowser(){

	var np=navigator.platform;
	var ua=navigator.userAgent;
	var flag = new String();
	
	if (np.indexOf("Win") != -1) {
		if (ua.indexOf("MSIE") != -1) {
			flag = "w1";
		} else if (ua.indexOf("Firefox") != -1) {
			flag = "w2";
		} else if (ua.indexOf("Netscape") != -1) {
			flag = "w3";
		} else if (ua.indexOf("Opera") != -1) {
			flag = "w4";
		} else if (ua.indexOf("Safari") != -1) {
			flag = "w5";
		}
	} else if (np.indexOf("Mac") != -1) {
		if (ua.indexOf("MSIE") != -1) {
			flag = "m1";
		} else if (ua.indexOf("Firefox") != -1) {
			flag = "m2";
		} else if (ua.indexOf("Netscape") != -1) {
			flag = "m3";
		} else if (ua.indexOf("Opera") != -1) {
			flag = "m4";
		} else if (ua.indexOf("Safari") != -1) {
			flag = "m5";
		}
	} else {
		flag = "other";
	}
	
	return flag;
}


function changeCSS(){ //※onloadより前に実行すること

	var np = checkBrowser().toString();
	if (np == "m2"){
		document.writeln('<style type="text/css">');
		document.writeln('body, th, td { ');
		document.writeln('font-family: ' + "'ヒラギノ角ゴ Pro W3',Arial,sans-serif; }");
		document.writeln('</style>');
	}
	
	if (np == "m5"){
		document.writeln('<style type="text/css">');
		document.writeln('body, th, td { ');
		document.writeln('font-family: ' + "'Hiragino Kaku Gothic Pro',Arial,sans-serif; }");
		document.writeln('</style>');
	}
	
	if (np == "m1" || np == "m3" || np == "m4"){
		document.writeln('<style type="text/css">');
		document.writeln('body, th, td { ');
		document.writeln('font-family: ' + "'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','Osaka',Arial,sans-serif; }");
		document.writeln('</style>');
	}
}

changeCSS();


function ieCSS(){	//IE用Conditional Comment
	document.writeln('<!--[if IE 6]><link rel="stylesheet" type="text/css" href="http://www.sun-eight.com/wp/wp-content/themes/wp.vicuna/style-mono/winie6.css" /><![endif]-->');
	document.writeln('<!--[if IE 7]><link rel="stylesheet" type="text/css" href="http://www.sun-eight.com/wp/wp-content/themes/wp.vicuna/style-mono/winie7.css" /><![endif]-->');
	document.writeln('<!--[if IE 8]><link rel="stylesheet" type="text/css" href="http://www.sun-eight.com/wp/wp-content/themes/wp.vicuna/style-mono/winie8.css" /><![endif]-->');
}

ieCSS();
