if(isset($_GET["EditTimeRule-js"])){EditTimeRule_js();exit;}
if(isset($_GET["EditTimeRule-popup"])){EditTimeRule_popup();exit;}
if(isset($_GET["EditTimeRule-template"])){EditTimeRule_template();exit;}



if(isset($_POST["EditTimeRule-template"])){EditTimeRule_template();exit;}
if(isset($_POST["EditTimeRule"])){EditTimeRule_save();exit;}
if(isset($_POST["EnbleTimeRule"])){EditTimeRule_enable();exit;}
if(isset($_POST["EditTimeRule-delete"])){EditTimeRule_delete();exit;}
if(isset($_POST["EditTimeTemplate"])){EditTimeRule_template_save();exit;}


if(isset($_GET["EditTimeRule-groups"])){EditTimeRule_groups();exit;}
if(isset($_GET["EditTimeRule-groups-list"])){EditTimeRule_groups_list();exit;}
if(isset($_POST["EditTimeRule-groups-add"])){EditTimeRule_groups_add();exit;}
if(isset($_POST["EditTimeRule-groups-delete"])){EditTimeRule_groups_delete();exit;}


rules();


function EditTimeRule_js(){
	$page=CurrentPageName();
	$tpl=new templates();	
	$ID=$_GET["ID"];
	if($ID>0){
			$q=new mysql_squid_builder();
			$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT TimeName FROM webfilters_sqtimes_rules WHERE ID='$ID'"));
			$TimeName=" »".utf8_encode($ligne["TimeName"]);
	}
    exit;
}
if (isset($_POST["EditTimeTemplate"])) {
    EditTimeRule_template_save();
    exit;
}
if (isset($_GET["EditTimeRule-groups"])) {
    EditTimeRule_groups();
    exit;
}
if (isset($_GET["EditTimeRule-groups-list"])) {
    EditTimeRule_groups_list();
    exit;
}
if (isset($_POST["EditTimeRule-groups-add"])) {
    EditTimeRule_groups_add();
    exit;
}
if (isset($_POST["EditTimeRule-groups-delete"])) {
    EditTimeRule_groups_delete();
    exit;
}
rules();
function EditTimeRule_js()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $ID = $_GET["ID"];
    if ($ID > 0) {
        $q = new mysql_squid_builder();
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT TimeName FROM webfilters_sqtimes_rules WHERE ID='{$ID}'"));