{strip}
<h2>{$data_9.header}</h2>
{if $limit_err == ''}
	{if $form_err != ''}
		<p class="error_msg">*&nbsp;{$form_err}</p>
	{/if}
	<form id="item_form" onsubmit="return checkBadWords();" action="{$site_root}/{$seo.myprofile}" method="post" enctype="multipart/form-data" name="item_form">
		<input type="hidden" name="sel" value="save_9">
		{if $data_9.par eq 'edit'}<input type="hidden" name="id_file" value="{$data_9.photo.id}">{/if}
		<input type="hidden" name="id_album" value="{$data_9.id_album}">
		<input type="hidden" name="upload_type" value="{$album_type}">
		
		<input type="hidden" id="type_use" name="type_use" value="upload">
		{if $data_9.par ne 'edit'}
			{if $album_type eq 'v'}
				<p>
					<input id="radio_upload" onclick="setVideoType('upload')" type="radio" name="video_type" value="upload" checked="checked" />
					<label for="radio_upload">{$lang.profile.video_upload}</label>&nbsp;&nbsp;
					<input id="radio_link" onclick="setVideoType('link')" type="radio" name="video_type" value="link">
					<label for="radio_link">{$lang.profile.video_embed}</label>
				</p>
			{/if}
			<input id="upload" class="video_upload" type="file" name="upload">
			<p class="h22">
				<span class="video_link error hidden"></span>
				{if $album_type eq 'v'}
					<input id="link" class="video_link hidden" type="text" name="link">
					<div class="upload_help video_upload">
						{$lang.profile.help_tip.video_max_size}
						<span class="bold">{$data_9.video_max_size}</span><br />
						{$lang.profile.help_tip.video_allowed_formats}
						<span class="bold">{$data_9.video_allowed_exts}</span>
					</div>
					<div class="upload_help video_link hidden">
						{$lang.profile.help_tip.video_link_help}
					</div>
				{/if}
			</p>
		{/if}
		{if $album_type eq 'v'}
			<p>
				<div>{$lang.profile.title}:</div>
				<div><input type="text" name="upload_title" id="upload_title" size="50" onkeyup="BadWords('upload_title');" style="width: 100%;" value="{$data_9.photo.upload_title}" /></div>
				<div id="bad_div_upload_title" class="bad_div_left"></div>
			</p>
		{/if}
		<p>
		{$lang.users.allow_type}:&nbsp;
		</p>
		<p>
			<select name="upload_allow" id="upload_allow"  {if $data.root eq 1}disabled{/if} onchange="IsGallary(this.value);" >
				<option value="1" {if $data_9.photo.allow eq 1} selected="selected"{/if}>{$lang.users.allow_1}</option>
				<option value="2" {if $data_9.photo.allow eq 2} selected="selected"{/if}>{$lang.users.allow_2}</option>
				<option value="3" {if $data_9.photo.allow eq 3} selected="selected"{/if}>{$lang.users.allow_3}</option>
			</select>
		</p>
		<div style="padding-top: 20px; text-align: {$default_left};">
			{$lang.profile.add_description}:<br/>
			<textarea name="user_comment" id="user_comment" style="width: 100%;" onkeyup="BadWords('user_comment');" rows="2">{$data_9.photo.user_comment}</textarea>
            <div id="bad_div_user_comment" class="bad_div_left"></div>
		</div>
		{if $album_type ne 'a'}
			<div style="padding-top: 20px">
				<input type="checkbox" id="is_gallary" name="is_gallary" value="1" {if $data_9.photo.is_gallary eq 1}checked="checked"{/if} {if $data_9.photo.allow && $data_9.photo.allow != 1}disabled{/if} onclick="ShowHideCatForm();">
				&nbsp;&nbsp;{if $album_type eq 'f'}{$lang.profile.show_in_photo_gallery}{/if}{if $album_type eq 'v'}{$lang.profile.show_in_video_gallery}{/if}
			</div>
			<div style="padding-top: 15px; {if $data_9.photo.is_gallary eq 1} display: block; {else} display: none; {/if}" id="categories_div_photo">
				<select name="categories" id="categories">
					{foreach item=item2 from=$data_9.categories}
					<option value="{$item2.id}" {if $item2.sel eq 1} selected="selected" {/if}>{$item2.name}</option>
					{/foreach}
				</select>
			</div>
		{/if}
		{if $data_9.par eq 'edit'}
			<div style="padding-top: 10px">
				{$lang.gallary.album}&nbsp;:<br>
				<select name="id_album">
					<option value="0" {if $data_9.id_album eq 0}selected="selected"{/if}>{$lang.profile.not_indicated}</option>
					{foreach item=item from=$data_9.albums}
					<option value="{$item.id}" {if $item.sel eq 1}selected="selected"{/if}>{$item.name}</option>
					{/foreach}
				</select>
			</div>
		{/if}
		<div style="padding-top: 10px">
			{if $use_uploadify && $uploadify_opts}
				<input type="button" class="button" value="{$lang.button.start_upload}" onclick="mupload.startUpload();">&nbsp;
			{else}
				<input type="submit" class="button" value="{$lang.button.save}">&nbsp;
			{/if}
			{if $data_9.par eq 'edit' && $album_type eq 'f'}
			<input type="button" class="button" onclick="launchWindow('{$data_9.photo.crop_link}','', {if $data_9.photo.imagesize[0]<300}600{else}{$data_9.photo.imagesize[0]}+300{/if}, 600, true);" value="{$lang.profile.recrop}">
			{/if}
		</div>
	</form>
{else}
	<p class="error_msg">*&nbsp;{$limit_err}</p>
{/if}
{/strip}
<script type="text/javascript">
	use_uploadify = {if $use_uploadify}1{else}0{/if};
	album_type = '{$album_type}';
	form_sub_page = {if $data_9.form_sub_page}{$data_9.form_sub_page}{else}8{/if};
{literal}
	try{
		uploadify_opts = use_uploadify ? eval({/literal}{$uploadify_opts}{literal}) : false;
	}catch(e){
		//alert(e.name+': '+e.message);
		uploadify_opts = {};
	}

	$(function(){
		isError = true;
		videoType = 'upload';
		$('#link').bind('keyup', function() {
			var regexp = /((<iframe)|(<object)){1}(.)*(src="http|s:\/\/[.]*){1}(.)*((<\/iframe>)|(<\/object>)){1}/gi;
			if (false == regexp.test($(this).val())) {
				isError = true;
			} else {
				isError = false;
			}
		});
		$('#item_form').bind('submit', function() {
			if ('link' == videoType && true == isError) {
				alert('Wrong link');
				return false;
			}
		});
		
		if(album_type == 'f' && use_uploadify && uploadify_opts){
			mupload = new MultiUpload({
				input_id: 'upload',
				form_id: 'item_form',
				err_text: '{/literal}{$lang.err.upload_err}{literal}',
				session_name: (typeof uploadify_opts.session_name !== 'undefined') ? uploadify_opts.session_name : '',
				session_id: (typeof uploadify_opts.session_id !== 'undefined') ? uploadify_opts.session_id : '',
				uploadify_obj: {
					uploader: '{/literal}{$site_root}/{$seo.myprofile}{literal}',
					fileTypeExts: (typeof uploadify_opts.file_types !== 'undefined') ? uploadify_opts.file_types : '*.*',
					fileSizeLimit: (typeof uploadify_opts.max_size !== 'undefined') ? uploadify_opts.max_size : 0,
					buttonText: '{/literal}{$lang.button.select_photos}{literal}',
					onQueueComplete: function(){
						ShowTab(form_sub_page,'{/literal}{$site_root}/{$seo.myprofile}{literal}?sel=4&id_album='+uploadify_opts.id_album, 4);
					}
				}
			});
		}
	})

	function setVideoType(type) {
		var speed=70;
		videoType = type;
		if ('upload' == type) {
			$('.video_link').fadeOut(speed, function(){$('.video_upload').fadeIn(speed)});
			$('#type_use').attr('value','upload');
		} else if ('link' == type) {
			$('.video_upload').fadeOut(speed, function(){$('.video_link').fadeIn(speed)});
			$('#type_use').attr('value','link');
		}
	}
	function ShowHideCatForm() {
		if ($('#is_gallary').is(':checked')) {
			$('#categories_div_photo').css('display','block');
		} else {
			$('#categories_div_photo').css('display','none');
		}
	}
	function IsGallary(par) {
		if (par == 1) {
			$('#is_gallary').removeAttr('disabled');
		} else {
			$('#is_gallary').attr('disabled','disabled');
			$('#is_gallary').removeAttr('checked');
			$('#categories_div_photo').css('display','none');
		}
	}
	
	function checkBadWords(){
		var result = true;
		if(($('#user_comment').size() && BadWords('user_comment')) || ($('#upload_title').size() && BadWords('upload_title'))){
			result = false;
		}
		return result;
	}
</script>
{/literal}