var rutaSitio

if(location.host == "localhost"){
	rutaSitio = location.protocol + '//' + location.host + '/hosfrisur'; 
}else{
	rutaSitio = location.protocol + '//' + location.host;
}

function ActualizarCarro(accion, productoId, cantidad){
			
	jQuery.ajax({
		
		type: "POST",
		url: rutaSitio + "/Compras/CarroEditor.asp",
		data: 'accion=' + accion + '&productoId=' + productoId + '&cantidad=' + cantidad,
		cache: false,
		async: false,
		success: function(html){
			
			jQuery("#imagenCargando").html("");
			
		},
		error: function(request, error){			
			
			jQuery("#imagenCargando").html("<img src='" + rutaSitio + "/Imagenes/loading_transparent.gif' width='25' height='25' />");
			
		}
		
	});
	
}

function ActualizarTotal(sesionId, idioma){

	jQuery.ajax({
		
		type: "GET",
		url: rutaSitio + "/Compras/CarroTotal.asp",
		data: 'sId=' + sesionId + '&idioma=' + idioma,
		cache: false,
		async: false,
		success: function(html){
			
			var valores = html.split('|');

			jQuery("#carroCantidad").html("Tiene: " + valores[0] + " productos");
			jQuery("#carroTotal").html("Total: " + valores[1] + " &euro;");
			
		},
		error: function(request, error){			
						
			jQuery("#carroCantidad").html("Tiene: ??? productos");
			jQuery("#carroTotal").html("Total: ??? &euro;");
			
		}
		
	});
	
}

function ActualizarCantidades(){
	
	var campos = jQuery('#formularioCarro').serialize();
	
	jQuery.ajax({
		
		type: "POST",
		url: rutaSitio + "/Compras/CarroEditor.asp",
		data: campos,
		cache: false,
		async: false,
		success: function(html){
			
			jQuery("#imagenCargando").html("");
			
		},
		error: function(request, error){			
			
			jQuery("#imagenCargando").html("<img src='" + rutaSitio + "/Imagenes/loading_transparent.gif' width='25' height='25' />");
			
		}
		
	});
	
}

