var  xmlHttp;
var vllave;
var xmlDoccf;
var flag;
var ctrrowid;
var componentelov;
var xmlPeticioncf;
var objectid;
var objetoJson;
var error;
var w;
function creaDom(resultado)
 {
  xmlDoccf= $.xmlDOM( resultado);
 }
 function recogeInfos(valorretornado){
   error=valorretornado;
   //alert(valorretornado);
   xmlPeticioncf=valorretornado;
   return valorretornado;
}

function muestraReloj()
{
// Compruebo si se puede ejecutar el script en el navegador del usuario
if (!document.layers && !document.all && !document.getElementById) return;

var mes=0;
// Obtengo la hora actual y la divido en sus partes
var fechacompleta = new Date();
var textofecha="";

if (fechacompleta.getDate()<10)
    textofecha="0"+fechacompleta.getDate()+"-";
else
    textofecha=fechacompleta.getDate()+"-";

mes=fechacompleta.getMonth();
mes++;
if (mes<10)
    textofecha+="0"+mes+"-";
else
    textofecha+=mes+"-";

    textofecha+=fechacompleta.getUTCFullYear();

var horas = fechacompleta.getHours();
var minutos = fechacompleta.getMinutes();
var segundos = fechacompleta.getSeconds();
var mt = "AM";
// Pongo el formato 12 horas
if (horas> 12) {
mt = "PM";
horas = horas - 12;
}
if (horas == 0) horas = 12;
// Pongo minutos y segundos con dos digitos
if (minutos <= 9) minutos = "0" + minutos;
if (segundos <= 9) segundos = "0" + segundos;
// En la variable 'cadenareloj' puedes cambiar los colores y el tipo de fuente
//cadenareloj = "<font size='-1' face='verdana'>" + horas + ":" + minutos + ":" + segundos + " " + mt + "</font>";
cadenareloj =horas + ":" + minutos + ":" + segundos + " " + mt;
// Escribo el reloj de una manera u otra, segun el navegador del usuario
 try{
     xmlHttp=new XMLHttpRequest();

if (document.layers) {
document.layers.spanreloj.document.write(cadenareloj);
document.layers.spanreloj.document.close();
}
else if (document.all) spanreloj.innerHTML = cadenareloj;
else if (document.getElementById)
$("#horayfecha").html(cadenareloj+": "+textofecha);
// Ejecuto la funcion con un intervalo de un segundo
setTimeout("muestraReloj()", 1000);
  }catch(e)
    {}
}

function obtieneVariable(nombreVariable)
{
 var temporal="";
  try{
       temporal=top.parent.$("#"+nombreVariable).val();
    }catch(e)
    {
        temporal=$("#"+nombreVariable, top.parent.frames[0].document).val();
        if (temporal=="" ||temporal==null)
            {
             try{
               temporal=$("#"+nombreVariable, windows.parent.frames[0].document).val();
              }catch(e){
                  alert("error obteniendo variable"+nombreVariable);
                  temporal="";

                    }

             }
    }
 return temporal;
}

function cargaVariable(nombreVariable,valor)
{
 var temporal="";
  try{
        // coloco el valor
        top.parent.$("#"+nombreVariable).val(valor);
    }catch(e)
    {
        $("#"+nombreVariable, top.parent.frames[0].document).val(valor);
        if (valor>"")
        {

        //alert("con variable"+nombreVariable+" valor "+valor);
        temporal=$("#"+nombreVariable, top.parent.frames[0].document).val();
        if (temporal=="" ||temporal==null)
               $("#"+nombreVariable, windows.parent.frames[0].document).val(valor);

        }
    }
}

function abreModalPadre(url,divfunte,alto,ancho,Titulo,izquierdo,ntop)
{

if (izquierdo==0 ||izquierdo==null)
    izquierdo=0;
if (ntop==0 ||ntop==null)
    ntop=0;
                parent.top.$('#'+divfunte).html('<IFRAME  id="frame" style="border: 0px; align=center; " SRC="'+url+'" width="100%" height = "100%" >');
		 parent.top.$( "#"+divfunte).dialog({
			autoOpen: true,
			height: alto,
			width: ancho,
                        title:Titulo,
                        resizable: true,
                        position: ([izquierdo,ntop]),
                        stack: false,
			modal: true,
			buttons: {
				Cancel: function() {

					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );

			}
		});
}

function abreModalSimple(url,divfunte,alto,ancho,Titulo,izquierdo,ntop)
{
    if (izquierdo==0 ||izquierdo==null)
       izquierdo=0;
    if (ntop==0 ||ntop==null)
        ntop=0;

    $('#'+divfunte).html();
                $('#'+divfunte).html('<IFRAME  id="frame" style="border: 0px; align=LEFT; " SRC="" width="100%" height = "100%" >');
		$("#frame").attr("src", url);

		 $( "#"+divfunte).dialog({
			autoOpen: true,
			height: alto,
			width: ancho,
                        title:Titulo,
                        resizable: true,
                        position: ([izquierdo,ntop]),
                        stack: false,
			modal: true,
			buttons: {
				Cancel: function() {

					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );

			},
                        Regresa: function() {

			}
		});
}

function abreModal(url,divfunte,alto,ancho)
{
     $('#'+divfunte).html();
                $('#'+divfunte).html('<IFRAME  id="frame" style="border: 0px; align=LEFT; " SRC="" width="100%" height = "100%" >');
		$("#frame").attr("src", url);

		 $( "#"+divfunte).dialog({
			autoOpen: true,
			height: alto,
			width: ancho,
                        resizable: true,
                        position: ([0,0]),
                        stack: false,
			modal: true,
			buttons: {
				Cancel: function() {

					$( this ).dialog( "close" );
                                        refrescar();
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );

                                refrescar();
			},
                        Regresa: function() {

                                refrescar();
			}
		});
}


function creaMensaje(titulo,detalle)
{

if (titulo=="ERROR")
 {
  titulo="Digital ERROR";

  var mensajealert = $('<div title="'+titulo+'"><p><table><tr><td><img src="../images/error.jpg"  onerror=this.src="../../images/error.jpg"></td><td><strong><font color="#000" size=4>'+detalle+'</font></strong></td></tr></table></p></div>');
 }
else
 {
  titulo="Digital Informa";
  var mensajealert = $('<div title="'+titulo+'"><p><table><tr><td><img src="../images/exito.jpg"  onerror=this.src="../../images/exito.jpg"></td><td><strong><font color="#000" size=4> '+detalle+'</font></strong></td></tr></table></p></div>');
  }
try{
mensajealert.dialog({
	modal: false,

               title: titulo,
               width: 350,
               minWidth: 300,
               maxWidth: 350,
			   position: 'top',
   		       show: 'blind',
		     hide: 'explode'
	        }

        );
 }catch(e) {
     alert(detalle);
   }
}

 function  cargaEntidades(categoria,componente,categoriaquellama,componenteimagen)
 {
     //alert("cargaEntidades categoria de maestro"+categoria);
   var parametros = { peticion:"E",categoria:categoria,categoriaquellama:categoriaquellama,componente:componenteimagen};
   
   var urlServer = "../objetos/leeimagen.php" 
   jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    error: function (xhr, desc, exceptionobj) {

                                   //if (xhr.responseText>"")
                                     //alert(xhr.responseText);
                     },

				   success: function(data) 
	                {
			 
					 recogegaleria( data,"E",componente);
                      
					}         
                  });
	// SI ES PERIODICO
	
	if (categoria==1 || categoria==2 || categoria==3 || categoria==4 || categoria==5 || categoria==6 )
	{
	  var parametros = { peticion:"RECIENTE",categoria:categoria,siguiente:1};
  
	 jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    error: function (xhr, desc, exceptionobj) {

                                     //if (xhr.responseText>"")
                                      //alert(xhr.responseText);
                     },

				   success: function(data) 
	                {
						 
				      if (categoriaquellama==7)
					   cargagaleria3(data,"imagenthumbail",categoriaquellama);
					   if (categoriaquellama==5)
					    cargagaleria3(data,"photos",categoriaquellama);
					  
					}         
                  }); 
	
	
	}

 }
 
 function  cargaEntidadesthumbs(categoria,componente,categoriaquellama,componenteimagen)  // entidades en thumbails
 {
     //alert("categoria de maestro"+categoria);
   var parametros = { peticion:"ET",categoria:categoria,categoriaquellama:categoriaquellama,componente:componenteimagen};
   
   var urlServer = "../objetos/leeimagen.php" 
   jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    error: function (xhr, desc, exceptionobj) {

                                     //if (xhr.responseText>"")
                                       //alert(xhr.responseText);
                     },

				   success: function(data) 
	                {
					 
					 recogegaleria( data,"E",componente);
                      
					}         
                  });
	// SI ES PERIODICO
	
	if (categoria==1 || categoria==2 || categoria==3 || categoria==4 || categoria==5 || categoria==6 )
	{
	  var parametros = { peticion:"RECIENTE",categoria:categoria,siguiente:1};
  
	 jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    error: function (xhr, desc, exceptionobj) {

                                     //if (xhr.responseText>"")
                                      //  alert(xhr.responseText);
                     },

				   success: function(data) 
	                {
						 
				      if (categoriaquellama==7)
					   cargagaleria3(data,"imagenthumbail",categoriaquellama);
					   if (categoriaquellama==5)
					    cargagaleria3(data,"photos",categoriaquellama);
					  
					}         
                  }); 
	
	
	}

 }
 
 function  cargacatalogo(categoria)
 {
   var parametros = { peticion:"C",categoria:categoria};
   
   var urlServer = "leeimagen.php" 
   jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogecatalogo( data,categoria);
					}         
                  });

 }
 function recogecatalogo(valorretornado,categoria){ 
   if (categoria=='01')
      document.getElementById("categoria01").innerHTML=valorretornado;
    if (categoria=='02')
      document.getElementById("categoria02").innerHTML=valorretornado;
   } 
   
   
function  cargallave(llave)
 { 
   var parametros = {llave:llave};
   top.frames['workspace'].location.href='basellave.php?llave='+llave;top.frames['workspace'].location.href='basellave.php?llave='+llave;
 }

function  cargainicial(){
 var llave=jQuery("#llave").val();
  
 
 if (llave==null ||llave=="")
     { 
	 // busca la que esta por defecto
	 
	  var urlServer = "leeimagen.php" 
	  var parametros = {peticion:"DEFAULT"};
      jQuery.ajax({type: "POST", 
	  url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"DEFAULT");
					}         
                  });
	llave=vllave;
	 }

  
 document.getElementById("galeria2").innerHTML="INICIANDO";
 
 var parametros = {llave:llave,peticion:"G"};
  
 var urlServer = "leeimagen.php" 
   jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"G","galeria2");
					}         
                  });

   parametros = {llave:llave,peticion:"I",categoria:1};
  
  
   jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"I");
					}         
                  }); 
				  
	 parametros = {llave:llave,peticion:"I",categoria:2};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"I2");
					}         
                  }); 
	 parametros = {llave:llave,peticion:"D",tipodetalle:"DET"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"D");
					}         
                  }); 
	parametros = {llave:llave,peticion:"D",tipodetalle:"DES"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"DES");
					}         
                  }); 
	parametros = {llave:llave,peticion:"D",tipodetalle:"FIC"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"FIC");
					}         
                  }); 
 
 /*parametros = {llave:llave,peticion:"MAP" };			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "json",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"MAP");
					}         
                  }); */
}

// carga galeria 3
function  cargagaleria3(llave,componente,galeria){
     //alert(llave+" "+componente+" "+galeria);
 if (llave!=null )
     { 
	 if (galeria==3)
	   var tipogaleria="G3";
	 if (galeria==4)
	   var tipogaleria="G4";
	if (galeria==5)
	   var tipogaleria="G5";
	if (galeria==6)
	   var tipogaleria="G6";
	   
	if (galeria==7 ||galeria==71 )
	   var tipogaleria="G7";



       if (galeria==11 )
	  var tipogaleria="G7GSLIDE";
	 
	componente="#"+componente; 
	  		  
  // alert(llave+" "+componente+" "+galeria);
 var parametros = {llave:llave,peticion:tipogaleria}; 
 var urlServer = "../objetos/leeimagen.php"; 
    jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                { 
					recogegaleria( data,tipogaleria,componente);
					}         
                  });

 
if (galeria==5 ||galeria==4 )	
  {
   
	var urlServer = "../objetos/leeimagen.php"; 
	parametros = {llave:llave,peticion:"D",tipodetalle:"DET"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:true,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
					
                     recogegaleria( data,"DET1");
					}         
                  });
				  
    parametros = {llave:llave,peticion:"D",tipodetalle:"DES"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
                     recogegaleria( data,"DES1");
					}         
                  }); 
				  
    parametros = {llave:llave,peticion:"TIT",tipodetalle:"TIT"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
                     recogegaleria( data,"TIT");
					}         
                  });	
  // busca los videos disponibles
  //alert("llamando videos"+llave);
  parametros = {llave:llave,peticion:"VIDEOS",tipodetalle:""};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"VIDEOS");
					}         
                  });	
			
  }

  // es el periodico
  if (galeria=7)	
    {
  // recoge los titulos, el autor, la fecha
    var parametros = {llave:llave,peticion:"MAP" };			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "json",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"GENERAL");
					}         
                  }); 
  
    
	// busca el curpo de la noticia
	 parametros = {llave:llave,peticion:"CUERPO",tipodetalle:"CUERPO"};			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
                     recogegaleria( data,"CUERPO");
					}         
                  }); 	
   				  
				  
   // trae las fotos en grande Superiores
    tipogaleria="G7G";
    var parametros = {llave:llave,peticion:tipogaleria}; 
    
    jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
					 
                     recogegaleria( data,tipogaleria,componente);
			}         
                  });
  // busca los videos disponibles
  // preguntar si la noticia tiene videos
  /*parametros = {llave:llave,peticion:"VIDEOS",tipodetalle:""};
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"VIDEOS");
					}         
                  });*/

 if (componente=="#imagenthumbail" && noHayobjetos==0)
  {
      noHayobjetos=0;
       parametros = {llave:llave,peticion:"G7GSLIDE",tipodetalle:""};
	jQuery.ajax({type: "POST",
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data)
	                {
                     recogegaleria( data,"G7GSLIDE");
					}
                  });
      }
  }
  
  if (galeria=71)	
    {
    // trae las fotos en grande
    tipogaleria="G7G";
    var parametros = {llave:llave,peticion:tipogaleria}; 
    
    jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data) 
	                {
					 
                     recogegaleria( data,"G71",componente);
					}         
                  });
   
  }
 } 
}

function mapa(){ 
     
    var urlServer = "leeimagen.php";
    var llave=jQuery("#llave").val();
    var parametros = {llave:llave,peticion:"MAP" };			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "json",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"MAP");
					}         
                  }); 


}
function video(){ 

    var urlServer = "leeimagen.php";
    var llave=jQuery("#llave").val();
	 
	var parametros = {llave:llave,peticion:"VIDEO",categoria:8};
    			  
	jQuery.ajax({type: "POST", 
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   success: function(data) 
	                {
                     recogegaleria( data,"VIDEO");
					}         
                  }); 


}
function recogegaleria(valorretornado,tipo,componente){ 
   var titulo;
   if (tipo=='G')
   {
     
     document.getElementById(componente).innerHTML=valorretornado;
     jQuery('#galeria2').val(valorretornado);
	 
    //sfHover;
	if (window.attachEvent) window.attachEvent("onload", sfHover);
   }
   if (tipo=='G3')
   {
     
       
    // document.getElementById("galeria3").innerHTML=valorretornado;
      jQuery(componente).html(valorretornado);
	  jQuery('.thumbs').piroBox({
			border: 10,
			borderColor : '#222',
			mySpeed: 700,
			bg_alpha: 0.3,
			cap_op_start : 0.4,
			cap_op_end: 0.8,
			pathLoader : '#000 url(css/ajax-loader.gif) center center no-repeat;',
			gallery : '.gallery_in li a',
			gallery_li : '.gallery_in li',
			next_class : '.next_in',
			previous_class : '.previous_in'
	});
	jQuery('.thumbs').piroBox({

<!--David this OPTIONS are for outside box navigation-->

			border: 1,
			mySpeed: 700,
			borderColor : '#444',
			bg_alpha: 0.5,
			cap_op_start : 0.4,
			cap_op_end: 0.8,
			pathLoader : '#000 url(css/ajax-loader.gif) center center no-repeat;',
			gallery : '.gallery li a',
			gallery_li : '.gallery li',
			single : '.single  a',
			next_class : '.next',
			previous_class : '.previous'
	});
	  
   }
   
   if (tipo=='G4')
   {
     
     
	 // componente="#"+componente;
    // alert(valorretornado);
      jQuery(componente).html(valorretornado);
	  
	  	// We only want these styles applied when javascript is enabled
			jQuery('div.navigation').css({'width' : '300px', 'float' : 'left'});
			jQuery('div.content').css('display', 'block');

			// Initially set opacity on thumbs and add
			// additional styling for hover effect on thumbs
			var onMouseOutOpacity = 0.67;
				// We only want these styles applied when javascript is enabled
			jQuery('div.navigation').css({'width' : '300px', 'float' : 'left'});
			jQuery('div.content').css('display', 'block');

			// Initially set opacity on thumbs and add
			// additional styling for hover effect on thumbs
			var onMouseOutOpacity = 0.67;
			jQuery('#thumbs ul.thumbs li').css('opacity', onMouseOutOpacity)
				.hover(
					function () {
						jQuery(this).not('.selected').fadeTo('fast', 1.0);
					}, 
					function () {
						jQuery(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
					}
				);

			jQuery(document).ready(function() {
				// Initialize Advanced Galleriffic Gallery
				var galleryAdv = jQuery('#gallery').galleriffic('#thumbs', {
					delay:                  2000,
					numThumbs:              12,
					preloadAhead:           10,
					enableTopPager:         true,
					enableBottomPager:      true,
					imageContainerSel:      '#slideshow',
					controlsContainerSel:   '#controls',
					captionContainerSel:    '#caption',
					loadingContainerSel:    '#loading',
					renderSSControls:       true,
					renderNavControls:      true,
					playLinkText:           'Iniciar Slide ',
					pauseLinkText:          'Detener Slide ',
					prevLinkText:           '&lsaquo; Previous Photo',
					nextLinkText:           'Next Photo &rsaquo;',
					nextPageLinkText:       'Next &rsaquo;',
					prevPageLinkText:       '&lsaquo; Prev',
					enableHistory:          true,
					autoStart:              false,
					onChange:               function(prevIndex, nextIndex) {
						jQuery('#thumbs ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
					},
					onTransitionOut:        function(callback) {
						jQuery('#caption').fadeTo('fast', 0.0);
						jQuery('#slideshow').fadeTo('fast', 0.0, callback);
					},
					onTransitionIn:         function() {
						jQuery('#slideshow').fadeTo('fast', 1.0);
						jQuery('#caption').fadeTo('fast', 1.0);
					},
					onPageTransitionOut:    function(callback) {
						jQuery('#thumbs ul.thumbs').fadeTo('fast', 0.0, callback);
					},
					onPageTransitionIn:     function() {
						jQuery('#thumbs ul.thumbs').fadeTo('fast', 1.0);
					}
				});
			});
			
   }
   
// GALERIA 5 PARA LOS ARTICULOS

 if (tipo=='G5')
   {
      // componente="#"+componente;
      //alert(valorretornado);
      jQuery(componente).html(valorretornado);
	  jQuery('#photos').galleryView({
				panel_width: 500,
				panel_height: 350,
				frame_width: 75,
				frame_height: 75
			});
	  
 }
 
 if (tipo=='G7' ) {
 jQuery(componente).html(valorretornado);  
 //alert("componente:"+componente+" "+valorretornado);
 var $fotoPrev = jQuery('#fotonavwrapper img.prev'),//prev button
								$fotoNext = jQuery('#fotonavwrapper img.next');//next button

							jQuery('.fotonav').serialScroll({
								items:'li',
								prev:'#fotonavwrapper img.prev',
								next:'#fotonavwrapper img.next',
								duration:700,
								step:3,
								cycle:false,
								onBefore:function(e, elem, $pane, $items, pos ){
									$fotoPrev.add($fotoNext).fadeIn();
									if ( pos == 0 ) {
										$fotoPrev.fadeOut();
									} else if( pos == $items.length - 1 ) {
										$fotoNext.fadeOut();
									}
								}
							});
 
 jQuery('.ademasPagesContainer').serialScroll({
							items:'div',
							axis: 'y',
							prev:'.caja-ademas img.prev',
							next:'.caja-ademas img.next',
							duration:700,
							step:5,
							cycle:false
						});
 }  
 if (tipo=='G7G'){ 
     jQuery('#fotosgrandes').html(valorretornado);
       
      if (valorretornado.length<30)
          {
          noHayobjetos=1;
          $(".mmedia-fotos").hide();
          /*
          
          $(".fotopage li div").attr("width","180px");
          $(".videopage li div").attr("width","180px");
          $(".col-dos").attr("width","180px");
          $(".caja-ademas").attr("width","180px");

          alert($(".col-dos").attr("width"));
          */
          }
        else
             $(".mmedia-fotos").show();

 
         

     jQuery('.fotopage').serialScroll({
	items:'li',
		navigation:'#fotonavwrapper li',
	duration:0
	});

  }
  if (tipo=='G7GSLIDE'){
        jQuery('#gallery').html(valorretornado);
        $('#gallery a').lightBox();
  }
  if (tipo=='G71'){ 
     jQuery('#fotosgrandes71').html(valorretornado);  
	 
	 jQuery('.fotopage').serialScroll({
							items:'li',
							navigation:'#fotonavwrapper li',
							duration:0
						});
	 
	 }     	 
   if (tipo=='E' || tipo=="IR")  // ENtidad e imagen por referencia
   {
      //alert("retorno "+valorretornado);
     componente="#"+componente;

    jQuery(componente).html(valorretornado);

	   }
   
   
    if (tipo=='I') document.getElementById("imagen1").innerHTML=valorretornado; 
    if (tipo=='I2') document.getElementById("imagen2").innerHTML=valorretornado; 
    if (tipo=='D') document.getElementById("detallellave").innerHTML=valorretornado; 
    if (tipo=='DET1') jQuery('#parte2').html(valorretornado);
    if (tipo=='DES1') jQuery('#parte1').html(valorretornado);
    if (tipo=='CUERPO') jQuery('#noticiaperiodico').html(valorretornado);

    if (tipo=='GENERAL')
	  {


      if (jQuery('#titulonoticia').html()>"")
        {
         jQuery('#titulonoticia').html('<h1 class="titulo">'+valorretornado["titulo"]+'</h1>');
     }
      jQuery('#autor').html("publicado por:"+valorretornado["autor"]);
      jQuery('#fechapublicacion').html(valorretornado["fecha"]);
        }
	if (tipo=='G6') 
	{
	//alert(valorretornado);
	jQuery('#mooflow').html(valorretornado);
	var mf = new MooFlow(jQuery('mooflow'), {
				useSlider: true,
				useAutoPlay: true,
				useCaption: true,
				useResize: true,
				useMouseWheel: true,
				useKeyInput: true,
				useViewer: true
			});
	}
	if (tipo=='VIDEOS') jQuery('#videos').html(valorretornado);
	
	if (tipo=='TIT')
	 {
   	  jQuery('#titulotop').html('<p class="titulo-secundario">'+valorretornado+'</p>');
	  jQuery('#titulobotton').html( '<p class="titulo-secundario">'+valorretornado+'</p>');
	
	}
	if (tipo=='FIC')  document.getElementById("ficha").innerHTML=valorretornado;
    if (tipo=='DEFAULT')  vllave=valorretornado; 
    if (tipo=='DES')
    {
   
    document.getElementById("titulo").innerHTML=valorretornado;
	titulo=valorretornado;
   }
   
   
   if (tipo=='MAP')  {
     titulo=valorretornado["descripcion"]; 
     var html1= '<div id="map1"  style="width: 500px; height: 500px;"></div> <div class="geo" title="'+titulo+'">';
     html1+= '<abbr class="latitude" title="'+valorretornado["latitud"]+'"> </abbr> <abbr class="longitude" title="'+valorretornado["longitud"]+'"> </abbr> ';
	 //document.getElementById("mapa").innerHTML=html1;
	  jQuery('#mapa').show('slow'); 
	  jQuery('#video').hide('slow');
     jQuery('#mapa').html(html1);
	 if (valorretornado["longitud"])
	   {
		 jQuery("#map1").googleMap(valorretornado["latitud"], valorretornado["longitud"], 10, {
			controls: ["GSmallMapControl", "GMapTypeControl"],
			markers: jQuery(".geo")
		  });
	   }
	}
	
	if (tipo=='VIDEO')  {
	  jQuery('#mapa').hide('slow');
	  jQuery('#video').show('slow');
	  
	 var pos=valorretornado.indexOf("XX1");
	 
	  valorretornado=valorretornado.substring(0,pos);
	   
	  so.addParam('flashvars','&file='+valorretornado+'&autostart=true&fullscreen=true');
      so.write('player');
 
	 }

}

function muestraVideo(nombrevideo){ 
 jQuery('#photos').hide('slow');
 jQuery('#video').show('slow');
  jQuery('#volergaleria').show('slow');
 so.addParam('flashvars','&file='+nombrevideo+'&autostart=true&fullscreen=true');
 so.write('player');
}

function muestragaleriadenuevo(){ 
 jQuery('#video').hide('slow');
 jQuery('#photos').show('slow');
 jQuery('#volergaleria').hide('slow');
  
}
function  cargaleria1php(llave,categoria)
 { 
   var parametros = {llave:llave};
   
 // alert("llave"+llave+" categoria"+categoria);
   //top.frames[''].location.href='galeria3.php?llave='+llave;
   if (categoria=='01')
      window.open('servicios_imagenes.php?llave='+llave,'mywindow');
   if (categoria=='02')
      window.open('productos_imagenes.php?llave='+llave,'mywindow');
	if (categoria=='03')
      window.open('trabajos_imagenes.php?llave='+llave,'mywindow');  
 }
 
  function  cargaleria3php(llave)
 { 
   var parametros = {llave:llave};
   //top.frames[''].location.href='galeria3.php?llave='+llave;
   window.open('galeria3.php?llave='+llave,'mywindow','width=900,height=700');
 }
 function  cargaleria4php(llave)
 { 
   var parametros = {llave:llave};
   //top.frames[''].location.href='galeria3.php?llave='+llave;
   window.open('galeria4.php?llave='+llave,'mywindow','width=900,height=700');
 }
 
 
 function regreso(){ 
  document.location.href="../index.php";
  return true;
}

function  cargaBoletines(llave,componente,galeria,rutaArchivo){


 if (llave!=null )
     {
	  var tipogaleria="G7";
   	componente="#"+componente;

   //alert(llave+" "+componente+" "+galeria+" llamando "+rutaArchivo);
 var parametros = {llave:llave,peticion:tipogaleria};
 var urlServer = rutaArchivo;
    jQuery.ajax({type: "POST",
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(rutaArchivo+ xhr.responseText);
                     },
				   success: function(data)
	                {

					recogegaleria( data,tipogaleria,componente);
					}
                  });

 }
}

function  cargaimagen(referencia,componente)
{
   
	var parametros = {llave:"",peticion:"IR",categoria:"",referencia:referencia};


 var urlServer = "../objetos/leeimagen.php";
    jQuery.ajax({type: "POST",
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert( xhr.responseText);
                     },
				   success: function(data)
	                {
 
					recogegaleria(data,"IR",componente);
					}
                  });


}

function queryToJson(sqlquery,ruta)
{
  var data="";
  if (ruta==null )
    var urlServer = "actcontenido/utility.php"
  else
    var urlServer = ruta+"actcontenido/utility.php"
  
 var parametros = { peticion:"QUERYJSON",sqlquery:sqlquery};
 jQuery.ajax({type: "POST",
   url: urlServer,
   data: parametros,
   dataType: "json",
   async:false,
   error: function (xhr, desc, exceptionobj) {
   //alert("error queryToJson "+xhr.responseText);
   },
   success: function(data)
  {
    //alert(data);
    objetoJson=data;
  }
});

} ;


//tipo cambio BCCR
function  tcbccr(componente,tipoIndicador)
{
    //alert(referencia)
 //$("#divtc").hide();
 var parametros = {indicador:tipoIndicador};
 var urlServer = "nosup/wepservices/recuperaTC.php";
    jQuery.ajax({type: "POST",
		 url: urlServer,
				   data: parametros,
				   dataType: "text",
				   async:true,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert( xhr.responseText);
                     },
				   success: function(data)
	                {

                        data=data.substring(270,data.length-104);
                        data=data.substring(0,7);
                        
                        if (tipoIndicador==317)
                           $("#"+componente).html('<span class="compra_venta">compra: </span> C'+data);
                        if (tipoIndicador==318)
                           {
                           $("#"+componente).html('<span>venta:</span>   C'+data);
                           $("#divtchidden").html($("#divtc").html());
                           }
                       $("#divtc").show();
			}
                  });

}

function  cargaimagenReciente(llave,referencia,componente,url,categoria)
{
	// PRIMERO ENCUENTRA La entidad mas reciente.
	 var parametros = { peticion:"RECIENTE",categoria:3,siguiente:1};
	 jQuery.ajax({type: "POST",
		           url: url,
				   data: parametros,
				   dataType: "text",
				   async:false,
				    error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },

				   success: function(data)
	                {
				   llave=data;
			}
                  });


   var parametros = {llave:llave,peticion:"IP",referencia:referencia};

    jQuery.ajax({type: "POST",
		           url: url,
				   data: parametros,
				   dataType: "text",
				   async:false,
				   error: function (xhr, desc, exceptionobj) {
                                   //alert(xhr.responseText);
                     },
				   success: function(data)
	                {

					recogegaleria( data,"IR",componente);
					}
                  });


}


