// ********************************************************************
// Copyright (C) 2001 Microsoft Corporation. All rights reserved.
//
//	IMPORTANT.  Please read the legal.txt file, located in the 
//	"<CMS Install Directory>\Server\httpexec\WBC\Internals" 
//	directory, governing the use of this internal file."
// ********************************************************************

// ********************************************************************
// File:	/NR/System/WBC/Internals/WBCFuncPages/IE-Specific/Table/table.js
// Author:	Microsoft Corporation.
// Purpose:	JS to support table dialog
// ********************************************************************

function onClickOkay(strPhName, strPhType) {

	var nColumns = g_pForm.NC_Columns.value;
	var nRows = g_pForm.NC_Rows.value;
	var nBorder;
	
	if (g_pForm.NC_Border.checked) {
		nBorder = 1;
	} else {
		nBorder = 0;
	}
	
	if (nColumns != parseInt(nColumns)) {
		alert(IDS_INVALID_COLUMNS);
		return;
	}
	
	if (nRows != parseInt(nRows)) {
		alert(IDS_INVALID_ROWS);
		return;
	} 
	
	if (nColumns <= 0) {
		alert(IDS_INVALID_COLUMNS_RANGE);
		return;
	}
	
	if (nRows <= 0) {
		alert(IDS_INVALID_ROWS_RANGE);
		return;
	}

	if (strPhType == IDS_PHTYPE_THINEDITIE) {
		// page launched by showModalDialog in compose.js
		// return string in format of "Columns;Rows;Border"
		var strRet = nColumns + ";" + nRows + ";" + nBorder;
		window.returnValue = strRet;
	} else {
		var pFuncWin = WBC_getFuncWin("WBC_setTable", window.opener);
		if (pFuncWin == null) {
			alert(IDS_FUNCTION_NOT_FOUND);
		} else {
			pFuncWin.WBC_setTable(strPhName, "", nColumns, nRows, nBorder);
		}
	}
	
	window.close();
}

function onClickCancel() {
	// retain special well-known value "Cancel"
	window.returnValue = "Cancel";
	window.close();
}

var g_pForm = document.NC_TableForm;