function ss_product_show_price(product_ID,pathtoapi) {
    	
	// Montar el value seleccionado
	
	var aoption_selected = new Array();
	var soption_selected = "";
	var aindex = 0;

	jQuery("[id^=ss_p_option_]").each(function(i,o) {
		aoption_selected[aindex] = o[o.selectedIndex].value; 
		aindex++;
    });
    
	soption_selected = aoption_selected.join("_"); 
	
   	var thetime = new Date();
   	var milis = thetime.getTime();
   	
   	jQuery("#ss_p_price").empty();
	jQuery("#ss_p_price").append('<img class="noBorders" src="'+pathtoapi+'/wp-content/plugins/simple-shop/ajax-loader-t.gif" />');
	jQuery.post(pathtoapi + '/wp-content/plugins/simple-shop/api.php?'+milis,{p:product_ID,ss_options:soption_selected,action:'get_price'},ss_product_show_price_callback,"json");
	
	// Disable de los elementos
    	
}

function ss_product_show_price_callback(data) {

	jQuery("#ss_p_price").empty();
	if(data.error!="") {
		jQuery("#pprice").append('-');
		alert(data.error);
	}
	else {
		jQuery("#ss_p_price").append(data.price + '&nbsp;€');
		jQuery("#ss_p_ref").attr('value',data.ref);
	}
}

function ss_add_to_cart(product_ID,pathtoapi) {
	
	var aoption_selected = new Array();
	var soption_selected = "";
	var aindex = 0;

	jQuery("[id^=ss_p_option_]").each(function(i,o) {
		aoption_selected[aindex] = o[o.selectedIndex].value; 
		aindex++;
    });
    
	soption_selected = aoption_selected.join("_"); 
	
	var p_ref = jQuery("#ss_p_ref").attr('value');
	
   	var thetime = new Date();
   	var milis = thetime.getTime();
   	
   	jQuery("#ss_buybutton").empty();
	jQuery("#ss_buybutton").append('<img class="noBorders" src="'+pathtoapi+'/wp-content/plugins/simple-shop/ajax-loader-t.gif" />');
	jQuery.post(pathtoapi + '/wp-content/plugins/simple-shop/api.php?'+milis,{p:product_ID,ss_options:soption_selected,ss_ref:p_ref,action:'add_to_cart'},ss_add_to_cart_callback,"json");
	
}

function ss_add_to_cart_callback(data) {
	
	
	if(data.error!="") {
		jQuery("#pprice").append('-');
		alert(data.error);
	}
	else {
		document.location.href = '/donde-comprar/';
	}


}