<?php
$show_init_form = false;	/* To display or not the initialization form */

/* Try to see if the call is from administration panel */
if(isset($admin_catdom_module_id) && $admin_catdom_module_id>0 && isset($_GET['action']) && $_GET['action'] == "custom_module") {
	$show_init_form = true;
	// Initialize defaults
	$module_max_per_line = 5;
	$module_show_featured_title = 1;
	$module_show_featured_section = 1;
	$module_show_secondary_section = 1;
	$module_show_adv_title = 1;
	$module_show_adv_delim = 1;
	
	$module_secondary_title = "";
	
	$current_catdom_module_id = $admin_catdom_module_id;
}

if($show_init_form) {
	// Try to get any previously saved customization
	if(isset($module_params) && is_array($module_params)) {
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
	?>
	<div class="inline_container">
	<form method="POST" action="custom_module_update.php" name="adverts_middle_frm" id="adverts_middle_frm">
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<th colspan="2" align="left">
					Adverts "Hotels" Customization
				</th>
			</tr>
			<tr>
				<td nowrap class="itdh">Show Featured Adverts Section</td>
				<td class="itd">
					<input type="radio" name="module_show_featured_section" id="module_show_featured_section_on" value="1" <?php if($module_show_featured_section == 1) echo "checked"; ?> style="vertical-align:middle;"> Yes
					<input type="radio" name="module_show_featured_section" id="module_show_featured_section_off" value="0" <?php if($module_show_featured_section == 0) echo "checked"; ?> style="vertical-align:middle;"> No
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Show Featured Adverts Category Title</td>
				<td class="itd">
					<input type="radio" name="module_show_featured_title" id="module_show_featured_title" value="1" <?php if($module_show_featured_title == 1) echo "checked"; ?> style="vertical-align:middle;"> Yes
					<input type="radio" name="module_show_featured_title" id="module_show_featured_title" value="0" <?php if($module_show_featured_title == 0) echo "checked"; ?> style="vertical-align:middle;"> No
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Show Secondary Adverts Section</td>
				<td class="itd">
					<input type="radio" name="module_show_secondary_section" id="module_show_secondary_section_on" value="1" <?php if($module_show_secondary_section == 1) echo "checked"; ?> style="vertical-align:middle;"> Yes 
					<input type="radio" name="module_show_secondary_section" id="module_show_secondary_section_off" value="0" <?php if($module_show_secondary_section == 0) echo "checked"; ?> style="vertical-align:middle;"> No 
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Show Secondary Adverts Category Title</td>
				<td class="itd">
					<input type="radio" name="module_show_adv_title" id="module_show_adv_title" value="1" <?php if($module_show_adv_title == 1) echo "checked"; ?> style="vertical-align:middle;"> Yes 
					<input type="radio" name="module_show_adv_title" id="module_show_adv_title" value="0" <?php if($module_show_adv_title == 0) echo "checked"; ?> style="vertical-align:middle;"> No 
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Show Secondary Adverts Category Delimiter (Line)</td>
				<td class="itd">
					<input type="radio" name="module_show_adv_delim" id="module_show_adv_delim_on" value="1" <?php if($module_show_adv_delim == 1) echo "checked"; ?> style="vertical-align:middle;"> Yes 
					<input type="radio" name="module_show_adv_delim" id="module_show_adv_delim_off" value="0" <?php if($module_show_adv_delim == 0) echo "checked"; ?> style="vertical-align:middle;"> No 
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Secondary Adverts Category Title</td>
				<td class="itd">
					<input type="text" name="module_secondary_title" value="<?php echo $module_secondary_title;?>" size="30" style="width:100%">
				</td>
			</tr>
			<tr>
				<td nowrap class="itdh">Maximum Adverts per line</td>
				<td class="itd"><input type="text" name="module_max_per_line" id="module_max_per_line" value="<?php echo $module_max_per_line; ?>" size="2" class="input"></td>
			</tr>
			
			<tr>
				<td nowrap class="itdh">Use defaults?</td>
				<td class="itd">
					<input type="radio" name="use_defaults" value="1" style="vertical-align:middle;"/> Yes 
					<input type="radio" name="use_defaults" value="0" checked style="vertical-align:middle;"/> No
				</td>
			</tr>
			<tr>
				<td colspan="2" align="right" class="footer">
					<input type="reset" value="Reset" name="submit" class="submit_button"/>
					<input type="submit" value="Save" name="submit" class="submit_button"/>
					<input type="hidden" value="<?php echo $current_catdom_module_id; ?>" name="admin_catdom_module_id" id="admin_catdom_module_id"/>
				</td>
			</tr>
		</table>
	</form>
	</div>
	<?php
	
	$module_forms = array(
		"form_name" => "adverts_middle_frm",
		"form_action" => "",
		"form_method" => "POST"
	);
}
else {
	// We are in the front-end
	// Initialize defaults
	$module_max_per_line = 5;
	$module_show_featured_title = 1;
	$module_show_featured_section = 1;
	$module_show_secondary_section = 1;
	$module_show_adv_title = 1;
	$module_show_adv_delim = 1;
	$module_secondary_title = '';
	
	// Try to get any customization done
	if(isset($module_params) && is_array($module_params)) {
		
		//echo '<pre>', var_export($module_params, true), '</pre>';
		
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
}
?>
