<!-- page rank sculpting index -->
<?php require '../public/system/headers/headers.php';?>
<?php echo $this->headLink()->appendStylesheet($this->websiteUrl . 'system/css/seotoaster.css'); ?>
<?php echo $this->headLink()->appendStylesheet($this->websiteUrl .'system/js/thickbox/thickbox.css'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/jquery/jquery.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/thickbox/thickbox.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/prsculpting/prsculpting.js'); ?>
<?php echo $this->headScript(); ?>

<div id="seotoaster" class="prsculpting">
    <div id="admineditwhat">{%Manage Link Sculpting%}</div>
    <div class="close_window" onclick="parent.tb_remove();"></div>
    <?php  echo $this->form; ?>
	<div id="how-to-remove" style="background-color:#A5C025;position:absolute;bottom: 10px;left:20px;width: 300px; -moz-border-radius:5px;text-align: center;padding:15px 0px;">
		<a id="lnk-rm-silos" href="javascript:;" onclick="$('#how-to-remove').hide();$('#silos-list').show();$('#lnk-list-hide').show();" style="font-size:16px;font-weight: bold; color: #fff;">{%How to remove a silo?%}</a>
	</div>
	<div id="silos-list" style="display:none;background:#FFFFCC;border: 5px solid #ddd	;-moz-border-radius:4px;width:300px;position:absolute;height: 200px; overflow-y:scroll;padding-left: 5px;left:150px;top:210px;z-index:999;">
		<?php if(!empty($this->silos)): ?>
			<table style="width:265px;">
				<tr>
					<th colspan="2" style="text-align:center;">{%Remove silos%}</th>
				</tr>
				<?php foreach ($this->silos as $silo): ?>
				<tr>
					<td style="border-bottom: 1px dashed #000;">
						<?php echo $silo['name']; ?>
					</td>
					<td><a href="javascript:;" onclick="rmSilo(<?php echo $silo['id']; ?>, '<?php echo htmlspecialchars($silo['name']); ?>')">{%delete%}</a></td>
				</tr>
				<?php endforeach; ?>
			</table>
		<?php else: ?>
			{%No silos yet.%}
		<?php endif; ?>
			<div style="position:absolute;bottom:10px;text-align: center;width:95%"><a href="javascript:;" onclick="$('#silos-list').hide(); $('#how-to-remove').show();">{%Close%}</a></div>
	</div>
	<div style="display: none;" id="silorm-msg" onclick="$(this).hide();"></div>
    <div id="prs-errors" class="errors"  style="display:none;cursor:pointer;" onclick="hideMessages();">
	<ul>
	    <li id="prs-exists" style="display:none;"><strong>Silo with such name already exists.</strong></li>
	    <li id="prs-lenght" style="display:none;"><strong>Silo name must be less then 250 characters.</strong></li>
	    <li id="prs-lenght-short" style="display:none;"><strong>Silo name must be at least 3 characters.</strong></li>
	    <li id="prs-empty" style="display:none;"><strong>Silo name can not be empty.</strong></li>
		<li id="prs-forbid" style="display:none;"><strong>Silo can contain only charachters, digits, spaces '-' and '_'</strong></li>
	</ul>
    </div>

    <div id="prs-success" class="success"  style="display:none;cursor:pointer;" onclick="hideMessages();">
	<ul>
	    <li id="add-success"><strong>New silo added to the silo selectors.</strong></li>
	</ul>
    </div>

    <table border="0" id="prs-headers">
		<thead>
			<th style="width:200px;"><!--<input type="checkbox" name="chlAll" id="chkall">&nbsp;-->{%Name%}</th>
			<th style="width:190px;">{%Weight%}</th>
			<th style="width:80px;">{%Silo%}</th>
		</thead>
    </table>

    <div id="prslist" style="height:400px; overflow-y:aouto; overflow-x:hidden;">
	<form action="<?php echo $this->websiteUrl; ?>sys/backend_prsculpting/saveprsculpting" method="post">
	    <table>
		<?php foreach ($this->pages as $page): ?>
			<?php if($page['categoryId'] == -1 && empty($page['pages'])) : continue; endif; ?>
		    <tr>
			<td colspan="3" style="font-weight: bold; padding-left: 5px; color: #5c5c5c;">
			    <div style=" position:relative;line-height:14px;">
				<?php echo ($page['categoryId'] != -1) ? $page['categoryName'] : '{%Without category%}' ;?><span style="position:absolute; right:30px;">{%Silo this category%}&nbsp;</span><span><input type="checkbox" style="position:absolute; right: 14px;" onclick="siloCotegory(this)" id="<?php echo str_replace(' ', '-', $page['categoryName']); ?>" <?php foreach ($this->silos as $silo): if(($page['categoryName'] == $silo['name']) && $silo['asCat']): echo 'checked="checked"'; endif; endforeach;?> /></span>
			    </div>
			</td>
		    </tr>
		    <tr>
			<?php if($page['categoryId'] != -1): ?>
			    <!--
			    <td>
				<input type="checkbox" name="toPrSculpt[<?php echo $page['id']; ?>][on]" id="toprsculpt-<?php echo $page['id']; ?>"/>
			    </td>
			    -->
			    <td style="width: 240px;">
				    <?php echo $page['navigationName']; ?>
			    </td>
			    <td style="width: 100px;">
				<select name="toPrSculpt[<?php echo $page['id']; ?>][weight]" id="toprsculptweight-<?php echo $page['id']; ?>">
				    <option value="0">0</option>
					<?php for($i=1; $i<=5; $i++): ?>
					    <option value="<?php echo $i; ?>" <?php echo ($page['weight'] == $i) ? 'selected="selected"' : '';?> ><?php echo $i; ?></option>
					<?php endfor; ?>
				</select>
			    </td>
			    <td>
				<select name="toPrSculpt[<?php echo $page['id']; ?>][silo]" class="silo <?php echo str_replace(' ', '-', $page['categoryName']); ?>" id="toprsculptsilo-<?php echo $page['id']; ?>">
				    <option value="-1">none</option>
					<?php foreach ($this->silos as $silo): ?>
					    <option value="<?php echo $silo['id']; ?>" <?php echo ($page['siloId'] == $silo['id']) ? 'selected="selected"' : '';?> ><?php echo $silo['name']; ?></option>
					<?php endforeach; ?>
				</select>
			    </td>
			<?php endif; ?>
		    </tr>
		    <?php if(isset($page['pages'])): ?>
			<?php foreach ($page['pages'] as $subPage): ?>
			    <tr>
				<!--
				<td>
				    <input type="checkbox" name="toPrSculpt[<?php echo $subPage['id']; ?>][on]" id="toprsculpt-<?php echo $subPage['id']; ?>"/>
				</td>
				-->
				<td style="width: 240px;">
					<?php echo $subPage['navigationName']; ?>
				</td>
				<td style="width: 100px;">
				    <select name="toPrSculpt[<?php echo $subPage['id']; ?>][weight]" id="toprsculptweight-<?php echo $subPage['id']; ?>">
					<option value="0">0</option>
					    <?php for($i=1; $i<=5; $i++): ?>
						<option value="<?php echo $i; ?>" <?php echo ($subPage['weight'] == $i) ? 'selected="selected"' : '';?> ><?php echo $i; ?></option>
					    <?php endfor; ?>
				    </select>
				</td>
				<td>
				    <select name="toPrSculpt[<?php echo $subPage['id']; ?>][silo]" class="silo <?php echo str_replace(' ', '-', $page['categoryName']); ?>" id="toprsculptsilo-<?php echo $subPage['id']; ?>">
					<option value="-1">none</option>
					    <?php foreach ($this->silos as $silo): ?>
						<option value="<?php echo $silo['id']; ?>" <?php echo ($subPage['siloId'] == $silo['id']) ? 'selected="selected"' : '';?> ><?php echo $silo['name']; ?></option>
					    <?php endforeach; ?>
				    </select>
				</td>
			    </tr>
			<?php endforeach; ?>
		    <?php endif; ?>
		<?php endforeach; ?>
	    </table>
	    <input type="submit" name="submit" id="done" value="{%DONE%}" class="formsubmit" />
	</form>
    </div>
	<input type="hidden" id="hid-main-wsurl" name="hid-main-wsurl" value="<?php echo $this->websiteUrl; ?>" />
</div>
