﻿/// <reference path="../JavaScript/jQuery-1.7.1.js" />
/// <reference path="../JavaScript/Basic.js" />


$(document).ready(function () {
	var tonyer = $('BODY>FORM>.Tonyer');

	var index = -1;
	var navigater = $('.Navigation>LI', tonyer);
	var path = new String(window.location.pathname);
	if (path.indexOf('/') == path.lastIndexOf('/')) {
		index = 0;
	} else if (path.indexOf('/Guest/') == 0) {

	} else {
		var folder = ['/Quotation/', '/Blog/', '/Album/', '/ToyBox/', '/TreasureBag/'];
		for (var i = 0, count = folder.length; i < count; i++) {
			if (path.indexOf(folder[i]) == 0) {
				index = i + 1;
			}
		}
	}
	if (index > -1) {
		navigater.eq(index).addClass('Current');
	}

	$('.QuotationRecent>.Quotation[pid]', tonyer).click(function () {
		var quotation = $(this);
		window.location.replace('/Quotation/?ID=' + quotation.attr('qid'));
	});
	$('A.UserLogout').click(function (e) {
		var sure = confirm('您确定要退出登录吗？');
		if (!sure) {
			return Utility.EventAbort(e);
		}
	});
});

function CommentReply(commentID) {
	var comment = $('#Comment' + commentID);
	var nickname = $.trim($('.Heading>.User>.Nickname', comment).text());
	var editor = $('.CommentEditor');
	var reply = editor.children('.Reply').empty().css('display', 'block');
	reply.append('回复<strong>' + nickname + '</strong>&emsp;&emsp;<a href="javascript:;" onclick="CommentReplyCancel()">取消</a>')
	$('#TextBoxContent', editor).focus();
	$('#HiddenFieldCommentIDReply').val(commentID);
}
function CommentReplyCancel() {
	var editor = $('.CommentEditor');
	editor.children('.Reply').empty().css('display', 'none');
	$('#TextBoxContent', editor).focus();
	$('#HiddenFieldCommentIDReply', editor).val(0);
}
function CommentQuote(commentID) {
	var comment = $('#Comment' + commentID);
	var content = comment.children('DIV.Content');
	var editor = $('.CommentEditor');
	var quote = editor.children('FIELDSET').empty().css('display', 'block');
	quote.append('<legend><a href="#Comment' + commentID + '">引用内容</a>&emsp;&emsp;<a href="javascript:;" onclick="CommentQuoteCancel()">取消</a></legend><div></div>');
	quote.children('DIV').append(content.contents().clone());
	$('#TextBoxContent', editor).focus();
	$('#HiddenFieldCommentIDQuote', editor).val(commentID);
}
function CommentQuoteCancel() {
	var editor = $('.CommentEditor');
	editor.children('FIELDSET').empty().css('display', 'none');
	$('#TextBoxContent', editor).focus();
	$('#HiddenFieldCommentIDQuote', editor).val(0);
}

