<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<style type="text/css">
<!--
@import url(<?php echo $template_path_core;?>css/aroundme_form.css);
-->
</style>

<script type="text/javascript" src="<?php echo $template_path_core;?>js/colourpicker.js"></script>

<form action="index.php?amn=core_stylesheet_edit" method="post" name="frm" id="id_frm">
<input type="hidden" name="module_id" value="<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>" />
<input type="hidden" name="item_id" value="<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>" />


<div class="col_left1">
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_stylesheet'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $item['item_title'];?> stylesheet</b><br />
					<?php echo $lang['txt_stylesheet_intro'];?><br />
				</p>
			</div>
		</div>
	</div>

	<?php
	if (isset($style_options)) {
	?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_stylesheet_editor'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<tr>
						<td>
							<input type="hidden" name="element_type" value="<?php echo $element['type'];?>" />
							
							<p>
								<label for="id_element_name"><?php echo $lang['txt_name'];?></label>
								<?php
								if (isset($edit_name) ||$element['type'] == "custom" && isset($_REQUEST['add_custom_element'])) {
								?>
									<input type="text" id="id_element_name" class="input1" name="element_name" value="<?php echo $element['name'];?>" /><br />
								<?php
								}
								else {
								?>
								<input type="hidden" name="element_name" value="<?php echo $element['name'];?>" />
								<?php echo $element['title'];?><br />
								<?php }?>
							</p>
							
							
							<p>
								<label for="id_style_description"><?php echo $lang['txt_description'];?></label>
								<?php
								if ($element['type'] == "custom") {
								?>
									<textarea cols="40" rows="2" style="width:200px;" id="id_style_description" class="input1" name="description"><?php echo $element['description'];?></textarea><br />
								<?php
								}
								else {?>
								<?php echo $element['description'];?><br />
								<?php }?>
							</p>
							
							
							<?php
							foreach ($style_options['styles'] as $keystyl => $styl):
							
							unset($value);
							
							if (!empty($element['styles'][$styl])) {
								$value = $element['styles'][$styl];
							}
							?>
							
							<?php
							if ($styl == "color") {
							?>
							
								<p>
									<label for="id_style_clr_<?php echo $keystyl;?>"><?php echo $lang['style_name']['color'];?></label>
									<input id="id_style_clr_<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" class="input1" size="8" value="<?php echo isset($value) ? $value : ''; ?>" onClick="javascript:inputfield='id_style_clr_<?php echo $keystyl;?>';" />
									<span id="id_style_clr_<?php echo $keystyl;?>_span" style="border:1px solid black;"><img src="<?php echo $template_path_core;?>img/pixel.png" width="12" height="4" alt="" /><br /></span>
								</p>
								
								<script type="text/javascript">
									document.getElementById('id_style_clr_<?php echo $keystyl;?>_span').style.backgroundColor = document.getElementById('id_style_clr_<?php echo $keystyl;?>').value;
								</script>
							
							<?php
							}
							elseif ($styl == "background-color") {
							?>
							
								<p>
									<label for="id_style_bg_<?php echo $keystyl;?>"><?php echo $lang['style_name']['background-color'];?></label>
									<input id="id_style_bg_<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" class="input1" size="8" value="<?php echo isset($value) ? $value : ''; ?>" onClick="javascript:inputfield='id_style_bg_<?php echo $keystyl;?>';" />
									<span id="id_style_bg_<?php echo $keystyl;?>_span" style="border:1px solid black;"><img src="<?php echo $template_path_core;?>img/pixel.png" width="12" height="4" alt="" /><br /></span>
								</p>
								
								<script type="text/javascript">
									document.getElementById('id_style_bg_<?php echo $keystyl;?>_span').style.backgroundColor = document.getElementById('id_style_bg_<?php echo $keystyl;?>').value;
								</script>
							<?php
							}
							elseif ($styl == "background-image" && isset($images)) {
							?>
								<p>
									<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['background-image'];?></label>
									<select name="style[<?php echo $styl;?>]">
									<option value="0">none</option>
									<?php
									foreach($images	 as $key => $img):
									
									$selected = "";
									
									if ($value == $img['file_md5_name']) {
										$selected = "selected=\"selected\"";
									}
									?>
									<option value="<?php echo $module_id;?>-<?php echo $img['file_md5_name'];?>" <?php echo $selected;?>><?php echo $img['file_save_name'];?></option>
									<?php
									endforeach;
									?>
									</select>
									<br />
								</p>
								
							<?php
							}
							elseif ($styl == "border-top") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['border-top'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "border-right") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['border-right'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "border-left") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['border-left'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "border-bottom") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['border-bottom'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "border-style") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['border-style'];?></label>
								<select id="style_cell<?php echo $keystyl;?>" name="style[<?php echo $styl;?>]">
									<option value="none" selected="selected"><?php echo $lang['txt_none'];?></option>
									<option value="dotted" <?php if (isset($value) && $value=="dotted") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['dotted'];?></option>
									<option value="dashed" <?php if (isset($value) && $value=="dashed") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['dashed'];?></option>
									<option value="solid" <?php if (isset($value) && $value=="solid") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['solid'];?></option>
									<option value="double" <?php if (isset($value) && $value=="double") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['double'];?></option>
									<option value="groove" <?php if (isset($value) && $value=="groove") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['groove'];?></option>
									<option value="inset" <?php if (isset($value) && $value=="inset") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['inset'];?></option>
									<option value="outset" <?php if (isset($value) && $value=="outset") { echo "selected=\"selected\"";}?>><?php echo $lang['border_type']['outset'];?></option>
								</select>
							</p>

							<?php
							}
							elseif ($styl == "margin-top") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['margin-top'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "margin-right") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['margin-right'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "margin-left") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['margin-left'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "margin-bottom") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['margin-bottom'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>

							<?php
							}
							elseif ($styl == "padding-top") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['padding-top'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "padding-right") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['padding-right'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "padding-left") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['padding-left'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "padding-bottom") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['padding-bottom'];?></label>
								<input id="style_cell<?php echo $keystyl;?>" type="text" name="style[<?php echo $styl;?>]" value="<?php if (isset($value)) { echo $value;}?>" class="input1" size="3" />&nbsp;px<br />
							</p>
								
							<?php
							}
							elseif ($styl == "float") {
							?>
							
							<p>
								<label for="style_cell<?php echo $keystyl;?>"><?php echo $lang['style_name']['float'];?></label>
								<select id="style_cell<?php echo $keystyl;?>" name="style[<?php echo $styl;?>]">
									<option value="none" selected="selected"><?php echo $lang['txt_none'];?></option>
									<option value="left" <?php if (isset($value) && $value=="dotted") { echo "selected=\"selected\"";}?>><?php echo $lang['float_type']['left'];?></option>
									<option value="right" <?php if (isset($value) && $value=="dashed") { echo "selected=\"selected\"";}?>><?php echo $lang['float_type']['right'];?></option>
								</select>
							</p>
							<?php }?>
							
							<?php
							endforeach;
							?>
							
							<hr />
							
							<p align="right">
								<?php
								if (isset($element['type']) && $element['type'] == "custom" && !isset($_REQUEST['add_custom_element'])) {
								?>
								<input type="submit" name="remove" class="input_submit" value="<?php echo $lang['sub_delete']; ?>"/>&nbsp;
								<?php }?>
								<input type="submit" name="update" class="input_submit" value="<?php echo $lang['sub_update']; ?>"/><br />
							</p>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<?php }?>
</div>

<div class="col_right1">
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_stylesheet_elements'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php echo $lang['txt_elements_intro'];?><br />
				
				<?php
				if (!empty($elements)) {
				foreach ($elements as $key => $i):
				?>
				<p>
					<?php
					if (isset($_REQUEST['element_name']) && $_REQUEST['element_name'] == $i['name']) {
					?>
					<b><?php echo $i['title'];?></b><?php if ($i['type'] == "custom") { echo "<sup>*</sup>";}?><br />
					<?php
					}
					else {
					?>
					<b><a href="index.php?amn=core_stylesheet_edit&amp;module_id=<?php echo $_REQUEST['module_id'];?>&amp;item_id=<?php echo $_REQUEST['item_id'];?>&amp;element_name=<?php echo $i['name'];?>"><?php echo $i['title'];?></a></b><?php if ($i['type'] == "custom") { echo "<sup>*</sup>";}?><br />
					<?php }?>
					<?php echo $i['description'];?><br />
				</p>
				<?php
				endforeach;
				}?>

				<?php
				if (empty($_REQUEST['add_custom_style'])) {
				?>
				<p align="right">
					<a href="index.php?amn=core_stylesheet_edit&amp;module_id=<?php echo $_REQUEST['module_id'];?>&amp;item_id=<?php echo $_REQUEST['item_id'];?>&amp;add_custom_element=1"><?php echo $lang['href_add_custom_style'];?></a><br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>

	<?php
	if (isset($style_options)) {
	?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_stylesheet_intro'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<?php echo $lang['txt_editor_colourpicker'];?><br />
				</p>
				
				<div id="colourpicker1"></div>
				
				<script type="text/javascript">
					var inputfield = '';
					initColourPicker('colourpicker1',30);
				</script>
			</div>
		</div>
	</div>
	<?php }?>
</div>
</form>