<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background: url('view/image/setting.png') 2px 9px no-repeat;"><span style="margin-left:30px;"><?php echo $heading_title; ?></span></h1>
    <div class="buttons">
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a>
      <a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a>
      </div>
  </div>
  <div class="content">  
  
    <div id="tabs" class="htabs">   
    <a href="#tab_affiliate"><?php echo $tab_commission; ?></a>    
    
    </div>
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <div id="tab_affiliate">
        <table class="form">
		   <tr>
            <td><?php echo $entry_affiliatepoints; ?></td>
            <td colspan=3>
			 <?php if ($config_affiliatepoints) { ?>
              <input type="radio" name="config_affiliatepoints" value="1" checked="checked" />
              <?php echo $text_yes; ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="config_affiliatepoints" value="0" />
              <?php echo $text_no; ?>
              <?php } else { ?> 
              <input type="radio" name="config_affiliatepoints" value="1" />
              <?php echo $text_yes; ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="config_affiliatepoints" value="0" checked="checked" />
              <?php echo $text_no; ?>
              <?php } ?> 
			  </td>
          </tr>
		   <tr>
            <td><?php echo $entry_affiliate_override; ?></td>
            <td colspan=3>
			 <?php if ($config_affiliate_override) { ?>
              <input type="radio" name="config_affiliate_override" value="1" checked="checked" />
              <?php echo $text_yes; ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="config_affiliate_override" value="0" />
              <?php echo $text_no; ?>
              <?php } else { ?> 
              <input type="radio" name="config_affiliate_override" value="1" />
              <?php echo $text_yes; ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="config_affiliate_override" value="0" checked="checked" />
              <?php echo $text_no; ?>
              <?php } ?> 
			  </td>
          </tr>
		  <tr>
            <td><?php echo $entry_default_group; ?></td>
            <td colspan=3>
				<select name="config_affiliate_group">
                    <?php foreach ($affiliate_groups as $affiliate_group) { ?>
                    <?php if ($affiliate_group['affiliate_group_id'] == $config_affiliate_group) { ?>
                    <option value="<?php echo $affiliate_group['affiliate_group_id']; ?>"  selected="selected"><?php echo $affiliate_group['name']; ?></option>
                    <?php } else { ?>
                    <option value="<?php echo $affiliate_group['affiliate_group_id']; ?>"><?php echo $affiliate_group['name']; ?></option>
                    <?php } ?>
                    <?php } ?>
                  </select>
			</td>
          </tr>
		  <tr>
            <td><?php echo $entry_ipaddress; ?></td>
                <td colspan=3><select name="config_affiliate_ipaddress">
                    <?php if ($config_affiliate_ipaddress) { ?>
                    <option value="1" selected="selected" ><?php echo $text_enabled; ?></option>
                    <option value="0"  ><?php echo $text_disabled; ?></option>
                    <?php } else { ?>
                    <option value="1"  ><?php echo $text_enabled; ?></option>
                    <option value="0" selected="selected"  ><?php echo $text_disabled; ?></option>
                    <?php } ?>
                  </select></td>
		  </tr>
		  <tr>
            <td><?php echo $entry_autocredit; ?></td>
                <td colspan=3><select name="config_affiliate_autocredit">
                    <?php if ($config_affiliate_autocredit) { ?>
                    <option value="1" selected="selected" ><?php echo $text_enabled; ?></option>
                    <option value="0"  ><?php echo $text_disabled; ?></option>
                    <?php } else { ?>
                    <option value="1"  ><?php echo $text_enabled; ?></option>
                    <option value="0" selected="selected"  ><?php echo $text_disabled; ?></option>
                    <?php } ?>
                  </select></td>
		  </tr>		  
		  <tr>
            <td ><?php echo $entry_refcustomer; ?></td>
                <td colspan=3><select name="config_refcustomer">
                    <?php if ($config_refcustomer) { ?>
                    <option value="1" selected="selected" ><?php echo $text_enabled; ?></option>
                    <option value="0"  ><?php echo $text_disabled; ?></option>
                    <?php } else { ?>
                    <option value="1"  ><?php echo $text_enabled; ?></option>
                    <option value="0" selected="selected"  ><?php echo $text_disabled; ?></option>
                    <?php } ?>
                  </select>
				</td>
		  </tr>
		  <tr>
				<td><?php echo $entry_payperaffiliate; ?></td>
				<td width="18%"><input type="text" name="config_payperaffiliate" value="<?php echo $config_payperaffiliate; ?>" /></td>     
				<td width="30%">Description<br><input type="text" name="config_payperaffiliate_descr" value="<?php echo $config_payperaffiliate_descr; ?>" size="30" /></td>	 
				<td><input type="checkbox" name="config_payperaffiliate_enable" <?php if($config_payperaffiliate_enable){ ?>  checked="checked" <?php } ?> size="3" /><?php echo $checkbox; ?></td>
          </tr> 
        </table>      
      </div>      
    </form>
  </div>
</div>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>');
<?php } ?>	
//--></script>
<script type="text/javascript"><!--
$('#template').load('index.php?route=setting/setting/template&template=' + encodeURIComponent($('select[name=\'config_template\']').attr('value')));


//--></script>
<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;

function addImage() {
    html  = '<tbody id="image-row' + image_row + '">';
	html += '<tr>';
    html += '<td class="left">';
	<?php foreach ($languages as $language) { ?>
	html += '<input type="text" name="banner_image[' + image_row + '][banner_image_description][<?php echo $language['language_id']; ?>][title]" value="" /> <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /><br />';
    <?php } ?>
	html += '</td>';	
	html += '<td class="left"><input type="text" name="banner_image[' + image_row + '][link]" value="" /></td>';	
	html += '<td class="left"><div class="image"><img src="<?php echo $no_image; ?>" alt="" id="thumb' + image_row + '" /><input type="hidden" name="banner_image[' + image_row + '][image]" value="" id="image' + image_row + '" /><br /><a onclick="image_upload(\'image' + image_row + '\', \'thumb' + image_row + '\');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$(\'#thumb' + image_row + '\').attr(\'src\', \'<?php echo $no_image; ?>\'); $(\'#image' + image_row + '\').attr(\'value\', \'\');"><?php echo $text_clear; ?></a></div></td>';
	html += '<td class="left"><a onclick="$(\'#image-row' + image_row  + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
	html += '</tr>';
	html += '</tbody>'; 
	
	$('#images tfoot').before(html);
	
	image_row++;
}
//--></script>
<script type="text/javascript"><!--
function image_upload(field, thumb) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value')),
					dataType: 'text',
					success: function(data) {
						$('#' + thumb).replaceWith('<img src="' + data + '" alt="" id="' + thumb + '" />');
					}
				});
			}
		},	
		bgiframe: false,
		width: 700,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script> 
<div style="margin-top:0px;">
<?php echo $footer; ?>
</div>