<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2005-2006 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts EasyCreate 1.1                 |
// +----------------------------------------------------------------------+
// | Authors: sudheesh<sudheesh@armia.com>        		              	  |
// |          									                          |
// +----------------------------------------------------------------------+
  include "../includes/session.php";
  include "../includes/config.php";
  include "../includes/function.php";
  $currentloc="../";
  include "../includes/applicationheader.php";
?>
<script language=javascript>
function checkNumber(t)
{
    t . value = parseInt(t . value);
    if (t . value . length == 0 || isNaN(t . value) || t . value . substr(0, 1) == " " || parseInt(t . value) < 0) {
        t . value = "";
        alert("Please Enter numeric value");
    } 
} 
var sInitColor;
var theArg = window . dialogArguments;
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 != "0") {
        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()
{
    var widthwithpercentage;
    var widthwithoutpercentage;
    widthwithpercentage = cellWidth;
    if (widthwithpercentage . substr(widthwithpercentage . length-1, widthwithpercentage . length) == "%")
        widthwithoutpercentage = widthwithpercentage . substr(0, widthwithpercentage . length-1);
    else
        widthwithoutpercentage = widthwithpercentage;
    var heightwithpercentage;
    var heightwithoutpercentage;
    heightwithpercentage = cellHeight;
    if (heightwithpercentage . substr(heightwithpercentage . length-1, heightwithpercentage . length) == "%")
        heightwithoutpercentage = heightwithpercentage . substr(0, heightwithpercentage . length-1);
    else
        heightwithoutpercentage = heightwithpercentage;

    tableForm . cell_width . value = widthwithoutpercentage;
    tableForm . cell_height . value = heightwithoutpercentage;
    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()
    } 
} 
function loadvalues()
{
    alert(theArg . colpsan); 
    // window.returnValue =s;
} 
</script>
<body >

<table width="100%" align=center>
      <tr>
	     <td align=center>
		    <FIELDSET>
					      <legend class=maintextbold>Cell Properties</legend>
						  <form name=tableForm>
								<table cellspacing=0 cellpadding=10 border=0>
								
											
												<tr><td class=maintext align=left>Background:</td><td align=left><select class=selectbox name=bgtype onchange="sBgType();"><option value=none>None</option><option value=color>Color</option></select></td>
												    <td colspan=2 valign=top align=left>
												     <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 class=button type=button value=" Set " onClick="tableForm.bgfile.value = sImgDlg();"></div>
												    </td></tr>
												<tr><td class=maintext align=left>Cell Width:</td><td align=left class=maintext><input class=textbox type=text name=cell_width size=3 maxlength=3 onBlur="javascript:checkNumber(this);">%</td>
													   <td class=maintext align=left>Cell Height:</td><td align=left class=maintext><input class=textbox type=text name=cell_height size=3 maxlength=3 onBlur="javascript:checkNumber(this);" >%</td></tr>
												<tr><td class=maintext align=left>Horizontal Align:</td><td><select class=selectbox name=align><option>None</option><option>Left</option><option>Center</option><option>Right</option></select></td>
													   <td class=maintext align=left>Vertical Align:</td><td align=left><select class=selectbox name=valign><option>None</option><option>Top</option><option>Middle</option><option>Bottom</option></select></td></tr>
												<tr><td class=maintext align=left>Column Span:</td><td align=left><input class=textbox type=text name=col_span size=3 maxlength=2 onBlur="javascript:checkNumber(this);"></td>
													   <td class=maintext align=left>Row Span:</td><td align=left><input class=textbox type=text name=row_span size=3 maxlength=2 onBlur="javascript:checkNumber(this);"></td></tr>
								<tr><td colspan=4 align=center>			
									<input class=button type=button value="Modify Cell" onClick="javascript:doModify();">
									<input class=button type=button value=Cancel onClick="javascript:window.close();">
								</td></tr>
								</table>
                      </form>
			</FIELDSET>
		 </td>
	  </tr>
	  	 				  
</table>

<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<?php
  include "./includes/editorfooter.php";
?>  