{if $ajax eq 0}
{include file="$admingentemplates/admin_top.tpl"}
{/if}
<link rel="stylesheet" media="screen" type="text/css" href="{$site_root}{$template_root}/css/colorpicker.css" />
{if $ajax eq 1}
{literal}
	<script type="text/javascript">
		$(document).ready(function(){
			$(".tabs li").append('<div class="tobconvleft"/>');
			$(".tabs li").append('<div class="tobconvright"/>');
			
			$(".show_help").wrap('<div style="display:table;"/>');
			
		});
	</script>
{/literal}
{/if}
<script type="text/javascript" src="{$site_root}{$template_root}/js/mobile/colorpicker.js"></script>
{if $ajax eq 0}
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_modules.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$header.razdel_name}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
{if $help.mobile_design_management != ''}
    <div class="help_text" style="display:block;">
        <div class="close_help">
            <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
        </div>
        <div class="help_body">
            <span class="help_title">{$lang.help}:</span>{$help.mobile_design_management}
        </div>
    </div>
{/if}
{/if}
<div id="table_content">
<ul class="tabs">
    <li>
        <a {if $section ne 'logo' && $section ne 'cities'}class="current"{/if} onclick="Cities('nelogo');">{$lang.mobile.colors_management}</a>
    </li>
    <li>
        <a {if $section eq 'logo'}class="current"{/if} onclick="Cities('logo');">{$lang.mobile.logo_management}</a>
    </li>
	
    <li>
        <a {if $section eq 'cities'}class="current"{/if} onclick="Cities('cities');">{$header.cities_manegement}</a>
    </li>
</ul>
<div class="panel_section" style="width:100%;">
<div class="panel_content" style="width: 100%;">
<div class="mobile_management" id="mobile_management" style="display:{if $section ne 'logo' && $section ne 'cities'}table{else}none{/if};">
	<form action="admin_mobile.php" method="POST" name="color_form" enctype="multipart/form-data">
		<input type="hidden" name="sel" value="save_colors">
		<div>
			<b>{$lang.settings.color_theme}:&nbsp;</b>
			<select name="theme_select" onchange="selectTheme(this.value)">
				{foreach from=$themes item=t}
					<option value="{$t}" {if $theme == $t}selected{/if}>{$lang.settings.color_preset_name.$t}</option>
				{/foreach}
			</select>
		</div>
		
		{foreach from=$colors item=item}
			<dl class="design_dl">
				<dd class="fl design_left_dd">{$item.color_name}:&nbsp;</dd>
				<dd class="fl design_right_dd">#<input type="text" name="color[{$item.id_color}]" id="color_{$item.id_color}" value="{$item.color}" style="width: 45px;">&nbsp;&nbsp;</dd>
				<dd class="fl design_left_dd"><div id="color_area_{$item.id_color}" style="background-color: #{$item.color}; width: 18px; height: 18px; border: 1px #000 solid;">&nbsp;</div></dd>
			</dl>
		{/foreach}
		<div>
			<a class="admin_button_major" onclick="javascript: document.color_form.submit();">{$lang.button.save}<span>&nbsp;</span></a>
		</div>
	</form>
</div>
<div class="mobile_management" id="mobile_management" style="display:{if $section eq 'logo'}table{else}none{/if};">
	<form action="admin_mobile.php" method="POST" name="logo_form" enctype="multipart/form-data">
	<input type="hidden" name="sel" value="save_logo">
	<div style="padding-top: 10px;">
		<div style="padding-top: 20px;"><b>{$lang.mobile.logotype}:</b><br />
			<img src="{$site_root}/templates/pilot_3_theme/images/mobile/logo.png?rand={$rand}" border="0" alt="" border="1">
			<br /><i>{$lang.mobile.logotype_hint}</i>
		</div>
	</div>
	<div class="fileinputs">
		<input type="file" name="logo" class="file" onchange="document.getElementById('file_text_logo').innerHTML = this.value.replace(/.*\\(.*)/, '$1');document.getElementById('file_img_logo').innerHTML = ChangeIcon(this.value.replace(/.*\.(.*)/, '$1'));"/>
		<div class="fakefile">
			<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<a href="#" class="admin_button btn_upload">{$lang.button.choose}<span>&nbsp;</span></a>
				</td>
				<td style="padding-left:10px;"><span id='file_img_logo'></span></td>
				<td style="padding-left:4px;"><span id='file_text_logo'></span></td>
			</tr>
			</table>
		</div>
	</div>
	{*<div style="padding-top: 15px;">
		<div style="padding-top: 20px;"><b>{$lang.mobile.logotype_background}:</b><br />
		<img src="{$site_root}/templates/pilot_3_theme/images/mobile/logo_bg.png?rand={$rand}" width="125" height="50" border="0" alt="" border="1">
		<br /><i>{$lang.mobile.logotype_background_hint}</i>
		</div>
	</div>
	<div class="fileinputs">
		<input type="file" name="logo_bg" class="file" onchange="document.getElementById('file_text_logo_bg').innerHTML = this.value.replace(/.*\\(.*)/, '$1');document.getElementById('file_img_logo_bg').innerHTML = ChangeIcon(this.value.replace(/.*\.(.*)/, '$1'));"/>
		<div class="fakefile">
			<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<a href="#" class="admin_button btn_upload">{$lang.button.choose}<span>&nbsp;</span></a>
				</td>
				<td style="padding-left:10px;"><span id='file_img_logo_bg'></span></td>
				<td style="padding-left:4px;"><span id='file_text_logo_bg'></span></td>
			</tr>
			</table>
		</div>
	</div>*}
	<div style="padding-top: 5px;">
		<a class="admin_button_major" onclick="javascript: document.logo_form.submit();">{$lang.button.save}<span>&nbsp;</span></a>
	</div>
	</form>
</div>
	<!-- cities -->
	<div class="mobile_management" id="mobile_management"  style="display:{if $section eq 'cities'}table{else}none{/if};">
		<div style="margin-top: 5px;">Used now in search and registration:</div>
		{if $cities}
		<div style="margin-top: 5px;margin-bottom: 5px;">
			<form action="admin_mobile.php" name="remove_form">
			<input type="hidden" name="sel" value="remove_city">
			<div>
				<div style="float: left; margin-bottom: 5px; height:41px; padding-top:8px;">
					<select name="city">
					{foreach item=item from=$cities}
						<option value="{$item.id}">{$item.name}</option>
					{/foreach}
					</select>
				</div>
				<div style="float: left; margin-left: 5px;">
					<a class="admin_button_major" onclick="javascript: document.remove_form.submit();">{$lang.mobile.remove_selected}<span>&nbsp;</span></a>
				</div>
				<div style="clear: both;"></div>
			</div>
			</form>
		</div>
		{else}
		<div style="text-align:center;">
			No cities used in search and registration
		</div>
		{/if}
		{if $countries}
		<form action="admin_mobile.php" method="POST" name=city_form enctype="multipart/form-data">
		<input type="hidden" name="sel" value="save_city">
		<table cellpadding="3" cellspacing="0">
		<tr>
			<td height="35">Select country:&nbsp;</td>
			<td>
			<div id="country_div">
				<select name="country" id="country" style="width: 195px;" onchange="SelectRegion(this.value, document.getElementById('region_div'), document.getElementById('city_div'));">
				<option value="0">------------------</option>
				{section name=s loop=$countries}
					<option value="{$countries[s].id}">{$countries[s].name}</option>
				{/section}
				</select>
			</div>
			</td>
		</tr>
		<tr>
			<td height="35">Select region:&nbsp;</td>
			<td>
			<div id="region_div">
			</div>
			</td>
		</tr>
		<tr>
			<td height="35">Select city:&nbsp;</td>
			<td>
			<div id="city_div">
			</div>
			</td>
		</tr>
		</table>
		<div style="padding-top: 5px;">
			<a class="admin_button_major" onclick="javascript: document.city_form.submit();">{$lang.button.save}<span>&nbsp;</span></a>
		</div>
		</form>
		{else}
		Countries are not installed
		{/if}
	</div>
</div>
</div>
</div>
{literal}
<script type="text/javascript">
$(document).ready(function(){
	{/literal}{foreach from=$colors item=item name=c}{literal}
	$('#color_{/literal}{$item.id_color}{literal}').ColorPicker({
		onSubmit: function(hsb, hex, rgb, el) {
			$(el).val(hex);
			$(el).ColorPickerHide();
			$('#color_area_{/literal}{$item.id_color}{literal}').css({'background-color' : hex});
		},
		onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
		}
	})
	{/literal}{/foreach}{literal}
});

function Cities(sect){
	var param = ''; 
	var tab = '';
	if (sect == 'cities') {
		param = 'cities'; 
		tab = 'cities';
	}
	else {
		param = ''; 
		if (sect == 'logo') tab = 'logo';
		else tab = '';
	}
	ajaxLoadingImage(1, 'table_content');
	$.post("admin_mobile.php", {sel:param, ajax:'1', section:tab}, function(data){
		ajaxLoadingImage(0, 'table_content');
		$('#table_content').html(data);
	});
}

function ChangeIcon(type){
	switch (type.toLowerCase())
	{
		case 'bmp':
		case 'jpg':
		case 'png':
		case 'gif':
		case 'tiff':
		type = type.toLowerCase();
		break;
		case 'jpeg':
		type = 'jpg';
		break;
		case 'tif':
		type = 'tiff';
		break;
		case 'mp3':
		case 'wav':
		case 'ogg':
		type = 'mp3';
		break;
		case 'avi':
		case 'wmv':
		case 'flv':
		type = 'avi';
		break;

		default: type = 'other'; break;
	};
	return "<img src='{/literal}{$site_root}{$template_root}/images/file_types/{literal}" + type +".png'>";
}

	function selectTheme(theme){
		location.href = '?theme='+theme;
	}

</script>
{/literal}
{if $ajax eq 0}
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}