<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	11/28/2013	ELL
// Revised: 11/21/2014	ELL
// Off-loaded JavaScript.
// Revised: 7/18/2019	ELL
// Added auto-create of default head if not exist.
// 

	include ("check_session.php");
	
	$last_head_edited = $_SESSION['last_head_edited'];
?>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Head Select | Breeze Website Builder</title>
<link rel="stylesheet" href="theme/<?php echo $theme; ?>/manager.css" type="text/css">

<style>
#btn_manage_head_code	{
	background-attachment:scroll;
	background-repeat:no-repeat;
	background-position: 5px -1px;
}
</style>

<script src="js/edit_head_select.js"></script>

<script>
<?php	echo "	var http = '$http';\n";	?>
</script>
</head>

<body>
<div id="sub_level_1_buttons">

          <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1"><?php echo EDIT_HEAD_SELECT_HEADING; ?></div><div class="button_heading_help" onClick="OpenHelpWindow('edit_head');">&nbsp;</div></div>
		    <?php
			$query = "SELECT head_name FROM " . BWB_TABLE_PREFIX . "head ORDER BY head_name";
			$result = $bwb_dbh->query($query);
			$default_head_found = false;
			while($row = $result->fetch(PDO::FETCH_ASSOC))
			{
				$head_name = $row["head_name"];
				if ($head_name == "head")
					$default_head_found = true;

				if ($head_name == $last_head_edited)
					$selected = " down_sub";
				else
					$selected = "";
					
				echo "<div class='button_sub_level_1$selected' onClick=\"window.location='edit_head.php?head_name=$head_name';\"><span class='button_text_sub_level_1'>$head_name</span></div>\n";
			}
			if (!$default_head_found)	{
				echo "<div class='button_sub_level_1' onClick=\"window.location='edit_head.php?head_name=head';\"><span class='button_text_sub_level_1'>head</span></div>\n";
				
				$query = "INSERT INTO " . BWB_TABLE_PREFIX . "head SET head_name = 'head', head_content='<!-- Page Content Divider -->'";
				$cnt = $bwb_dbh->exec($query);
			}
		?>
      
      <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1"><?php echo MANAGE_HEAD_HEADING; ?></div><div class="button_heading_help" onClick="OpenHelpWindow('manage_head');">&nbsp;</div></div>
        
        <div class='button_sub_level_1' onClick="window.location='manage_head.php';" id="btn_manage_head_code"><span class='button_text_sub_level_1' style="left:35px;"><?php echo MANAGE_HEAD_MANAGE_BTN; ?></span></div>

</div>
</body>
</html>