var variable=1;
var xmlHttp;
var blinker; 
var elcarrito=false;
var mem=new Array(2);
mem[1]=new Array();
mem[2]=new Array();
mem[3]=new Array();
var currmem=0;
var padelante=false;
var largototal=0;
var varvitrina2;
var varvitrina;
var encadenado=0;
var mantenerse=true;
var cantidadamostrar=10;
var anchoevitrina=0;
var anchofvitrina=0;
var largoevitrina=0;
var largofvitrina=0;


function inghistorial(eldiv, str){
document.getElementById("adeboton").style.display="none";
document.getElementById("regboton").style.display="none";
mem[1][currmem]=eldiv;
mem[2][currmem]=str;
if (mantenerse){
encadenado=encadenado+1;
}else{
}
mem[3][currmem]=encadenado;
mem[3][currmem+1]=0;
currmem=currmem+1;
largototal=encadenado;
}

function reghistorial(){
padelante=false;
if(document.getElementById("resbusqueda"))
document.getElementById("resbusqueda").innerHTML="";
currmem=currmem-1;
elanterior=mem[3][currmem];
while (elanterior==mem[3][currmem-1])
{
currmem=currmem-1;
}
elanterior=mem[3][currmem-1];
while (elanterior==mem[3][currmem-1])
{
currmem=currmem-1;
encadenado=mem[3][currmem];
renuevalimpiaundiv(mem[2][currmem],mem[1][currmem]);
}
elanterior=mem[3][currmem];
while (elanterior==mem[3][currmem+1])
{
currmem=currmem+1;
}

padelante=true;
currmem=currmem+1;
}

function adehistorial(){
padelante=false;
if(document.getElementById("resbusqueda"))
document.getElementById("resbusqueda").innerHTML="";
elanterior=mem[3][currmem];
currmem=currmem-1;
while (elanterior==mem[3][currmem+1])
{
currmem=currmem+1;
encadenado=mem[3][currmem];
renuevalimpiaundiv(mem[2][currmem],mem[1][currmem]);
}
padelante=true;
elanterior=mem[3][currmem];
while (elanterior==mem[3][currmem+1])
{
currmem=currmem+1;
}
encadenado=mem[3][currmem];
currmem=currmem+1;
}


function limpiar(){
document.getElementById("estado").innerHTML="" ;
};

function localizar(texto){
document.getElementById("lugar").innerHTML=texto;
};

function renuevalimpiaestado(str)
{
$clear(varvitrina2);
$clear(varvitrina);
if (padelante)
inghistorial("estado", str);
if(document.getElementById("resbusqueda"))
document.getElementById("resbusqueda").innerHTML="";
document.getElementById("pantallanegra").style.display="block";
document.getElementById("esperando").style.display="block";
if(document.getElementById("tbltotal"))
new Fx.Tween('tbltotal').start('opacity', 1, 0.3);
new Request.HTML({
	url: '/'+str,
	method: 'get',
	update: 'estado',        link:'chain',
	evalScripts: true, 
	onComplete: function(){
if(document.getElementById("pantallanegra"))
  document.getElementById("pantallanegra").style.display="none";
if(document.getElementById("esperando"))
  document.getElementById("esperando").style.display="none";
if(document.getElementById("tbltotal"))
  new Fx.Tween('tbltotal').start('opacity', 0.3, 1);
if(document.getElementById("alimpiar"))
var localizacion=  document.getElementById("alimpiar").value;
if(document.getElementById("contenidototal"))
document.getElementById("contenidototal").style.height="100%";
if(document.getElementById("estado"))
{
document.getElementById("estado").style.height="90%";
document.getElementById("estado").style.padding="5px";
}
if(document.getElementById("enlaces"))
document.getElementById("enlaces").style.height="90%";
if(document.getElementById("enlaceder"))
document.getElementById("enlaceder").style.height="73%";
if(document.getElementById("ccv"))
document.getElementById("ccv").style.height="10%";
if(largototal>1)
{
var losbotones="";
if(encadenado>1)
{
document.getElementById("regboton").style.display="block";
}else
if(document.getElementById("regboton"))
document.getElementById("regboton").style.display="none";
if(largototal>encadenado)
{
document.getElementById("adeboton").style.display="block";
}
else
if(document.getElementById("adeboton"))
document.getElementById("adeboton").style.display="none";

}
}
}).send();

/*document.getElementById("alimpiar").value="estado";
limpiar();
renovar(str,"estado");
*/
document.getElementById("tbltotal").style.height="100%";
}
function renuevalimpiaundiv(str,eldiv)
{
$clear(varvitrina2);
$clear(varvitrina);
if (padelante)
inghistorial(eldiv, str);

if(document.getElementById("pantallanegra"))
document.getElementById("pantallanegra").style.display="block";
if(document.getElementById("esperando"))
document.getElementById("esperando").style.display="block";
if(document.getElementById("contenidototal"))
new Fx.Tween('contenidototal').start('opacity', 0.1, 0.7);
new Request.HTML({
	url: '/'+str,
	method: 'get',
	update: eldiv,
        link:'chain',
	evalScripts: true, 
	onComplete: function(){
if(document.getElementById("pantallanegra"))
document.getElementById("pantallanegra").style.display="none";
if(document.getElementById("esperando"))
document.getElementById("esperando").style.display="none";
if(document.getElementById("contenidototal"))
new Fx.Tween('contenidototal').start('opacity', 0.3, 1);
if(document.getElementById("alimpiar"))
var localizacion=  document.getElementById("alimpiar").value;
if(document.getElementById("contenidototal"))
document.getElementById("contenidototal").style.height="100%";
if(document.getElementById("estado"))
document.getElementById("estado").style.height="80%";
if(document.getElementById("enlaces"))
document.getElementById("enlaces").style.height="73%";
if(document.getElementById("enlaceder"))
document.getElementById("enlaceder").style.height="73%";
if(document.getElementById("ccv"))
document.getElementById("ccv").style.height="10%";
if(largototal>1)
{
var losbotones="";
if(encadenado>1)
{
document.getElementById("regboton").style.display="block";
}else
if(document.getElementById("regboton"))
document.getElementById("regboton").style.display="none";
if(largototal>encadenado)
{
document.getElementById("adeboton").style.display="block";
}else
if(document.getElementById("adeboton"))
document.getElementById("adeboton").style.display="none";

}

}
}).send();

/*document.getElementById("alimpiar").value="estado";
limpiar();
renovar(str,"estado");
*/
document.getElementById("tbltotal").style.height="100%";
}

function renuevaestado(str)
{
var pruebita=document.getElementById("varvitrina2");
if (pruebita!=null)
$clear(varvitrina2);
document.getElementById("alimpiar").value="estado";
renovar(str);
	}

function renovarcontenidototal(str)
{ 
var pruebita=document.getElementById("varvitrina2");
if (pruebita!=null)
$clear(varvitrina2);
new Fx.Tween('contenidototal').start('opacity', 1, 0.3);
 document.getElementById("contenidototal").innerHTML="";
 document.getElementById("alimpiar").value="contenidototal";
 renovar(str,"contenidototal");
	}
 function renovar(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url=str
url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
var localizacion=  document.getElementById("alimpiar").value;
if(document.getElementById("pantallanegra"))
document.getElementById("pantallanegra").style.display="none";
if(document.getElementById("esperando"))
document.getElementById("esperando").style.display="none";
if(document.getElementById("contenidototal"))
new Fx.Tween('contenidototal').start('opacity', 0.3, 1);
if(document.getElementById("alimpiar"))
var localizacion=  document.getElementById("alimpiar").value;
if(document.getElementById("contenidototal"))
document.getElementById("contenidototal").style.height="100%";
if(document.getElementById("estado"))
document.getElementById("estado").style.height="73%";
if(document.getElementById("enlaces"))
document.getElementById("enlaces").style.height="73%";
if(document.getElementById("enlaceder"))
document.getElementById("enlaceder").style.height="73%";
if(document.getElementById("ccv"))
document.getElementById("ccv").style.height="10%";

if (localizacion=="estado")
{
document.getElementById("estado").innerHTML=document.getElementById("estado").innerHTML+xmlHttp.responseText 
}else{
document.getElementById("contenidototal").innerHTML=document.getElementById("contenidototal").innerHTML+xmlHttp.responseText 
	}
}else  { 


}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}





function ingresarprod(id)
{
<!--Se debe poner esta lìnea al iniciar una pàgina web de cliente o visitante
<!--
<!--
<!--
<!--
<!--
<!--document.getElementById('espaciocarrito').innerHTML=leercookie("carrito");


<!--la funcion ingresar, toma los valores seleccionados por el usuario para poner un objeto en el carrito
<!--y lo coloca ahí tomando los valores del catálogo que esta siendo presentado.

var total= Number(document.getElementById('total').innerHTML); 
var newcarro="";
if (total==0){

document.getElementById('espaciocarrito').innerHTML="";
limpiarcarrito();
newcarro="  <table><tr  align=\u0022center\u0022 class=\u0022style3\u0022><td >Cant.</td><td >Img.</td><td colspan=\u00222\u0022>Subtotal</td> <td></td>  </tr><table>";

}
var titulo="nom_producto"+id;
var maximo="max_producto"+id;
var imagen="img_producto"+id;
var precio="precio_producto"+id;
var subtotal=0;
var carroant= document.getElementById('espaciocarrito').innerHTML;
var pruebita="subtot"+id;
pruebita=document.getElementById(pruebita);
if (pruebita==null)
{
var max=document.getElementById(maximo).innerHTML;
newcarro=newcarro+"<table id=\u0022elem"+id+"\u0022><tr> <td> <input id=\u0022cant"+id+"\u0022 title=\u0022Cantidad\u0022  type=\u0022text\u0022 value=\u00221\u0022 size=\u00221\u0022 onChange=\u0022multiplicar(\u0027"+id+"\u0027)\u0022/> <input id=\u0022punit"+id+"\u0022 type=\u0022hidden\u0022 value=\u0022"+document.getElementById(precio).innerHTML+"\u0022/> <input id=\u0022max"+id+"\u0022 type=\u0022hidden\u0022 value=\u0022"+max+"\u0022/></td><td align=\u0022right\u0022>  <input name=\u0022imageField\u0022 id=\u0022foto"+id+"\u0022  type=\u0022image\u0022 src=\u0022"+document.getElementById(imagen).src+"\u0022 title=\u0022"+document.getElementById(titulo).innerHTML+"\u0022></td><td> $</td><td align=\u0022right\u0022 style=\u0022width:50px\u0022><b  title=\u0022Subtotal\u0022 id=\u0022subtot"+id+"\u0022 >"+Number(document.getElementById(precio).innerHTML).toFixed(2)+"</b> </td><td>  <input id=\u0022botoncito"+id+"\u0022 type=\u0022button\u0022 type=\u0022Submit\u0022 title=\u0022Eliminar\u0022 value=\u0022 \u0022 size=\u00222\u0022 onClick=\u0022borra(\u0027"+id+"\u0027)\u0022/></td></tr></table>";
carroant=carroant+newcarro;
document.getElementById('espaciocarrito').innerHTML=carroant;
var preciototal=document.getElementById(precio).innerHTML;
ides("ing",id,1);
alert("El producto: '"+document.getElementById(titulo).innerHTML+"' ha sido colocado en el carrito de compras");
}else{
var canti=Number(document.getElementById('cant'+id).value)+1;
document.getElementById('cant'+id).value=canti;
multiplicar(id);
var canti2=document.getElementById('cant'+id).value;
if (canti==canti2)
alert("Hay  "+canti+" unidades del producto: '"+document.getElementById(titulo).innerHTML+"'en el carrito de compras");

}
carroant= document.getElementById('espaciocarrito').innerHTML;
Cookie.write("carrito", carroant, {duration: 10})
document.getElementById("ordenar").disabled="";
multiplicarprod();
  }


function multiplicarprod()
{
document.getElementById("ordenar").disabled="";
document.getElementById('total').innerHTML=0;
var total=0;
var ids=document.getElementById('ids').value;
//Cookie.dispose("ids");
var nuevaid="";
if(ids)
{
document.getElementById("mensajecarrito").innerHTML=""; 
while (ids.indexOf("-")>0)
{
	var apuntador=ids.indexOf("-");
	var id=ids.substring(ids.indexOf("*")+1,apuntador);
	var ids=ids.substring(ids.indexOf("*")+1,ids.length);
	var apuntador2=ids.indexOf("x");
	apuntador=ids.indexOf("-");

   var cantidad=Number(ids.substring(apuntador+1,apuntador2));
	ids=ids.substring(apuntador2+1,ids.length);
var subtotid="subtot"+id;
var cantid="cant"+id;
var punitid="punit"+id;
var preciounitario=document.getElementById(punitid).value;
var punit=Number(preciounitario);
var subtotal=Number(punit)*Number(cantidad);
subtotal=subtotal.toFixed(2);
total=Number(total)+Number(subtotal);
document.getElementById(cantid).value=Math.round(cantidad);
document.getElementById(subtotid).innerHTML=subtotal;
nuevaid=nuevaid+"*"+id+"-"+cantidad+"x";

}
document.getElementById('ids').value=nuevaid;
document.getElementById('total').innerHTML=total.toFixed(2);
if(total==0) {
limpiarcarrito();
}
Cookie.write("total",total.toFixed(2), {duration: 10});
Cookie.write("carrito", document.getElementById("espaciocarrito").innerHTML, {duration: 10})
 }else{
limpiarcarrito();
}
if(elcarrito)
mostrarcarrito("nada");

var previewpedido="muestrapedidodecarrito";
previewpedido=document.getElementById(previewpedido);
if (previewpedido)
{
mostrarcarrito("muestralo");
}
}






function limpiarcarrito()
{

document.getElementById("espaciocarrito").innerHTML="";
document.getElementById("mensajecarrito").innerHTML="No tiene productos seleccionados";
document.getElementById("ordenar").disabled="disable";

document.getElementById("ids").value="";
Cookie.dispose("total");
Cookie.dispose("ids");
Cookie.dispose("carrito");

}



function multiplicar(unid)
{
var totalproducto=Number(document.getElementById("subtot"+unid).innerHTML);
var maximo=Number(document.getElementById("max"+unid).value);
var lacantidad=document.getElementById('cant'+unid).value;
var unnum;
var esmaximo=false;
if (isNaN(lacantidad)){
alert("Cantidad no válida");
lacantidad=1;}
if (lacantidad<0){
lacantidad=1;
}
if(lacantidad>maximo)
{
	lacantidad=maximo;
esmaximo=true;
	}

document.getElementById('cant'+unid).value=Number(Math.round(lacantidad));
var elprecio=document.getElementById("punit"+unid).value;
unnum=Number(elprecio)*Number(Math.round(lacantidad));
unnum=unnum.toFixed(2);
document.getElementById("subtot"+unid).innerHTML= unnum;
ides("mod",unid,lacantidad);
if (lacantidad==0){
borra(unid);
ides("del",unid);
}
var carroant= document.getElementById('espaciocarrito').innerHTML;
Cookie.write("carrito",carroant, {duration: 10});

if(esmaximo)
{
	alert("Disponibilidad: "+maximo+".");
	}
multiplicarprod();

}


function vaciarCarrito()
{

<!--la funcion vaciarCarrito(), como su nombre lo indica, quita los objetos que han sido seleccionados para el carrito de compras, lo deja vacío y el total=0.
var eltotal=document.getElementById('total').innerHTML;
document.getElementById('espaciocarrito').innerHTML="";
ides("bor",0,0);
limpiarcarrito();
multiplicarprod();
alert("El carrito ha sido vaciado.");

}

function borra(id)
{
var totalproducto=Number(document.getElementById("subtot"+id).innerHTML);
var titproducto=document.getElementById("foto"+id).title;
//aumentaTotal(totalproducto,'dis');
ides("del",id,0);
//http://www.maestrosdelweb.com/editorial/dom/
var ancla = document.getElementById("elem"+id);
var padre = ancla.parentNode;
var hijoRemovido = padre.removeChild(ancla);
Cookie.write("carrito",document.getElementById('espaciocarrito').innerHTML, {duration: 10});

var total = Number(document.getElementById('total').innerHTML).toFixed(2); 
if (total>0){
}else{
limpiarcarrito();
}
multiplicarprod();
alert("El producto:   \u0022 "+titproducto+"\u0022   ha sido removido satisfactoriamente.");

}

function ides(valor,id,cantidad)
{

if (!window.document.getElementById("ids").value)
{
var antid="";
}else{
var antid=window.document.getElementById("ids").value;
}
var inicio, fin, cantprov;
var prov1, prov2,prov3, postid,apuntador;
var largo=antid.length;
switch (valor)
{
case "ing":
antid=antid+"*"+id+"-"+cantidad+"x";


				  break;
case "mod":
prov1="*"+id+"-";
prov2=prov1.length;
inicio=antid.indexOf(prov1);
inicio=inicio+prov2;
//cortamos la parte anterior a la cantidad del valor buscado
prov1=antid.substring(0,inicio);
//cortamos la parte posterior a el igual "=" del valor buscado
inicio=inicio;
prov3=antid.substring(inicio,largo);
apuntador=prov3.indexOf("x");
largo=prov3.length;
antid=prov1+cantidad+prov3.substring(apuntador,largo);
break;
case "del":
prov1="*"+id+"-";
prov2=prov1.length;
inicio=antid.indexOf(prov1);
inicio=inicio-1;
//cortamos la parte anterior a la cantidad del valor buscado
prov1=antid.substring(0,inicio);
//cortamos la parte posterior a el igual "=" del valor buscado
inicio=inicio+1;
prov3=antid.substring(inicio,largo);
apuntador=prov3.indexOf("x");
largo=prov3.length;
antid=prov1+prov3.substring(apuntador,largo);
break;
case "bor":
antid="";
break;
default:
}
Cookie.write("ids",antid, {duration: 10});

window.document.getElementById("ids").value=antid;
}

function mostrartienda(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
//var referente=document.getElementById("referente").value;
//location.href=referente+'.php?id_tienda='+id;
muestraregistro(id,"tienda");
}

function mostrartipotienda(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
renuevalimpiaestado('PaginaPrincipal.php?pagina=mostrartipotienda&id='+id);
}
function mostrarnoticia(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
muestraregistro(id,"noticia");
}
function mostrartiponoticia(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
var id_tienda=document.getElementById("id_tienda").value;
renuevalimpiaestado('PaginaPrincipal.php?pagina=mostrartiponoticia&id_tiponoticia='+id+'&id_tienda='+id_tienda);
}

function mostrarproducto(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
muestraregistro(id,"producto");
}
function muestraregistro(id,tabla)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
document.getElementById("pantallanegra").style.display="block";
document.getElementById("mostrador").style.top="25%"; 
document.getElementById("mostrador").style.left="15%";
document.getElementById("mostrador").style.display="block";
document.getElementById("datosmostrador").innerHTML="Cargando...";
document.getElementById("esperando").style.display="none";
var referente=document.getElementById("referente").value;
new Fx.Tween('contenidototal').start('opacity', 1, 0.3);
str='PaginaPrincipal.php?pagina=muestraregistro&tabla='+tabla+'&id='+id+'&referente='+referente;
new Request.HTML({
	url: '/'+str,
	method: 'get',
	update: 'datosmostrador',
	evalScripts: true, 
	onComplete: function(){

}
}).send();







}
function mostrartipoproducto(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
var id_tienda=document.getElementById("id_tienda").value;
renuevalimpiaestado('PaginaPrincipal.php?pagina=mostrartipoproducto&id_tipoproducto='+id+'&id_tienda='+id_tienda);
}
function mostrarsuptipoproducto(id)
{//Esta función nos permite personalizar cada pagina poniéndole los datos de la tienda seleccionada
var id_tienda=document.getElementById("id_tienda").value;
renuevalimpiaestado('PaginaPrincipal.php?pagina=mostrarsuptipoproducto&id_suptipoproducto='+id+'&id_tienda='+id_tienda);
}

function siguiente(tabla,accion)
{
	var imagen=document.getElementById("imagen"+tabla).value;
	var alt =document.getElementById("alt"+tabla).value;
	var inicio=document.getElementById("inicio"+tabla).value;
	var cantidad=document.getElementById("cantidad"+tabla).value;
	var fin=document.getElementById("fin"+tabla).value;
var tope=Number(cantidad);
//Recorremos un puesto las imagenes hacia la izquierda 
var i=1;
while (i<tope)
{
var j=i+1;
var texto="img"+tabla+j;
var texto1="img"+tabla+i;

document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
i=i+1;
}
//tomamos el anterior valor al primero para que tome el primer lugar
var texto="label"+tabla+"despues"+inicio;
document.getElementById("inicio"+tabla).value=document.getElementById(texto).value;
//tomamos el siguiente valor al ultimo mostrado para que tome su lugar
var texto="label"+tabla+"despues"+fin;
document.getElementById("fin"+tabla).value=document.getElementById(texto).value;
//Tomamos los valores del siguiente valor a mostrar en la variable id
var id =document.getElementById(texto).value;
var texto="label"+tabla+"despues"+id;
var siguienteid=document.getElementById(texto).value;
if (siguienteid=="0"){
	var texto="label"+tabla+"despues"+fin;
document.getElementById("Siguiente"+tabla).disabled="disable";
	}
document.getElementById("Anterior"+tabla).disabled="";
var texto="label"+tabla+imagen+id;
var img=document.getElementById(texto).value;
var texto="label"+tabla+alt+id;
var nombre=document.getElementById(texto).value;
 document.getElementById("img"+tabla+cantidad).innerHTML="<input id=\u0022"+tabla+imagen+id+"\u0022 name=\u0022imageField\u0022 type=\u0022image\u0022 src=\u0022Imagenes/miniatura/"+img+"\u0022 title=\u0022"+nombre+"\u0022 alt=\u0022"+nombre+"\u0022 align='middle'  onclick=\""+accion+"('"+id+"')\"/>";

	}
	
	
	
	function anterior(tabla,accion)
{
	var imagen=document.getElementById("imagen"+tabla).value;
	var alt =document.getElementById("alt"+tabla).value;
	var inicio=document.getElementById("inicio"+tabla).value;
	var cantidad=document.getElementById("cantidad"+tabla).value;
	var fin=document.getElementById("fin"+tabla).value;
var i=Number(cantidad);
//Recorremos un puesto las imagenes hacia la izquierda 
while (i>=2)
{
var j=i-1;
var texto="img"+tabla+j;
var texto1="img"+tabla+i;

document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
i=i-1;
}
//tomamos el anterior valor al ultimo mostrado para que tome su lugar
var texto="label"+tabla+"antes"+fin;
document.getElementById("fin"+tabla).value=document.getElementById(texto).value;
//tomamos el siguiente valor al primero para que tome el primer lugar
var texto="label"+tabla+"antes"+inicio;
document.getElementById("inicio"+tabla).value=document.getElementById(texto).value;
//Tomamos los valores del anterior valor a mostrar en la variable id
var id =document.getElementById(texto).value;
var texto="label"+tabla+"antes"+id;
var siguienteid=document.getElementById(texto).value;
if (siguienteid=="0"){
	var texto="label"+tabla+"antes"+inicio;
document.getElementById("Anterior"+tabla).disabled="disable";
	}
document.getElementById("Siguiente"+tabla).disabled="";
var texto="label"+tabla+imagen+id;
var img=document.getElementById(texto).value;
var texto="label"+tabla+alt+id;
var nombre=document.getElementById(texto).value;
 document.getElementById("img"+tabla+"1").innerHTML="<input id=\u0022"+tabla+imagen+id+"\u0022 name=\u0022imageField\u0022 type=\u0022image\u0022 src=\u0022Imagenes/miniatura/"+img+"\u0022 title=\u0022"+nombre+"\u0022 alt=\u0022"+nombre+"\u0022 align='middle'  onclick=\""+accion+"('"+id+"')\"/>";

	}
	
	function nuevacookie(nombre,valor,dias){
		var hoy=new Date();
		hoy.setTime(hoy.getTime());
		dias=dias*1000*60*60*24;
		var fechaexpiracion= new Date(hoy.getTime()+dias);
		document.cookie=nombre+"="+valor+"&mfsl;expires="+fechaexpiracion.toGMTString();
		}
		
		function leercookie(nombre)
		{
			var tamanonombre=nombre.length+1;
		var igual=document.cookie.indexOf(nombre+"=")+tamanonombre;
		var largo=document.cookie.length;
		primeraparte=document.cookie.substr(igual,largo);
		var final=primeraparte.indexOf("&mfsl;");
		primeraparte=primeraparte.substr(0,final);
		if(primeraparte==null)
		{
			primeraparte="";}
		return (primeraparte);
			}
			
			
		
function ingresar(texto)
{

renuevalimpiaestado(texto);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}



function seleccioncliente(ids,texto,id,idusuario,operacion)
{
var ids=ids.substring(1,ids.length)+".";
var idsseleccionadas="";
var contador=0;
while (ids.length>0)
{
	var apuntador=ids.indexOf(".");
	var numero=ids.substring(0,apuntador);
	ids=ids.substring(apuntador+1,ids.length);
var seleccionado=document.getElementById(texto+numero).checked;
    if(seleccionado){
          idsseleccionadas=idsseleccionadas+"."+numero;
          contador=contador+1;  

    }
}

         idsseleccionadas=idsseleccionadas.substring(1,idsseleccionadas.length)+".";


renuevalimpiaestado("conexion.php?tipoconsulta=guardargrupocliente&operacion="+operacion+"&cadena="+idsseleccionadas+"&id="+id+"&contador="+contador+"&idusuario="+idusuario);

}
function enviarboletin(id)
{
renuevaestado("conexion.php?tipoconsulta=enviarboletin&id="+id);
}


function validarentero(nombre)
{
var lacantidad=Number(document.getElementById(nombre).value);
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
var devolver=true;
if (isNaN(lacantidad)){
lacantidad="0";
lacantidad=parseInt(lacantidad);
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Debe Ingresar un Número";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

devolver=false;
}
if (lacantidad<0){
lacantidad="";
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Debe Ingresar un Número mayor a cero";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
devolver=false;
}
document.getElementById(nombre).value=lacantidad;
return(devolver); 
}

function validartexto(nombre)
{
var lacantidad=document.getElementById(nombre).value;
var unnum;
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
document.getElementById("espacio"+nombre).innerHTML=""; 
if (lacantidad.length==0){
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="* Requerido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
return(true);
}

function validardescripcionlarga(nombre)
{
var lacantidad=document.getElementById(nombre).value;
var unnum;
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
document.getElementById("espacio"+nombre).innerHTML=""; 
if (lacantidad.length<1){
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="* Requerido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
return(true);
}


function validaremail(nombre)
{
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
var email = document.getElementById(nombre).value;
var filtro=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (email.length == 0 ) {
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="* Requerido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

return(false);
}
if (filtro.test(email))
{ 
return (true);
}
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Ingrese una dirección de correo válida";
return(false);
}

function validardoble(nombre)
{
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
var email = Number(document.getElementById(nombre).value);
var filtro=/[0-9]+(\.[0-9]+)?/;
if (isNaN(email)){
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Número inválido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

}else{
return(true);
}

if (email.length == 0 ) {
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="* Requerido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

return(false);
}

document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Número inválido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

return(false);
}


function validarnumero(nombre)
{
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
var numero = Number(document.getElementById(nombre).value);
if (isNaN(numero)){
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Número inválido";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 

}else{
return(true);
}
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Datos no válidos";
return(false);
}

function esDigito(digito){
var codigo = digito.charCodeAt(0);
return ((codigo > 47) && (codigo < 58));
}

function valSep(fecha){
var bOk = false;
bOk = bOk || ((fecha.charAt(4) == "-") && (fecha.charAt(7) == "-"));
bOk = bOk || ((fecha.charAt(4) == "/") && (fecha.charAt(7) == "/"));
bOk = bOk || ((fecha.charAt(4) == ":") && (fecha.charAt(7) == ":"));
return bOk;
}

function finMes(oTxt){
var nMes = parseInt(oTxt.substr(5, 2), 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; break;
case 3: nRes = 31; break;
case 4: nRes = 30; break;
case 5: nRes = 31; break;
case 6: nRes = 30; break;
case 7: nRes = 31; break;
case 8: nRes = 31; break;
case 9: nRes = 30; break;
case 10: nRes = 31; break;
case 11: nRes = 30; break;
case 12: nRes = 31; break;
}
return nRes;
}

function valDia(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.substr(8, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.substr(5, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt.substr(0,4);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

function validarfecha(nombre){
///Código obtenido de http://www.cssboulevar.com.ar/codigos/?id=124
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
var fecha = document.getElementById(nombre).value;
var valido = true;
if (fecha.value != ""){
valido = valido && (valAno(fecha));
valido = valido && (valMes(fecha));
valido = valido && (valDia(fecha));
valido = valido && (valSep(fecha));
document.getElementById(nombre).value=fecha;
if (!valido){
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Fecha no válida";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
}
return(true);
}

function validarlink(nombre)
{
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
var link = document.getElementById(nombre).value;
var filtro=/^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)( [a-zA-Z0-9\-\.\?\,\’\/\\\+&%\$#_]*)?$/;
if (link.length == 0 ) {
document.getElementById(nombre).value="N/A";
return(true);
}
if (filtro.test(link))
{ 
return (true);
}
if (link=="N/A")
{ 
return (true);
}
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Link no válido. En caso de no tenerlo, dejar el espacio en blanco";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
function validarcontrasena(nombre, comprobacion)
{
document.getElementById("espacio"+nombre).innerHTML=""; 
document.getElementById(nombre).style.backgroundColor="rgb(256,256,256)";
document.getElementById(comprobacion).style.backgroundColor="rgb(256,256,256)";
var link = document.getElementById(nombre).value;
var filtro=/( [a-zA-Z0-9\-\.\?\,\’\/\\\+&%\$#_]*)?$/;
if ((link.length>5 )&&(link.length<11 )) {
if (filtro.test(link))
{ 
var comprob=document.getElementById(comprobacion).value;
if (link==comprob)
{ 
return (true);
}else if (comprob=="")
{ 
document.getElementById(comprobacion).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Re ingresar contraseña para comprobación.";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}else 
{ 
document.getElementById(comprobacion).style.backgroundColor="rgb(256,0,0)";
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Contraseña ingresada no coincide";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
}else 
{ 
document.getElementById(comprobacion).style.backgroundColor="rgb(256,0,0)";
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Caracteres no válidos.";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}
}else 
{ 
document.getElementById(comprobacion).style.backgroundColor="rgb(256,0,0)";
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Contraseña debe contener entre 6 y 10 caracteres.";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);
}

document.getElementById(comprobacion).style.backgroundColor="rgb(256,0,0)";
document.getElementById(nombre).style.backgroundColor="rgb(256,0,0)";
document.getElementById("espacio"+nombre).innerHTML="Contraseña no válida";
document.getElementById("espacio"+nombre).style.color="rgb(256,0,0)"; 
return(false);



}


	function ordenarCarrito()
	{

<!--la funcion vaciarCarrito(), como su nombre lo indica, quita los objetos que han sido seleccionados para el carrito de compras, lo deja vacío y el total=0.
if (confirm("Acepta realizar el pedido de los productos y cantidades contenidos en el carro de Compras")) { 
var ids=document.getElementById('ids').value;
renuevalimpiaestado("conexion.php?tipoconsulta=crearpedido&valores="+ids);
document.getElementById('estado').innerHTML=document.getElementById('espaciocarrito').innerHTML;
vaciarCarrito();

}
		}

function mostrarcontenidovitrina(tabla,id,nombre,descripcion,imagen){
document.getElementById("fotovitrina").src='';
document.getElementById("titulovitrina").innerHTML=nombre;
document.getElementById("descvitrina").innerHTML=descripcion;
document.getElementById("fotovitrina").alt=nombre;
document.getElementById("fotovitrina").title=nombre;
document.getElementById("fotovitrina").src='Imagenes/'+imagen;
redimensionar2('Imagenes/'+imagen);
$clear(varvitrina2);
if (document.getElementById("fotovitrina").src!='Imagenes/'+imagen)
	varvitrina2= redimensionar2.periodical(500, null, $('Imagenes/'+imagen)); 	
} 


function mostrarlogovitrina(imagen,nombre,descripcion){
mostrarcontenidovitrina("","",nombre,descripcion,imagen)
}
 
function mostrarpedido(id){
renuevalimpiaestado("cliente.php?accion=mostrarpedido&id_pedido="+id);
}
function mostrarpedidotienda(id){
renuevalimpiaestado("ATienda.php?pagina=mostrarpedido&id_pedido="+id);
}
function cambiarestado(id){
renuevalimpiaestado("ATienda.php?pagina=cambiarestado&id_prodpedido="+id);
}
 
function enviarmensaje(emisor,receptor)
{
renuevalimpiaestado("main.php?pagina=enviarmensaje&emisor="+emisor+"&receptor="+receptor);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}
function ACCenviarmensajetienda(tienda)
{
renuevalimpiaestado("ACC.php?pagina=enviarmensajetienda&tienda="+tienda);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}
function ACCenviarmensajecliente(tienda)
{
renuevalimpiaestado("ACC.php?pagina=enviarmensajecliente&cliente="+tienda);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}
function clienteenviarmensajetienda(tienda)
{
renuevalimpiaestado("cliente.php?accion=enviarmensajetienda&tienda="+tienda);
<!-- var errores=document.getElementById("errores").value;

<!-- document.getElementById("estado").innerHTML="" ;
}
function ATiendaenviarmensajecliente(tienda)
{
renuevalimpiaestado("ATienda.php?pagina=enviarmensajecliente&cliente="+tienda);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}
function clienteenviarmensajeadministrador(tienda)
{
renuevalimpiaestado("cliente.php?accion=enviarmensajeadministrador&cliente="+tienda);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}
function ATiendaenviarmensajeadministrador(tienda)
{
renuevalimpiaestado("ATienda.php?pagina=enviarmensajeadministrador&tienda="+tienda);
<!-- var errores=document.getElementById("errores").value;
<!-- document.getElementById("estado").innerHTML="" ;
}

function siguientenot(tabla,accion,valor)
{
new Fx.Tween('noticiavalidasanimadas',{duration:500,link: 'chain'}).start('opacity', 1, 0.3).start('opacity', 0.3, 1);
	var imagen=document.getElementById("imagen"+tabla).value;
	var alt =document.getElementById("alt"+tabla).value;
	var desc =document.getElementById("desc"+tabla).value;
	var tipo =document.getElementById("tipo"+tabla).value;
	var tienda =document.getElementById("tienda"+tabla).value;
var texto="inicio"+tabla;
	var inicio=Number(document.getElementById(texto).value);
if(inicio==0)
{
inicio=valor;
}else{
valor=inicio;
}
	var cantidad=document.getElementById("cantidad"+tabla).value;
	var fin=document.getElementById("fin"+tabla).value;
var tope=Number(cantidad);
var textoinicio="label"+tabla+"despues"+valor;
//Recorremos un puesto las imagenes hacia la izquierda 
var i=1;
while (i<tope)
{
var j=i+1;
var texto="img"+tabla+j;
var texto1="img"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
var texto="nom"+tabla+j;
var texto1="nom"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
var texto="desc"+tabla+j;
var texto1="desc"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
var texto="tipo"+tabla+j;
var texto1="tipo"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
var texto="tienda"+tabla+j;
var texto1="tienda"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;

i=i+1;
}
//tomamos el anterior valor al primero para que tome el primer lugar
texto="inicio"+tabla;
document.getElementById(texto).value=document.getElementById(textoinicio).value;
//tomamos el siguiente valor al ultimo mostrado para que tome su lugar
var texto="label"+tabla+"despues"+valor;
document.getElementById("fin"+tabla).value=document.getElementById(texto).value;
//Tomamos los valores del siguiente valor a mostrar en la variable id
var id =document.getElementById(texto).value;
var texto="label"+tabla+"despues"+id;
var siguienteid=document.getElementById(texto).value;
if (siguienteid=="0"){
	var texto="label"+tabla+"despues"+fin;
document.getElementById("Siguiente"+tabla).disabled="disabled";
variable=0;
	}
document.getElementById("Anterior"+tabla).disabled="";
var texto="label"+imagen+id;
var img=document.getElementById(texto).value;
texto="label"+alt+id;
texto=document.getElementById("label"+alt+id).value;
var texto2="nom"+tabla+cantidad;
document.getElementById(texto2).innerHTML=texto;

texto=document.getElementById("label"+desc+id).value;
var texto2="desc"+tabla+cantidad;
document.getElementById(texto2).innerHTML=texto;

texto=document.getElementById("label"+tipo+id).value;
var texto2="tipo"+tabla+cantidad;
document.getElementById(texto2).innerHTML=texto;

texto=document.getElementById("labeltienda"+id).value;
var texto2="tienda"+tabla+cantidad;
document.getElementById(texto2).innerHTML=texto;

var texto="label"+alt+id;
var nombre=document.getElementById(texto).value;
 document.getElementById("img"+tabla+cantidad).innerHTML="<input id=\u0022"+imagen+id+"\u0022 name=\u0022imageField\u0022 type=\u0022image\u0022 src=\u0022Imagenes/miniatura/"+img+"\u0022 title=\u0022"+nombre+"\u0022 align='middle' style='margin-top:10px;' onclick=\""+accion+"('"+id+"')\"/>";
	}
	
	
	
	function anteriornot(tabla,accion,valor)
{
new Fx.Tween('noticiavalidasanimadas',{duration:500,link: 'chain'}).start('opacity', 1, 0.3).start('opacity', 0.3, 1);
var imagen=document.getElementById("imagen"+tabla).value;
	var alt =document.getElementById("alt"+tabla).value;
	var inicio=document.getElementById("inicio"+tabla).value;
	var cantidad=document.getElementById("cantidad"+tabla).value;
	var tipo=document.getElementById("tipo"+tabla).value;
	var tienda=document.getElementById("tienda"+tabla).value;
	var fin=document.getElementById("fin"+tabla).value;
var i=Number(cantidad);
//Recorremos un puesto las imagenes hacia la izquierda 
while (i>=2)
{
var j=i-1;
var texto="img"+tabla+j;
var texto1="img"+tabla+i;
document.getElementById(texto1).innerHTML=document.getElementById(texto).innerHTML;
i=i-1;
}
//tomamos el anterior valor al ultimo mostrado para que tome su lugar
var texto="label"+tabla+"antes"+fin;
document.getElementById("fin"+tabla).value=document.getElementById(texto).value;
//tomamos el siguiente valor al primero para que tome el primer lugar
var texto="label"+tabla+"antes"+inicio;
document.getElementById("inicio"+tabla).value=document.getElementById(texto).value;
//Tomamos los valores del anterior valor a mostrar en la variable id
var id =document.getElementById(texto).value;
var texto="label"+tabla+"antes"+id;
var siguienteid=document.getElementById(texto).value;
if (siguienteid=="0"){
	var texto="label"+tabla+"antes"+inicio;
document.getElementById("Anterior"+tabla).disabled="disabled";
variable=1;
	}
document.getElementById("Siguiente"+tabla).disabled="";
var texto="label"+imagen+id;
var img=document.getElementById(texto).value;
var texto="label"+alt+id;
var nombre=document.getElementById(texto).value;
 document.getElementById("img"+tabla+"1").innerHTML="<input id=\u0022"+imagen+id+"\u0022 name=\u0022imageField\u0022 type=\u0022image\u0022 src=\u0022Imagenes/miniatura/"+img+"\u0022  style='margin-top:10px;' title=\u0022"+nombre+"\u0022 align='middle' onclick=\""+accion+"('"+id+"')\"/>";
document.getElementById("nom"+tabla+"1").innerHTML=nombre;
	var desc =document.getElementById("desc"+tabla).value;
var nombre=document.getElementById("label"+desc+id).value;
document.getElementById("desc"+tabla+"1").innerHTML=nombre;
	var tipo =document.getElementById("tipo"+tabla).value;
var tipo2=document.getElementById("label"+tipo+id).value;
document.getElementById("tipo"+tabla+"1").innerHTML=tipo2;
	var tienda =document.getElementById("tienda"+tabla).value;
var tipo2=document.getElementById("label"+tienda+id).value;
document.getElementById("tienda"+tabla+"1").innerHTML=tipo2;


	}
	
	
	
function movernoticia(espacio)
{
siguientenot('noticiavalida','mostrarnoticia',1);
/*
 if (($("Anteriornoticiavalida").get('disabled'))&&($(Siguientenoticiavalida).get('disabled')))
{
}else if ((variable==1))
{
siguientenot('noticiavalida','mostrarnoticia',1);
}else{
anteriornot('noticiavalida','mostrarnoticia',1);
}
*/
}

function cambiarencabezado(espacio)
{
if (document.getElementById('apuntadorbanner').value==null)
{
var apuntador=1;
}else
{
var apuntador=document.getElementById('apuntadorbanner').value;
}
var imagenApuntador='url(Imagenes/'+document.getElementById('labelencabezado'+apuntador).value+')';
var nombreApuntador=document.getElementById('labelnombre'+apuntador).value;
var siguienteApuntador=document.getElementById('labelsiguiente'+apuntador).value;
$(encabezado).setStyle('backgroundImage',imagenApuntador);
document.getElementById('apuntadorbanner').value=siguienteApuntador;

}

function cerrardiv(objeto)
{
document.getElementById("pantallanegra").style.display="none";
document.getElementById(objeto).style.display="none";
document.getElementById("datosmostrador").innerHTML="Cargando...";
document.getElementById("esperando").style.display="none";
new Fx.Tween('contenidototal').start('opacity', 1);
document.getElementById("contenidototal").style.height="100%";
document.getElementById("estado").style.height="73%";
document.getElementById("enlaces").style.height="73%";
document.getElementById("enlaceder").style.height="73%";
document.getElementById("ccv").style.height="10%";


}
function activarnoticiasanimadas(){
desactivarnoticiasanimadas();
blinker = movernoticia.periodical(9000, null, $('noticiasanimadas')); 

}
function desactivarnoticiasanimadas(){
if (blinker)
$clear(blinker);
}
function ponermenu(lugar,objeto,idsubobjeto){

document.getElementById(lugar).innerHTML="";
document.getElementById(lugar).style.display="block";
document.getElementById(lugar).innerHTML=document.getElementById(idsubobjeto).innerHTML;
new Fx.Reveal($(lugar)).reveal();
new Fx.Move($(lugar), {
  relativeTo: $(objeto),
  position: 'centerLeft',
  edge: 'center'

}).start();

}
function ponermenubarra(lugar,objeto,idsubobjeto,event){
$(lugar).style.display='block';
document.getElementById(lugar).innerHTML="";
document.getElementById(lugar).innerHTML=document.getElementById(idsubobjeto).innerHTML;
document.getElementById(lugar).style.width=$(objeto).getStyle("width");
$(lugar).style.left=event.clientX ;
$(lugar).style.top=event.clientY ;

}

function nocerrar(){
document.getElementById("menuenlaces").style.display="block";
}
function mantener(nombre){
document.getElementById(nombre).style.display="block";
}
function mostrarcarrito(nada){
localizar("Mi Pedido");
var ids=document.getElementById("ids").value;
renuevalimpiaestado("conexion.php?tipoconsulta=mostrarcarrito&ids="+ids);
elcarrito=true;
}

function participar(email,id){

renuevalimpiaestado("main.php?pagina=concurso&id="+id+"&email="+email);
}

function hacercatalogo(nivel,id_nivel,id_tienda,ellike){
renuevalimpiaundiv('main.php?pagina=mostrarcategorias&id_tienda='+id_tienda+'&nivel='+nivel+'&id_nivel='+id_nivel+'&ellike='+ellike,"resbusqueda");
mantenerse=false;
str2='main.php?pagina=productos&id_tienda='+id_tienda+'&nivel='+nivel+'&id_nivel='+id_nivel+'&ellike='+ellike;
renuevalimpiaundiv(str2,"estado");
mantenerse=true;

}

function ajustarimagen(contenedor,dirimagen,imgresultante)
{
var altooriginal=$(contenedor).getHeight();
var anchooriginal=$(contenedor).getWidth();
ajustarimagen2(altooriginal,anchooriginal,dirimagen,imgresultante);
}

function ajustarevitrina(dirimagen,imgresultante)
{
var altooriginal=largoevitrina;
var anchooriginal=anchoevitrina;
ajustarimagen2(altooriginal,anchooriginal,dirimagen,imgresultante);
}
function ajustarfvitrina(dirimagen,imgresultante)
{
var altooriginal=largofvitrina;
var anchooriginal=anchofvitrina;
ajustarimagen2(altooriginal,anchooriginal,dirimagen,imgresultante);
}


function ajustarimagen2(altooriginal,anchooriginal,dirimagen,imgresultante)
{
$(imgresultante).lowsrc="Imagenes/cargando.php";

var altooriginal2=altooriginal;
var anchooriginal2=anchooriginal;

var newImg1 = new Image();
newImg1.src = dirimagen;
var largo = newImg1.height;
var ancho = newImg1.width;
var ancho1=anchooriginal;
var largo1=(ancho1*largo)/ancho;
var largo2=altooriginal;
var ancho2=(largo2*ancho)/largo;
if ((ancho1<=anchooriginal)&&(largo1<=altooriginal))
{
$(imgresultante).style.width=ancho1+"px";
$(imgresultante).style.height=largo1+"px";
}
else
{
$(imgresultante).style.width=ancho2+"px";
$(imgresultante).style.height=largo2+"px";
if (altooriginal==0)
{
$(imgresultante).style.width="100%";
$(imgresultante).style.height="100%";
}

}
}
function ajustarfigura(contenedor,imgresultante)
{
var altooriginal=$(contenedor).getHeight();
var anchooriginal=$(contenedor).getWidth();

$(imgresultante).style.width=anchooriginal+"px";
$(imgresultante).style.height=altooriginal+"px";

}

function mostrarenladiv(str)
{//Esta función muestra los datos de la i de pedido
document.getElementById("pantallanegra").style.display="block";
document.getElementById("mostrador").style.top="25%"; 
document.getElementById("mostrador").style.left="15%";
document.getElementById("mostrador").style.display="block";
document.getElementById("datosmostrador").innerHTML="Cargando...";
document.getElementById("esperando").style.display="none";
var referente=document.getElementById("referente").value;
new Fx.Tween('contenidototal').start('opacity', 1, 0.3);
new Request.HTML({
	url: '/'+str,
	method: 'get',
	update: 'datosmostrador',
	evalScripts: true, 
	onComplete: function(){

}
}).send();

}
function esenter(e) {
  tecla = (document.all) ? e.keyCode : e.which;
  if (tecla==13) return (true);
else return (false);
}
