﻿function AgregarItem(cod_paquete,cod_periodo){
	$.get("cart.php?opcion=agregaritem&cod_paquete="+cod_paquete+"&cod_periodo="+cod_periodo,
		function(txt){
			$("li#cart").html("<a href=\"checkout.php\">Car("+txt+")</a>");
		})
// 	alert("se agrego al carrito de compras");
}

function RemoverItem(id_item){
	window.location="cart.php?opcion=removeritem&id_item="+id_item;
}

function AgregarItems(){
	var tagsArray = new Array();
	if( typeof $("#dominio_trial").val() !== 'undefined' && $("#dominio_trial").val()!=''){
		$("input:checked").each(function(id){
			message = jQuery("input:checked").get(id);
			tagsArray.push("("+$("#dominio_trial").val()+"|"+message.value+")");
		});
	}
	else{
// 		alert('no existe2');
		$("input:checked").each(function(id){
			message = jQuery("input:checked").get(id);
			tagsArray.push(message.value);
		});
	
	}
	
	
	$.post("cart.php",{'opcion':'agregaritems','dominios[]':tagsArray,'cod_periodo':$("input#cod_periodo_dominio").val(),'cod_paquete':$("input#cod_paquete_dominio").val()},
		function(txt) {
 			$("li#cart").html("<a href=\"checkout.php\">Car("+txt+")</a>");
			});
 	$("div#search-result").html("");
 	alert("Se agregó al carrito de compras");
}
function lanzaPrevisualizacion(paquete, periodo){
	AgregarItem(paquete,periodo);
	alert("Se agregó al carrito de compras");
}
/**
 * IniciarEfectos
 * 
 * @package    yachay
 * @author     Jonathan Olger Nieto Lajo <johan.nieto.lajo@gmail.com>
 */
function lanzaPrevisualizacion2(paquete, periodo)
{
	$.ajax
  ({
    type        : "POST",
    url         : "cart.php?opcion=listardetalle&cod_paquete=" + paquete + "&cod_periodo=" + periodo,
    data        : {  },
    dataType    : "html",
    cache       : false,
    beforeSend  : function ()
    {
    },
    success     : function (datos)
    {
      $("#ventana_modal_carrito").html(datos);
			$("#ventana_modal_carrito").dialog
			({
				title    : "Informacion",
				create   : function(event, ui) { },
				close    : function(event, ui) { },
			  draggable: false,
			  modal    : true,
			  resizable: false,
			  width    : 700,
			  height   : 420,
			  zIndex   : 999999,
			  buttons  : 
			  [
			    {
			      text: "Agregar",
			      click: function() 
			      {
							AgregarItem(paquete, periodo);
							
							$(this).dialog("close");
			      }
			    },
			    {
			      text: "Cancelar",
			      click: function() { $(this).dialog("close"); }
			    }
			  ]
			});
    }
  });
}

