<h2>{$form.login}</h2>
<div class="float_left">
{if $form.upload_type eq 'f'}
	<div style="width:760px;overflow:auto;text-align:center;" id="slides">
	</div>	
	<a id="photo_pager_l" onclick="left()" class="arr-left1-icon" style="cursor:pointer;">&nbsp;</a>
	<a id="photo_pager_r" onclick="right()" class="arr-right1-icon" style="cursor:pointer;">&nbsp;</a>
{else}
	<div>
        <a href="{$form.file_path}"    class="player"
            style="display:block;width:650px;height:450px;"
            id="player">
        </a>
        <script type="text/javascript" src="{$server}/flowplayer/flowplayer-3.2.8.min.js"></script>
        <script type="text/javascript" src="{$server}/flowplayer/flowplayer.ipad-3.2.8.js"></script>
        <script type="text/javascript" src="http://flowplayer.org/media/js/site.js"></script>
        <script>
        $f("player", "{$server}/flowplayer/flowplayer-3.2.8.swf").ipad();
        </script>
	{*if $form.is_flv eq 1}
		{literal}
			<script type="text/javascript" src="{$site_root}{$template_root}/flash/flowplayer-3.2.4.min.js"></script>
		{/literal}	
		<a href="{$form.file_path}" style="display:block; width:520px;height:330px" id="player"></a>
		{literal}
		<script>
		flowplayer("player", "{$site_root}{$template_root}/flash/flowplayer-3.2.4.swf");
		</script>
		<script type="text/javascript">
		$(document).ready(function(){
			if(typeof($f) != 'undefined'){
				$('#close').click(function() {
					$f().stop();
				});
				$('#mask').click(function() {
					$f().stop();
				});
			}
		});
		</script>
		{/literal}
	{else}
		<OBJECT ID="MediaPlayer1" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Loading MicrosoftR WindowsR Media Player components..."  type="application/x-oleobject" type="application/x-oleobject" height="480" width="640">
		<PARAM NAME="AutoStart" VALUE="True">
		<PARAM NAME="FileName" VALUE="{$form.file_path}">
		<PARAM NAME="ShowControls" VALUE="True">
		<PARAM NAME="ShowStatusBar" VALUE="true">
		<EMBED type="application/x-mplayer2"  pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="{$form.file_path}" name="MediaPlayer1" autostart=1 showcontrols=0 height="480" width="640"></EMBED>
		</OBJECT>
	{/if*}
	</div>
{/if}
{if $user_id ne '2'}
	<!-- vote -->
	{if $form.no_rating ne '1'}
		<div style="overflow:hidden;width:40%;padding:0 32%; display:{if $form.no_rating eq 1} none; {else} table; {/if}" id="vote_marks">	
			{foreach from=$vote_arr item=item}
			<div class="float_left">
				<a onclick="marks({$item},'show'); VoteAction('{$form.id_upload}', '{$item}', '{$form.id_category}', document.getElementById('active_section'),'v'); document.getElementById('vote_marks').style.display = 'none'; return false;" href="#">
				<img id="mark{$item}" name="mark{$item}" src="{$form.vote_icon_0_path}" onmouseover="marks({$item},'show');" onmouseout="marks({$item},'hide');" border="0">
				</a>
			</div>
			{/foreach}
		</div>
		<div id="active_section"></div>
		<p style="text-align:center;">
			<input type="button" onclick="document.location.href='{$site_root}/{$seo.gallery}?sel=category&id_category={$form.id_category}&upload_type={$form.upload_type}';" value="{$lang.button.rate_all}">
			&nbsp;&nbsp;&nbsp;
			<input type="button" onclick="$('#mask').hide(); $('.window').hide();" value="{$lang.button.close}">
		</p>
	{/if}
	<!-- vote -->
		
	<div style="overflow:hidden;">
		<div class="float_left" style="width:470px;margin-bottom:10px;">			
			<!-- comment -->			
			<p>{$lang.giftshop.comment}:</p>
			<div class="comments_links_gallary"></div>
			<div align="{$default_left}" id="comments"></div>		
			<!-- comment -->			
			<div class="search_form_hide_show" style="padding:10px; width:375px; margin-top:10px;">
				<div style="width:100%; text-align:{$default_left}">
					<input type="hidden" name="sel" id="sel" value="set_comment" />
					<input type="hidden" name="id_user" id="id_user" value="{$form.id_user}" />
					<input type="hidden" name="id_upload" id="id_upload" value="{$id_image}" />
					<input type="hidden" name="id_album" id="id_album" value="{$id}" />
					<input type="hidden" name="upload_type" id="upload_type" value="{$form.upload_type}" />
					<div style="margin: 10px 2px; text-align: {$default_right}; display: table; width: 100%;" />
					<textarea onkeyup="BadWords('message_popup'); textchange2();"name="message_popup" id="message_popup" cols="45" rows="2"></textarea>
					<div id="bad_div_message_popup" class="bad_div"></div>
					<div class="float_right" style="margin-top:4px;margin-{$default_right}:7px;" id="count_sym2">256</div>
					<script>
					{literal}
						function textchange2() {
							var count = 256;
							a = $('#message_popup').val().length;
							if (a > count) {
								$('#message_popup').val($('#message_popup').val().substring(0, count));
							}
							a = $('#message_popup').val().length;
							$('#count_sym2').text(count - a);
							if (a > count){
								$('#message_popup').css("disabled", "disabled");
							}
						}
					{/literal}
					</script>
					<div style="height: 16px; width: 10px;" class="float_left icon_smail_for_comment" onclick="return displaySmileLayer('smiles_comment');"></div>						
					<div id="smiles_comment" class="smiles" style="display:none; {$default_left}: 90px; bottom: 10px; width: 255px;">					
						<ul>
						{section name=sm loop=$smiles}
						{if $use_default_smiles eq '1'}
						<li class="float_left">
							<a style="cursor:pointer;" onclick="document.getElementById('message_popup').value=document.getElementById('message_popup').value+'{$smiles[sm].value}'; document.getElementById('smiles_comment').style.display = 'none';">
								<img src="{$smiles_path}/emoticons/{$smiles[sm].file}" class="smile_icon" alt="">
							</a>
						</li>
						{else}
						<li class="float_left">
							<a style="cursor:pointer;" onclick="document.getElementById('message_popup').value=document.getElementById('message_popup').value+'{$smiles[sm].value}'; document.getElementById('smiles_comment').style.display = 'none';">
								<img src="{$site_root}/uploades/smiles/{$smiles[sm].file}" class="smile_icon" alt="">
							</a>
						</li>
						{/if}
						{/section}
						</ul>
					</div>
				</div>
			</div>
			<div style="text-align:{$default_left}; margin-top:5px;" align="{$default_right}">
				<input type="button" name="send_comment" onclick="AddComment();" id="send_comment" value="{$lang.button.add}">		
			</div>			
		</div>		
		<div class="float_right" width="210px;">
			<!-- abuse report -->
			{if $abuse_link}
				<a href="#" id="abuse_link" onClick="onformclick=1;
				{if $form.upload_type=='a' || $form.upload_type=='v'}$('#video_screen_box').css('height',$('#video_screen_box').attr('offsetHeight')); $('#video_screen').toggle(); {/if} abuseReportForm(); return false;">{$lang.abuse.report_link}</a>
				<div id="abuse_form_tpl" style="display:none;width:260px;">
					<div id="abuse_form" style="z-index:100;">
						<div><font class="text_head">{$lang.abuse.form_header_text}</font></div>
						<div align="{$default_left}">
							{foreach name=amt from=$abuse_link.abuse_types_msg item=item}
							<input type="radio" name="ab_type_msg" value="{$item}" {if $smarty.foreach.amt.iteration == 2}checked="checked"{/if} /> {$lang.abuse.msg_types.$item}<br />
							{/foreach}
						</div>
						<div class="sep"></div>
						<div>{$lang.abuse.get_descr}:</div>
						<div>
							<textarea id="ab_msg" style="width:97%" onBlur="if (this.value=='') $('#submit_am').attr('disabled','disabled'); else $('#submit_am').attr('disabled','');"  onkeyup="if (this.value=='') $('#submit_am').attr('disabled','disabled'); else $('#submit_am').attr('disabled','');" rows="3" cols="5"></textarea>
						</div>
						<div align="{$default_right}">
							<input id="submit_am" type="button" value="{$lang.button.send}" disabled="disabled" onClick="sendAbuseReport({$abuse_link.id_user},{$abuse_link.id_item},'{$abuse_link.item_type}');" />
						</div>
					</div>
				</div>
				{literal}
				<script type="text/javascript">
				var onformclick = 0;
				$(document).ready(function(){
					$(document).click(function(){
						$("#abuse_form_parent").click(function(){onformclick=1;});
						if (!onformclick){
							if ($("#abuse_form_parent").html()){
								$("#abuse_form_parent").remove();
								$("#video_screen").show();
							}
						}
						onformclick=0;
					});
				});
				</script>
				{/literal}
			{/if}
			<!-- abuse report -->
		</div>		
	</div>
{/if}

	<!--<div style="width:420px;height:100px;float:left;overflow:hidden;position:relative;" align="center" id="">
	{section loop=$scroll_preview name=item start=$scroll.start max=$scroll.end}
		<div id="{$smarty.section.item.index}" style="float:left;padding:5px;position:relative;">
			<img src="{$scroll_preview[item].img}" border="0" onClick="GetComments({$scroll_preview[item].id}, 1);">
		</div>
	{/section}
	</div>-->
               
	
</div>
{literal}
<script type="text/javascript">
	{/literal}
	var file = '{$form.file_name}';	
	var id = {$id};
	var cur_slide = {$form.num_selected};
	var arr_images=[{foreach item=item name=k from=$item_img}'{$item.image_path}'{if !$smarty.foreach.k.last},{/if}{/foreach}];	
	var arr_id=[{foreach item=item name=k from=$item_img}'{$item.id}'{if !$smarty.foreach.k.last},{/if}{/foreach}];
	var arr_num=[{foreach item=item name=k from=$item_img}'{$item.number}'{if !$smarty.foreach.k.last},{/if}{/foreach}];
	var count = {$form.count};
	{literal}
	
	$(document).ready(function() {				
		ShowContent(cur_slide);		
	});
	
	function ShowContent(cur_slide){
		$('#id_file').val(arr_id[cur_slide]);
		$('#id_upload').val(arr_id[cur_slide]);
		text_slides = "<img src='"+arr_images[cur_slide]+"' >";
		$("#slides").html(text_slides);
		GetComments(arr_id[cur_slide], 1);
	}
		
	function right(){
		$.post(file,{sel:"gallery", id:id, id_image:arr_id[cur_slide+1]},function(data){	
			$('#slides').fadeTo(600,0.2, function() {
				$('#slides').fadeTo(200,1);		
				if (cur_slide == (arr_images.length - 1)) {cur_slide = 0;} 
				else {cur_slide = cur_slide + 1;}
				ShowContent(cur_slide);
			});
		});
	}	
	function left(){
		$.post(file,{sel:"gallery", id:id, id_image:arr_id[cur_slide+1]},function(data){	
			$('#slides').fadeTo(600,0.2, function() {
				$('#slides').fadeTo(200,1);		
				if (cur_slide == 0) cur_slide = arr_images.length - 1;
				else cur_slide = cur_slide - 1;
				ShowContent(cur_slide);
			});
		});
	}	
	function displaySmileLayer(id)	{
		if (document.getElementById(id).style.display == 'none') {
			document.getElementById(id).style.display = 'inline-block';
		} else {
			document.getElementById(id).style.display = 'none';
		}
		return false;
	}
	function AddComment() {
		var height_comment = $('#comments').height();
        $('#comments').css({'height':height_comment});
        var message = $('#message_popup').val();
        var id = $('#id_upload').val();
		var type = $('#upload_type').val();
        if (message != '' && id > 0){        
		ajaxLoadingImage(1, 'comments');
		$.post(SEO_SITE_ROOT+'/'+file, {sel:'set_comment', id:id, message:message, type:type}, function(data){
            if (data == 'send'){
                $('#error_msg').html('');
                $('#comments').html('');
                $('#message_popup').val('');
                count = 256;
                $('#count_sym2').html(count);
				GetComments(arr_id[cur_slide], 1);
            }
			else{
				data = '<p>'+data+'</p>'
				$('#error_msg').html(data);
				GetComments(arr_id[cur_slide], 1);
			}
        });
        }
    }
	
	function GetComments(id, page) {
		$('.comments_links_gallary').html('');
		$('#comments').css({'height':$('#comments').height(), 'width':'470px', 'padding-top':'10px', 'display':'table'});
		$('.hotornot').css('display','none');
		ajaxLoadingImage(1, 'comments');
			
		$.post(SEO_SITE_ROOT+'/'+file, {sel:'get_comments', id:id, page:page}, function(data){
			var resp = getJQData(data);
	  
			if (resp['err'] != undefined) {
				 $('#comments').html('<div id="error_msg" class="error_msg">'+resp['err']+'<\/div><div>&nbsp;</div>');
			} else {
				var right = '{/literal}{$default_right}{literal}';
				$('#comments').html('');
				if (resp['count'])
					$('.comments_links_gallary').css({'height':'20px', 'width':'420px', 'display':'table'});
				for (var i=0;i<resp['count'];i++) {
					$('#comments').append("<div class='comment_upload' style='padding-bottom:5px;display:table;width:100%;'><div class='comment_author'><img style='margin-"+right+":5px;' class='icon imgcanvas float_left' src='"+resp[i]["icon_path"]+"'><div class='float_left' style='width:345px;'><a href='"+resp[i]["profile_link"]+"'>"+resp[i]["name"]+"</a> ("+resp[i]["date_post"]+"): &nbsp;&nbsp;&nbsp; <a style='cursor: pointer;' onclick='DeleteUploadComment(this, "+resp[i]["id_comment"]+");' >"+resp[i]["del_lang"]+"</a> <p class='comment_message'>"+resp[i]["comment"]+"<\/p><\/div><\/div>");				
				}
				for (i=0; i<resp['count']; i++) {
					if ((i+resp['page']) == resp['page']){
						$('.comments_links_gallary').append("<span>"+resp['showing']+" "+resp['page']+" "+resp['of']+" "+resp['count_page']+"</span>");
					
						if (resp['links'][i]['previous_page'] == 1){
							$('.comments_links_gallary').append("<a href='#' onclick='GetComments("+id+", "+(resp['links'][i]['val']-
							i)+")' class='back-page-act' id='back-page-act_top'>&nbsp;</a>");
						}
						if (resp['links'][i]['previous_page'] == 2){
							$('.comments_links_gallary').append("<a href='javascript: void(0);' class='back'>&nbsp;</a>");
						}
						
						if (resp['links'][i]['next_page'] == 1){
							$('.comments_links_gallary').append("<a href='#' onclick='GetComments("+id+", "+resp['links'][i]['val']+")' class='next-page-act' id='next-page-act_top'>&nbsp;</a>");
						}
						if (resp['links'][i]['next_page'] == 2){
							$('.comments_links_gallary').append("<a href='javascript: void(0);' class='next'>&nbsp;</a>");
						}
					}
				}				
			}
			$('#comments').css({'height':'100%'});
		});
        ajaxLoadingImage(0, 'comments');        
	}
	var delete_progress = 0;
	
	function DeleteUploadComment(obj, comment_id){
		var delete_alert = '{/literal}{$lang.err.comment_delete_confirm|escape:javascript}{literal}';
		if(delete_alert != ''){
			if(!confirm(delete_alert)){
				return;
			}
		}

		if(delete_progress == 0){
			delete_progress = 1;
		}else{
			return;
		}
		if(comment_id == undefined || comment_id == 0 || obj == undefined){
			return;
		}
		
		$(obj).blur();
		$.ajax({
			type: 'POST',
			url: SEO_SITE_ROOT + '/'+file,
			data: {'sel':'delete_upload_comment', 'comment_id':comment_id},
			success: function(msg){
				if(msg != 'ERROR'){
					delete_progress = 0;
					$(obj).closest('.comment_upload').remove();
				}
				else{
					delete_progress = 0;
					var del_comment = '{/literal}{$lang.err.comment_cant_del|escape:javascript}{literal}';

					$(obj).html('[{/literal}{$lang.button.delete|replace:"'":"\\'"}{literal}]');
					if(del_comment != ''){
						alert(del_comment);
					}
				}
			}
		});
	}
</script>
{/literal}