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

 var sInitColor;

 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;
 }

 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;
 }

 window.onload = function(){
  tableForm.cell_width.value = cellWidth;
 	tableForm.cell_height.value = cellHeight;
  tableForm.col_span.value = dialogArguments.colSpan;
  tableForm.row_span.value = dialogArguments.rowSpan;

  for (i=0; i<tableForm.align.options.length; i++)
 	 if(tableForm.align.options[i].text.toLowerCase() == dialogArguments.align.toLowerCase())
    tableForm.align.options[i].selected = true;

  for (i=0; i<tableForm.valign.options.length; i++)
 	 if(tableForm.valign.options[i].text.toLowerCase() == dialogArguments.vAlign.toLowerCase())
    tableForm.valign.options[i].selected = true;

  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();
 	this.focus();
 }

var cellBgColor = dialogArguments.bgColor;
var cellWidth = dialogArguments.width;
var cellHeight = dialogArguments.height;
var cellAlign = dialogArguments.align;
var cellvAlign = dialogArguments.vAlign;

 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 (tableForm.cell_width.value < 0) {
		alert("Cell Width must contain a valid, positive number")
		error = 1
		tableForm.cell_width.select()
		tableForm.cell_width.focus()
	}

	if (tableForm.cell_height.value < 0) {
		alert("Cell Height must contain a valid, positive number")
		error = 1
		tableForm.cell_height.select()
		tableForm.cell_height.focus()
	}

	if(!error){

	 returnValue = new Object();
  returnValue.width = tableForm.cell_width.value;
  returnValue.height = tableForm.cell_height.value;
  returnValue.colSpan = tableForm.col_span.value;
  returnValue.rowSpan = tableForm.row_span.value;
  returnValue.align = tableForm.align[tableForm.align.selectedIndex].text;
  returnValue.vAlign = tableForm.valign[tableForm.valign.selectedIndex].text;
  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>
<tr><td><fieldset><legend>Cell Properties</legend>
	<table cellspacing=0 cellpadding=5>
		<tr><td>Background:</td><td><select name=bgtype onchange="sBgType();"><option value=none>None</option><option value=color>Color</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>
		<tr><td>Cell Width:</td><td><input type=text name=cell_width size=3 maxlength=3></td>
			   <td>Cell Height:</td><td><input type=text name=cell_height size=3 maxlength=3></td></tr>
		<tr><td>Horizontal Align:</td><td><select name=align><option>None</option><option>Left</option><option>Center</option><option>Right</option></select></td>
			   <td>Vertical Align:</td><td><select name=valign><option>None</option><option>Top</option><option>Middle</option><option>Bottom</option></select></td></tr>
		<tr><td>Column Span:</td><td><input type=text name=col_span size=3 maxlength=3></td>
			   <td>Row Span:</td><td><input type=text name=row_span size=3 maxlength=3></td></tr>
	</table></fieldset><br>
	<input type=button value="Modify Cell" onClick="javascript:doModify();">
	<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>