// opacityOver
$.fn.opacityOver = function(){
	return this.each(function(){
		$(this).hover(function(){
			$(this).animate({'opacity':0.6},{duration:0,queue:false});
		},function(){
			$(this).animate({'opacity':1},{duration:0,queue:false});
		});
	});
};



// Rollover ----------------------------------------
function initRollOverImages() {
  var image_cache = new Object();
  $("img.imgover").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_ro;
    $(this).hover(
      function() { if(!$(this).hasClass("active")){this.src = imgsrc_ro;} },
      function() {if(!$(this).hasClass("active")){this.src = imgsrc; }})
  });
}

$(function() {
	flatColumns('div.roundBottom','div.actionBox','4','null');
	initRollOverImages();
	
	$('#bnrBox a').opacityOver();
	$('#actionBtn a').opacityOver();
	$('.actionBox a').opacityOver();
	//$('#s_partner a img').opacityOver();
	$('#footer_navi a').opacityOver();
	$('#contents-right a').opacityOver();
	$('#sengen2_form input').opacityOver();
	$('.btn a').opacityOver();
	
	
});



// MenuActive ----------------------------------------
function NaviActive(id){
	var target_img = "#"+id+" img";
	if(!$(target_img).attr("src")) {
		target_img = "img#"+id;	
	}
	$(target_img).each(function(i) {
		dot = this.src.lastIndexOf('.');
		var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		this.src = imgsrc_ro;
		$(this).hover(function() { this.src = imgsrc_ro; },function() { this.src = imgsrc_ro; });
	});
}

/*
flatheights.js---------------------------------------------------------------------------
Version: 2007-08-01
Copyright (c) 2007, KITAMURA Akatsuki
$.changeLetterSize.addHandler(func)
*/
$.changeLetterSize={handlers:[],interval:1000,currentSize:0};(function($){var self=$.changeLetterSize;var ins=$('<ins>M</ins>').css({display:'block',visibility:'hidden',position:'absolute',padding:'0',top:'0'});var isChanged=function(){ins.appendTo('#main');var size=ins[0].offsetHeight;ins.remove();if(self.currentSize==size)return false;self.currentSize=size;return true;};$(isChanged);var observer=function(){if(!isChanged())return;$.each(self.handlers,function(i,handler){handler();});};self.addHandler=function(func){self.handlers.push(func);if(self.handlers.length==1){setInterval(observer,self.interval);}};})(jQuery);(function($){var sets=[];var flatHeights=function(set){var maxHeight=0;set.each(function(){var height=this.offsetHeight;if(height>maxHeight)maxHeight=height;});set.css('height',maxHeight+'px');};$.fn.flatHeights=function(){if(this.length>1){flatHeights(this);sets.push(this);}
return this;};$.changeLetterSize.addHandler(function(){$.each(sets,function(){this.height('auto');flatHeights(this);});});})(jQuery);function flatColumns(flatParent,flatTarget,columNum,notElem){$(flatParent).each(function(){var sets=[],temp=[];if(columNum==2){$(this).find(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)%2==0&&i!=0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==3){$(this).find(flatTarget).not(notElem).each(function(i){temp.push(this);if(i%3==2){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==4){$(this).children(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)/4>=1&&(i+1)%4==0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==5){$(this).children(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)/5>=1&&(i+1)%5==0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}
$.each(sets,function(){$(this).flatHeights();});});}



