<?php use_helper('UrlFunctions'); ?>
<?php use_helper('UtilFunctions');?>
<script>

acutalizarEspecialidad = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=getEspecialidad&nombreElm='+destino+'&value='+elm.value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
}
</script>
<script>
actualizaJSON = function(request, json){
  var numeroElementos = json.length;
  for (var i = 0; i < numeroElementos; i++){
    if($(json[i][0])){
  	  switch ($(json[i][0]).tagName){
  	    case 'TD'      : Element.update(json[i][0], json[i][1]); break;
  	    case 'INPUT'   : $(json[i][0]).value=json[i][1]; break;
  	    case 'SELECT'  : 
  	      var objDDL = $(json[i][0]);
  	      if(typeof(cont) == 'undefined'){
  	        var cont = 0;
  	        objDDL.options.length = 1;
  	      }
  	      var a_contentValues = json[i][1].split("_;_");
      		var value	= a_contentValues[0];
      		var text	= a_contentValues[1];
  	      var option	= new Option(text,value);
      		try{
      			objDDL.add(option,null);
      		}catch (e){
      			objDDL.add(option,-1);
      		}
  	      cont++;
  	    break;
  	  }
    }else{
      if(json[i][0].indexOf("function") > -1){
        eval("scriptEval = "+json[i][0]);
        scriptEval();
      }
    }
  }
}
</script>
<script type="text/javascript">
        tinyMCE.init({
                // General options
                
                mode: 'exact',
                elements: 'elm1',
                language: 'es',
    
                //mode : "textareas",
                theme : "advanced",
                plugins : "embed,imagemanager,filemanager,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

                // Theme options
                theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
                theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen,|,embed",
                //theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,insertfile,insertimage",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_resizing : true,
                document_base_url: "http://www.peru-retail.com/convex/",
				relative_urls : false,
				remove_script_host : true,

                // Example content CSS (should be your site CSS)
                content_css : "examples/css/content.css",

                // Drop lists for link/image/media/template dialogs
                //template_external_list_url : "examples/lists/template_list.js",
                //external_link_list_url : "examples/lists/link_list.js",
                //external_image_list_url : "examples/lists/image_list.js",
                //media_external_list_url : "examples/lists/media_list.js",

                // Replace values for the template plugin
                template_replace_values : {
                        username : "Some User",
                        staffid : "991234"
                }
        });
</script>
<?php

if(isset($control)){

  $o_ConvTexto =  new ConvTextoDP();
  
  $o_ConvTexto->setIdTexto($id);
  $o_ConvTexto->setTitulo($Titulo);
  $o_ConvTexto->setDescripcionCorta(addslashes($DescripcionCorta));
  $o_ConvTexto->setDescripcionLarga(addslashes($DescripcionLarga));
  $o_ConvTexto->setUrl(nameToURL($Titulo));
  //$o_ConvTema->setFecha($Fecha);
  //$o_ConvTema->setNumeroorden($orden);
  $o_ConvTexto->setEstado($cboEstado);
  //$o_ConvTema->setFilejpg($_FILES);
  $o_ConvTexto->setFechaCreacion(date("Y-m-d H:i:s"));
  $o_ConvTexto->setUsuarioCreacion(myUser::getUser()->getUserId());
  
	
  $bResult = $o_ConvTexto->update();
  //exit;
  if($bResult > 0){
    ?>
    <script language="JavaScript">
    parent.objMainTab.reqBody('<?=buildUrl('texto/list')?>','001&msg=Se modifico el Texto');
    parent.objMainTab.windowsCloseAll();
    </script>
    <?
  }else{
   $mensaje = $bResult;
  }
  
}

 	

  $o_ConvTexto = new ConvTextoFN();
  $o_ConvTexto->setIdTexto($id);
  $a_o_ObjectBean = $o_ConvTexto->select();
  list($key,$o_ObjectBean)=each($a_o_ObjectBean);

 
?>

<img src="/images/common/spacer.gif" width="10">
<table class="cuerpo" width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td height="0">
		  <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
			  <td class="titleBody"><li>Editar Texto</li></td>
			</tr>
		  </table>
		</td>
	</tr>
      <script type="text/javascript">
        validatePass = function(){
            valid.onSubmit = false;
        }
      </script>
	<tr>
		<td valign="top">
			<form id="form1" name="form1" method="POST" enctype="multipart/form-data">
				<input type="hidden" name="control" value="1">
		  
				<table hspace="20px" class="marco" width="96%">
					<tr>
						<td valign="top" colspan="2">
				
							<table hspace="20px"  width="50%" style="border:1px solid #d3d3d3; min-height:220px">
								<tr>
									<td height="0">
								  
										<table width="100%" border="0" cellspacing="6" cellpadding="0">
										   
											<tr>
												<td width="10%"><label class="label">Titulo</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese el titulo" type="text" name="Titulo" id="Titulo" size="35" maxlength="120" value="<?php echo htmlspecialchars($o_ObjectBean->getTitulo());?>"/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td width="10%" ><label class="label">Descripción Corta</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese el descripcioncorta" type="text" name="DescripcionCorta" id="DescripcionCorta" size="35" maxlength="300" value="<?php echo htmlspecialchars($o_ObjectBean->getDescripcionCorta());?>"/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td nowrap="nowrap" width="10%" ><label class="label">Descripcion Larga</label></td>
												<td nowrap="nowrap" colspan="2"><textarea class="required" title="Ingrese el Detalle" name="DescripcionLarga" id="elm1" cols="50" rows="4" ><?php echo stripslashes($o_ObjectBean->getDescripcionLarga())?></textarea></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											
											
											<tr>
											   <td  width="10%" ><label class="label">Estado</label></td>
												<td nowrap="nowrap" width="38%">
												   <select name="cboEstado" id="cboEstado" class="combo required" title="Seleccione el estado"/> 
													  <option value="" >Seleccione</option>
													  <option value="A" <?php  if($o_ObjectBean->getEstado() == 'A') echo "selected='selected'"?>>Publicado</option>
													  <option value="I" <?php  if($o_ObjectBean->getEstado() == 'I') echo "selected='selected'"?>>No Publicado</option>
													</select>
												</td>
											 </tr>  
										</table>
												
									</td>
								</tr>
								<tr>
									<td height="0" width="100%">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td><img src="/images/common/spacer.gif" width="10"></td>
											</tr>
											<tr>
											  <td align="center">
											  <input type="hidden" name="typeSubmit" id="typeSubmit">
											  <input type="hidden" name="noredir" id="noredir" value="<?=$noredir?>">
											  <input class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='list';">
											  <input class="button" type="button" value="Cancelar" onclick="document.location.href='<?=buildUrl('texto/list',"block=001")?>';"/>
											  </td>
											</tr>
											<tr>
												<td height="10">&nbsp;</td>
											</tr>
										</table>
								
									</td>
								</tr>
							
							</table>
							
							
						</td>
					</tr>
				</table>
			</form>
				<script type="text/javascript">
					$("#form1").validate();
				 </script>
		</td>
	</tr>
</table>
