<?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>        		              	  |
// +----------------------------------------------------------------------+
//User trying to save the current page in another name is shown this window.
//It asks for the name the current page is to be saved with.
include "../includes/session.php";
include "../includes/config.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>
<script>
returnValue = new Object();
returnValue.type="";
returnValue.name="";
//The user clicking the 'Submit' button calls this function
//The name entered by the user is checked for validity by the regular expression check
//IF true then .htm is suffixed to the pageName and set as the returnValue of the window 
//and window is closed.
function createPage() {
	var re = /^[a-z]+[0-9]*[a-z]*[^\.]$/gi;
	if(re.test(document.frmNew.txtName.value) == false) {
		alert("Please enter a valid name for your document (no special characters or extensions).");
		return;			
	}
	//return;
	if(document.frmNew.txtName.value.length <= 0 || document.frmNew.txtName.value.indexOf(' ') == 0) {
		alert('Please enter a valid name for your page.');
		return;
	}
	returnValue.name=document.frmNew.txtName.value + ".htm";
	window.close();
}
//User clicks on the 'Cancel' button to invoke this function
//This function closes the current window.
function cancel() {
	window.close();
}
</script>
<body>
<form name="frmNew" method="post">
<table width="100%">
	<tr>
		<td width="100%">
			<fieldset>
				<legend class=maintextbold>Save page as ...</legend>
				<table width="100%"  border="0">
				  <tr>
					<td colspan="3">&nbsp;</td>
				  </tr>
				  <tr>
					<td width="34%" class="maintext"><div align="right">Page Name</div></td>
					<td width="2%">&nbsp;</td>
					<td width="64%"><input name="txtName" type="text" id="txtName" size="25" maxlength="50"></td>
				  </tr>
				  <tr>
					<td colspan="2">&nbsp;</td>
					<td><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="Submit" type="button" id="Submit" value="Submit" onClick="javascript:createPage();" class="editorbutton">&nbsp;<input name="Cancel" type="button" id="Cancel" value="Cancel" onClick="javascript:cancel();" class="editorbutton"></td>
				  </tr>
				</table>
			</fieldset>
		</td>
	</tr>
</table>
</form>
<?php
  include "./includes/editorfooter.php";
?> 