// JavaScript Document

//====================================================================

//トップメニューの選択
function setTopMenu( menu ) {
	$("#menu li."+menu+" a").addClass("now");
}

//====================================================================

//店舗メニューの選択
function setShopMenu(n) {
	var nm = ""+n;
	$("li.stab_"+nm+" a").addClass("now");
}


//====================================================================

//ページ移動
function selectPage(url) {
	location.href = url;
}


//====================================================================

//ページを１回だけリロード
function reloadPage() {
	if ( window.name != "kuchikomi" ) {
		location.reload();
		window.name = "kuchikomi";
	}
}

//====================================================================

//削除確認ダイアログ
function del() {
	
	if (confirm("本当に削除してよろしいですか？\n\n（取り消しできません）")) {
		return true;
	}
	return false;
}


//=====================================================================

//URLの確認
function checkURL(name) {
	var url = $("input[name='"+name+"']").val();
	
	if ( url != ""  ) {
		window.open( url );
	}
}


//====================================================================

//ツールチップ

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


//====================================================================

//評価レーダーのセット
function setRadar(id,val) {
	
	//alert(id+":"+index);
	
	var evid = id.split('speed')[1];
	$(":hidden[name='evalue["+evid+"]']").val(val);
	prevRadar();
	
	//alert (evid);
}

//====================================================================

//ユーザーのアクセスチェック（クッキー処理）
function checkUser( callurl, path, cookname ) {
	
	var ck = $.cookie(cookname);
	var url = callurl+"&callback={callback}";
	
	$.getJSONP( url, function(json) {
		var id = json.usrid;
		
		//logout
		if (id == null) {
			$.cookie(cookname,null);
			$(".user_name").hide();
			$.get( path+"_controll.php", { m:"ajax_logout" } );
			
		//login
		} else {
			//$.cookie('<% $cookie_name_user %>',id,{ expires:365, path:'/', domain:'<% $domain %>' });
			$.cookie(cookname,id,{ expires:365, path:'/' });
			$(".user_name").show();
			if (ck == null) reloadPage();
		}
	});
}


//====================================================================

//管理サイトへユーザークッキーを送信
function outputUserCook(usrid) {
	
	var url = "http://www.11kuchikomi.com/_controll.php?m=ajax_cook&usrid="+usrid+"&callback={callback}";
	
	$.getJSONP( url, function(json) {
		var id = json.usrid;
		
		//alert ("sys:"+id);
		
		if (id != null) selectPage('msg_edit.html');
	});
	
}




