<!-- my profile sidebar box -->

<form class="my-profile-sidebar" method="post" action="{$smarty.const.RL_URL_HOME}request.ajax.php?mode=thumbnail&item=1" enctype="multipart/form-data">
	<div class="picture">
		<input id="thumbnail_input" type="file" name="thumbnail" title="{$lang.upload_profile_photo}" />
	</div>

	<div class="info">
		<div class="table-cell small">
			<div class="name">{$lang.username}</div>
			<div class="value">{$profile_info.Username}</div>
		</div>
		<div class="table-cell small">
			<div class="name">{$lang.account_type}</div>
			<div class="value">{$profile_info.Type_name}</div>
		</div>
		{if $profile_info.Type_description}
		<div class="table-cell small" style="margin-top: 5px;">
			<div class="value">{$profile_info.Type_description}</div>
		</div>
		{/if}
	</div>
</form>

{addJS file=$rlTplBase|cat:'js/ajaxfileupload.js'}

<script>
var current_thumbnail = {if $profile_info.Photo}'{$smarty.const.RL_FILES_URL}{$profile_info.Photo}'{else}false{/if};
var original_picture = {if $profile_info.Photo_original}'{$smarty.const.RL_FILES_URL}{$profile_info.Photo_original}'{else}false{/if};
var request_data = '{$smarty.request.info}';
var thumb_width = {if $config.account_thumb_width}{$config.account_thumb_width}{else}110{/if};
var thumb_height = {if $config.account_thumb_height}{$config.account_thumb_height}{else}140{/if};
var request_data = '{$smarty.request.info}';

var ph_empty_error = '{$lang.crop_empty_coords}';
var ph_too_small_error = '{$lang.crop_too_small}';
lang['not_image_file'] = "{$lang.not_image_file}";
lang['uploading_completed'] = "{$lang.uploading_completed}";
lang['delete_confirm'] = '{$lang.delete_confirm}';
</script>

<script class="fl-js-static">
{literal}

var uploadThumbHandler = function(){	
	$.ajaxFileUpload({
		url: $('form.my-profile-sidebar').attr('action'), 
		secureuri: false,
		fileElementId: 'thumbnail_input',
		dataType: 'json',
		success: function(data, status) {
			if (typeof(data.error) != 'undefined') {
				if (data.error) {
					printMessage('error', 'Unable to save the image on the server, please contact support.');
				} else {
					printMessage('notice', lang['uploading_completed']);
				}
			}
		},
		error: function (data, status, e) {
			printMessage('error', 'Unable to save the image on the server, please contact support.');
		}
	});
}

var profileResetInstance = function(){
	$('.image-preview').css('backgroundImage', '').removeClass('loaded');
	$('div.image-preview-wrapper div.icons').hide();
}

$(document).ready(function(){
	$('#thumbnail_input').imgPreview({
		current: current_thumbnail,
		thumbnail_width: thumb_width,
		thumbnail_height: thumb_height
	});
});

{/literal}
</script>

<!-- my profile sidebar box end -->