<script type="text/javascript">

	function checkForRelated(el)
	{
		jQuery.ajax( {
			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_statistics&noheader=1&do=related&selection='+jQuery(el).val(),
			dataType: 'json',
			success: function(data) {

				jQuery('#filter-related-wrapper').empty();
				
				if (!jQuery.isEmptyObject(data))
				{
					jQuery('#filter-related-wrapper').html('<label style="width:8em; margin-left:10px; height:2em; line-height:2em; padding:2px; display:block; float:left;" for="filter-related"><?php echo __('im Vergleich zu', 'wpsg'); ?></label><select name="filter[related]" id="filter-related" size="1"><option value=""><?php echo __('-- Bitte wählen ---', 'wpsg'); ?></option></select>');
					jQuery.each(data, function(i, item) {
						jQuery('#filter-related').append('<option value="' + item.value + '">' + item.name + '</option>');
					});
				}

				<?php 
					if ($this->view['filter']['related'] > 0)
					{
				?>
				jQuery("#filter-related").val("<?php echo $this->view['filter']['related']; ?>");
				<?php 	
					}
				?>
			}
		} );
	}

</script>

<?php foreach ($this->view['charts'][$_REQUEST['id']]['type'] as $type => $data) { ?>
<a class="<?php echo (($_REQUEST['type'] == $type)?'current':''); ?>" href="admin.php?page=wpsg-Statistics&amp;id=<?php echo $_REQUEST['id']; ?>&amp;type=<?php echo $type; ?>"><?php echo wpsg_hspc($data['name']); ?></a>
<?php } ?>

<br />

<form name="wpsg_statistics_form" id="wpsg_statistics_form" method="post" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Statistics">
	
	<label style="width:5em; height:2em; line-height:2em; padding:2px; display:block; float:left;" for="filter-standard"><?php echo __('Auswahl', 'wpsg'); ?></label>
	
	<div style="float:left;" id="filter-standard-wrapper">	
		<select name="filter[standard]" id="filter-standard" size="1" onchange="<?php if ($_REQUEST['id'] == 0 || $_REQUEST['id'] == 1) { ?>checkForRelated(this);<?php } ?>">
		<?php foreach ($this->view['standardFilter'] as $index => $filter) { ?>
			<option value="<?php echo wpsg_hspc($index)?>" <?php if ($index == $this->view['filter']['standard']) { ?>selected="selected"<?php } ?>><?php echo wpsg_hspc($filter['name']); ?></option>
		<?php } ?>
		</select>
	</div>
	
	<div style="float:left;" id="filter-related-wrapper">
	
	</div>
	
	<input style="float:left; margin-left:25px;" type="submit" class="button-secondary" value="<?php echo __('Anzeigen', 'wpsg'); ?>" />
	
	<div class="wpsg_clear"></div><br/>
	
	<div class="customfilter" style="display:none;">
		<?php echo wpsg_drawForm_Date('filter[day][0]',  __('von', 'wpsg'), $this->view['filter']['day'][0]['d'].'.'.$this->view['filter']['day'][0]['m'].'.'.$this->view['filter']['day'][0]['Y'], array('time' => false)); ?>
		<?php echo wpsg_drawForm_Date('filter[day][1]',  __('bis', 'wpsg'), $this->view['filter']['day'][1]['d'].'.'.$this->view['filter']['day'][1]['m'].'.'.$this->view['filter']['day'][1]['Y'], array('time' => false)); ?>
	</div>
	
	<input type="hidden" id="wpsg_statistics_order" name="filter[order]" value="<?php echo wpsg_hspc($this->view['filter']['order']); ?>" />
	<input type="hidden" id="wpsg_statistics_sort" name="filter[sort]" value="<?php echo wpsg_hspc($this->view['filter']['sort']); ?>" />
	
	<input type="hidden" id="wpsg_statistics_type" name="type" value="<?php echo wpsg_hspc($_REQUEST['type']); ?>" />
	
	<input type="hidden" name="id" value="<?php echo wpsg_hspc($_REQUEST['id']); ?>" />   
	
</form>

<script type="text/javascript">

	jQuery(document).ready(function(){

	
		jQuery('#filter-standard').bind('change', function(){

			if (parseInt(jQuery(this).val()) == 11)
			{
				jQuery('.customfilter').css('display', 'block');	
				jQuery('.customfilter .customfilter-input').each(function(index, value) { 
					jQuery(this).removeAttr('disabled');
				});		
			}
			else
			{
				jQuery('.customfilter').css('display', 'none');	
				jQuery('.customfilter .customfilter-input').each(function(index, value) { 
					jQuery(this).attr('disabled', 'disabled');
				});	
			}		
			
		});

		jQuery('#filter-standard').trigger('change');
		
	});

</script>

<br /><br />