<?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 hidden field in the editable area.
//It inserts a hidden field 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 Hidden Field button invokes this function
//It constructs an html string for hidden field and paste it to the parent window
//and paste it to the selected area using PasteHTML() function 
function InsertHiddenField() {
	var sel = window.opener.document.selection;
	if (sel!=null) {
		var rng = sel.createRange();
	   	if (rng!=null) {
			name = document.hiddenForm.hidden_name.value
			value = document.hiddenForm.hidden_value.value

		error = 0

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

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

        		HTMLTextField = '<input id=ewp_element_to_style type=hidden' + name + value + '>'
         		rng.pasteHTML(HTMLTextField)

				oHidden = window.opener.foo.document.getElementById("ewp_element_to_style")

				if (window.opener.borderShown == "yes") {
					oHidden.runtimeStyle.border = "0px"
					oHidden.runtimeStyle.width = "20px"
					oHidden.runtimeStyle.height = "20px"
					oHidden.runtimeStyle.backgroundImage = "url(" + window.opener.HTTPStr + "://" + window.opener.URL + window.opener.pathToImages + "/hidden.gif)"
					oHidden.runtimeStyle.fontSize = "99px"
				}
				oHidden.style.border = "0px"
				oHidden.style.height = "20px"
				oHidden.style.backgroundColor="#cccccc"
				oHidden.removeAttribute("id")


		} // End if
		} // End if
	} // End If

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

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

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=hiddenForm>
<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 Hidden Field</b></td>
  </tr>
  <tr>
	<td>&nbsp;</td>
	  <td class="maintext"><br>Enter the required information and click &quot;Insert Hidden Field&quot; to insert a Hidden 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="174">
			  <input type="text" name="hidden_name" size="10" class="Text90" maxlength="50">
		  </td>
			<td class="maintext" width="106">Initial Value:</td>
			<td width="256" class="body">
			  <input type="text" name="hidden_value" size="10" class="Text150">
			</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="insertHiddenField" value="Insert Hidden Field" class="editorbutton" onClick="javascript:InsertHiddenField();">
	<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";
?> 