var menu = {
	"login" : 
	{
		"on" : "templates/image/login_re.gif", 
		"off": "templates/image/login.gif"
	},
	"registUser" : 
	{
		"on" : "templates/image/bt_register-over.png", 
		"off": "templates/image/bt_register.png"
	},
	"logout" : 
	{
		"on" : "templates/image/bt_logout-over.png", 
		"off": "templates/image/bt_logout.png"
	},
	"post" : 
	{
		"on" : "templates/image/bt_post-over.png", 
		"off": "templates/image/bt_post.png"
	}	
};

var preloads = [];

jQuery(document).ready(function(){
	
	jQuery(".nav")
	.superfish({
		animation : { opacity:"show",height:"show", delay:0, speed:"fast"}
	})
	.find(">li:has(ul)")
		.mouseover(function(){
			jQuery("ul", this).bgIframe({opacity:false});
		})
		.find("a")
			.focus(function(){
				jQuery("ul", jQuery(".nav>li:has(ul)")).bgIframe({opacity:false});
			});
	
	
	for(var id in menu)
	{
		var selector  = "#" + id;
		jQuery(selector + "> img").attr({ src: eval("menu."+id+".off") });
		
		jQuery(selector)
		.hover(
			function() {
				jQuery("img", this).attr({ src: eval("menu."+this.id+".on") });
			},
			function() {
				jQuery("img", this).attr({ src: eval("menu."+this.id+".off") });
			}
		);
		
		var image = new Image();
		image.src = eval("menu."+id+".on");
		preloads.push(image);
	};
	
});
