<?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: sudheesh<sudheesh@armia.com>        		              	  |
// |          									                          |
// +----------------------------------------------------------------------+

include "../includes/session.php";
include "../includes/config.php";
include "../includes/function.php";
$tmpsiteid=$_SESSION['session_currenttempsiteid'];
$templateid=$_SESSION['session_currenttemplateid'];
$userid=$_SESSION["session_userid"];
if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 

 
 if($_POST['btnpayment']=="Publish using FTP/ZIP"){
   header("location:" . $_SESSION["session_secureserver"] . "/publishpage.php?uid=".$userid."&tid=" . $tmpsiteid . "&type=simple&style=" . $_SESSION["session_style"] . "&" );
   exit;
 }else  if($_POST['btnaddpage']=="Add/Remove Pages"){
   $_SESSION['session_backurl']="simpleIEeditor/editor.php";
   header("location:../addlinks.php?urltype=back&urlfrom=editor&");
   exit;
 }else if($_POST['btneditsite']=="Edit Site details"){
   $_SESSION['session_backurl']="simpleIEeditor/editor.php";
   header("location:../getsitedetail.php?urltype=back");
   exit;
 }else if($_POST['btnback']=="Back"){
   $_SESSION['session_backurl']="simpleIEeditor/editor.php";
   header("location:../addlinks.php?urltype=back");
   exit;
 }
        /*check whether the site exist in tbl_template_mast with 
		* the  combination of current templateid,userid and type
		if site exist in database  check for the pages exist in workarea location
		*/ 
		$errormessage="";
		$qry="select * from tbl_tempsite_mast where ntempsite_id='".$tmpsiteid."' and nuser_id='".$userid."' and ntemplate_id='".$templateid."' and vtype='simple'";
		if( mysql_num_rows( mysql_query($qry))>0){
		    if(! is_dir("../workarea/tempsites/".$tmpsiteid)){
			  $errormessage="Site temporary removed.please contact administrator to resolve issue!";
			}
		
		}else{
		   $errormessage="You are not authorized to view this page!";
		   header("location:../sitemanager.php");
		   exit;
		  
		}
		if($errormessage !=""){
		  echo $errormessage;
		  exit;
		
		}
/*
* Save html files in wrokarea/tempsites/,save editable content in sitepages/tempsite/
*/ 
function SaveSitepage($userid,$tmpsiteid,$templateid,$editabletext,$pagename){
       //set_magic_quotes_runtime(0);
       $basicloc=fetchBasicLocation(1);
	   $temperory_location=$basicloc."/workarea/tempsites/".$tmpsiteid;
	   $real_location=$basicloc."/workarea/sites/";
	
	   $qry=" select * from tbl_tempsite_mast where ntempsite_id='".$tmpsiteid."'";
       $rs=mysql_query($qry);
       $row=mysql_fetch_array($rs);
         //strip slashes and put htmlentities for title,metadesc,metakey
             $row['vmeta_description']=htmlentities($row['vmeta_description']);
             $row['vmeta_key']=htmlentities($row['vmeta_key']);
             $row['vtitle']=htmlentities($row['vtitle']);
	   //call smarty libraries
	    require('../smarty/lib/Smarty.class.php');
		remove_dir("../smarty/templates_c");
		@mkdir("../smarty/templates_c",0777);
		@chmod("../smarty/templates_c",0777);
		if($row['vcolor'] !="NULL" and $row['vcolor'] !=""){
		  $siteclrvalue=".variable { background-color:".$row['vcolor']."; }";
		}else{
		  $siteclrvalue=""; 
		}
		$smarty = new Smarty();
		$smarty->template_dir = "../".$_SESSION["session_template_dir"]."/".$templateid;
		$smarty->compile_dir = '../smarty/templates_c';
		$smarty->cache_dir = '../smarty/cache';
		$smarty->config_dir = '../smarty/configs';
	    //clear the cache
		
		if(strcasecmp($pagename,"home.htm")==0){
			    $smarty->clear_cache('index.tpl');
				$smarty->assign('vsite_metadesc', $row['vmeta_description']);
				$smarty->assign('vsite_metakey', $row['vmeta_key']);
			    $smarty->assign('vsite_title', $row['vtitle']);
			    $smarty->assign('vsitecolor', $siteclrvalue);
			    $smarty->assign('vlogoband', $row['vlogo']);
			    $smarty->assign('vcompanyband',$row['vcompany']);
			    $smarty->assign('captionband', $row['vcaption']);
			    $smarty->assign('vsite_links', $row['vlinks']);
				$smarty->assign('vsite_editable', $editabletext);
			    $html=$smarty->fetch('index.tpl', $cache_id = null, $compile_id = null, false);
			
				$fp=fopen("../workarea/tempsites/".$tmpsiteid."/$pagename","w");
		        fwrite($fp,$html,strlen($html));
		        fclose($fp);
				file_replace ($temperory_location, ".", "../workarea/tempsites/".$tmpsiteid."/$pagename");
				$fp1=fopen("../sitepages/tempsites/$tmpsiteid/$pagename","w");
		        fputs($fp1,$editabletext);
		        fclose($fp1);
				file_replace ($temperory_location, ".", "../sitepages/tempsites/$tmpsiteid/$pagename");
		  }else{
		        $smarty->clear_cache('subpage.tpl');
				$smarty->assign('vsite_metadesc', $row['vmeta_description']);
				$smarty->assign('vsite_metakey', $row['vmeta_key']);
			    $smarty->assign('vsite_title', $row['vtitle']);
			    $smarty->assign('vsitecolor', $siteclrvalue);
			    $smarty->assign('vinnserlogoband', $row['vsub_log']);
			    $smarty->assign('vinnercompanyband',$row['vsub_company']);
			    $smarty->assign('innercaptionband', $row['vsub_caption']);
			    $smarty->assign('vsite_links', $row['vsub_sitelinks']);
				$smarty->assign('vsubsite_editable', $editabletext);
			    $html=$smarty->fetch('subpage.tpl', $cache_id = null, $compile_id = null, false);
				
				$fp=fopen("../workarea/tempsites/".$tmpsiteid."/$pagename","w");
		        fputs($fp,$html);
		        fclose($fp);
				file_replace ($temperory_location, ".", "../workarea/tempsites/".$tmpsiteid."/$pagename");
				//save editable text
				$fp=fopen("../sitepages/tempsites/$tmpsiteid/$pagename","w");
		        fputs($fp,$editabletext);
		        fclose($fp);
				
				file_replace ($temperory_location, ".", "../sitepages/tempsites/$tmpsiteid/$pagename");
		  
		  }		
		
	   
}
/*function to save changes to resource file
* var_deletedimages - list of deleted images seperated by |
* $var_newimages -list of new images
* this function remove all the entries for deleted images.add new entry for inserted images
*/ 

$resource_save_flag = false;
function SaveResource($resource_location,$var_deletedimages,$var_newimages) {

            global $resource_save_flag;
			if($resource_save_flag == false) {
				if($_SESSION["session_checkid"] >= $_POST["checkid"]) {
					return;
				}
				else {
					$_SESSION["session_checkid"]=$_POST["checkid"];
					$resource_save_flag = true;
				}
			}
		
			if(is_file($resource_location)) {
			$content_arr = file($resource_location);
			if(strlen($var_deletedimages) > 0) {	// IF Delete images > 0
				$deleted_arr = explode('|',$var_deletedimages);
				$deleted_count = count($deleted_arr);
				for($i=0;$i < $deleted_count;$i++) {	// FOR LOOP - I
						$temp_string=$deleted_arr[$i];
						switch(substr($temp_string,0,2)) {
							case "ug":
									$temp_string = "usergallery/".$_SESSION["session_userid"]."/images/". $temp_string;
									break;
							case "sg":
									$temp_string = "systemgallery/" . $temp_string;
									break;
							case "sl":
									$temp_string = "samplelogos/" . $temp_string;
									break;
							default:
									continue;											
						}
					$temp_count = 0;	
					foreach($content_arr as $lines) {	// FOR LOOP - II
						if(strcmp($temp_string,rtrim($lines,"\n")) == 0) {
							$content_arr[$temp_count] = "";
							break;
						}
						$temp_count++;
					}		// END FOR LOOP - II	
				}			// END FOR LOOP - I
			}		// END IF Delete images > 0
			}
			$fwriter=fopen($resource_location,"w");
			if(count($content_arr) > 0) {
				foreach($content_arr as $lines) {	// FOR LOOP 
					if($lines != "") {
						fputs($fwriter,$lines);
					}
				}
			}
			if(strlen($var_newimages) > 0) {	// IF New images > 0
				$new_arr = explode('|',$var_newimages);
				$new_count = count($new_arr);
				for($i=0;$i < $new_count;$i++) {	// FOR LOOP - I
					$temp_string=$new_arr[$i];
					switch(substr($temp_string,0,2)) {
						case "ug":
								$temp_string = "usergallery/".$_SESSION["session_userid"]."/images/" . $temp_string . "\n";
								break;
						case "sg":
								$temp_string = "systemgallery/" . $temp_string . "\n";
								break;
						case "sl":
								$temp_string = "samplelogos/" . $temp_string . "\n";
								break;
						default:
								continue;											
					}
					fputs($fwriter,$temp_string);
				}
			}	// END IF New images > 0
			fclose($fwriter);
}
/* replace $search-search string (ie http://192.168.011)
*  $replace- replace string(.)
*  $filename-name of the file(ie workarealocation/home.htm
*/ 
function file_replace ($search, $replace, $filename) {
		   if (file_exists($filename)) {
			       $cnt = file_get_contents($filename);
				   $cnt = preg_replace($search,$replace,$cnt);
				  
				     $htmlcontents=$cnt;
				      $headposition=strpos($htmlcontents,"<head>");
					  if(!$headposition){
								 $headposition=strpos($htmlcontents,"<HEAD>");			      
					  }
					  /* check whether <head> tag exist.if exist assign all the content between <head> and </head> to $headelements 
					  *  then replace $headelements to "" at the end of this function
					  *  check whether the <body> tag exist .if exist assing all the content <body > to $bodyelemants
					  *  replace   $bodyelemants to ""
					  */
					  if($headposition){
					     $backslashheadposition=strpos($htmlcontents,"</head>");
						 if(!$backslashheadposition){
								 $backslashheadposition=strpos($htmlcontents,"</HEAD>");			      
					     }
						 $headelements=substr($htmlcontents, $headposition,$backslashheadposition-$headposition+7);
						 
						 $bodyposition=strpos($htmlcontents,"<BODY");
						 if(!$bodyposition){
								 $bodyposition=strpos($htmlcontents,"<body");			      
					     }
						  if($bodyposition){
						      $bodyelemants=substr($htmlcontents,$bodyposition, strpos(substr($htmlcontents,$bodyposition),">")+1);
							 
						  }
					  }
					 $htmlcontents=str_replace($bodyelemants,"",$htmlcontents );
					 $htmlcontents=str_replace($headelements,"",$htmlcontents );
					 $htmlcontents = preg_replace("<html>","",$htmlcontents);
					 $htmlcontents = preg_replace("</html>","",$htmlcontents);
					 $htmlcontents = preg_replace("</body>","",$htmlcontents);
				     $cnt=$htmlcontents;
			        fwrite(fopen($filename,"w"),$cnt);  //here file_put_contents() cannot be used since it is available only on php5 
			   		return true;
		   }
		   return false;
}
if($_POST["actiontype"] == "save" || $_POST["actiontype"] == "saveandcreate") {

	 if(!validateSizePerUser($_SESSION["session_userid"],$size_per_user,$allowed_space)) {
           echo "<script> alert('Your space exceeded permitted limit." . 
				"(Space taken by you: " . human_read($size_per_user) . " " . 
				"Allowed space: " . human_read($allowed_space) . ") \\r\\n" . 
				"Delete unused images or any/all of the sites created by you to proceed further.'); location.href='../usermain.php'; </script>";
		  
     }else{
	
	        $pagename=$_POST['currentpage'];
			$var_deletedimages=$_POST["deletedimages"];
			$var_newimages=$_POST["newimages"];

			$resource_location="../workarea/tempsites/$tmpsiteid/resource.txt";
			
			$htmtext=$_POST["EditorHTM"].$_POST["EditorHTM2"].$_POST["EditorHTM3"].$_POST["EditorHTM4"].$_POST["EditorHTM5"];
			
			SaveSitepage($userid,$tmpsiteid,$templateid,$htmtext,$pagename);
			
			SaveResource($resource_location,$var_deletedimages,$var_newimages);
	} 		
						 
}
/* every time when a user calls this page,page name will be passed as GET variable without extension(ie home)
*  if page name is empty ,page name will be set as default(ie Home)
*/
$pagename=addslashes(trim($_GET['page']));
$pagenamewithouthtm=$pagename;
if($pagename==""){
  $pagenamewithouthtm="Home";
  $pagename="home.htm";
}else{
  $pagename=$pagename.".htm";
}
$currenteditablefile=$pagename;
$currenteditableurllocation="../workarea/tempsites/$tmpsiteid/$currenteditablefile";
/*check for the user requested page exist in workarea location
*/ 
if( is_file("../sitepages/tempsites/$tmpsiteid/$pagename")){
       copy("../sitepages/tempsites/$tmpsiteid/$pagename","../workarea/tempsites/$tmpsiteid/$currenteditablefile");
       chmod($currenteditableurllocation,0777);
}else{
    $errormessage="Site pages temporarily removed. please contact administrator to resolve the issue!";
	echo $errormessage;
	exit;
}
include "./userheader.php";
?>
<SCRIPT language=JavaScript src="js/formatbar.js"></script>
<script>
	//document.body.onload=loading();
</script>
<SCRIPT>
function savefile(){

document.getElementById('htmltext').value=foo.document.body.innerHTML;
document.frmbtnedit.submit();

}
function savePage(a) {
		if(foo.document.readyState != "complete") {
			alert('The page you are trying to save has not yet loaded completely. Please wait for the page to load completely.');	
			return;
		}
		try{
			if (SelMode == 2) {
				ShowHtml()
			}
		}catch(e){}
 		//document.all("EditorHTM").value = foo.document.body.innerHTML
		//alert(foo.document.body.innerHTML);
		document.all("EditorHTM").value = foo.document.documentElement.outerHTML
		
		//document.all("EditorHTM").value = foo.document.documentElement.innerHTML;
		re = /&amp;/g
		document.all("EditorHTM").value = document.all("EditorHTM").value.replace(re,'&')
		
		htmlLength = document.all("EditorHTM").value.length

		myHTML = document.all("EditorHTM").value
		mcLength = myHTML.length / 5;
        
		document.all("EditorHTM").value = myHTML.substring(0, mcLength);
		document.all("EditorHTM2").value = myHTML.substring(mcLength, mcLength*2 + 1);
		document.all("EditorHTM3").value = myHTML.substring(mcLength*2+1, mcLength*3 + 1);
		document.all("EditorHTM4").value = myHTML.substring(mcLength*3+1, mcLength*4 + 1);
		document.all("EditorHTM5").value = myHTML.substring(mcLength*4+1, myHTML.length);

		document.all("deletedimages").value = checkForDeleted();
		document.all("newimages").value = checkForNew();

		switch(a) {
			case 1:	
					document.all("actiontype").value = "save";
					break;
			case 2:		
				document.all("actiontype").value = "saveandcreate";
				break;
			default:
					alert("Invalid function call.");
					return;
		}
		/* checkid is used to track page refreshment.to avoid add more images in resource.txt file*/
		if(isNaN(document.all("checkid").value) || document.all("checkid").value.length <= 0 || (parseInt(document.all("checkid").value) <= 0)) {
			document.all("checkid").value=1;
		}
		else {
			document.all("checkid").value = parseInt(document.all("checkid").value) + 1;
		}
		document.all("PageDetails").submit();
}
function viewpreview(){
           if(foo.document.readyState != "complete") {
			alert('The page you are trying to priview has not yet loaded completely. Please wait for the page to load completely.');	
			return;
		  }

            var leftPos = (screen.availWidth-500) / 2;
		    var topPos = (screen.availHeight-400) / 2 ;
			var currentpage=document.all("currentpage").value;
		    winurl="showsitepreview.php?currentpage="+currentpage+"&";
		    insertFormWin = window.open(winurl,'','width=' + screen.availWidth + ',height=' + screen.availHeight + ',scrollbars=yes,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos); 
           

}
processFlag=false;
function process() {
	if(processFlag == false) {
		processFlag=true;
			finalImages = foo.document.images;
			i=0;
			var sourceCount=source.length;
			
			var finalCount=finalImages.length;
			while(i < sourceCount) {
				if(source[i] != "") {
					var strTemp=source[i];
					strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
					if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
						j=0;
						while(j < finalCount) {
							if(finalImages[j].src != "") {
								var strTemp2 = finalImages[j].src;
								if(strTemp == strTemp2.substring((strTemp2.lastIndexOf("/") + 1),(strTemp2.length))) {
									source[i]="";
									finalImages[j].src="";
									break;
								}
							}
							j++;
						}
					}
					else {
						source[i] == "";
					}
				}
				i++;
			}
	}
}
function checkForDeleted() {
	var strDeleted = "";
	process();
	var sourceCount=source.length;
	for(i=0;i<sourceCount;i++) {
		if(source[i] != "") {
			var strTemp=source[i];
			strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
			if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strDeleted = strDeleted + strTemp + "|";
			}
		}
	} 
	if(strDeleted.length > 0) {
		strDeleted = strDeleted.substring(0,strDeleted.length-1);
	}
	return strDeleted;
}
function checkForNew() {
	var strNew = "";
	process();
	var finalCount=finalImages.length;
	//alert(finalCount);
	for(i=0;i<finalCount;i++) {
		if(finalImages[i].src != "") {
			var strTemp=finalImages[i].src;
			strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
			if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strNew = strNew + strTemp + "|";
			}
		}
	} 
	if(strNew.length > 0) {
		strNew = strNew.substring(0,strNew.length-1);
	}
	return strNew;
}
function SaveCompelsory(){
	if(confirm("Do you want to save your current page ?")){
	  savePage(1);
	}

}
</SCRIPT>
<table width="100%"  border="0" cellspacing="0" cellpadding="0" class=background>
<tr>
<td  valign="top" align=center>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<tr>
				  <td align=center><img src="../images/cstep4.gif"><br></td>
				</tr>
				<tr>
				  <td align=center>&nbsp;</td>
				</tr>
                <tr>
                <td >
				<!-- Main section starts here-->
				         
						         
						                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
																  <TBODY>
																  <?php
																      $pagenamewithouthtm=addslashes(trim($_GET['page']));
																	  if($pagenamewithouthtm=="")
																	       $pagenamewithouthtm="home";
																	  /* display all pages that the user created for the current site*/	   
																	  $qry="select * from tbl_tempsite_pages where ntempsite_id='".$_SESSION['session_currenttempsiteid']."' order by ntempsp_id";
																	  $res=mysql_query($qry);
																	?>
																    <tr>
																	    <td COLSPAN="2">
																		   <table align=left border=0>
																		       <tr>
																			    <?php
																				        $totalcharctercountinpagename=0;
																					    while($row=mysql_fetch_array($res)){
																						 
																						$pagenamewithspace=$row['vpage_name'];
																						$row['vpage_name']=str_replace(" ","" , $row['vpage_name']);
																						$totalcharctercountinpagename=$totalcharctercountinpagename+strlen($row['vpage_name']);
																						if($totalcharctercountinpagename >100){ 
																						  echo "</tr><tr>";
																						  $totalcharctercountinpagename=0;
																						}
																						/* set different style for selected page and other page.if no page selected default page will be home
																						   page name that will be passed as GET variable converted to lowercase.
																						*/
																						if( strcasecmp($pagenamewithouthtm,$row['vpage_name'])==0){
																				?>
																									    <td class=maintext  valign="top">
																										   
																										   <table width="70px" height="45"  border="1" cellpadding="0" cellspacing="0" bordercolor="#1E63AE">
																		                                        <tr>
																		                                          <td align="center" valign="top" bgcolor="#47B1E4" style="width:70px; word-wrap: break-word;">
																												   <a class=anchor href="./editor.php?page=<?php echo strtolower($row['vpage_name'])?>&">  <img border=0 src="images/pageclear.gif" width="30" height="35"></a><br>
																												   <a class=editorlinks href="./editor.php?page=<?php echo strtolower($row['vpage_name'])?>&"> <?php echo strtolower($row['vpage_name']); ?></a>
																												  </td>
																		                                        </tr>
																		                                      </table>
																										   
																										   
																										
																										</td>  
																										<TD>&nbsp;</TD>  
																				
																						<?php		
																								}else{
																						 ?>
																						                    
																										       <td class=maintext valign="top">
																											  
																												             <table width="70px" height="45"  border="1" cellpadding="0" cellspacing="0" bordercolor="#A2BFCC">
																															     
																								                                        <tr>
																								                                          <td align="center" valign="top" bgcolor="#D0DFE6" style="width:70px; word-wrap: break-word;" >
																																		  <a class=anchor href="./editor.php?page=<?php echo strtolower($row['vpage_name'])?>&" onclick="SaveCompelsory();"><img border=0 src="images/pagefade.gif" width="30" height="35"> </a>
																																		   <br>
																																            <a class=editorlinks href="./editor.php?page=<?php echo strtolower($row['vpage_name'])?>&" onclick="SaveCompelsory();">     <?php echo strtolower($row['vpage_name']); ?> </a>
																																		  </td>
																								                                        </tr>
																																
																								                               </table>
																													   
																												
																											   <!--<a class=anchor href="./editor.php?page=<?php echo strtolower($row['vpage_name'])?>&"><?php echo $row['vpage_name']; ?> </a>-->
																											   </td>
																											   <TD>&nbsp;</TD>  
																											   
																								 <?php	
																									}
																									
																							     ?>
																					   
																					   <?php }
																					    
																					    ?>
																			   
																			   </tr>
																		   
																		   </table>
																		</td>
																	  
																	</tr>
																	 <tr><td class=borderbg><img src="./image/spacer.gif" width=0 height=1></td></tr>
																  <TR>
																  <TD class=bodyband height=22 COLSPAN="2">
																      <TABLE class=toolbar id=toolbar_full cellSpacing=0 cellPadding=0
																      width="100%" align=center border=0>
																      <TBODY>
																      <TR>
																      <TD class=bodyband height=22 >
																
																       <?php
																
																       include("includes/formatbar.inc");
																
																       ?>
																
																
																
																
																        </TD></TR>
																        </TBODY>
																        </TABLE>
																
																   </TD></TR>
																   <tr>
																     <td>
																	   <DIV id=charMenu style="DISPLAY: none">
																			<TABLE 
																			style="BORDER-RIGHT: buttonshadow 2px solid; BORDER-TOP: buttonhighlight 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 14px; BORDER-LEFT: buttonhighlight 1px solid; CURSOR: hand; BORDER-BOTTOM: buttonshadow 1px solid; FONT-FAMILY: Verdana" 
																			borderColor=#666666 cellSpacing=5 cellPadding=1 bgColor=buttonface border=1>
																			  <TBODY>
																			  <TR>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD></TR>
																			  <TR>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD></TR>
																			  <TR>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD></TR>
																			  <TR>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD></TR>
																			  <TR>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD>
																			    <TD onclick=parent.insertChar(this) width=15>�</TD></TR></TBODY></TABLE>
																		</DIV>
																	 <SELECT id=sPageSwitch style="DISPLAY: none" unselectable="on"
																            onchange=sGoTo(this.options[this.selectedIndex].value); ></SELECT>
																	 </td>
																   </tr>
																   <!-- iframe window -->
																  
																	<tr>
																	   <td COLSPAN="2">
																	   
																	     <IFRAME id=foo contentEditable=true
																style="BORDER-RIGHT: #000000 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: #000000 0px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; OVERFLOW: auto; BORDER-LEFT: #000000 0px solid; WIDTH: 100%; PADDING-TOP: 0px; BORDER-BOTTOM: #000000 0px solid; SCROLLBAR-BASE-COLOR: #dddddd; ; HEIGHT:400px; BACKGROUND-COLOR: white"
																src="<?php echo $currenteditableurllocation?>"></IFRAME></IFRAME>
																	   
																	   </td>
																	</tr>
																	<tr>
																	   <td>
																	     <IFRAME id=fooStyles
																contentEditable=true style="DISPLAY: none"
																src="images/00af970f4b9590626dcfdb96a5f4b4d4.htm"></IFRAME>
																	   </td>
																	</tr>
																  
																	  <tr><td align=right width="37%">
																	   <form name=PageDetails method=post>
																	    <input type="hidden" name="checkid" id="checkid" value="<?php echo($_SESSION["session_checkid"]); ?>">
																	    <input type=hidden id=htmltext name=htmltext value="" >
																		<input type="hidden" name="pageurl" id="pageurl" value="<?php echo($currenteditableurllocation); ?>">
																		<input type=hidden id=currentpage name=currentpage value="<?php echo $pagename?>" >
																		<INPUT type=hidden name="EditorHTM" id="EditorHTM" value=""> 
																		<INPUT type=hidden name="EditorHTM2"  value="">
																		<INPUT type=hidden name="EditorHTM3"  value=""> 
																		<INPUT type=hidden name="EditorHTM4"  value=""> 
																		<INPUT type=hidden name="EditorHTM5"  value="">
																		<input type="hidden" name="deletedimages" id="deletedimages" value="">
																		<input type="hidden" name="newimages" id="newimages" value="">
																		<input type="hidden" name="actiontype" id="actiontype" value="">
																	    <input class=button type=button id=savedata name=savedata value="Save this page(<?php echo $pagenamewithouthtm?>)" onclick="savePage(1);">
																		<input class=button type=button id=sitepreview name=sitepreview value="Preview" onclick="viewpreview();">
																		</form>
																		</td><td align=left>
																		  <form name=frmbackbuttons method=post>
																		  &nbsp; <input class=button name="btnpayment" type=submit value="Publish using FTP/ZIP" >
																			     <input class=button name="btnaddpage" type=submit value="Add/Remove Pages" >
																				<input class=button name="btneditsite" type=submit value="Edit Site details" >
																			     <input class=button name="btnback" type=submit value="Back" >
																		   </form>
																	  </td>
																	
																	 
																	  </tr>
																	
																	<tr>
																	   <td>&nbsp;</td>
																	</tr>
																	<!--<form name=frmbackbuttons method=post>
																	
																	<tr>
																	    <td>
																		   <table width="40%" align=right>
																		      <tr>
																			     <td><input class=button name="btnpayment" type=submit value="Publish using FTP/ZIP" ></td>
																			     <td><input class=button name="btnaddpage" type=submit value="Add/Remove Pages" ></td>
																				 <td><input class=button name="btneditsite" type=submit value="Edit Site details" ></td>
																			     <td><input class=button name="btnback" type=submit value="Back" ></td>
																			  </tr>
																		   </table>
																		</td>
																		 
																	</tr>
																	</form>-->
																</TBODY>
															</TABLE>			                             
															   
														   
				<!-- Main section ends here-->
                </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
				<tr><td>&nbsp;</td></tr>
                </table>
</td>
</tr>
</table>

<?php
include "./userfooter.php";
?>
<script>
  //document.onload=loading();
</script>