<?php
header('Content-Type: text/html; charset=windows-1251');
if (isset ($_REQUEST['utf8']))  // 
{$utf8=$_REQUEST['utf8'];}
else  //
{}
//--------------
include "../f.php";   // 
//--------------

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('error_reporting', E_ALL);


?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Start form</title>
<style>
td {color:#316290;font-family:tahoma;font-size:12px;font-weight:normal;}
th {color:#316290;font-family:tahoma;font-size:12px;font-weight:bold;}
a {color:#254A6C;font-family:tahoma;font-size:12px;font-weight:normal;}
b {color:#316290;font-family:tahoma;font-size:12px;font-weight:bold;}
.redlink {color:#B92327;font-family:tahoma;font-size:11px;font-weight:normal;}
.bluelink {color:#254A6C;font-family:tahoma;font-size:11px;font-weight:normal;}
a:hover {color:white;font-family:tahoma;font-size:12px;font-weight:normal;background:black}
</style>
</head>
<?php 
$pa="12345";
$pa="atiru";
$da=false;
$os2=false;   //
$p="";
if (isset ($_REQUEST['T1']))  
{if (!empty($_REQUEST['T1'])) {$da=true;$p=$_REQUEST['T1'];}
else
{$p="";}
}

if (isset ($_REQUEST['typ']))          //
{$typ=$_REQUEST['typ'];}             
else
{$typ="";}
//$typ=$_REQUEST['typ'];
if ($typ=="1")
{
if (file_exists(getcwd ( )."/1.txt"))
{unlink (getcwd ( )."/1.txt");}
echo '<body background="../d~e~f/bkg4.gif" leftMargin=0 id=bod topMargin=0 style="overflow:hidden;" width=100% height=100% >';
echo '
<table id=monoz  border=0 style="width:100%;height:100%;z-index:3;position:absolute;top:0px;left:0px;">
<tr ><td width=30%>&nbsp;</td><td width=30%  valign=center align=center>
<table border=0 width=300 style="background:white" >
<tr>
<td  height=30px align=center><big style="color:red" >CORRECT COMPLETION OF THE ADMINISTRATOR S WORK!
<br>
You can close this page! </big>
</td></tr>
</table>
</td><td width=30%>&nbsp;</td></tr></table></body></html>';
die; 
}
// 
if ($typ=="2")
{
$w = fopen(getcwd ( )."/2.txt", 'w') or exit;   
fclose($w); 
}

// 
if ($typ=="3")
{
if (file_exists(getcwd ( )."/2.txt"))
{unlink (getcwd ( )."/2.txt");}
}

// 
if ($typ=="12")
{
if (file_exists(getcwd ( )."/odin.txt"))
{unlink (getcwd ( )."/odin.txt");}
}

// 
if ($typ=="10")
{
$w = fopen(getcwd ( )."/odin.txt", 'w') or exit;   
fclose($w); 
}
if ($typ=="9")
{
echo '<body background="../d~e~f/bkg4.gif" leftMargin=0 id=bod topMargin=0 style="overflow:hidden;" width=100% height=100% >';
echo '<center><big style=font-size:20;color:red;text-align:center>P H P in '.php_uname().'</big><br>';
echo '<button onclick=for2.elements("B1").click() style="background:white;color:red"  title="Click me to continue." >Continue.</button></center>';
echo '<form id=for2 method="POST" action="start.php" style=display:none >
<input type="submit" value="  V  " name="B1" title="Complete password entry.">
<input type="password" name="T1" size="15" value="'.$p.'"></form>';
echo '<div style="height:85%;width:100%;OVERFLOW: scroll;background:white">';
phpinfo();
echo '</div></body></html>';
die;
}
?>
<body background="../d~e~f/bkg4.gif" leftMargin=0 id=bod topMargin=0 style="visibility:hidden;overflow:hidden;" width=100% height=100% >
<table id=h style="z-index:2;opacity:0.3;visibility:hidden;height:100%;width:100%;position:absolute;top:0;left:0;background:black;filter:alpha(opacity=30)"><tr><td>&nbsp;&nbsp;&nbsp;</td><tr></table> 
<?php



if (isset ($_REQUEST['u']))
 {$utf8=1;
  $ip=getcwd().'/1251';
 if (file_exists($ip)) {rmdir($ip);}}  // 
 
if (isset ($_REQUEST['w'])) 	//
 {$utf8=0;
  $ip=getcwd().'/1251';
 if (file_exists($ip)) {} 		//
  else {mkdir($ip);}} 		 	//

if (file_exists(getcwd().'/1251')) 
{$utf8=0;} else {$utf8=1;}     // 
echo '<b style=color:red>WEBSITE:</b> <b id=sname2>';
include "../plan/name.txt";
echo '</b>';


echo '<table border=0 height=100% width="100%" style="position:absolute;top:20;left:0">
<TBODY><TR><td valign=top align="center" >';
$kat=getcwd ( );	 		// 
if (!file_exists($kat."/otd.txt")) //
{
$filenamew = $kat.'/otd.txt';	  	//
$hw = fopen($filenamew, 'w') or exit;  //
$w='Brief/Name/Password/Pages';
fwrite($hw,c($w,1)."\r\n");
$w='Admin/Administrator/123/';
fwrite($hw,c($w,1)."\r\n");
fclose($hw);
$da=false; echo '<h3 style="color:red">The file ../otd/otd.txt has been deleted! The file has been restored, the damaged data has been deleted! Type administrator password = 123 and press Enter.</h3>';
}
else
{
$l = file($kat."/otd.txt");
$ll=array();  
$i=0;
foreach ($l as $li => $lin)
{$ll[$i++]=c($lin,0);
if ($li==1) // 
{$stt=explode("/", $ll[1]); //
$pa=$stt[2];
}}}
if ($da)  // 
{if ($p==$pa) // 
{$stt=explode("/", $ll[0]); //
echo '<nobr><b><big>SUBJECTS</big>';
echo '&nbsp;ascending</b>&nbsp;<img id=ksort onclick=izs(this) src=../d~e~f/yes.gif 
title="Sort in ascending order: check me, click the title in the header; Sort descending: undo, click the header in the header; Unsort: click again.">
&nbsp;&nbsp;&nbsp;<button title="To begin" onclick=tnd(0) style="background:white">&nbsp;&#8593;&nbsp;</button>&nbsp;&nbsp
<button style="background:white" onclick=tnd(9999999) title="To end">&nbsp;&#8595;&nbsp;</button>&nbsp;&nbsp
<button style="background:white" onclick=ptab() title="In a separate window for printing">&nbsp;P&nbsp;</button>
&nbsp;
</nobr>';
echo '
<br><b>filter in <b id=zs>?</b> by </b>
<input type="text" id=goto size="20" title="One or more filtering contexts separated by /.">
&nbsp;<button onclick=got(0) form="" style=width:28 
title="Show only those rows that contain context anywhere in the text that is clicked on the column number. ">
S</button>&nbsp;
<button onclick=got(2) style=width:28 title="Cancel selection">C</button>';
echo '<center><b id=soob style="color:brown">';
//echo $soob."&nbsp;";
echo '</b></center>';
  echo '<table id=zag  onclick=clz(this,event)   border="1" width="100%" style="background:#eee8aa"><THEAD>
<TR id=sort>'."\n";
  echo '<TH width=38 title=0>N</TH>'."\n";
  for ($i = 0;$i<2; $i++) 
   {if ($i==0)
{echo '<TH width=83 title=1>'.$stt[$i].'</TH>'."\n";
}
else
{ echo '<TH title=2>'.$stt[$i].'&nbsp;(access to pages)</TH>'."\n";
   }}
  echo "</TR>
<tr id=sel title='Click me to filter.'><TH>1</TH><TH>2</TH><TH>3</TH></THEAD></table>";
echo '<DIV id=k onclick=v(event) style="OVERFLOW: scroll" align=left>';
echo '<table border="0"  width="100%"  ><TBODY><TR><td align="center" valign=center >';
// 
foreach ($ll as $li => $lin)
{if ($li==0)  // 
 {echo "<table border=1 id=tab2 width=100% ><TBODY>\n";
 }
 else  // 
 {$stt=explode("/", $lin); // 
 echo '<tr>'."\n"; 
 if ($da)   // 
    {if ($stt[2]==$p or $p==$pa)  // 
      {$os2=true;   // 
      echo '<TD width=35>'.$li.'</TD>'."\n";  
        for ($i = 0;$i<2; $i++) 
        {echo '<TD width=80>'.$stt[$i].'</TD>'."\n";
          if ($i=1)
          {if ($p==$pa)
			{echo '<td  title="'.trim($stt[2]).'"><a target=_blank  onclick=otd1(this,event) href="otd1.php'.'?nam='. $stt[1].'&pag='. $li.'">'.$stt[1]."</a></td>\n";
			}
             else
            {echo '<td ><a target=_blank href="otd1.php'.'?nam='. $stt[1].'&pag='. $li.'&pas='. $stt[2].'&pasa=1234322'.'&utf8='.$utf8.'">'.$stt[1]."</a></td>\n";}
           }
          else   {echo '<td>'.$stt[1]."</td>\n";} 
        }
      }
	  else
	  {
	 }
     }
     else   // 
     {echo '<td width=35>'.$li.'</td>'."\n";  
       for ($i = 0;$i<2; $i++) 
       { echo '<td width=80>'.trim($stt[$i]).'</td>'."\n";
         if ($i=1)
         {echo '<td ><a href="nopass.htm">'.trim($stt[1]).'</a></td>'."\n";}
         else   {echo '<td>'.trim($stt[1])."</td>\n";} 
       }
      }
  echo "</tr>\n";
 } 
}
echo '</tbody></table>';
echo '</td></tr></tbody></table></div>';
}
else  // 
{foreach ($ll as $li => $lin)
{ if ($li==0)  // 
 {}
 else                                        // 
 { $stt=explode("/", $lin);                  // 
  if ($stt[2]==$p)                           // 
{echo '<a id="to" onclick="otd1(this,event)" target=_blank href="otd1.php'.'?nam='. $stt[1].'&pag='. $li.'&pas='. $stt[2].'&pasa=1234322'.'&utf8='.$utf8.'">'.$stt[1]."</a>\n";
echo '<form id=pol method="POST" action="otd1.php">';
echo '<input id=s type="submit" value="go" name="s" >';
echo '<input type="hidden" value="'. $stt[1].'" name="nam">';
echo '<input type="hidden" value="'. $li.'" name="pag">';
echo '<input type="hidden" value="'. $stt[2].'" name="pas">';
echo '<input type="hidden" value="'.$pa.'" name="gpas">';
echo '<input type="hidden" value="'. $utf8.'" name="utf8">';
echo '<input type="hidden" value="" name="typ">';
echo '</form>';
echo '<script>
document.getElementById("s").click()  
</script>';
break;
}
}}}
}
?>
</td>
<td valign="center" align="center" >
<table border=0 width=100%><tbody>
<tr>
<td valign="top" align="center" >
<b>For sites and applications &nbsp;&nbsp;&nbsp;
<a  href="../help/0.htm" target=_blank>&nbsp;Help&nbsp;</a>
<br> <font color=red size=4> CMS "ONPHPONLY", free of charge, V 5.72E from 01-01-2021
</font><br>
ALL DATA IN FILES, NO_SQL!
WORKS ON ALL BROWSERS IN FULL VOLUME!
<br> Design, programming, copyright: Yasankin V.N., Yasankina G.P. </b> <br>
 <a  href="mailto:yasankin@gmail.com&#13;&#10;"><b>Ask a question by e-mail.</b></a> &nbsp;&nbsp;&nbsp; <b>Translated by https://translate.google.ru</b>
  </td></tr></tbody></table>
<b style="color:red">Encoding:
<?php if ($utf8==1) {echo "UTF-8";} else {echo "&nbsp;&nbsp;windows-1251";}
$rew=date_default_timezone_set("Asia/Krasnoyarsk");
//$rew=default_charset("windows-1251");
 ?>&nbsp;&nbsp;&nbsp; timezone:&nbsp;&nbsp;Asia/Russia/Krasnoyarsk</b>
 <form method="POST" action="start.php" id=par>
<b>Enter your password:</b>
<input type="password" name="T1" size="15" value="<?php  echo $p;  ?>">
<input type="submit" value="  V  " name="B1" title="Complete password entry.">
<input type="reset"  value="  X  " name="B2" style=display:none  title="Reset entered password">
<input type="hidden"  value="  X  " name="T2"  title="Reset entered password">
<input type="hidden"  value="<?php  echo $typ;  ?>" name="typ"  title="Administrator commands.">
</form>
<?php
if ($da)   
{if  ($os2)
{

echo '<table><tr><td><li> This software is provided "as is" without warranty of any kind.
<li> The authors are not responsible for any damage caused by using this software product.
<li> You can use and distribute CMS without restrictions.
<li> You can modify the CMS software or create derivative products,
based on this software.
<li style = color: red> You may not rent or sell this software.</td></tr></tyable>'; 

if ($p==$pa)
{// 
echo '<table id=adm border=1><tr><td width=250 valign=top>
<b>THE ADMINISTRATOR CAN:</b>';
if (file_exists(getcwd ( )."/2.txt"))
{echo '<li><a  target=_blank href="" onclick=doso(event) style="color:green">OPEN access to the site</a>';
}
else
{ echo '<li><a  target=_blank href=""  onclick=dosc(event) style="color:red">CLOSE site access</a>';
	 echo '<li><a title="Adding, deleting groups, subgroups, pages. Changing their location on the site BEFORE CHANGING THE STRUCTURE CLOSE ALL WINDOWS EXCEPT THIS! " 
	  target=_blank href="../menu.php?utf8='.$utf8.'">Change structure</a><br>'."\n".
	  '<li><a target=_blank href="../plan/m.php" title="Entering, changing data located on the main page">Change main page.</a>'."\n<br>";
 } 
 if (file_exists(getcwd ( )."/odin.txt"))
{ echo '<li><a onclick=odin(event,12) title="Set up multi-user mode."   target=_blank href=#>Set to MULTI-USER mode.</a>';

}
else
{echo '<li><a onclick=odin(event,10) title="Set the application to single-user mode"  target=_blank href=#>Set SINGLE-USE mode</a>';
}
if (file_exists(getcwd ( )."/2.txt"))
{ 
 echo '<li><a   target=_blank href=saveall.php?add=all&spv=1;2;3>Pages all save</a>';
 echo '<li><a  target=_blank href=restoreall.php?typ=5>Pages all restore</a>';
 echo '<li><a  target=_blank href=restoreall.php?typ=55>Restore selected pages</a>';
}
if  (strstr(" ".php_uname(), 'Windows')) // 
//*******************************************************************
{
       echo '<li><a  target=_blank href=../../pages.zip>Archive of all pages download</a>';
      echo '<li><a  target=_blank href=../../pages2.zip>Download archive of selected pages</a>';
}
else
{
      echo '<li><a  target=_blank href=../../pages.tar.gz>Archive of all pages download</a>';
      echo '<li><a  target=_blank href=../../pages2.tar>Download archive of selected pages</a>';
  
}
	  //	  
      echo '<li><a  target=_blank href=phpinfo.php  title="OS and PHP Help">PHP</a>';
echo '<li><a title="Run P Designer offline."  target=_blank href=../pgdrw57_1/start2.php>Autonomous PA.</a>';
//
//


	  echo '</td><td width=250 valign=top>'."\n";
	  echo '<b>DIRECTORIES:</b><br>';
if (file_exists(getcwd ( )."/2.txt"))
{}
else
{

echo '	  <li><a title="Creation, modification, removal of subjects editing the site. " 
	  target=_blank href="../redspr.php?file=otd/otd.txt&im=';
 	  echo tr("directory of subjects of the site");
	  echo "&tip=";
	  echo "object";
	  echo '">Subjects</a>'."\n";
	  echo '<li><a title="Maintaining a list of text variables."  target=_blank href="../tc.php">Text variables</a>';
	  echo '<li><a title="Maintaining a directory of image file extensions that can be uploaded to the site." 
	  target=_blank href="../redspr.php?file=otd/img.txt&im=';
 	  echo tr("directory of the type of pictures that can be loaded");
	  echo "&tip=";
	  echo "tip";
	  echo '">Image extensions</a>'."\n";
	  echo '<li><a title="Maintaining a directory of file extensions that can be uploaded to the site." 
	  target=_blank href="../redspr.php?file=otd/new.txt&im=';
 	  echo tr("directory of the type of files that can be loaded");
	  echo "&tip=";
	  echo "tip";
	  echo '">File extensions to download</a>'."\n";
	  echo '<li><a title="Directory of e-mail addresses." 
target=_blank href="../redspr.php?file=menu/mail.txt &im=';
 	  echo tr("mail directory");
	  echo "&tip=";
	  echo "mail";
	  echo '">e-mail</a>'."\n";
echo '<li><a title="Directory of Internet addresses of external sites http: //." 
target=_blank href="../redspr.php?file=menu/http.txt &im=';
 	  echo tr("list of external internet sites");
	  echo "&tip=";
	  echo "http";
	  echo '">Websites</a>'."\n";
echo '<li><a title="Directory of addresses of external files fttp: //." 
target=_blank href="../redspr.php?file=menu/fttp.txt &im=';
 	  echo tr("directory of external internet sites");
	  echo "&tip=";
	  echo "fttp";
	  echo '">Files</a>'."\n";
	  }
//
echo ' <li><a target=_blank href=sprall.php?typ=6>Contents of the archive.</a>';
echo ' <li><a target=_blank href=sprall.php?typ=7>Contents of the archive of the selected pages.</a>';

//
   	 echo '<li><a  href="../help/4.htm" target=_blank>&nbsp;Help&nbsp;</a>';
      echo '<li><a  target=_blank href=# onclick=zak(event)>To finish work.</a>
</td></tr></table>';	   

	 
	 
	 
	 //
 
	 if (file_exists($kat."/1.txt") and $typ=="")
{
echo '<b style="color:red">THE ADMINISTRATOR IS WORKING, OR THERE WAS AN INCORRECT COMPLETION OF THE WORK!</b><br>';
}
if (file_exists($kat."/2.txt"))
{echo '<b id=rep style="color:red"> Access to the site is CLOSED!</b>';}
else
{echo '<b  id=rep style="color:green"> Access to the site is OPEN!</b>';}

if (file_exists($kat."/odin.txt"))
{echo '<b id=rep style="color:red"> Single-user mode!</b>';}
else
{echo '<b  id=rep style="color:green"> Multi-user mode!</b>';}



	 echo  '<br><br><B>RIGHTS OF SUBJECTS:</b><br>';
	  echo '</font>';
echo '<li> To change the password and page access rights, click the subject in the "Name" column';
echo '<li> After entering new and / or deleting old subjects, click F5 to appear (delete) them in the list. </ul>';
     $w = fopen($kat."/1.txt", 'w') or exit;   
     fclose($w); 

	  }
	}
    else
    {echo '<br><br><b><font style="background:red;color:white"> Password is a mistake! '."</font></b>\n";}
 }
   else
  {echo '<br><br><b><font style="background:red;color:white">   No access! '."</font></b>\n";}
?>
</td></tr></tbody></table>
</center>
<form id=per method="POST" action="otd1.php" target=_blank>
<input type="submit" style="display:none" value="V" name="st" title="Complete password entry">
<input type="hidden"  value="" name="nam">
<input type="hidden"  value="" name="pag">
<input type="hidden"  value="<?php echo $p;?>" name="pas">
<input type="hidden"  value="<?php echo $pa;?>" name="gpas">
<input type="hidden"  value="<?php echo $utf8;?>" name="utf8">
<input type="hidden" value="" name="typ">
</form>
<script type="text/javascript">
//*****************************************************************************************************
//  Attention ! mozilla - if there is more than 1 FORM tag on the page, then access to form elements only via ID
//******************************************************************************************************
window.onload=function ()
{
if (document.getElementById("k")!=undefined)
{obj9= document.getElementById("k")
obj9.style.height=document.getElementById("h").offsetHeight-130
obj9.scrollLeft=0
obj9.scrollTop=0
}
document.getElementById("bod").style.visibility="visible"
}
//
function saves(event)
{
ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
if (document.getElementById('rep').innerHTML.indexOf('OPENED')>0) 
{
alert("To save, close access to the site!")
return
}

if (confirm("The creation of the archive may take a long time, \r\n wait for the message ALL PAGES ARE SAVED IN THE ARCHIVE!")) 
{
document.getElementById("h").style.visibility="visible"
document.getElementById('rep').innerHTML=document.getElementById('rep').innerHTML+"<MARQUEE style='WIDTH: 100%' behavior=alternate>WORKS SAVE! WAIT ...</MARQUEE>"
par.elements["typ"].value="4"
par.elements["B1"].click()
}
}

//**********************************************************
function restoprs(p) // 
//*********************************************************
{event.cancelBubble = true
event.returnValue = false
if (document.getElementById('rep').innerHTML.indexOf('OPENED')>0) 
{alert("To restore, close access to the site!")
return
}
if (p=="5")
{if (!confirm("ATTENTION ! All existing pages will be REMOVED!\r\n "+
"\r\nArchive recovery can take a long time, \r\n wait for the message PAGES RESTORED!"))
{return}
}
if (p=="55")
{if (!confirm("ATTENTION ! Pages to be restored \r\n from a selective archive must be in the structure, \r\n if they are not there, correct the structure file!"+
"\r\nArchive recovery can take a long time, \r\n wait for the message PAGES RESTORED!"))
{return
}}
document.getElementById("h").style.visibility="visible"
document.getElementById('rep').innerHTML=document.getElementById('rep').innerHTML+"<MARQUEE style='WIDTH: 100%' behavior=alternate>RESTORATION WORKS! WAIT ...</MARQUEE>"
par.elements["typ"].value=p
par.elements["B1"].click()
}



//******************************************************
function dosc(event)  //
//******************************************************
{ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value="2"
par.elements["B1"].click()
}

//*******************************************************
function doso(event)  //
//*******************************************************
{ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value="3"
par.elements["B1"].click()
}


//*************************************************************************************
function odin(event,p)  // 
//*************************************************************************************
{
if (p==10)
{alert("Attention ! Multiple users working on one table in single user mode results in "+
"to incorrect results and failures! \r\n Provide one user access to the site by system means!")
}	
ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value=p
par.elements["B1"].click()
}






//************************************************
function spra(event,p)  // 
//***********************************************
{document.getElementById("h").style.visibility="visible"
ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value=p
par.elements["B1"].click()
}

//*****************************************************
function php(event)  // 
//****************************************************
{ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value="9"
par.elements["B1"].click()
}


//******************************************************************
function zak(event)  // 
//******************************************************************
{ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
par.elements["typ"].value="1"
par.elements["B1"].click()
}

obj=per
obj2=""
//********************************************************************
function otd1(p,event)   //
//********************************************************************
{ev = event || window.event
ev.cancelBubble = true
ev.returnValue = false
try 
{ev.preventDefault()} 
catch (err) {}
var t = ev.target || ev.srcElement
if (document.getElementById("adm")==undefined)
{alert("Not administrator!")
return
}
per.elements["nam"].value=t.innerHTML
z=t.href.split("pag=")
per.elements["pag"].value=z[1]
if (obj2!="")
{obj2.style.background=""
}
t.parentNode.style.background="yellow"                  // 
obj2=t.parentNode
per.elements["st"].click()
}


//*******************************************
function tnd(p)  // 
//*******************************************
{document.getElementById('k').scrollTop=p}

//**************************************************
function izs(p) // 
//**************************************************
{if (p.src.indexOf('no.gif')>0) 
{p.src='../d~e~f/yes.gif'}
else
{p.src='../d~e~f/no.gif' }}

objsort=""
objselect=""
isort="no"
//**************************************************************
function clz(p,event)  // 
//**************************************************************
{ev = event || window.event
var t = ev.target || ev.srcElement
if (t.tagName!="TH") return
if (t.parentNode.id=="sort")                       // 
{if (objsort!="")                                  // 
{if (t.style.background.indexOf("yellow")>=0)      // 
{sort2(3)
return
}
objsort.style.background=""
objsort.style.color=""
}
isort=t.title
t.style.background="yellow"
t.style.color="brown"
objsort=t
if (document.getElementById("ksort").src.indexOf('no.gif')>0)
{sort2(2)}
else
{sort2(1)}
objsort=t
}
else if (t.parentNode.id=="sel")            // 
{
if (objselect!="")                         // 
{objselect.style.background=""
objselect.style.color=""}
t.style.background="yellow"
t.style.color="brown"
document.getElementById("zs").innerHTML=t.innerHTML
objselect=t
document.getElementById("soob").innerHTML="Column "+ t.innerHTML +" for filter is selected."
}
else
{return}
}

//********************************************************
function sort2(p)  // 
//********************************************************
{if (p==1 || p==2 || p==3)
{if (obj2!="")                // 
{obj2.style.background=""
}
// 
var mss = new Array();        // 
is=isort                    // 
mas=document.getElementById("tab2").getElementsByTagName("TR")

if (p==3)
{p=1
is=0
isort="no"
objsort.style.background=""
objsort.style.color=""
document.getElementById("soob").innerHTML="Sorting canceled."
}
else if (p==1)
{document.getElementById("soob").innerHTML="Sort ascending, column "+(parseInt(is,10)+1)+" !"}
else if (p==2)
{document.getElementById("soob").innerHTML="Sort Descending, Column"+(parseInt(is,10)+1)+" !"}

if (is==1 )
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
mss[j]=mas2[1].innerHTML+mas2[0].innerHTML+"#"+(j)
}}
else if (is==0)
{for(var j = 0; j <mas.length ; j++)
{mas2=mas[j].getElementsByTagName("TD")
tt=mas2[0].innerHTML
tt2="0000000"+tt
tt2=tt2.substr(parseInt(tt.length))
mss[j]=tt2+"#"+(j)
}}
else
{for(var j = 0; j <mas.length; j++)
{mas2=mas[j].getElementsByTagName("A")
mas22=mas[j].getElementsByTagName("TD")
mss[j]=mas2[0].innerHTML.toUpperCase()+mas22[0].innerHTML+"#"+(j)
}}
mss=mss.sort()
mtr="<table border=1 id=tab2 width=100%>"
if (p==1)
{
for(var j = 0; j < mas.length; j++)
{sss=mss[j].split("#")
iii=parseInt(sss[1])
mtr=mtr+mas[iii].outerHTML
}}
else
{for(var j = mas.length-1; j>=0; j--)
{sss=mss[j].split("#")
iii=parseInt(sss[1])
mtr=mtr+mas[iii].outerHTML
}}
document.getElementById("tab2").outerHTML=mtr+"</table>"
}
}

obj2=""   //
//************************************************************
function v(event)  // 
//***********************************************************
{event = event || window.event
var t = event.target || event.srcElement
if (t.outerHTML.indexOf('checkbox')>0)
{return}	
if (t.tagName=="TD" )                                   //
{if (obj2!="")
{obj2.style.background=""
}
t.style.background="yellow"                  //
obj2=t
}}

fi2=false     // 
//****************************************************************************************
function got(p)   //
//****************************************************************************************
{if (p==2 &&  !fi2)
{return	}	
mtr2=document.getElementById("tab2").getElementsByTagName("TR")  // 
if (p==2)
{for(var j = 0; j <= mtr2.length-1; j++)
{mmtr2=mtr2[j].getElementsByTagName("TD")
mtr2[j].style.display=""
}
fi2=false	
document.getElementById("soob").innerHTML="Filter canceled!"
return
}
if (document.getElementById("goto").value=="" && p==0)
{alert("Enter the filter context!")	
return}
if (document.getElementById("zs").innerHTML=="?")
{alert("No column selection! Click the desired column in the table!")
return}
kont=document.getElementById("goto").value
mkont=kont.split("/")
for(var jj = 0; jj <= mkont.length-1; jj++)
{if (mkont[jj]=="")
{alert("Empty context in filter list!")
return
}}


//
fi=parseInt(document.getElementById("zs").innerHTML,10)-1
//
if (obj2!="")
{obj2.style.background=""
obj2=""
}


for(var j = 0; j <= mtr2.length-1; j++)
{mmtr2=mtr2[j].getElementsByTagName("TD")
if (fi==2)
{text2=mmtr2[2].getElementsByTagName("A")[0].innerHTML	
}
else
{text2=mmtr2[fi].innerHTML}
fi2=true
for(var jj = 0; jj <= mkont.length-1; jj++)
{if (fi!=0)
{if (text2.indexOf(mkont[jj])>=0)
{mtr2[j].style.display="";break}
else
{mtr2[j].style.display="none"
}}
else
{if (text2==mkont[jj])
{mtr2[j].style.display="";break}
else
{mtr2[j].style.display="none"
}}}}

document.getElementById("soob").innerHTML="Filtering!"
}

//********************************************************************
function ptab() // 
//********************************************************************
{
newstr2="<b>Website: </b>"+document.getElementById("sname2").innerHTML
newstr2=newstr2+"<h2 style='text-align:center'>List of subjects</h2>"
is=""
if (isort!="no")
{if (document.getElementById("ksort").src.indexOf("yes.gif")>0)
{is="  sort by column N "+(parseInt(isort,10)+1)+ " ascending "
}
else
{is=" sort by column N "+(parseInt(isort,10)+1)+" descending"
}}
if (fi2)
{newstr2=newstr2+ "Filter by '"+
document.getElementById("goto").value+"' in "+document.getElementById("zs").innerHTML+ is 
}
else
{newstr2=newstr2+is
}
mstr=document.getElementById("tab2").getElementsByTagName("TR")
newstr2=newstr2+"<table width=100% border=1><tr> <th>N</th><th>Briefly</th><th>Name</th></tr><tr><th>1</th><th>2</th><th>3</th></tr>"
for(var j = 0; j <mstr.length; j++)  
{if (mstr[j].style.display!="none")
{newstr=""
mstrtd=mstr[j].getElementsByTagName("TD")
mstrtd2=mstr[j].getElementsByTagName("A")
newstr=newstr+"<tr><td>"+mstrtd[0].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd[1].innerHTML+"</td>"
newstr=newstr+"<td>"+mstrtd2[0].innerHTML+"</td></tr>"
newstr2=newstr2+newstr
}}
newstr2=newstr2+"</table>"
dop=window.open("","","");
tnap="<HTML><HEAD><META http-equiv=Content-Type content='text/html; charset=windows-1251'></head>"
tnap=tnap+newstr2+"</html>"
dop.document.write(tnap)
}
</script>
</body></html>
