function RefrescaSesion()
{	document.getElementById("froculta").src = 'refresca.asp';
	setTimeout("RefrescaSesion()","60000");
}

function WindowOpenCentrado(url, name, param,w, h, perc) 
{	var winX = (screen.availWidth - w)*perc*.01;
	var winY = (screen.availHeight - h)*perc*.01;
	popupWin = window.open(url, name, 'width=' + w + ',height=' + h +',left=' + winX + ',top=' + winY + ','+param);
}

function EnviarBusqueda()
{	if (document.getElementById('Buscar').value=='')
	{	alert('Informe la palabra de búsqueda');
		document.getElementById('Buscar').focus();
		return false;
	}
	else//resultados.asp
   	{	self.parent.location.href='Productos.asp?PC='+document.getElementById('Buscar').value ;return false;	}
}	

function EnviarContacto()
{	if (document.getElementById("contacto").value=="")
	{	alert("Informe el nombre completo.");
		document.getElementById("contacto").focus();
		return false;
	}
	document.FormularioC.submit();
}

function Tecla_(Campo,funcion)
{	if (self.event.keyCode == 13 )
	{	self.event.keyCode = 9;
		if (self.event.srcElement.name == Campo)
		{	if (funcion=='EnviarBusqueda')
			{	EnviarBusqueda();	}			
		}
	}	
}

function EnvioDetalle(CFr,CF,CSF,CTP,CA,CAs,Parametros)
{	document.getElementById('CFr').value = CFr;
	document.getElementById('CF').value = CF;
	document.getElementById('CSF').value = CSF;
	document.getElementById('CTP').value = CTP;
	document.getElementById('CA').value = CA;
	document.getElementById('CAs').value = CAs;	
	document.getElementById('Parametros').value = Parametros;	
	
	document.FormularioProductos.submit();
}

function EnviarMasInfo()
{	if (document.getElementById('contacto').value=='')
	{	alert('Informe el nombre completo');
		document.getElementById('contacto').focus();
		return false;
	}
	if (document.getElementById('comentarios').value=='')
	{	alert('Informe el campo comentarios');
		document.getElementById('comentarios').focus();
		return false;
	}
	document.FormularioMasInfo.submit();
}

function EnviarPass()
{	if (document.getElementById('PassActual').value=='')
	{	alert('Informe la clave de acesso actual');
		document.getElementById('PassActual').focus();
		return false;
	}
	if (document.getElementById('PassNuevo').value=='')
	{	alert('Informe la nueva clave de acesso');
		document.getElementById('PassNuevo').focus();
		return false;
	}
	if (document.getElementById('PassRepetir').value=='')
	{	alert('Repita la nueva clave de acesso');
		document.getElementById('PassRepetir').focus();
		return false;
	}
	
	if (document.getElementById('PassNuevo').value != document.getElementById('PassRepetir').value )
	{	alert('La nueva clave de acceso no coincide');
		document.getElementById('PassRepetir').focus();
		return false;
	}
	
	
	document.FormularioPass.submit();
}

function EnviarNumFactura()
{	if (document.getElementById('NumFactura').value=='')
	{	alert('Informe el número de factura');
		document.getElementById('NumFactura').focus();
		return false;
	}
	document.FormularioNumFactura.submit();
}

function EnviarPedido2()
{	
	if ((document.getElementById('CodigoTransportista').value!='5') && (document.getElementById('CodigoTransportista').value!='6'))
	{	if (document.FormularioPedido2.envio[0].checked)
		{	document.FormularioPedido2.submit();	}	
		else
		{	if (document.getElementById('empresa').value=='')
			{	alert('Informe la empresa');
				document.getElementById('empresa').focus();
				return false;
			}
			if (document.getElementById('contacto').value=='')
			{	alert('Informe el nombre completo');
				document.getElementById('contacto').focus();
				return false;
			}
			if (document.getElementById('direccion').value=='')
			{	alert('Informe la dirección completa');
				document.getElementById('direccion').focus();
				return false;
			}
			if (document.getElementById('cp').value=='')
			{	alert('Informe el código postal');
				document.getElementById('cp').focus();
				return false;
			}
			if (document.getElementById('poblacion').value=='')
			{	alert('Informe la población');
				document.getElementById('poblacion').focus();
				return false;
			}
			if (document.getElementById('telefono').value=='')
			{	alert('Informe el teléfono / fax');
				document.getElementById('telefono').focus();
				return false;
			}
			document.FormularioPedido2.submit();
		}
	}
	else
	{	document.FormularioPedido2.submit();	}
}

function DevolverProductosSeleccionados(cont,Cadena)
{	//alert (Cadena);
	var Valores=""	
	var Valores2=""	
	if (!(document.getElementById("Condiciones").checked)) //Sino esta marcado
	{	alert("Debe leer y aceptar las condiciones de devolución de Desyman");
	}
    else
	{	for (i=0; i<cont; i++)
		{	if (document.getElementById("SelectProducto"+i).checked)
			{	Valores=Valores+i+"|";	//Guardamos los q estan seleccionados
			}
		}	
		
		document.getElementById("Contador").value=Valores;
		document.getElementById("ContadorSeries").value=Cadena;
		document.FormularioDevoluciones.submit();
	}	
}

function DevolverPedidoEntero(cont, Cadena)
{		
	for (j=0; j<cont; j++)
	{	document.getElementById("SelectProducto"+j).checked="true";			
	}
	
	DevolverProductosSeleccionados(cont, Cadena);
}

function RevisarCantidad(obj)
{	
	if (obj.value=="")
	{	alert("Informe un valor."); 
		obj.select();
		obj.focus();
	}
	
	var longi=obj.value.length; 
	var sw="S"; 
	for (x=0; x<longi; x++) 
	{	v1=obj.value.substr(x,1); 
		v2 = parseInt(v1); 
		
		if (isNaN(v2)) 
		{ sw= "N";} 
	} 
	if (sw=="S") 
	{	var number = parseFloat(obj.value);
		if(number<=0)
		{	alert("Informar un valor mayor 0."); 
			obj.select();
			obj.focus();
		}
	} 
	else 
	{	alert("Sólo valores numéricos ..."); 
		obj.select();
		obj.focus();
	}	
	
}