// RollOver
$(function () {
	$.rollover = {
		init : function () {
			$('a img,input[type="image"]').not('[src*="_on."]')
				.bind('mouseover', this.over)
				.bind('mouseout',  this.out)
				.each(this.preload);
		},

		over : function () {
			this.setAttribute('src', this.getAttribute('src').replace('_off.', '_on.'));
		},

		out : function () {
			this.setAttribute('src', this.getAttribute('src').replace('_on.', '_off.'));
		},

		preload : function () {
			new Image().src = this.getAttribute('src').replace('_off.', '_on.');
		}
	};

	$.rollover.init();
});

//extension
$(document).ready(function(){

	$('a[href$=pdf]').addClass('pdf');

	$('a[href$=doc]').addClass('doc');

	$('a[href$=xls]').addClass('xls');
	
//	$("a[@href$=gif]").addClass("img");
	
//	$("a[@href$=jpg]").addClass("img");

//	$("a[@href$=ram]").addClass("sound");

//	$("a[@href$=mp3]").addClass("sound");

});

//headernavi
  $(document).ready(function(){
		$("#nav-one li").hover(
			function(){ $("ul", this).fadeIn("slow"); }, 
			function() { } 
		);
	if (document.all) {
			$("#nav-one li").hoverClass ("sfHover");
		}
  });
  
	$.fn.hoverClass = function(c) {
		return this.each(function(){
			$(this).hover( 
				function() { $(this).addClass(c);  },
				function() { $(this).removeClass(c); }
			);
		});
	};	 
	

// PNG fix
// if (window.DD_belatedPNG) DD_belatedPNG.fix('li.bottom'); 

//flatheight
$(window).bind('load',function(){
    
    var sets = [], temp = [];
    $('.section > dl.howto').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
    
    var sets = [], temp = [];
    $('.section > dl.howto dt').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
    
    var sets = [], temp = [];
    $('.section > dl.howto dd').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });

//cm dt
    var sets = [], temp = [];
    $('.section > dl.cm1 dt').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
 
//cm dd
    var sets = [], temp = [];
    $('.section > dl.cm1 dd').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
 
//cm dt
    var sets = [], temp = [];
    $('.section > dl.cm2 dt').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });

//cm dd
    var sets = [], temp = [];
    $('.section > dl.cm2 dd').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });

//recipe list recipe_index
    var sets = [], temp = [];
    $('.recipe_index dl').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });

//recipe list
    var sets = [], temp = [];
    $('.list dl').each(function(i) {
        temp.push(this);
        if (i % 5 == 4) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
//recipe_ranking
    var sets = [], temp = [];
    $('.recipe_rank li').each(function(i) {
        temp.push(this);
        if (i % 40 == 39) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
//ec
    var sets = [], temp = [];
    $('.information dl dd.text').each(function(i) {
        temp.push(this);
        if (i % 4 == 3) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);

    /* 各組ごとに高さ揃え */
    $.each(sets, function() {
        $(this).flatHeights();
    });
});
