/*
PROGRAMADO POR Caucana Tecnología, S.L.
para LOS REMEDIOS DE CHABELA
20-02-2009
*/
var ajax_cesta_detalle_anadir;
var ajax_cesta_detalle_anadir_restar;
var ajax_te_faltan;
var ajax_cerrar_pedido;
var ajax_gastos_envio;

//function bajar()
//{
//	//document.getElementById('carruso').behavior ='down';
//	document.getElementById('carruso').scrollAmount ='5';
//}
function acepto_condiciones_contrato(url)
{
x=confirm('¿Acepta las Condiciones de contratación?');
		if (x==true)
		{
			voy(url);
		}
		else
		{
			
		}
}

function modificar_gastos_envio(idcesta,total)
{
			var ajax				=	ajax_gastos_envio;
			ajax					=	GetXmlHttpObject();
			idzon					=	document.getElementById("idzona").value;			
			
			var url="ajax/ajax_paso1_gastos_de_envio.php";
			url=url+"?idcesta="+idcesta+"&idzona="+idzon+"&total="+total; 
			ajax.onreadystatechange= function() { 
					
					if (ajax.readyState==4)
									{ 	
										cesta_detalle_anadir_restar('0','0');																		
									}
									else
									{
										document.getElementById('div_precio_final').innerHTML="<img src='concalma.gif'>"
									}
													
					}; ; //con esto paso parametros
										
			
						ajax.open("GET",url,true);
						ajax.send(null);

		
}
function telf()
{
	alert('De momento solo vendemos por teléfono.\nLlámanos al 933 866 198.\nPORTES 3€\nDESCUENTO 7% a partir de 30€ de compra\nIVA INCLUIDO')
}


function cesta_detalle_anadir_restar(idcesta_detalle,operacion)
{
	//dado un idcesta_detalle, anadir o restar
	
			var ajax				=	ajax_cesta_detalle_anadir_restar;
			ajax					=	GetXmlHttpObject();
			var url="inc/inc-cesta-compra.php";
			url=url+"?idcesta_detalle="+idcesta_detalle+"&operacion="+operacion+"&ajax=1"; 
			ajax.onreadystatechange= function() { 
					
					if (ajax.readyState==4)
									{ 	
										document.getElementById('cesta_compra_paso1').innerHTML=ajax.responseText;
										
									}
									else
									{
										document.getElementById('div_precio_final').innerHTML="<img src='concalma.gif'>"
									}
													
					}; ; //con esto paso parametros
										
			
						ajax.open("GET",url,true);
						ajax.send(null);
		
}

function anadir_cesta_detalle(idproducto_precio,idproducto)
{

			var ajax				=	ajax_cesta_detalle_anadir;
			ajax					=	GetXmlHttpObject();

			var url="ajax/ajax_anadir_cesta_detalle.php";
			url=url+"?idproducto_precio="+idproducto_precio;
			ajax.onreadystatechange= function() {

					if (ajax.readyState==4)
									{
										document.getElementById('res_anadir_'+idproducto).innerHTML=ajax.responseText;
										modificar_te_faltan();
									}
									else
									{
										document.getElementById('res_anadir_'+idproducto).innerHTML="Añadiendo ...";
										document.getElementById('res_anadir_'+idproducto).style.display="block";
									}

					}; ; //con esto paso parametros


						ajax.open("GET",url,true);
						ajax.send(null);
/*			var ajax				=	ajax_cesta_detalle_anadir;
			ajax					=	GetXmlHttpObject();

			var url="ajax/ajax_anadir_cesta_detalle.php";
			url=url+"?idproducto="+idproducto+"&referencia_cliente="+referencia_cliente+"&idioma="+idioma+"&forzado_precio="+forzado_precio+"&forzado_concepto="+forzado_concepto;
			ajax.onreadystatechange= function() {

					if (ajax.readyState==4)
									{
										document.getElementById('res_anadir_'+idproducto).innerHTML=ajax.responseText;
										modificar_te_faltan();
									}
									else
									{
										document.getElementById('res_anadir_'+idproducto).innerHTML="Añadiendo ...";
										document.getElementById('res_anadir_'+idproducto).style.display="block";
									}

					}; ; //con esto paso parametros


						ajax.open("GET",url,true);
						ajax.send(null);*/



}

/*
function anadir_cesta_detalle(idproducto,referencia_cliente,idioma)
{
			var ajax				=	ajax_cesta_detalle_anadir;
			ajax					=	GetXmlHttpObject();
		
			var url="ajax/ajax_anadir_cesta_detalle.php";
			url=url+"?idproducto="+idproducto+"&referencia_cliente="+referencia_cliente+"&idioma="+idioma; 
			ajax.onreadystatechange= function() { 
					
					if (ajax.readyState==4)
									{ 	
										document.getElementById('res_anadir_'+idproducto).innerHTML=ajax.responseText;
										modificar_te_faltan();
									}
									else
									{
										document.getElementById('res_anadir_'+idproducto).innerHTML="Añadiendo ...";
										document.getElementById('res_anadir_'+idproducto).style.display="block";
									}
													
					}; ; //con esto paso parametros
										
			
						ajax.open("GET",url,true);
						ajax.send(null);

	
		
}
*/
function modificar_te_faltan()
	{
		//esto es una modificación doble
			var ajax				=	ajax_te_faltan;
			ajax					=	GetXmlHttpObject();
			var url="inc/inc-te-faltan.php";
			url=url+"?ajax=1"; 
			ajax.onreadystatechange= function() { 
					
					if (ajax.readyState==4)
									{ 	
										document.getElementById('tequedan').innerHTML=ajax.responseText;
										
									}
									else
									{
										//document.getElementById('res_anadir_'+idproducto).innerHTML="Añadiendo ...";
										//document.getElementById('res_anadir_'+idproducto).style.display="block";
									}
													
					}; ; //con esto paso parametros
										
			
						ajax.open("GET",url,true);
						ajax.send(null);
	}

function esconder(id)
	{  		 			
		 	document.getElementById(id).style.display="none";	
	}
function ver(id)	
	{
			document.getElementById(id).style.display="block";
	}
function voy(url)
	{
	parent.window.location.href=url;	
	}
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;
}