$(function(){
	//for menu;
	if(typeof(current_menu)!="undefined"){
		$("#menu ul>li").eq(current_menu).addClass("current");	
	}
	
	$("#menu ul>li").hover(function(){
		var $this=$(this);
		$this.addClass("now");
		var timenow=new Date();
		temp=timenow.getTime();
		if($this.find("ol").length){
			if(!$this.data("timestamp")){
				$this.data("timestamp",temp);
				$this.addClass("now");
				$this.find("ol").slideDown("fast",function(){
					$this.addClass("now");
				});
			}
		}
	},function(){
		var $this=$(this);
		if($this.find("ol").length){
			$this.find("ol").slideUp("fast",function(){
				$this.removeClass("now");
				$this.removeData("timestamp");
			});
		}else{
			$this.removeClass("now");
		}
	})
	
	$("#menu ol li:last-child").css("border-bottom","none");
	
	// for friendlink;
	var timeouttriggle;
	var linkhidden=true;
	$("dl.friendlink dt").click(function(){
		if(linkhidden){
			$(this).next().slideDown("fast",function(){linkhidden=false;});
		}else{
			$(this).next().slideUp("fast",function(){linkhidden=true;});
		}
	})
	$("dl.friendlink a").click(function(){
		$("dl.friendlink dd").slideUp("fast",function(){linkhidden=true;});
	})
	$("dl.friendlink").hover(function(){
		if(timeouttriggle){clearTimeout(timeouttriggle);}
	},function(){
		timeouttriggle=setTimeout(function(){$("dl.friendlink dd").slideUp("fast",function(){linkhidden=true;});},100);
	})
	
	//for img hover animate;
	$("img.imghover,img.imghoverlong,img.imghover_case,img.imghover_career").hover(function (){
		switch($(this).css("width")){
			case "480px":
				$(this).animate({
					backgroundPosition:"480px top"
				},"fast",function(){
					$(this).css("background-position","-500px top")
					.animate({
						backgroundPosition:"0px top"
					},"slow")
				});
				break;
			case "175px":
				$(this).animate({
					backgroundPosition:"175px top"
				},"fast",function(){
					$(this).css("background-position","-195px top")
					.animate({
						backgroundPosition:"0px top"
					},"slow")
				});
				break;
			case "342px":
				$(this).animate({
					backgroundPosition:"342px top"
				},"fast",function(){
					$(this).css("background-position","-362px top")
					.animate({
						backgroundPosition:"0px top"
					},"slow")
				});
				break;
			default:
				$(this).animate({
					backgroundPosition:"195px top"
				},"fast",function(){
					$(this).css("background-position","-215px top")
					.animate({
						backgroundPosition:"0px top"
					},"slow")
				});
		}
		
	},function(){
		$(this).animate({
			backgroundPosition:"0px top"
		},"fast");
	});
})
