var display_url=0
var Apagar=0;
var posInicialLeft = 0;
var arrIndex=0;
function MostrarRightClickPopup(Id)
{
	Datos.hidId.value=Id;
	posInicialLeft=document.body.scrollLeft+event.clientX+150;
	ie5menuXP.style.left=document.body.scrollLeft+event.clientX;
	ie5menuXP.style.top=document.body.scrollTop+event.clientY;
	ie5menuXP.style.visibility="visible";
	return false;
}
function noshowmenuie5()
{
	return false;
}

function MostrarRightClickPopupNombre(Id, Cod, nombre, ListaPrecio, Bonificacion, Discrimina, Iva1)
{
	Datos.hidId.value=Cod;
	Datos.hRazonSocial.value=nombre;
	Datos.hListaPrecio.value=ListaPrecio;
	Datos.hBonificacion.value=Bonificacion;
	Datos.hDiscrimina.value=Discrimina;
	Datos.hIva1.value=Iva1;
	posInicialLeft=document.body.scrollLeft+event.clientX+150;
	ie5menuXP.style.left=document.body.scrollLeft+event.clientX;
	ie5menuXP.style.top=document.body.scrollTop+event.clientY;
	ie5menuXP.style.visibility="visible";
	return false;
}

function MostrarRightClickPopupTipo(Id, tipo)
{
	Datos.hidId.value=Id;
	Datos.hTipo.value=tipo;
	posInicialLeft=document.body.scrollLeft+event.clientX+150;
	ie5menuXP.style.left=document.body.scrollLeft+event.clientX;
	ie5menuXP.style.top=document.body.scrollTop+event.clientY;
	ie5menuXP.style.visibility="visible";
	return false;
}

function hidemenuie5()
{
	ie5menuXP.style.visibility="hidden";
	//document.getElementById("lnkFichas").style.backgroundColor="";
	Apagar=0;
}

function highlightie5()
{
		if (event.srcElement.className=="menuitems" || event.srcElement.className=="menuitems2" || event.srcElement.className=="menuitems3")
		{
			var Nombre = "ico" + event.srcElement.id.substring(3);
			if(event.srcElement.id.substring(0,3)=="ico" || event.srcElement.id.substring(0,3)=="fnt" || event.srcElement.id.substring(0,3)=="lbb" || event.srcElement.id.substring(0,3)=="lbl")
			{
				Nombre = "lnk" + event.srcElement.id.substring(3);
				if(!document.getElementById(Nombre))
					Nombre = event.srcElement.id;

				document.getElementById(Nombre).style.backgroundColor="#ffeec2";
			}
			else
			{
				event.srcElement.style.backgroundColor="#ffeec2"
			}
			if(event.srcElement.id.substring(3)=="Fichas" && Apagar==0)
			{
				Apagar=1;
				MostrarPopupFichas();			
			}
			else if(event.srcElement.id.substring(3)=="Editar" || event.srcElement.id.substring(3)=="Eliminar" || event.srcElement.id.substring(3)=="Nueva")
			{
				Apagar=0;
				//document.getElementById("lnkFichas").style.backgroundColor="";
			}

			if (display_url==1)
				window.status=event.srcElement.url;
		}
}

function lowlightie5()
{
	if(event.srcElement.id.substring(3)=="Fichas" && Apagar==1)
	{
		//Significa que he desplegado el popup de fichas por lo tanto
		//el items debe continuar iluminado
	}
	else
	{
		if (event.srcElement.className=="menuitems" || event.srcElement.className=="menuitems2" || event.srcElement.className=="menuitems3")
		{
			var Nombre = "ico" + event.srcElement.id.substring(3);
			if(event.srcElement.id.substring(0,3)=="ico" || event.srcElement.id.substring(0,3)=="fnt" || event.srcElement.id.substring(0,3)=="lbb" || event.srcElement.id.substring(0,3)=="lbl")
			{
				Nombre = "lnk" + event.srcElement.id.substring(3);
				if(!document.getElementById(Nombre))
					Nombre = event.srcElement.id;
				document.getElementById(Nombre).style.backgroundColor="";
    		}
			else
			{
    			event.srcElement.style.backgroundColor="";
    		}
			window.status='';
		}
	}
}

function jumptoie5()
{
}
function MostrarPopupFichas()			
{
    document.getElementById("lnkFichas").style.backgroundColor="#ffeec2";
	ie5menu.style.left=posInicialLeft;
	ie5menu.style.top=document.body.scrollTop+event.clientY;
	document.getElementById("ie5menu").style.visibility="visible";
}
			
var filaAnterior = new Object();
//function seleccionar(backColor,textColor)
function seleccionar(id)
{
	cel = eval('id'+ id);
	if(filaAnterior.id != null)
		filaAnterior.style.backgroundColor = colorAnterior;

	colorAnterior = cel.style.backgroundColor;
	filaAnterior = cel;
	cel.style.backgroundColor = "#FFE168";
	Datos.hidId.value = id;
}

function seleccionarNombre(id, Cod,  nombre, ListaPrecio, Bonificacion, Discrimina, Iva1)
{
	cel = eval('id'+ id);
	if(filaAnterior.id != null)
		filaAnterior.style.backgroundColor = colorAnterior;

	colorAnterior = cel.style.backgroundColor;
	filaAnterior = cel;
	cel.style.backgroundColor = "#FFE168";
	Datos.hidId.value = Cod;
	Datos.hRazonSocial.value=nombre;
	Datos.hListaPrecio.value=ListaPrecio;
	Datos.hBonificacion.value=Bonificacion;
	Datos.hDiscrimina.value=Discrimina;
	Datos.hIva1.value=Iva1;
	
	
}
	
function seleccionarTipo(id, tipo)
{
	cel = eval('id'+ id);
	if(filaAnterior.id != null)
		filaAnterior.style.backgroundColor = colorAnterior;

	colorAnterior = cel.style.backgroundColor;
	filaAnterior = cel;
	cel.style.backgroundColor = "#FFE168";
	Datos.hidId.value = id;
	Datos.hTipo.value=tipo;
}

function seleccionarIdCount(id, count)
{
	cel = eval('id'+ count);
	if(filaAnterior.id != null)
		filaAnterior.style.backgroundColor = colorAnterior;

	colorAnterior = cel.style.backgroundColor;
	filaAnterior = cel;
	cel.style.backgroundColor = "#FFE168";
	Datos.hidId.value = id;
}

function popup(url,epi,barra,scroll,w,h) {
	vent=window.open(url,'Recomendar','screenx=0,screeny=0,toolbar=' + barra + ',width=' + w + ',height='+ h + ',directories=no,status=no,scrollbars=' + scroll + ',resize=no,menubar=no');vent.focus();
}

function popupCarro(articulo) {
	var url='/Modules/View/Subir.aspx?codproducto=' + articulo;
	var w=300;
	var h=150;
	var epi='no';
	var barra='no';
	var scroll='no';
	vent=window.open(url,'','screenx=0,screeny=0,toolbar=' + barra + ',width=' + w + ',height='+ h + ',directories=no,status=no,scrollbars=' + scroll + ',resize=no,menubar=no');
	vent.focus();
}

function popupVerProducto(articulo) {
	var url='/Modules/View/VerProducto.aspx?codproducto=' + articulo;
	var w=605;
	var h=450;
	var epi='no';
	var barra='no';
	var scroll='yes';
	vent=window.open(url,'','screenx=0,screeny=0,toolbar=' + barra + ',width=' + w + ',height='+ h + ',directories=no,status=no,scrollbars=' + scroll + ',resize=no,menubar=no');
	vent.focus();
}

function popupVerProductoweb(articulo) {
	var url='/web/VerProductoweb.aspx?codproducto=' + articulo;
	var w=605;
	var h=450;
	var epi='no';
	var barra='no';
	var scroll='yes';
	vent=window.open(url,'','screenx=0,screeny=0,toolbar=' + barra + ',width=' + w + ',height='+ h + ',directories=no,status=no,scrollbars=' + scroll + ',resize=no,menubar=no');
	vent.focus();
}

function ActionsPaneCollapse_OnClick()
{
  if (event.keyCode == 0 || event.keyCode == 13) {
    idActionsPane.style.display = "none";
    idActionsTable.style.display = "none";
    idActionsPaneCollapsed.style.display = "";
    idActPaneExpandArrow.style.display = "";
    idActPaneExpandArrow.focus();
  }
}


function ActionsPaneExpand_OnClick()
{
  if (event.keyCode == 0 || event.keyCode == 13) {
    idActionsPane.style.display = "";
    idActionsTable.style.display = "";
    idActionsPaneCollapsed.style.display = "none";
    idActPaneExpandArrow.style.display = "none";
    idActPaneCollapseArrow.focus();
  }
}


function expandir(dato,name)
		{
			var texto;
			texto = eval(dato);
//			if (texto.style.display == 'none'){texto.style.display = 'list-item';}
//			else {texto.style.display = 'none';}

			if (texto.style.display == 'none')
			{
				texto.style.display = 'list-item';
				if(dato == "Item1")
					ToggleImg(name, 'filtro_over.gif');
				if(dato == "Item2")
					ToggleImg(name, 'busqueda_small_over.gif');

			}

			else
			{
				texto.style.display = "none";
				if(dato == "Item1")
					ToggleImg(name, 'filtro_on.gif');
				if(dato == "Item2")
					ToggleImg(name, 'busqueda_small_on.gif');

			}

  
		}
		function ToggleImg(name, src)
		{
			name.src = "/img/" + src;
		}

		
		function cargar(dato)
		{
			var texto;
			long = dato.length;
			posinicio = 0;
			poscoma = dato.indexOf(",");
			while (poscoma != -1)
			{
				texto = eval(dato.substring(posinicio, poscoma));
				texto.style.display = "none";
				dato = dato.substr(poscoma + 1, long);
				poscoma = dato.indexOf(",");
			}
		}

document.oncontextmenu=noshowmenuie5;
//if (document.all&&window.print)
  // document.body.onclick=hidemenuie5();


function popup(url,barra,scroll,w,h) 
{
	vent=window.open(url,'','screenx=0,screeny=0,toolbar=' + barra + ',width=' + w + ',height=' + h +',directories=no,status=no,scrollbars=' + scroll + ',resize=yes,menubar=no,top=150,left=200');
	vent.focus();
}


function ActionsPaneCollapse_OnClick()
{
  if (event.keyCode == 0 || event.keyCode == 13) {
    idActionsPane.style.display = "none";
    idActionsTable.style.display = "none";
    idActionsPaneCollapsed.style.display = "";
    idActPaneExpandArrow.style.display = "";
    idActPaneExpandArrow.focus();
  }
}


function ActionsPaneExpand_OnClick()
{
  if (event.keyCode == 0 || event.keyCode == 13) {
    idActionsPane.style.display = "";
    idActionsTable.style.display = "";
    idActionsPaneCollapsed.style.display = "none";
    idActPaneExpandArrow.style.display = "none";
    idActPaneCollapseArrow.focus();
  }
}


function expandir(dato,name)
		{
			var texto;
			texto = eval(dato);
//			if (texto.style.display == 'none'){texto.style.display = 'list-item';}
//			else {texto.style.display = 'none';}

			if (texto.style.display == 'none')
			{
				texto.style.display = 'list-item';
				if(dato == "Item1")
					ToggleImg(name, 'filtro_over.gif');
				if(dato == "Item2")
					ToggleImg(name, 'busqueda_over.gif');

			}

			else
			{
				texto.style.display = "none";
				if(dato == "Item1")
					ToggleImg(name, 'filtro_on.gif');
				if(dato == "Item2")
					ToggleImg(name, 'busqueda_on.gif');

			}

  
		}
		function ToggleImg(name, src)
		{
			name.src = "/img/" + src;
		}

		
		function cargar(dato)
		{
			var texto;
			long = dato.length;
			posinicio = 0;
			poscoma = dato.indexOf(",");
			while (poscoma != -1)
			{
				texto = eval(dato.substring(posinicio, poscoma));
				texto.style.display = "none";
				dato = dato.substr(poscoma + 1, long);
				poscoma = dato.indexOf(",");
			}
		}

function ventana(url,name,propiedades) {
	window.open(url,name,propiedades); 
}

function fechaactual() {
	var mydate=new Date();
	var year=mydate.getYear();
	if (year < 1000)
		year+=1900;
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();
	if (daym<10)
		daym="0"+daym;

	var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sábado");
	var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	document.write(dayarray[day] + " " + daym + " de " + montharray[month] + " de " + year);
}

function fechaactualParam(dia, mes, ano) {
	var mydate=new Date(ano,mes-1,dia);
	var year= ano;
	var day=mydate.getDay();
	var month=mes-1;
	var daym=dia;
	if (daym<10)
		daym="0"+daym;

	var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sábado");
	var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	document.write(dayarray[day] + " " + daym + " de " + montharray[month] + " de " + year);
}
