///////////////////////////////////////////////
// doc.js
//
// David Yang (yang@synda.com)
// 2003.11.4
//////////////////////////////////////////////

function openMaximizedDocletWindow(sURL)
{
	var sName = 'new_doc_win';
	var w = screen.availWidth - 10;
	var barH = screen.height - screen.availHeight;
	var h = screen.availHeight - barH*5;

	var sFeatures = 'left=0,top=0,width=' + w + ',height=' + h;
	sFeatures = sFeatures + ',resizable=yes,scrollbars=yes,status=yes';
	sFeatures = sFeatures + ',menubar=yes,toolbar=yes,location=yes';
	window.open(sURL, sName, sFeatures);
}

function btn_docbarMouseOver()
{
	var e = window.event.srcElement;
	e.style.cursor = 'hand';
	e.style.color = e.getAttribute('HCOLOR');
}

function btn_docbarMouseOut()
{
	var e = window.event.srcElement;
	e.style.cursor = 'default';
	e.style.color = e.getAttribute('LCOLOR');
}

function btn_docbarClick(sURL)
{
	var sLink = String(sURL);
	var e = window.event.srcElement;

	var isPrivate = e.getAttribute('PRIVATE');
	if (isPrivate == '1') {
		sLink = '/misc/deny.htm';
		var vArguments;
		var sFeatures = 'dialogWidth:400px;dialogHeight:300px;center:yes;edge:raised;resizable:no;scroll:yes;status:no';
		window.showModalDialog(sLink, vArguments, sFeatures);
		return;
	}
	else {
		if (sLink.indexOf('/') >= 0 || sLink.indexOf('.asp') >= 0) {
			window.navigate(sURL);
		}
		else {
			var e = document.all.tags("TR");
			for (var i = 0; i < e.length; i++) {
				var d = e.item(i);
				if (d.id && d.style.display == '') {
					d.style.display = 'none';
				}
			}

			eval(sLink).style.display = '';
		}
	}
}

function btn_docbarSave()
{
	window.external.addFavorite( window.location.href, window.document.title );
	return true;
}

function cmtbar_btnMouseOver()
{
	var e = window.event.srcElement;
	e.style.cursor = 'hand';
	e.style.color = e.getAttribute('HCOLOR');
}

function cmtbar_btnMouseOut()
{
	var e = window.event.srcElement;
	e.style.cursor = 'default';
	e.style.color = e.getAttribute('LCOLOR');
}

function cmtbar_btnPrevPage(sFormName)
{
	try {
		var e = eval(sFormName);
		var page_num = parseInt(e.page_num.value) - 1;
		if (page_num > 0) {
			e.page_num.value--;
			var url = window.location.href;
			if (window.location.pathname == '/') {
				url = url + 'default.asp';
			}
			e.action = url;
			e.submit();
		}
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function cmtbar_btnNextPage(sFormName)
{
	try {
		var e = eval(sFormName);
		var page_num = parseInt(e.page_num.value) + 1;
		if (page_num <= e.total_pages.value) {
			e.page_num.value++;
			var url = window.location.href;
			if (window.location.pathname == '/') {
				url = url + 'default.asp';
			}
			e.action = url;
			e.submit();
		}
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function assocbar_btnMouseOver()
{
	var e = window.event.srcElement;
	e.style.cursor = 'hand';
	e.style.color = e.getAttribute('HCOLOR');
}

function assocbar_btnMouseOut()
{
	var e = window.event.srcElement;
	e.style.cursor = 'default';
	e.style.color = e.getAttribute('LCOLOR');
}

function assocbar_btnPrevPage(sFormName)
{
	try {
		var e = eval(sFormName);
		var page_num = parseInt(e.assocbox_page_num.value) - 1;
		if (page_num > 0) {
			e.assocbox_page_num.value--;
			var url = window.location.href;
			if (window.location.pathname == '/') {
				url = url + 'default.asp';
			}
			e.action = url;
			e.submit();
		}
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function assocbar_btnNextPage(sFormName)
{
	try {
		var e = eval(sFormName);
		var page_num = parseInt(e.assocbox_page_num.value) + 1;
		if (page_num <= e.total_pages.value) {
			e.assocbox_page_num.value++;
			var url = window.location.href;
			if (window.location.pathname == '/') {
				url = url + 'default.asp';
			}
			e.action = url;
			e.submit();
		}
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function btn_commentSubmit(sFormName)
{
	try {
		var e = eval(sFormName);
		var cid = e.cid.value;
		var docid = e.docid.value;
		var sCommentCheck = e.comment_check.value;
		var sName = e.sName.value;
		var sSalutation = e.sSalutation.value;
		var sEmail = e.sEmail.value;
		var sContent = e.sContent.value;

		eval(sFormName + '_ifrm').setData(cid, docid, sCommentCheck, sName, sSalutation, sEmail, sContent);
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function btn_stfSubmit(sFormName)
{
	try {
		var e = eval(sFormName);
		var cid = e.cid.value;
		var docid = e.docid.value;
		var langid = e.langid.value;
		var sTitle = e.title.value;
		var sTo = e.sTo.value;
		if (sTo == '') {
			alert('请给出收件人地址!');
			e.sTo.focus();
			return;
		}
		var sFrom = e.sFrom.value;
		if (sFrom == '') {
			alert('请给出发件人地址!');
			e.sFrom.focus();
			return;
		}
		var sSender = e.sSender.value;
		var sMsg = e.sMsg.value;

		eval(sFormName + '_ifrm').setData(cid, docid, sTitle, sTo, sFrom, sSender, sMsg);
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

function btn_scoreSubmit(sFormName)
{
	try {
		var e = eval(sFormName);
		var cid = e.cid.value;
		var docid = e.docid.value;
		var score = -1;
		for (var i = 0; i < e.score.length; i++) {
			if (e.score[i].checked) {
				score = e.score.length - i;
				break;
			}
		}
		var suggestion = e.suggestion.value;

		eval(sFormName + '_ifrm').setData(cid, docid, score, suggestion);
	}
	catch (e) {
		alert('Error: ' + e.description);
	}
}

