//	PRODUCTOS ///////////////////////////////////////////////////////////////////////////////////////////////////

//funcion que inserta un producto en la cesta
function ShopProductoAdd(Id)
{  //mostramos el loading
   $("id_producto_form_submit").hide();
   $("id_producto_form_submit_loading").show();
  	//enviamos el ajax
   Gamas=new Array();
   for (i=0; $("shop_producto_add_gama_"+ i)!=null; i++)
      Gamas.push($("shop_producto_add_gama_"+ i).value);
 	new Ajax.Updater("shop_producto_add", RaizGet()+ "system/shop/php/web_acciones.php",
	{	parameters:
		{	accion: "ShopProductoAdd",
			shop_producto_id: Id,
			shop_producto_gamas: Gamas.toString(),
			shop_producto_unidades: $("id_shop_producto_add_unidades").value}});
	//ocultamos el loading
   $("id_producto_form_submit").show();
   $("id_producto_form_submit_loading").hide();

   //actualizamos la cesta mini
   ShopCestaMiniUpdate();                        										  						}

//	CESTA MINI //////////////////////////////////////////////////////////////////////////////////////////////////

//funcion que actualiza la cesta mini
function ShopCestaMiniUpdate()
{  new Ajax.Updater("shop_cesta_mini", RaizGet()+ "system/shop/php/web_acciones.php",
	{	parameters:
		{	accion: "ShopCestaGetMini"}});   																	}

//	DATOS ///////////////////////////////////////////////////////////////////////////////////////////////////////

//funcion que muestra/oculta los formularios
function ShopDatosTipoCheck(Opcion)
{	if (Prototype.Browser.IE)
	{	if (Opcion.value==1) 
		{	$('id_shop_datos_user').hide();
			$('id_shop_datos_login').show();
			$('id_shop_datos_passget').show();																	}
		else 
		{	$('id_shop_datos_user').show();
			$('id_shop_datos_login').hide();
			$('id_shop_datos_passget').hide();																	}}
	else		
	{	if (Opcion.value == 1) {
		Effect.Fade('id_shop_datos_user', {duration:0.3});
		Effect.Appear('id_shop_datos_login', {delay: 0.5, duration:0.3});
		Effect.Appear('id_shop_datos_passget', {delay: 0.5, duration:0.3});													}
	else {
		Effect.Fade('id_shop_datos_login', {duration:0.3});
		Effect.Fade('id_shop_datos_passget', {duration:0.3});
		Effect.Appear('id_shop_datos_user', {delay: 0.5, duration:0.3});														}}}

//	CONFIRMACION ////////////////////////////////////////////////////////////////////////////////////////////////

//funcion que comprueba la confirmacion
function ShopConfirmacionCheck(Tpv)
{	//comprobamos las condiciones
	if (!$("id_shop_confirmacion_condiciones").checked)
	{	$("id_shop_confirmacion_error").show();
		return;																									}

	//comprobamos el tipo de pago
	if (Tpv)
	{	$("id_shop_confirmar_continuar").hide();
		$("shop_condiciones_div").hide();
		$("shop_confirmacion_pago").show();
		$("shop_confirmacion_pago").src="system/cliente/inc/web_tpv_iframe.php";
		Effect.ScrollTo("id_shop_pago_div");																	}
	else document.location.href="pedido-confirmado";															}

//	FACTURA /////////////////////////////////////////////////////////////////////////////////////////////////////

//funcion que obtiene una factura
function ShopFacturaGet(Id)
{	//mostramos/ocultamos
	$("shop_pedidos_loading_"+ Id).show();
	$("shop_pedidos_editar_"+ Id).hide();	
	//enviamos el ajax
	new Ajax.Updater("shop_factura", RaizGet()+ "system/web/php/web_acciones.php",
	{	parameters:
		{	funcion: "ShopFacturaGet",
			id: Id}});
	$("shop_pedidos_editar_"+ Id).show();	
	$("shop_pedidos_loading_"+ Id).hide();																		}

//funcion que comprueba una factura
function ShopFacturaCheck(Id)
{  	//mostramos/ocultamos
	$("id_shop_factura_submit_loading").show();
	$("id_shop_factura_submit").hide();	
	//enviamos el ajax
	new Ajax.Updater("shop_factura", RaizGet()+ "system/web/php/web_acciones.php",
	{	parameters:
		{	funcion: 		"ShopFacturaCheck",
			id: 			Id,
			f_empresa: 		$("id_f_empresa").value,
			f_cif: 			$("id_f_cif").value,
			f_direccion: 	$("id_f_direccion").value,
			f_direccion_2: 	$("id_f_direccion_2").value,
			f_poblacion: 	$("id_f_poblacion").value,
			f_provincia: 	$("id_f_provincia").value,
			f_cp: 			$("id_f_cp").value,
			f_pais: 		$("id_f_pais").value},
		onComplete: function(transport)
		{	//redireccionamos
			if (transport.responseText.include("reload")) document.location.reload(); }});						}
