<?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 link for an existing page in the editable area.
//It inserts a link to an existing page using javascript.
include "../includes/session.php";
include "../includes/config.php";
include "../includes/function.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>

<script>
//Function to return a link
//An object is created which is assigned a value of the selected page
//and window is closed.
 function sInsertLink(){
   	
	linkSource = sLoc.options[sLoc.selectedIndex].value;
	if(linkSource) { 
	returnValue = new Object();
	if(linkSource.length > 0) {
   returnValue = new Object();
   returnValue.url = linkSource;
   }

   window.close();
  }else{
   alert("Link address cannot be left blank");
   focus();
  }
 }
</script>

<body>
<table width=260 cellspacing=0 cellpadding=0>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td height="60">
 <fieldset><legend class="maintext"><b>Local Page</b></legend><div class="maintext">Select one of the pages you have already created.</div><img src=../images/spacer.gif width=1 height=20>
 <select id=sLoc style=" width:240px; "><option> - Select a page - </option>
 <?php
 	if($_GET["type"] == "new") {
 		$sql = "select vpage_name from tbl_tempsite_pages where ntempsite_id='" . $_SESSION["session_currenttempsiteid"] . "'";
	}
	else {
		$sql = "select vpage_name from tbl_site_pages where nsite_id='" . $_SESSION["session_currenttempsiteid"] . "'";
	}
	$result = mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($result) > 0) {
		while($row = mysql_fetch_array($result)) {
			echo("<option value=\"" . $row["vpage_name"] . "\">" . $row["vpage_name"] . "</option>");
		}
	}
 ?>
 </select><br>&nbsp;<div align="center"><input type=button id=hypOK value="&nbsp;&nbsp;&nbsp; OK &nbsp;&nbsp;&nbsp;" onclick="sInsertLink();" class="editorbutton"> <input type=button value=Cancel onclick="javascript: window.close();"  class="editorbutton"></div></fieldset>
</td></tr>
</table>
<?php
  include "./includes/editorfooter.php";
?> 