<?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 clicking on the page properties from the menu invokes this page.
include "../includes/session.php";
include "../includes/config.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>
<script language=javascript>
 var myPage = window.opener.foo;
 var pageTitle = myPage.document.title;
 var metaKeywords = metaDescription = "";
 var oDescription
 var oKeywords
 var sInitColor;
//This function may be invoked by clicking on any of these:BGcolor,default text color,link color
//Used to select color for appropriate sections of the html document 
 function callColorDlg(src){
  if(sInitColor == null)
   var sColor = dlgHelper.ChooseColorDlg();
  else
   var sColor = dlgHelper.ChooseColorDlg(sInitColor);
   if(sColor !="0"){
	  sColor = sColor.toString(16);
	  if (sColor.length < 6) {
	   var sTempString = "000000".substring(0,6-sColor.length);
	   sColor = sTempString.concat(sColor);
	  }
	
	  document.all[src].style.backgroundColor = '#' + sColor;
	  sInitColor = sColor;
   }
 }
 //This block gets the meta tag from the parent page
 //It reads in the name of the meta tags and splits it into keywords and description 
 var metaData = myPage.document.getElementsByTagName('META')
 for (var m = 0; m < metaData.length; m++) {
	if (metaData[m].name.toUpperCase() == "KEYWORDS") {
      metaKeywords = metaData[m].content
	  oKeywords = metaData[m]
	}
	  
	if (metaData[m].name.toUpperCase() == 'DESCRIPTION') {
      metaDescription = metaData[m].content
	  oDescription = metaData[m]
	}

 }
//When the page gets loaded, it reads in the meta tag information,page title,bgcolor,
//text color,link color etc and sets the value of the elements in the page appropriately
 onload = function(){
  pageForm.pagetitle.value = pageTitle;
  pageForm.description.value = metaDescription;
  pageForm.keywords.value = metaKeywords;
  document.all.bgcolor.style.backgroundColor = myPage.document.body.bgColor ? myPage.document.body.bgColor : '#ffffff';
  document.all.textcolor.style.backgroundColor = myPage.document.body.text ? myPage.document.body.text : '#000000';
  document.all.linkcolor.style.backgroundColor = myPage.document.body.link ? myPage.document.body.link : '#0000ff';
 }
//The user clicking the 'Apply' button invokes this function
//This function apply the changes as given in the page to the document loaded in the editable area.
 function doModify(param) {
  myPage.document.body.bgColor = document.all.bgcolor.style.backgroundColor;
  myPage.document.body.text = document.all.textcolor.style.backgroundColor;
  myPage.document.body.link = document.all.linkcolor.style.backgroundColor;
  myPage.document.title = pageForm.pagetitle.value;
  var oHead = myPage.document.getElementsByTagName('HEAD');
  if(oKeywords != null){
   oKeywords.content = pageForm.keywords.value;
  }else{
   var oMetaKeywords = myPage.document.createElement("META");
   oMetaKeywords.name = "Keywords";
   oMetaKeywords.content = pageForm.keywords.value;
   oHead(0).appendChild(oMetaKeywords)
  }

  if (oDescription != null){
   oDescription.content = pageForm.description.value;
  }else{
   var oMetaDesc= myPage.document.createElement("META");
   oMetaDesc.name = "Description"
   oMetaDesc.content = pageForm.description.value;
   oHead(0).appendChild(oMetaDesc);
  }

  if(param == 1){
   document.write('<form name=subForm method=post action=' + location.href + '?doAll=1><input type=hidden name=pagetitle value="' + pageForm.pagetitle.value + '"><input type=hidden name=description value="' + pageForm.description.value + '"><input type=hidden name=keywords value="' + pageForm.keywords.value + '"><input type=hidden name=bgcolor value=' + document.all.bgcolor.style.backgroundColor + '><input type=hidden name=textcolor value=' + document.all.textcolor.style.backgroundColor + '><input type=hidden name=linkcolor value=' + document.all.linkcolor.style.backgroundColor + '></form>');
   subForm.submit();
   return false;
  }else{
   opener.foo.focus();
   window.close();
  }
 }

</script>
<body>
<form name=pageForm onsubmit="doModify();">
<table cellspacing=0 cellpadding=5>
 <tr><td colspan=2 class=maintextbold><p>Below you can perform search engine optimization for your current page by entering description and meta keywords.</p></td></tr>
</table>
<table cellspacing=5 cellpadding=0>
 <tr><td valign=top><fieldset><legend class=maintextbold>Search Engine Options</legend><table cellspacing=0 cellpadding=5>
   <tr><td class=maintext>Meta Keywords:<br>
       <font size=1>e.g. cars, motors, bumper... etc.</font><br>
       <input class=textbox type=text name=keywords size=48></td></tr>
   <tr>
     <td class=maintext>Description:<br>
       <font size=1>e.g. website selling new and used cars</font><br>
       <textarea class=textbox name=description cols=25 rows=4></textarea></td>
   </tr>
  </table>
 </fieldset>
 </td><td valign=top><fieldset><legend class=maintextbold>Page Style Options</legend><table cellspacing=0 cellpadding=5>
   <tr><td colspan=2 class=maintext>Page title<br><font size=1>Title of the browser window. (e.g. Acme site)</font><br><input type=text name=pagetitle size=51><br><br></td></tr>
   <tr>
     <td colspan="2" class=maintext><div align="right">(Click on the boxes to select color.) </div></td>
     </tr>
   <tr><td class=maintext>Background color: </td><td><img src=../images/spacer.gif width=30 height=17 border=1 id=bgcolor onclick="callColorDlg('bgcolor');"></td></tr>
   <tr><td class=maintext>Default text color: </td><td><img src=../images/spacer.gif width=30 height=17 border=1 id=textcolor onclick="callColorDlg('textcolor');"></td></tr>
   <tr><td class=maintext>Link color: </td><td><img src=../images/spacer.gif width=30 height=17 border=1 id=linkcolor onclick="callColorDlg('linkcolor');"></td></tr>
  </table>
 </fieldset></td><tr>
 <tr><td colspan=2 align="center"><input type=submit value="Apply" class=editorbutton>  <input type=button class=editorbutton value=Cancel onClick="javascript: window.close(); opener.foo.focus();"></td></tr>
</table>
</form>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<?php
  include "./includes/editorfooter.php";
?> 