
(function($) {
	
	$.fn.opOver = function(op,oa,durationp,durationa){
		
		var c = {
			op:op? op:1.0,
			oa:oa? oa:0.6,
			durationp:durationp? durationp:'fast',
			durationa:durationa? durationa:'fast'
		};
		

		$(this).each(function(){
			$(this).css({
					opacity: c.op,
					filter: "alpha(opacity="+c.op*100+")"
				}).hover(function(){
					$(this).fadeTo(c.durationp,c.oa);
				},function(){
					$(this).fadeTo(c.durationa,c.op);
				})
		});
	},
	
	$.fn.wink = function(durationp,op,oa){

		var c = {
			durationp:durationp? durationp:'slow',
			op:op? op:1.0,
			oa:oa? oa:0.2
		};
		
		$(this).each(function(){
			$(this)	.css({
					opacity: c.op,
					filter: "alpha(opacity="+c.op*100+")"
				}).hover(function(){
				$(this).css({
					opacity: c.oa,
					filter: "alpha(opacity="+c.oa*100+")"
				});
				$(this).fadeTo(c.durationp,c.op);
			},function(){
				$(this).css({
					opacity: c.op,
					filter: "alpha(opacity="+c.op*100+")"
				});
			})
		});
	}
	
})(jQuery);

	$(document).ready(function() {
		$('.ro3').opOver(0.8,1.0);
	});

	$(document).ready(function() {
		$('.ro2').wink();
	});

	$(document).ready(function() {
		$('.ro').opOver(1.0,0.6,200,500);
	});
	
	var cache = [];
	$(function(){
	
		//画像のプリロード
		$.preLoadImages = function(src) {
			var cacheImage = document.createElement('img');
			cacheImage.src = src;
			cache.push(cacheImage);
		}
		
		$("img,input").each(function(){
			if ($(this).attr("src")){
				//画像のプリロード
				var offFilename = $(this).attr('src');
				var onFilename = offFilename.replace(/_off/,'_on');
				jQuery.preLoadImages(onFilename);		
			}
		});
		
    });
	
	$(document).ready(function(){
	
		$("img[src*='_on']").addClass("current");
		$("img,input").mouseover(function(){
			if ($(this).attr("src")){
        if ($(this).attr("src").indexOf("_off.") != -1) {
  				$(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
        }
			}
		});
		$("img,input").mouseout(function(){
			if ($(this).attr("src") && !$(this).hasClass('current')){
        if ($(this).attr("src").indexOf("_on.") != -1) {
			  	$(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
        }
			}
		});
	});

//rollover manually on,off
$.fn.extend({
  rolloverOn: function(other) {
    $(this).each(function() {
      if (other) {
        $(other).rolloverOff();
      }
      $(this).addClass('current');
      $(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
    });
  },
  rolloverOff: function() {
    $(this).each(function() {
      $(this).removeClass('current');
      $(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
    });
  }
});


