<?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">
			<?php echo $lang['hdr_stylesheet_editor'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<tr>
						<td>
							<?php
							foreach ($allowable_styles as $keyelmt => $elmt):
							?>
							
							<p>
								<b><?php echo $lang['element_name'][$keyelmt];?></b><br />
							</p>
							
							<?php
							foreach ($elmt['styles'] as $keystyl => $styl):
							
							unset($value);
							
							if (!empty($stylesheet_arr[$elmt['element']][$styl])) {
								$value = $stylesheet_arr[$elmt['element']][$styl];
							}
							?>
							
							<?php
							if ($styl == "color") {
							?>
							
								<p>
									<label for="id_style_clr_<?php echo $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['color'];?></label>
									<input id="id_style_clr_<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?php echo $styl;?>]" class="input1" size="8" value="<?php echo isset($value) ? $value : ''; ?>" onClick="javascript:inputfield='id_style_clr_<?php echo $keyelmt . $keystyl;?>';" />
									<span id="id_style_clr_<?php echo $keyelmt . $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 $keyelmt . $keystyl;?>_span').style.backgroundColor = document.getElementById('id_style_clr_<?php echo $keyelmt . $keystyl;?>').value;
								</script>
							
							<?php
							}
							elseif ($styl == "background-color") {
							?>
							
								<p>
									<label for="id_style_bg_<?php echo $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['background-color'];?></label>
									<input id="id_style_bg_<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?php echo $styl;?>]" class="input1" size="8" value="<?php echo isset($value) ? $value : ''; ?>" onClick="javascript:inputfield='id_style_bg_<?php echo $keyelmt . $keystyl;?>';" />
									<span id="id_style_bg_<?php echo $keyelmt . $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 $keyelmt . $keystyl;?>_span').style.backgroundColor = document.getElementById('id_style_bg_<?php echo $keyelmt . $keystyl;?>').value;
								</script>
							<?php
							}
							elseif ($styl == "background-image" && isset($images)) {
							?>
								<p>
									<label for="style_cell<?php echo $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['background-image'];?></label>
									<select name="style[<?php echo $elmt['element'];?>][<?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="1-<?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 $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['border-top'];?></label>
								<input id="style_cell<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?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 $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['border-right'];?></label>
								<input id="style_cell<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?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 $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['border-left'];?></label>
								<input id="style_cell<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?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 $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['border-bottom'];?></label>
								<input id="style_cell<?php echo $keyelmt . $keystyl;?>" type="text" name="style[<?php echo $elmt['element'];?>][<?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 $keyelmt . $keystyl;?>"><?php echo $lang['style_name']['border-style'];?></label>
								<select id="style_cell<?php echo $keyelmt . $keystyl;?>" name="style[<?php echo $elmt['element'];?>][<?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 }?>
							
							<?php
							endforeach;
							?>
							
							<hr />
							
							<?php
							endforeach;
							?>
							
							<p align="right">
								<input type="submit" name="update" class="input_submit" value="<?php echo $lang['sub_update']; ?>"/><br />
							</p>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>

<div class="col_right1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_stylesheet_intro'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $item['item_title'];?></b><br />
				</p>
				
				<hr />
				
				<p>
					<b><?php echo $lang['hdr_editor_tools'];?></b><br />
				</p>
				
				<div id="colourpicker1"></div>
				
				<script type="text/javascript">
					var inputfield = '';
					initColourPicker('colourpicker1',30);
				</script>
			</div>
		</div>
	</div>
</div>
</form>