/*ロールオーバー
------------------------------*/
(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);

(function($) {
$(function() {
	$('.over').opOver();
	$('.wink').wink();
});
})(jQuery);


/*画像置換
------------------------------*/
jQuery.fn.jQIR = function(format, path, onload)
{
	if(!document.images) return this;
	path = path || "";
	this.each(
		function()
		{
			var img = $("<img>"), el = jQuery(this);
			var file;
			var re = /(?:{src\:)(\S+)(?:})/i;
			var m = this.className.match(re);
			if(m)
			{
				file = path + m[1];
			}
			else
			{
				file = path + this.id + "." + format;
			}
			
			jQuery(img).attr(
			{
				src: file,
				alt: el.text()
			}).load(typeof onload == "function" ? onload : function(){} );
			var a = el.find("a");
			var toAppend = a.length ? a.empty().append(img) : img;
			el.empty().append(toAppend);
		}
	)
	return this;
}

/*画像置換
------------------------------*/
$(document).ready(function(){
    $("img.rollover").each(function() {
        var off = this.src;
        var dot = this.src.lastIndexOf('.');
        var on = this.src.substr(0, dot) +
            '_on' + this.src.substr(dot, 4);
        $(this).hover(
            function() { this.src = on; },
            function() { this.src = off; });
    });
});




/*
	onload call
**************************************/

	$j(document).ready(function(){
		dropdownMenu.init();
	});

/*
	dropdownMenu
**************************************/

	var dropdownMenu=
	{	
		init:function()
		{
			if(!$j.browser.msie) return;
			var version = $j.browser.version;
			if(version==6)
				dropdownMenu.ie6Fix();
			else if(version==7)
				dropdownMenu.ie7Fix();
		},
		ie6Fix: function()
		{
			$j("div.treeNav li").hover(function(){
				$j(this).children("ul").eq(0).css("display","block");
				dropdownMenu.showOnlyDirectChild(this);
			},function(){
				$j(this).children("ul").eq(0).css("display","none");
				dropdownMenu.hideAllDescendent(this);
			});
		},
		ie7Fix: function()
		{
			$j("div.treeNav li").hover(function(){
				dropdownMenu.showOnlyDirectChild(this);
			},function(){
				dropdownMenu.hideAllDescendent(this);
			});
		},
		showOnlyDirectChild: function(elem)
		{
			$j(elem).children("ul").eq(0)
				.css("visibility","visible")
				.find("ul").css("visibility","hidden");
		},
		hideAllDescendent: function(elem)
		{
			$j(elem).find("ul").css("visibility","hidden");
		}
	}
