<?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>        		              	  |
// +----------------------------------------------------------------------+
//Insert a textfield in the editable area.
//It inserts a textfield using javascript.
include "../includes/session.php";
include "../includes/config.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>
<script language=JavaScript>
window.onload = this.focus
var error
//User clicking on the Insert text filed button invokes this function
//It constructs an html string for text field and paste it to the parent window
//and paste it to the selected area using PasteHTML() function  
function InsertTextField() {
	var sel = window.opener.document.selection;
	if (sel!=null) {
		var rng = sel.createRange();
	   	if (rng!=null) {
			name = document.textForm.text_name.value
			width = document.textForm.text_width.value
			max = document.textForm.text_max.value
			value = document.textForm.text_value.value
			type = document.textForm.text_type[textForm.text_type.selectedIndex].text

		error = 0
		if (isNaN(width) || width < 0) {
				alert("Character Width must contain a valid, positive number")
				error = 1
				textForm.text_width.select()
				textForm.text_width.focus()
		} else if (isNaN(max) || max < 0) {
				alert("Maximum Characters must contain a valid, positive number")
				error = 1
				textForm.text_max.select()
				textForm.text_max.focus()
		}

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

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

				if (width != "") {
					width = ' size="' + width + '"'
				} else {
					width = ""
				}

				if (max != "") {
					max = ' maxlength="' + max + '"'
				} else {
					max = ""
				}

        			HTMLTextField = '<input type="' + type + '"' + name + value + width + max + '>'
					window.opener.foo.focus();
         			rng.pasteHTML(HTMLTextField)
		} // End if
		} // End if
	} // End If

	if (error != 1) {
		self.close();
	}
} // End function

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

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

</script>
</head>
<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=textForm>
<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>Insert Text Field</b></td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	  <td class="maintext"><br>Enter the required information and click &quot;Insert Text Field&quot; to insert a Text Field into your webpage.<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="80">Name:</td>
			<td class="body" width="200">
			  <input type="text" name="text_name" size="10" class="Text90" maxlength="50">
		  </td>
			<td class="maintext" width="80">Initial Value:</td>
			<td class="body">
			  <input type="text" name="text_value" size="10" class="Text150">
			</td>
		  </tr>
		  <tr>
			<td class="maintext" width="80">Character Width:</td>
			<td class="body">
			  <input type="text" name="text_width" size="10" class="Text50" maxlength="3">
			</td>
			<td class="maintext" width="80">Maximum Characters:</td>
			<td class="body">
			  <input type="text" name="text_max" size="10" class="Text50" maxlength="3">
			</td>
		  </tr>
		  <tr>
			<td class="maintext" width="80">Type</td>
			<td class="body">
			  <select name="text_type" class=text70>
			  <option selected>Text
			  <option>Password</option>
			  </select>
			</td>
			<td class="body" width="80">&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="insertTextField" value="Insert Text Field" class="editorbutton" onClick="javascript:InsertTextField();">
	<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>
<?php
  include "./includes/editorfooter.php";
?> 