<html>
<head>
<title>Table Properties</title>
<link rel=stylesheet type=text/css href=../css/sn.css>
<script language=javascript>

 var sInitColor;

 function callColorDlg(src){
  if(sInitColor == null)
   var sColor = dlgHelper.ChooseColorDlg();
  else
   var sColor = dlgHelper.ChooseColorDlg(sInitColor);

  sColor = sColor.toString(16);
  if (sColor.length < 6) {
   var sTempString = "000000".substring(0,6-sColor.length);
   sColor = sTempString.concat(sColor);
  }

  document.all[src].style.backgroundColor = '#' + sColor;
  sInitColor = sColor;
 }

 function sImgDlg(){
  res = showModalDialog('sImg.php', null, 'dialogWidth: 330px; dialogHeight: 225px; center: yes; resizable: no; scroll: no; status: no;');
  if(res == 'lib')
   res = showModalDialog('../lib/lib.php', null, 'dialogWidth: 770px; dialogHeight: 450px; center: yes; resizable: no; scroll: no; status: no;');
  if(res)
   return res;
 }

 onload = function() {
 	tableForm.table_padding.value = dialogArguments.cellPadding == "" ? 1 : dialogArguments.cellPadding;
 	tableForm.table_spacing.value = dialogArguments.cellSpacing == "" ? 2 : dialogArguments.cellSpacing;
 	tableForm.table_border.value = dialogArguments.border ? dialogArguments.border : 0;
 	tableForm.table_width.value = dialogArguments.width ? dialogArguments.width : "";

  if(dialogArguments.bgColor){
   document.all.bgcolor.style.backgroundColor = dialogArguments.bgColor;
   tableForm.bgtype.options[1].selected = true;
  }else if(dialogArguments.background){
   tableForm.bgfile.value = dialogArguments.background;
   tableForm.bgtype.options[2].selected = true;
  }
  sBgType();
 }

 function sBgType(){
  switch(tableForm.bgtype.options[tableForm.bgtype.selectedIndex].value){
   case 'none':
    sImage.style.display = 'none';
    sColor.style.display = 'none';
    break;
   case 'color':
    sImage.style.display = 'none';
    sColor.style.display = 'block';
    break;
   case 'image':
    sImage.style.display = 'block';
    sColor.style.display = 'none';
    break;
  }
 }

 function doModify() {
 	var error = 0;
 	if (isNaN(tableForm.table_padding.value) || tableForm.table_padding.value < 0 || tableForm.table_padding.value == "") {
 		alert("Cell Padding must contain a valid, positive number")
 		error = 1
	 	tableForm.table_padding.select()
	 	tableForm.table_padding.focus()
	 } else if (isNaN(tableForm.table_spacing.value) || tableForm.table_spacing.value < 0 || tableForm.table_spacing.value == "") {
		 alert("Cell Spacing must contain a valid, positive number")
		 error = 1
		 tableForm.table_spacing.select()
		 tableForm.table_spacing.focus()
	 } else if (isNaN(tableForm.table_border.value) || tableForm.table_border.value < 0 || tableForm.table_border.value == "") {
 		alert("Border must contain a valid, positive number")
	 	error = 1
		 tableForm.table_border.select()
		 tableForm.table_border.focus()
	 }

	 if(!error){
	  returnValue = new Object();
   returnValue.cellPadding = tableForm.table_padding.value;
   returnValue.cellSpacing = tableForm.table_spacing.value;
   returnValue.border = tableForm.table_border.value;
   returnValue.width = tableForm.table_width.value;
   if(tableForm.table_columns)
    returnValue.columns = tableForm.table_columns.value;
   if(tableForm.table_rows)
    returnValue.rows = tableForm.table_rows.value;
   switch(tableForm.bgtype.options[tableForm.bgtype.selectedIndex].value){
    case 'color':
     returnValue.bgColor = document.all.bgcolor.style.backgroundColor;
     break;
    case 'image':
     returnValue.background = tableForm.bgfile.value;
     break;
   }
   window.close()
	 }
 }

</script>
</head>
<body>
<form name=tableForm>
<table cellspacing=0 cellpadding=10 width=100%>
<tr><td><fieldset><legend>Table Properties</legend>
	<table cellspacing=0 cellpadding=5 width=100%>
  <tr><td>Background:</td><td><select name=bgtype onchange="sBgType();"><option value=none>None</option><option value=color>Color</option><option value=image>Image</option></select></td>
		    <td colspan=2 valign=top>
		     <div id=sColor style="position:absolute; display:none;"><img src=../images/spacer.gif width=30 height=17 border=1 id=bgcolor onclick="callColorDlg('bgcolor');"></div>
		     <div id=sImage style="position:absolute; display:none;"><input type=text readonly size=19 name=bgfile> <input type=button value=" Set " onClick="tableForm.bgfile.value = sImgDlg();"></div>
		    </td></tr>
		<script>
		 if(typeof(dialogArguments.border) == 'undefined')
		  document.write('<tr><td>Columns:</td><td><input type=text name=table_columns size=2 maxlength=2 value=2></td><td>Rows:</td><td><input type=text name=table_rows size=2 maxlength=2 value=2></td></tr>');
		</script>
		<tr><td>Cell Padding:</td><td><input type=text name=table_padding size=2 maxlength=2></td>
		    <td>Cell Spacing:</td><td><input type=text name=table_spacing size=2 value=2 maxlength=2></td></tr>
		<tr><td>Border:</td><td><input type=text name=table_border size=2 value=1 maxlength=2></td>
      <td>Width:</td><td><input type=text name=table_width size=3 maxlength=3></td></tr>
		</table></fieldset><br><script> document.write('<input type=button value="' + (typeof(dialogArguments.border) == 'undefined' ? 'Insert Table' : 'Modify Table') + '" onClick="javascript:doModify();">'); </script> <input type=button value=Cancel onClick="javascript:window.close()">
</td></tr></table>
</form>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
</body>
</html>