/*
 * イベントのバインド
 */
$(function(){
	
	$("a[href^=#]").bind("click", scrollTop);
	
})



/*
 * popup
 */
function popup( url, width, height, name )
{
	var name = name || "popup";
	var params = [
								
		"width=" + width,
		"height=" + height,
		"menubar=no",
		"toolbar=no",
		"location=no",
		"status=no",
		"scrollbars=yes",
		"resizeble=yes"
		
	].join(",");
	
	window.open( url, "popup", params ).focus();
}


/*
 * scroll
 */
function scrollTop(ev,target)
{
	var top = $($(this).attr("href")).offset().top;
	
	// 時間の設定
	var t = $(this).offset().top / 3;
	
	if( t == 0 )
		// すでにトップの場合は返す
		return;
	else if( t <= 400 )
		// 400px以下にはイージングをかけない
		e = null;
	else
		// デフォルトの動作	
		e = "easeInOutCubic";
		
	// アニメーション
	$($.browser.safari ? "body" : "html").animate({scrollTop:top},t,e);
	
	return false;
}
