// SARCAN Inc.
// SARCAN Js Library

//=====================================
// Display Fade
//=====================================
function disp_fade(c){
	/*読み込み時*/
	$(c).hide();
	$(c).each(function (i) {
		$(this).delay(i * 100).fadeIn("slow");
	});
}

//=====================================
// Accordion
//=====================================
function accordion(c,h,hidetag,displayfirst,s){
	if(displayfirst){
		$(c+" "+hidetag+":not(:first)").css("display","none");
	}else{
		$(c+" "+hidetag).css("display","none");
	}
	
	$(c+" "+h).mouseover(function(){
		$(this).css({
		"background-color":"#f5f4f1",
		"cursor":"pointer"
		});
	});
	
	$(c+" "+h).mouseout(function(){
		$(this).css({
		"background-color":"#fbfbfa",
		});
	});
	
	$(c+" "+h).click(function(){
		if($(this).next(hidetag).css("display")=="none"){
			$(c+" "+hidetag).slideUp(s);
			$(this).next(hidetag).slideDown(s);
		}
	});
	
}


//=====================================
// Tweener
//=====================================
function tweener(target,top0,right0,top1,right1,speed,interval){
	$("."+target).css({
		"position":"absolute",
		"top":top0 + "px",
		"right":right0 + "px",
		"display":"none"
	});

	setTimeout( function() {
		$("."+target).animate({
			opacity: "toggle",
			top:"+="+top1+"px",
			right:"+="+right1+"px",
		},speed,"easeOutCubic");
	}, interval );
	
}



//=====================================
// Tool Tip
//=====================================
function tooltip(pos,start_disp){

	if(pos=="top"){
		tt_wrap();
		
		$(".tooltip .tip").css({
			"top":"-100px",
			"left":"50%",
			"margin-left":"-105px",
		});
		
		tt_top(start_disp);
	}

	if(pos=="bottom"){
		tt_wrap();
		
		$(".tooltip .tip").css({
			"bottom":"-100px",
			"left":"50%",
			"margin-left":"-105px",
		});
		
		tt_bottom(start_disp);
	}
		
}

function tt_wrap(){
	$(".tooltip .tip").wrapInner("<div class='wrapper'></div>");
}


/*チップ配置　トップ*/
function tt_top(start_disp){
		
	if(start_disp){
		disp_fade(".tooltip .tip");
		
		var INTERVAL = 1000;
		setTimeout( function() {
			$(".tooltip .tip").animate({opacity: "toggle",top:"-=10px"},"slow");
		}, INTERVAL );
	}
	
	/*マウスアクション*/
	$(".tooltip").hover(
		/*マウスオーバー*/
		function(){
			$(".tip",this).animate({opacity:"toggle",top:"+=10px"},"fast");
		},
		/*マウスアウト*/
		function(){
			$(".tip",this).animate({opacity: "toggle",top:"-=10px"},600);
		}
	);
	
	$(".tooltip").click(function(){
		$(".tip",this).animate({opacity: "toggle",top:"-=10px"},1200);	
	}
	);
}

/*チップ配置　ボトム*/
function tt_bottom(start_disp){
	
	if(start_disp==""){
		start_disp = 1;
	}
	
	if(start_disp){
		disp_fade(".tooltip .tip");
		
		var INTERVAL = 1000;
		setTimeout( function() {
			$(".tooltip .tip").animate({opacity: "toggle",bottom:"-=10px"},"slow");
		}, INTERVAL );
	}
	
	/*マウスアクション*/
	$(".tooltip").hover(
		/*マウスオーバー*/
		function(){
			$(".tip",this).animate({opacity:"toggle",bottom:"+=10px"},"fast");
		},
		/*マウスアウト*/
		function(){
			$(".tip",this).animate({opacity: "toggle",bottom:"-=10px"},"fast");
		}
	);
	
	$(".tooltip").click(function(){
		$(".tip",this).animate({opacity: "toggle",bottom:"-=10px"},"fast");	
	}
	);
	
	return false;
}
