$(function() {
	// 連携キット、local時はexit
	if ($.LiVE.bdkit && location.protocol=="file:") return;
	
	var $rt = $.LiVE.Elements.WIDGETS.richtext.find(".default"),
		path = location.pathname.match(/\w+\.html$/),
		filePath = path ? location.pathname.replace(path,'') : location.pathname;
	
	$rt.each(function() {
		var $this = $(this).parent(),
			id = $this.attr("id"),
			data = $.LiVE.widget[id].data,
			closechk = $.LiVE.widget[id].close;
		
		$rt.height('100%');
		
		if ($.LiVE.mode.edit.activate == false) {
			var cookie = {
				name: "richtext-" + id
			};
			
			var val = $.cookie(cookie.name, {path: filePath});
			if (val != null) {
				// オプションが変更されたら初回は表示
				if (val != data.frequency) {
					$.cookie(cookie.name, null, {path: filePath});
				} else {
					$this.remove();
					return;
				}
			}
			
			// 初回のみ
			if (data.frequency == 1) {
				$.cookie(cookie.name, data.frequency, {expires: 365, path: filePath});
			// 一日に一度
			} else if (data.frequency == 2) {
				$.cookie(cookie.name, data.frequency, {expires: 1, path: filePath});
			// ブラウザ終了時に削除
			} else if (data.frequency == 3) {
				$.cookie(cookie.name, data.frequency, {path: filePath});
			}
		}
		
		// disp close button
		if ( closechk ) $this.append('<div class="close"></div>');
		
		$this.find(".close").click(function() {
			$this.css("display","none");
		});
	});
	
});