$(document).ready(function(){

/* ----------------------------------------------------
	■ローカルナビ
---------------------------------------------------- */
var naviL = $("div#side ul.naviL");
$("li:first-child",naviL).addClass("begin");
$("li:last-child",naviL).addClass("end");
$("li.on:last-child",naviL).addClass("endOn");


/* ----------------------------------------------------
	■編集ボタン
---------------------------------------------------- */
// Cookieを保存
$('a#edit-on').click(
	function(){
		$.cookie('edit_on',1,{expires:30});
		return false;
	}
);

// Cookieを削除
$('a#edit-off').click(
	function(){
		$.cookie('edit_on', null);
		return false;
	}
);

// Cookieがある場合
if($.cookie("edit_on")){
	$(".entryBox").prepend('<a href="" class="editBtn">EDIT</a>'); // EDITボタンを追加
	$(".entryTable th").prepend('<a href="" class="editBtn">EDIT</a>'); // EDITボタンを追加

	$(".entryBox > a.editBtn").hover(
		function() {
			eid = $(this).parent('.entryBox').attr('id').replace(/ID/ig, '');
			cid = $('#cid').attr('value').replace(/cat/ig, '');
			$(this).attr('href','http://smashweb.jp/admin/?cat=entry&act=edit&cid=' + cid + '&eid=' + eid);
		}
	);
	
	$(".entryTable th a.editBtn").hover(
		function() {
			eid = $(this).parents('tr').attr('id').replace(/ID/ig, '');
			cid = $('#cid').attr('value').replace(/cat/ig, '');
			$(this).attr('href','http://smashweb.jp/admin/?cat=entry&act=edit&cid=' + cid + '&eid=' + eid);
		}
	);
}


/* ----------------------------------------------------
	■FancyBox
---------------------------------------------------- */
$("a.editBtn").fancybox({
	'width'				: '95%',
	'height'			: '95%',
	'autoScale'			: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe'
});

/* End */
});

