var anterior;

function Cambia_Usuario(nombre)
{
	if (nombre != '')
		window.parent.document.getElementById("Usuario").innerHTML = 'Bienvenido: <a target = "pagina" class="Control" href="Logueo.aspx">' + nombre + "</a>"
	else
	{
		window.parent.document.getElementById("Usuario").innerHTML = '';
		window.parent.frames['pagina'].location.href = 'principal.aspx?UsuarioValido=SI';
	}
}

function PrintThis(id, producto) 
{ 
	var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
	sOption += "scrollbars=yes,width=750,height=500,left=100,top=25";
	var html = window.document.all[id].innerHTML;
	var winprint=window.open("","",sOption); 
	winprint.document.open(); 
	winprint.document.write('<html><HEAD><title>Ficha del Producto: ' + producto + '</title><LINK href="Estilo.css" type="text/css" rel="stylesheet"></HEAD><body><table style="WIDTH: 100%; HEIGHT: 100%" cellSpacing="0" cellPadding="0" border="0"><Tr><td align="center"><IMG src="imagenes/logolehmann.gif"></td></Tr>'); 
	winprint.document.write(html);          
	winprint.document.write('<Tr><Td align="center">LIBRERÍA LEHMANN S.A. Tel. (506) 522-4881 Fax: (506) 233-0713<br>E-Mail: <a href="contacto.aspx">servicio@librerialehman.com</a> Apdo.: 10011-1000 San José, Costa Rica</Td></Tr></table></body></html>'); 
	winprint.document.close(); 
	winprint.focus();
	winprint.print(); 
}

function OpenPopupImage(imageurl, width, height, url) 
{ 
  	var wleft = (screen.width - width) / 2;
  	var wtop = (screen.height - height) / 2;
  
	var sOption="toolbar=no,location=no,directories=no,menubar=no,top=" + wtop + ",left=" + wleft; 
	sOption += "scrollbar=no,width=" + width + ",height=" + height;
	var htmlimg = "<img Style='Position=Absolute; Top: 3px; Left= 3px' src='" + imageurl + "'>";
	
	if(url != '')
	{
		if(url.indexOf('http') == -1)
			url = 'http:\\\\' + url;
				
		htmlimg = "<a target='_blank' href='" + url + "'>" + htmlimg + "</a>";
	}
	
	var winprint=window.open("","popwin",sOption); 
	winprint.document.open(); 
	winprint.document.write('<html><HEAD><title>Publicidad Librerialehmann.com</title><LINK href="Estilo.css" type="text/css" rel="stylesheet"></HEAD><body>'+ htmlimg + '</body></html>'); 
	winprint.document.close(); 
	winprint.focus();
}
		
function MenuSelecciona(menu)
{
	if(anterior != null &&  menu.id == anterior.id)
		return;
		
	window.document.all["der" + menu.id].style.background = "url(Imagenes/cat_der2.gif)";
	window.document.all["cen" + menu.id].style.background = "url(Imagenes/cat_cen2.gif)";
	window.document.all["izq" + menu.id].style.background = "url(Imagenes/cat_izq2.gif)";
	menu.style.font.fontColor = "#ffffff";
	
	if (anterior != null)
	{	
   			window.document.all["der" + anterior.id].style.background = "url(Imagenes/cat_der.gif)";
			window.document.all["cen" + anterior.id].style.background = "url(Imagenes/cat_cen.gif)";
			window.document.all["izq" + anterior.id].style.background = "url(Imagenes/cat_izq.gif)";
  			anterior.style.font.fontColor = "Red";
	}
  	

  	if ((menu.innerText == "Todas ") || (menu.innerText == "  "))
  		window.document.getElementById("TituloCategoria").innerText = "Catálogo Virtual"
	else  				
	  	window.document.getElementById("TituloCategoria").innerText = menu.innerText;    

	window.frames['menu'].location.href = "menu.aspx?padre=" + menu.id + "&padre_nombre=" + ((menu.id=='0')?"Todas las Categorías":menu.name);

	anterior = menu;
}


function Buscar_Articulo()
{
	if (window.document.getElementById("textobuscar").value.length > 2)
	{
  		window.frames['pagina'].location.href = "Listar_Articulos.aspx?buscar=SI&tipo=" + window.document.getElementById("combo_busqueda").selectedIndex + "&campo=" + window.document.getElementById("combo_busqueda").options[window.document.getElementById("combo_busqueda").selectedIndex].value  + "&texto=" + window.document.getElementById("textobuscar").value; 
  		window.document.getElementById("textobuscar").focus;
  	}
}	

//document.oncontextmenu = function() { return false; }
//document.onmousedown = function() { return false; }