function CreateAddToCart(id, artikelname, popupDisabled, meshop_sid)
{
    CreatePopup(meshop_sid);

    $('#add_to_cart'+id).click(function() {
        jQuery.ajax({
            type: 'post',
            url: '/ajax/checkout/cart/add/product?meshop_sid='+meshop_sid,
            dataType: 'html',
            data: jQuery('#prod'+id+' :input'),
            success: function (html) {
                jQuery('#module-cart').html(html);
            },
            complete: function () {
                $('body').after('<img src="' + $('#productImage_'+id).attr('src') + '" id="temp' + id + '" style="position: absolute; top: ' + parseInt( $('#productImage_'+id).offset().top ) + 'px; left: ' + parseInt( $('#productImage_'+id).offset().left ) + 'px; z-index: 999; display: block;" />');
                jQuery('#temp'+id).focus().animate( {
                        top : 70,
                        left : parseInt( ( $(window).width() / 2 + $('#sitebody').width() / 2 ) - 330 ),
                        opacity : 0,
                        width : 25,
                        heigth : 25
                    }, {
                		duration: 1250,
                		specialEasing: {
                            opacity: 'easeInSine',
                            width:   'easeInExpo',
                            height:  'easeInExpo'
                        },
                		complete: function () {
                            if (popupDisabled === true)
                            {
                                window.location.href = window.location.href;
                            }
                            else
                            {
                                $('#CartEventBoxText').html($('#productImage_'+id).attr('title') + ' zum Warenkorb Hinzugef&uuml;gt!');
                                $('#add_to_cart').dialog('open');
                                $('.ui-dialog-buttonset button').button();
                            }
                		}
                	}
                );
            }
        });
        return false;
    }); 
}

function CreateVariantAddToCart(id, artikelname, imageid, meshop_sid)
{
    CreatePopup(meshop_sid);

    //$('body').after('<img src="' + $('#productImage_'+imageid).attr('src') + '" id="temp' + imageid + '" style="position: absolute; top: ' + parseInt( $('#productImage_'+imageid).offset().top ) + 'px; left: ' + parseInt( $('#productImage_'+imageid).offset().left ) + 'px; z-index:99;" />');

    $('#add_to_cart'+id).click(function() {
        //$('body').after('<img src="' + $('#productImage_'+imageid).attr('src') + '" id="temp' + imageid + '" style="position: absolute; top: ' + parseInt( $('#productImage_'+imageid).offset().top ) + 'px; left: ' + parseInt( $('#productImage_'+imageid).offset().left ) + 'px; z-index:99;" />');
        jQuery.ajax({
            type: 'post',
            url: '/ajax/checkout/cart/add/product?meshop_sid='+meshop_sid,
            dataType: 'html',
            data: jQuery('#prod'+id+' :input'),
            success: function (html) {
                jQuery('#module-cart').html(html);
            },
            complete: function () {
                $('body').after('<img src="' + $('#productImage_'+imageid).attr('src') + '" id="temp' + imageid + '" style="position: absolute; top: ' + parseInt( $('#productImage_'+imageid).offset().top ) + 'px; left: ' + parseInt( $('#productImage_'+imageid).offset().left ) + 'px; z-index:99;" />');
                jQuery('#temp'+imageid).animate( {
                        top : 70,
                        left : parseInt( ( $(window).width() / 2 + $('#sitebody').width() / 2 ) - 330 ),
                        opacity : 0,
                        width : 25,
                        heigth : 25
                    }, {
                		duration: 1250,
                		specialEasing: {
                            opacity: 'easeInSine',
                            width:   'easeInExpo',
                            height:  'easeInExpo'
                        },
                		complete: function () {
                            $('#CartEventBoxText').html($('#productImage_'+imageid).attr('title') + ' zum Warenkorb Hinzugef&uuml;gt!');
                            $('#add_to_cart').dialog('open');
                            $('.ui-dialog-buttonset button').button();
                        }
                	}
                ).focus();
                
            }
        });
        return false;
    });
}

function CreatePopup(meshop_sid)
{
    $(function() {
		$("#add_to_cart").dialog({
	        autoOpen: false,
	        width: 350,
	        modal: true,
	        show: "explode",
	        hide: "explode",
	        resizable: false,
	        buttons: {
	            'Weiter einkaufen': function() {
	                $(this).dialog('close');
	            },
	            'Zur Kasse': function() {
					$(this).dialog('close');
	            	document.location.href = 'http://people.mauve.eu/checkout/cart/?meshop_sid='+meshop_sid;
	            }
	        }
	    });
	});
}
