<?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: jimmy<jimmy.jos@armia.com>        		              	  |
// +----------------------------------------------------------------------+
//Modifying a checkbox in the editable area.
//It modifies the checkbox properties using javascript.
include "../includes/session.php";
include "../includes/config.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>
	<script language=JavaScript>
var myPage = window.opener;
window.onload = setValues;

var checkboxName = myPage.selectedCheckbox.name;
var checkboxValue = myPage.selectedCheckbox.value;
var checkboxType = myPage.selectedCheckbox.checked; // true or false
var checkboxClass = myPage.selectedCheckbox.className;
//setValues called at the time of loading
//set values passed to the document and sets it to the input fields. 
function setValues() {

	if (checkboxClass != "") {
		checkboxClass = " class=" + checkboxClass
	}

	checkboxForm.checkbox_value.value = checkboxValue;
	checkboxForm.checkbox_name.value = checkboxName;
	this.focus();
}
//User clicking the modify button invokes this function
//It creates a checkbox with the values given in this screen and closes the window.
function doModify() {
	var sel = window.opener.document.selection;
		if (sel!=null) {
			var rng = sel.createRange();
		}

		name = document.checkboxForm.checkbox_name.value
		value = document.checkboxForm.checkbox_value.value
		type = document.checkboxForm.checkbox_type[checkboxForm.checkbox_type.selectedIndex].text

		if (value != "") {
			value = ' value="' + value + '"'
		} else {
			value = ""
		}

		if (name != "") {
			name = ' name="' + name + '"'
		} else {
			name = ""
		}

   		HTMLTextField = '<input type=checkbox' + name + value + type + checkboxClass + '>'
   		myPage.selectedCheckbox.outerHTML = HTMLTextField
    
    window.close()
}

function printType() {
	if ((checkboxType != undefined) || (checkboxType != "")) {
		if (checkboxType == false) { 
			checkboxType = "Unchecked"
		}

		if (checkboxType == true) {
			checkboxType = "Checked"
		}

		document.write('<option selected>' + checkboxType)
		document.write('<option>Checked')
		document.write('<option>Unchecked</option>')
	}
}

document.onkeydown = function () { 
			if (event.keyCode == 13) {	// ENTER
				doModify()
			}
};

document.onkeypress = onkeyup = function () {
	if (event.keyCode == 13) {	// ENTER
	event.cancelBubble = true;
	event.returnValue = false;
	return false;			
	}
};

</script>

<body>
		<div class="MainBody" style="width:100%; height:100%">
		<table width="96%" height="10%" align="center" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="10" height="11"><img src="images/main_lc.gif" width="10" height="11"></td>
						<td background="images/main_tbg.gif" height="11"><font size="1"><img src="images/1x1.gif" width="1" height="1"></font></td>
						<td width="10" height="11"><img src="images/main_rc.gif" width="10" height="11"></td>
					</tr>
					<tr>
						<td width="10" height="11" background="images/main_lm.gif"></td>
						<td bgcolor="#F7F7F7" height="100%" class="body" style="padding:10px" valign="top">
			

<form name=checkboxForm>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td width="15"><img src="_images/1x1.gif" width="15" height="1"></td>
	  <td class="maintext"><b>Modify CheckBox</b></td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	  <td class="maintext"><br>Enter the required information and click &quot;Modify CheckBox&quot; to modify the selected CheckBox.<br>
		Click the &quot;Cancel&quot; Button to  close this window.<br>&nbsp;</td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	<td class="body">&nbsp;</td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	<td class="body">
	    <table border="0" cellspacing="0" cellpadding="5" width="98%" class="bevel2">
		  <tr>
		    <td class="maintext" width="126">Name:</td>
			<td class="body" width="111">
			  <input type="text" name="checkbox_name" size="10" class="Text90" maxlength="50">
		  </td>
			<td class="maintext" width="123">Initial Value:</td>
			<td width="256" class="body">
			  <input type="text" name="checkbox_value" size="10" class="Text150">
			</td>
		  </tr>
		  
		  <tr>
			<td class="maintext" width="126">Initial State:</td>
			<td class="body">
			  <select name="checkbox_type" class=text90>
				<script>printType()</script>
			  </select>
			</td>
			<td class="body" width="123">&nbsp;</td>
			<td class="body">&nbsp;</td>
		  </tr>
	    </table>
	</td>
  </tr>
  <tr>
	<td colspan="2"><img src="images/1x1.gif" width="1" height="10"></td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	<td align="center">
	    <input type="button" name="modifyCheckbox" value="Modify CheckBox" class="editorbutton" onClick="javascript:doModify();">
	<input type="button" name="Submit" value="Cancel" class="editorbutton" onClick="javascript:window.close()">
	</td>
  </tr>
</table>
</form>						</td>
						<td width="10" background="images/main_rm.gif" height="11"></td>
					</tr>
					<tr>
						<td width="10" height="11"><img src="images/main_lcb.gif" width="10" height="11"></td>
						<td background="images/main_bbg.gif" height="11"><font size="1"><img src="images/1x1.gif" width="1" height="1"></font></td>
						<td width="10" height="11"><img src="images/main_rcb.gif" width="10" height="11"></td>
					</tr>
				</table>
				<br>&nbsp;
					</div>
					</div>
<?php
  include "./includes/editorfooter.php";
?> 	