﻿
function popupLogin() {
	var url = sLoginPopupUrlPrefix.replace('_successCallback_', encodeURIComponent(sLoginCallbackUrl));
	var nTop = (window.screen.availHeight - 200) / 2;
	var nLeft = (window.screen.availWidth - 400) / 2;
	window.open(url, 'wndLoginWindow', 'width=400, height=200, scrollbars=0, status=0, resizable=0, toolbar=0, titlebar=0, location=0, left=' + nLeft + ', top=' + nTop);
}

function popupReport(targetType, targetId, writer, title) {
	if(sLoginUserId){
	   if(sLoginUserId==writer){
		alert(sReportMessage);
           	return;
	   }else{
		var nTop = (window.screen.availHeight - 200) / 2;
		var nLeft = (window.screen.availWidth - 400) / 2;
		window.open('', 'wndReportWindow', 'width=430, height=300, scrollbars=0, status=0, resizable=0, toolbar=0, titlebar=0, location=0, left=' + nLeft + ', top=' + nTop);

		var url;
		if(targetType == 'question') url = sReportQuestionUrlTemplate.replace('_questionId_', targetId);
		else if(targetType == 'answer') url = sReportAnswerUrlTemplate.replace('_answerId_', targetId);
		else if(targetType == 'comment') url = sReportCommentUrlTemplate.replace('_commentId_', targetId);
		else if(targetType == 'append') url = sReportAppendUrlTemplate.replace('_questionId_', targetId);
		else {alert('assertion fail : targetType = ' + targetType); return false;}
		var oForm = $('popupReportForm');
		oForm.action = url;
		oForm.target = 'wndReportWindow';
		if(title != null) {
			oForm.title.value = title;
		} else {
			oForm.title.value = null;
		}
		if(writer != null) {
			oForm.writer.value = writer;
		} else {
			oForm.writer.value = null;
		}

			oForm.submit();
        	}
		}else{
			// 【登录页面】
			var	iframe = $('loginFrame'),
				iframe_doc = iframe.contentWindow.document,
				login = iframe_doc.getElementById('loginid');

			alert(sLoginMessage);
			login.focus();
			return;
		}
	}
function goListPage(nPage,nPageSize) {
		document.location.href = sListPageUrlTemplate.replace("_page_", nPage).replace("_pageSize_", nPageSize);
	}
