<?php ob_start(); ?>
<?php $mobile= $_SESSION['user_mobile'];?>
<?php $touchs= $_SESSION['user_touchs'];?>
<?php //$orient= $_SESSION['orient'];?>

<?php //include('../cfg/res.php');?>
<?php //if(file_exists('../cfg/res.php')){include('../cfg/res.php');} ?>	
<?php if(file_exists('../cfg/config.php')){include('../cfg/config.php');}?>	

<?php if(empty($pcodigo)){$pcodigo='$';}?>
<?php if(empty($pobj)){$pobj=3;}?>
<?php if(empty($pdeci)){$pdeci=0;}?>
<?php if(empty($pmodi)){$pmodi=0;}?>
<?php if(empty($plimit)){$plimit=10;}?>
<?php if(empty($pdest)){$pdest=1;}?>
<?php if(empty($ptitle) || $pdest==2){$ptitle='';}?>
<?php if(empty($ptabla)){$ptabla='empr';}?>
<?php //if(empty($pcodigo)){$pcodigo=$_SESSION['user_vcrx_empr'];}?>

<?php if(empty($pcaption)){$pcaption=$pcodi;}?>
<?php //if(empty($pcaption) && (mb_stristr('sist.supe',substr($_SESSION['user_vcrx_tipo'],0,4))) ){$pcaption=$ptabla;} ?>
<?php if(empty($pcolumn)){$pcolumn='descri';}?>

<?php if(empty($psize)){$psize="50";}?>
<?php //if(empty($psize)){$psize=12;}?>
<?php if(empty($ponclick)){$ponclick1="_clickimg('img1_".$pidtxt."');";}?>
<?php if(empty($ponclick)){$ponclick="_clickimg('img_".$pidtxt."');";}?>
<?php $pfile = $pruta.$psrc;?>
<?php if($pobj==1){$plimit=1;} ?>


<?php// echo $pruta;?>
<?php
// 		$sql_imgs='selec;'
// 		$res_imgs=msql_query($sql_getcod,$link_vcrx);

		$sql_imgs='select * from '.$ptabla.'0 ';
		$sql_imgs.='where '.$ptabla.'_file is not null ';
		if($ptabla=='imgi'){$sql_imgs.='and '.$ptabla.'_item like "'.$pcodigo.'%" ';}
		if($ptabla=='imge'){$sql_imgs.='and '.$ptabla.'_enti like "'.$pcodigo.'%" ';}
		$sql_imgs.='and trim('.$ptabla.'_file)!="" ';
		$sql_imgs.='and '.$ptabla.'_status!="O" ';
		$sql_imgs.='and '.$ptabla.'_status!="X" ';
		$sql_imgs.='order by '.$ptabla.'_defa desc, '.$ptabla.'_file ';
		$sql_imgs.='limit '.$plimit;
		$res_imgs=msql_query($sql_imgs,$link_vcrx);	

//  		echo explain_sql($sql_imgs);

?>

<?php if(msql_num_rows($res_imgs)>0){ ?>
<?php if($pobj>1){?>
	<table id="<?php echo 'tab_'.$pidtxt; ?>" cellpadding="0" border="0" width=""
					style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;">
	<tr valign="top">
		<td width="20%" valign="top"
				style="<?php if(msql_num_rows($res_imgs)==1){echo 'display:none;'; }?>"
				>
<?php } ?>
	<?php if($pobj==3){ ?>
	<?php } ?>
	<?php $crowi=0; ?>
	<?php $res_imgs=msql_query($sql_imgs,$link_vcrx);	?>
	<?php while ($aso_imgs=msql_fetch_assoc($res_imgs)){  ?>
		<?php $crowi++; ?>
		<?php $pname=$aso_imgs[$ptabla.'_file'];?>
		<?php $pfile='../'.$ptabla.'/'.$pname;?>
		<?php if(file_exists($pfile)){ ?>
			<?php
				if($crowi==1)
				{
          $pfile1=$pfile;
          $sql_updt='update '.$ptabla.'0 set '.$ptabla.'_defa=1 where '.$ptabla.'_codigo='.$aso_imgs[$ptabla.'_codigo'].'';
          $res_updt=msql_query($sql_updt,$link_vcrx);	
				}
			?>

			<?php if($pobj==2){ ?>
				<td align="center">
			<?php } ?>
			<?php if($pobj==3){ ?>
					<div align="center" >
			<?php } ?>
			<img  id="img_<?php echo $pname;?>"
				src="<?php echo $pfile;?>"
				<?php if ($pobj==1 or $pobj==2){?>
					width="<?php if($mobile=='true'){echo $psize*3;}else{echo $psize;}?>px"
					ondblclick="_clickimg('img_<?php echo $pname;?>');" 
				<?php } ?>
				<?php if ($pobj==3){?>
					width="100%"
					<?php if($mobile=='true'){ ?>
					 	onclick="{document.getElementById('img1_<?php echo $pidtxt;?>').src=this.src;}"
						ondblclick="_clickimg('img_<?php echo $pname;?>');" 
					<?php }else{ ?>
						onclick="_clickimg('img_<?php echo $pname;?>');" 
						onmouseover="{document.getElementById('img1_<?php echo $pidtxt;?>').src=this.src;}"
					<?php} ?>
				<?php } ?>
				valign="middle"
			/>
			<?php if($pobj==2){ ?>
				</td>
			<?php } ?>
			<?php if($pobj==3){ ?>
				</div>
			<?php } ?>
		<?php }else{ ?>
		<?php
			$sql_updt='update '.$ptabla.'0 set '.$ptabla.'_status="X" where '.$ptabla.'_codigo='.$aso_imgs[$ptabla.'_codigo'].'';
			$res_updt=msql_query($sql_updt,$link_vcrx);	
		?>	
		<?php } ?>
		
	<?php } ?>

	<?php if($pobj>1){ ?>
    </td>
	  <td align="center" valign="top" width="80%">
  <?php } ?>
      
	<?php if($pobj==3){ ?>
		<img id="img1_<?php echo $pidtxt; ?>"
			src="<?php echo $pfile1; ?>"
			width="100%"
			<?php if($mobile=='true'){ ?>
			ondblclick="<?php echo $ponclick1;?>"
			<?php }else{ ?>
			onclick="<?php echo $ponclick1;?>"
			<?php} ?>
			valign="middle"
			/>
	<?php } ?>
	<?php if($pobj>1){?>
	</td>
	</tr>
	</table>
	<?php } ?>
<?php } ?>

<?php $pfile=''; ?>
<?php $psrc=''; ?>
<?php $pruta=''; ?>
<?php $psize=0; ?>
<?php $pobj=0; ?>
<?php $ponmouse=''; ?>
<?php $ponclick=''; ?>
<?php $ptabla=''; ?>


<?php $pvalor=0; ?>
<?php $pdeci=0; ?>
<?php $pdest=0; ?>
<?php $ptitle=''; ?>

<?php $obstart = ob_get_clean(); ?>
<?php alltrim($obstart); ?>
<?php //$obstart='' ;?>

<?php echo $obstart; ?>
