<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php if (defined(FRONT_PAGE_VIEW) || $FRONT_PAGE_VIEW) { ?>
	<script type="text/javascript" src="/media/system/js/mootools.js"></script>
    <style type="text/css">
		.clr { clear: both; overflow:hidden; height: 0; }
		
		.adminlist tbody td
		{
			border:1px solid #E2E2E2 !important;
		}
		
		table.adminlist {
			width: 100%;
			border-spacing: 1px;
			background-color: #e7e7e7;
			color: #666;
		}
		
		table.adminlist td,
		table.adminlist th { padding: 4px; }
		
		table.adminlist thead th {
			text-align: center;
			background: #f0f0f0;
			color: #666;
			border-bottom: 1px solid #999;
			border-left: 1px solid #fff;
		}
		
		table.adminlist thead a:hover { text-decoration: none; }
		
		table.adminlist thead th img { vertical-align: middle; }
		
		table.adminlist tbody th { font-weight: bold; }
		
		table.adminlist tbody tr			{ background-color: #fff;  text-align: left; }
		table.adminlist tbody tr.row1 	{ background: #f9f9f9; border-top: 1px solid #fff; }
		
		table.adminlist tbody tr.row0:hover td,
		table.adminlist tbody tr.row1:hover td  { background-color: #ffd ; }
		
		table.adminlist tbody tr td 	   { height: 25px; background: #fff; border: 1px solid #fff; }
		table.adminlist tbody tr.row1 td { background: #f9f9f9; border-top: 1px solid #FFF; }
		
		table.adminlist tfoot tr { text-align: center;  color: #333; }
		table.adminlist tfoot td,
		table.adminlist tfoot th { background-color: #f3f3f3; border-top: 1px solid #999; text-align: center; }
		
		table.adminlist td.order 		{ text-align: center; white-space: nowrap; }
		table.adminlist td.order span { float: left; display: block; width: 20px; text-align: center; }
		
		table.adminlist .pagination { display:table; padding:0;  margin:0 auto;	 }

		
		
		table.adminform {
			background-color: #f9f9f9;
			border: solid 1px #d5d5d5;
			width: 100%;
			border-collapse: collapse;
			margin: 8px 0 10px 0;
			margin-bottom: 15px;
			width: 100%;
		}
		table.adminform.nospace { margin-bottom: 0; }
		table.adminform tr.row0 { background-color: #f9f9f9; }
		table.adminform tr.row1 { background-color: #eeeeee; }
		
		table.adminform th {
			font-size: 11px;
			padding: 6px 2px 4px 4px;
			text-align: left;
			height: 25px;
			color: #000;
			background-repeat: repeat;
		}
		table.adminform td { padding: 3px; text-align: left; }
		
		table.adminform td.filter{
			text-align: left;
		}
		
		table.adminform td.helpMenu{
			text-align: right;
		}
		
		
		fieldset.adminform { border: 1px solid #ccc; margin: 0 10px 10px 10px; }
		
		/** Table styles **/
		
		table.adminlist {
			width: 100%;
			border-spacing: 1px;
			background-color: #e7e7e7;
			color: #666;
		}
		
		table.adminlist td,
		table.adminlist th { padding: 4px; }
		
		table.adminlist thead th {
			text-align: center;
			background: #f0f0f0;
			color: #666;
			border-bottom: 1px solid #999;
			border-left: 1px solid #fff;
		}
		
		table.adminlist thead a:hover { text-decoration: none; }
		
		table.adminlist thead th img { vertical-align: middle; }
		
		table.adminlist tbody th { font-weight: bold; }
		
		table.adminlist tbody tr			{ background-color: #fff;  text-align: left; }
		table.adminlist tbody tr.row1 	{ background: #f9f9f9; border-top: 1px solid #fff; }
		
		table.adminlist tbody tr.row0:hover td,
		table.adminlist tbody tr.row1:hover td  { background-color: #ffd ; }
		
		table.adminlist tbody tr td 	   { height: 25px; background: #fff; border: 1px solid #fff; }
		table.adminlist tbody tr.row1 td { background: #f9f9f9; border-top: 1px solid #FFF; }
		
		table.adminlist tfoot tr { text-align: center;  color: #333; }
		table.adminlist tfoot td,
		table.adminlist tfoot th { background-color: #f3f3f3; border-top: 1px solid #999; text-align: center; }
		
		table.adminlist td.order 		{ text-align: center; white-space: nowrap; }
		table.adminlist td.order span { float: left; display: block; width: 20px; text-align: center; }
		
		
		
		
		

		
		input.system-openid, input.com-system-openid {
		   background: url(http://openid.net/login-bg.gif) no-repeat;
		   background-color: #fff;
		   background-position: 0 50%;
		   color: #000;
		   padding-left: 18px;
		}
		#system-message    { margin-bottom: 10px; padding: 0;}
		#system-message dt { font-weight: bold; }
		#system-message dd { margin: 0; font-weight: bold; text-indent: 30px; }
		#system-message dd ul { color: #0055BB; margin-bottom: 10px; list-style: none; padding: 10px; border-top: 3px solid #84A7DB; border-bottom: 3px solid #84A7DB;}
		#system-message dt.message { display: none; }
		#system-message dd.message {  }
		#system-message dt.error { display: none; }
		#system-message dd.error ul { color: #c00; background-color: #E6C0C0; border-top: 3px solid #DE7A7B; border-bottom: 3px solid #DE7A7B;}
		#system-message dt.notice { display: none; }
		#system-message dd.notice ul { color: #c00; background: #EFE7B8; border-top: 3px solid #F0DC7E; border-bottom: 3px solid #F0DC7E;}
		#system-message li
		{
			margin-left:-20px;
			list-style-image:none;
		}
		#system-message dd.message ul { background: #C3D2E5 url(../images/notice-info.png) 4px center no-repeat;}
		#system-message dd.error ul { color: #c00; background: #E6C0C0 url(../images/notice-alert.png) 4px top no-repeat; border-top: 3px solid #DE7A7B; border-bottom: 3px solid #DE7A7B;}
		#system-message dd.notice ul { color: #c00; background: #EFE7B8 url(../images/notice-note.png) 4px top no-repeat; border-top: 3px solid #F0DC7E; border-bottom: 3px solid #F0DC7E;}
		
	</style>
<?php } else { ?>
	<?php JToolBarHelper::title(JText::_('COMPONENT_TO_SEND_IMAGES'), 'generic.png'); ?>
	<?php JToolBarHelper::preferences('com_simpleimage'); ?>
    
	<style type="text/css">
        #submenu-box
        {
            display:none;
        }
    </style>

<?php } ?>

<script type="text/javascript">
	
	var num = 0;
	window.addEvent('load', function() {
			
		<?php if ($this->msg) { ?>
			$$('.fade').setStyle('display','block'); 
		<?php } ?>						 
									 
		$$('.adicionar_nova').addEvent('click', function(){
			novaLinha(num);
		});	
		novaLinha(num++);
		novaLinha(num++);
		novaLinha(num++);
		novaLinha(num++);
		novaLinha(num++);
		
		
		$('tipoEnvio').addEvent('change', function(e){
			var el = $('tipoEnvio').value;
			
			$$('.galeria').setStyle('display','none');  
			$$('.categoria').setStyle('display','none');  
			$$('.banner').setStyle('display','none');  
			
			$$('.'+el).setStyle('display','');  

		});
		
	});

	function removerLinha(num)
	{
		$('linha'+num).remove();
	}

	function novaLinha(num)
	{
		var row = 0;
		if (num % 2 == 0)
			row = '1';

		var tr    = new Element('tr', {
			'class':'row'+row,
			'id':'linha'+num
		});

		var td1    = new Element('td');		
		var input1 = new Element('input', {
			'type':'file',
			'name':'imagem[]',
			'id':'img'+num
		});
	
		var td2    = new Element('td');		
		var input2 = new Element('textarea', {
			'rows':'1',
			'cols':'30',
			'name':'descricao[]',
			'id':'descricao'+num
		});
		
		var td3    = new Element('td');		
		td3.innerHTML = '<?php echo $this->selectGrande; ?>';

		var td4    = new Element('td');		
		td4.innerHTML = '<?php echo $this->selectPequeno; ?>';

		var td5    = new Element('td', {'align':'center'});		
		var input5 = new Element('a', {
			'href':'javascript:void(0)',
			'class':'adicionar_nova'
		});
		input5.innerHTML = "<?php echo JText::_('Criar nova linha'); ?>";
		input5.addEvent('click', function(){novaLinha(num++);});

		var br = new Element('br');

		var input6 = new Element('a', {
			'href':'javascript:void(0)',
			'class':'remover_nova',
			'id':num
		});
		input6.innerHTML = "<?php echo JText::_('Remover linha'); ?>";
		input6.addEvent('click', function(){removerLinha(this.id);});


		input1.injectInside(td1);
		input2.injectInside(td2);
		input5.injectInside(td5);
		br.injectInside(td5);
		input6.injectInside(td5);
		td1.injectInside(tr);
		td2.injectInside(tr);
		td3.injectInside(tr);
		td4.injectInside(tr);
		td5.injectInside(tr);




		tr.injectInside($('tabela1'));
		
		
	}

</script>

<?php if (defined(FRONT_PAGE_VIEW) || $FRONT_PAGE_VIEW) { ?>
    <div class="componentheading"><?php echo JText::_('COMPONENT_TO_SEND_IMAGES'); ?></div>
    <br />
<?php } ?>


<?php if ($this->msg) { ?>
    <dl id="system-message">
    <dt class="message">Mensagem</dt>
    <dd class="message message fade">
        <ul>
            <li><?php echo $this->msg; ?></li>
            <?php if ($this->galeria) { ?>
	            <li><?php echo JText::_( 'CODE_TO_GALLERY'); ?></li>
                <li><textarea style="width:100%;" rows="1">{gallery}<?php echo $this->galeria; ?>{gallery}</textarea></li>
            <?php } ?>
        </ul>
    </dd>
    </dl>
<?php } ?>


<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data" >



<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th>
                <?php echo JText::_( 'IMAGE').JText::_( 'IMAGE_TYPES'); ?>
            </th>
            <th>
              <?php echo JText::_( 'DESCRIPTION');?>
            </th>
            <th>
              <?php echo JText::_( 'BIG_IMAGE_WIDTH');?>
            </th>
            <th>
              <?php echo JText::_( 'LITTLE_IMAGE_WIDTH');?>
            </th>
            <th>
              <?php echo JText::_( 'ACTION');?>
            </th>
        </tr>            
    </thead>
    <tbody align="left"  id="tabela1">
        
    </table>
</div>
<br />
<table class="adminlist">
	<tr>
    	<td>
        	<?php echo JText::_( 'WHERE_TO_USE_THE_IMAGES'); ?>
        </td>
        <td>
        	<select name="tipoEnvio" id="tipoEnvio">
            	<option selected="selected" value="categoria"><?php echo JText::_( 'IMAGES_FOR_ARTICLE'); ?></option>
            	<option value="galeria"><?php echo JText::_( 'IMAGES_FOR_GALLERY'); ?></option>
            	<option value="banner"><?php echo JText::_( 'IMAGES_FOR_BANNER'); ?></option>
            </select>
        </td>
	</tr>
    
    <tr class="categoria">
    	<td>
        	<?php echo JText::_( 'IMAGE_CATEGORIES'); ?>
        </td>
        <td>
	        <?php echo $this->categorias; ?>

        </td>
	</tr>
    
        <tr class="galeria" style="display:none">
            <td>
                <?php echo JText::_( 'GALLERY_NAME'); ?>
            </td>
            <td>
            	<input type="text" name="nomeNovaGaleria" size="80" />
            </td>
        </tr>
        <tr class="galeria" style="display:none">
            <td>
                <?php echo JText::_( 'ADD_IMAGES_TO_A_GALLERY_THAT_EXISTS'); ?>
            </td>
            <td>
				<?php echo $this->galeriasExistentes; ?>
            </td>
        </tr>

</table>

<div  class="banner" style="display:none">
</div>

<input type="hidden" name="option" value="com_simpleimage" />
<input type="hidden" name="task" value="upload" />
<input type="hidden" name="controller" value="com_simpleimage" />

<br />
<div align="center">
	<input type="submit" name="submit" value="<?php echo JText::_( 'DO_UPLOAD'); ?>" />
</div>
 
</form>
<br />
<br />
<br />
<br />

