    
var tapas_id = 13;

intcheck = function(){
    if (isNaN(this.value)){
        this.value = "";
        alert("Indtast venligst antal som et tal.");
    }
}

function in_array (needle, haystack, argStrict) {
    var key = '',
        strict = !! argStrict;
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    } 
    return false;
}

function zipcity(o, cityfield){
        $("#"+cityfield).val(arr_postnumre[o]);
        
        if (o != "" && arr_delivery[o]){
            delivery = true;
        } else if (o != "" && !arr_delivery[o]){
            if ($("#sel_del_type").val() == 1){
                if (!confirm("Vi leverer ikke til det angivne postnummer. Vil du ændre til Afhentning?")){
                    return false;
                }
            }
        }
        if ($("#sel_del_type").val() == 1){
        if (cityfield == "address2_city" || (cityfield == "address_city" && $("#deladdr_zip").val() == "")){
            $.get("/includes/plugins/x.php?orderlines&zip="+o,
            function(data){
                $("#totals").html(data);
            });        
        }                                  }
}

function get_top_cats(){
    $.get('/includes/plugins/x.php', function(data){
        var items = [];
        out = "<div class='order_section' id='top'><h1>Vælg produkt</h1>";
        $($.parseJSON(data)).each(function(){
            out += "<input type='radio' value='"+this.ID+"' name='productcategory' class='pcat' />&nbsp;"+this.NAME+"<br/>";
        });
        out += "</div>"
        $("#productdiv").append(out);

        $(".pcat").click(function(){
             get_sub_cats(this.value);                                       
        });

    });                                                    
}

function get_sub_cats(id){
    $("#sub").remove();
    $.get('/includes/plugins/x.php?c='+id, function(data){
        var items = [];
        out = "<div class='order_section' id='sub'><h1>Hvilken buffet ønsker du?</h1>";
        $($.parseJSON(data)).each(function(){
            out += "<input type='radio' value='"+id+"' name='product' class='prod' />&nbsp;"+this.NAME+"<br/>";
        });
        $("#productdiv").append(out);
    });                            
}
    
function kidsmenu(v){
    if (v == 1) $("#kidsmenu").slideDown();
    if (v == 0) $("#kidsmenu").slideUp();
}

function deladdr(v){
    if (v == 1){
	    $("#deladdr").slideDown();
	    $("#deladdr input").addClass("mandatory");
	}
    if (v == 0){
	    $("#deladdr").slideUp();
	    $("#deladdr input").removeClass("mandatory");
	}
}

function delivery(v){
    $("#delivery_datewrap").slideDown();
    if (v == 1){
        $("#w1").fadeOut().text("Leveringsdato").fadeIn();
        $("#w2").fadeOut().text("Leveringstidspunkt").fadeIn();
    }
   if (v == 2){
        $("#w1").fadeOut().text("Afhentningsdato").fadeIn();
        $("#w2").fadeOut().text("Afhentningstidspunkt").fadeIn();
    }
 }

function flow_steps(v, product_id){
    num_steps = 3;
    //tapas_id = 13;
    out = "";
    orig_cls = "";
    /*if (product_id == tapas_id){
        num_steps = 3;
        orig_cls = "tapas ";
    }*/
    cls = orig_cls;
    out += "<div id='flow_steps'>";
    for (i=1; i<=num_steps; i++){                                
        if (i == num_steps) cls += " last ";
        if (i == v) cls += " current ";
        out += "<span class='"+cls+"'>Trin " + i + " af "+num_steps+"</span>";
        cls = orig_cls;
    }
    out += "<div class='clr'></div></div>";
    return out;
}

tapas_ids = new Array();

function save_tapas(){
    
    tapasmenu = false;
    if ($("#product_id").val() == tapas_id) tapasmenu = true;

    // text description of selection
    selected_tapas = "";

    // ids used when the colorbox is popped up again
    tapas_ids = [];

    // string to save ids for form post
    tapas_summary = "";
    
    sel = "#tapasmenudiv input.tapascount";
    // if (tapasmenu) sel += ":checked";               
    sel += ":checked";
    $(sel).each(function(){
        if (isNaN(this.value)){
            this.value = 0;
        }
        if (this.value > 0){
            // if (!tapasmenu) selected_tapas += 1*this.value + " stk. " + $(this).next("span.tapasname").text() + "<br/>"; 
            if (!tapasmenu) selected_tapas += $(this).next("span.tapasname").text() + "<br/>"; 
            if (tapasmenu) selected_tapas += $(this).next("span.tapasname").text() + "<br/>"; 
            tapas_ids[$(this).attr("name").split("_")[1]] = 1*this.value;
            tapas_summary += $(this).attr("name").split("_")[1]+"|"+this.value+"___";
        }
    });
    if (selected_tapas == "") selected_tapas = "Intet valgt.<br/>";
    $("#sel_tapas").html(selected_tapas);
    $("#tapas_summary").val(tapas_summary);
    $("#tapas_after").slideDown();
    $("#tapas_before").hide();

    submode = "&submode=addon";
    if ($("#product_id").val() == tapas_id) submode = "&submode=fullmenu"; 
    
    if (tapasmenu) $("<a href='/includes/plugins/x.php?mode=tapas"+submode+"' id='select_tapas' class='ajax' style='line-height:25px'>Vælg påny</a>").appendTo("#sel_tapas");
    if (!tapasmenu) $("<a href='/includes/plugins/x.php?mode=tilbehoer"+submode+"' id='select_tapas' class='ajax' style='line-height:25px'>Vælg påny</a>").appendTo("#sel_tapas");
    $(".ajax").colorbox({"opacity": 0.5});
    $.colorbox.close();
}


function validate_step(v, next){
        
    if (v == 1){                                
        err = 0;

        $("input.mandatory").each(function(){
            $(this).css("border", "1px solid #aaa");
            if (this.value == ""){
                $(this).css("border", "1px solid red");
                err++;
            }
        });
        if (err > 0){
            alert("Der er obligatoriske felter, der ikke er udfyldt (markeret med rød ramme).");
            return;                       
        }

        if ($("input[name='count_adults']").val()*1 < $("#min_order").val()*1){
            err++;
            alert("Bestil venligst mindst "+$("#min_order").val()+" kuverter.");
            return;
        } 

        if ($("input[name='count_kids']").val() > 0 && !$('input[name=kids_menu_type]:checked').val() && $("#product_id").val() != tapas_id){
            err++;
            alert("Vælg venligst type af børnemenu.");
            return;
        } 

        if ($("#pickup_only").val() != 1){
            if (!$('input[name=delivery_type]:checked').val()){
                err++;
                alert("Vælg venligst, om der ønskes levering eller afhentning.");
                return;
            } 

            if ($('input[name=delivery_type]:checked').val() == 1){
                word = "leverings";
            }
            if ($('input[name=delivery_type]:checked').val() == 2){
                word = "afhentnings";
            }
            if ($('input[name=delivery_date]').val() == ""){
                err++;
                alert("Angiv venligst "+word+"dato.");
                return;
            } 

            split_date = $('input[name=delivery_date]').val().split("/");
            if (split_date.length != 3 || split_date[0].length != 2 || split_date[1].length != 2 || split_date[2].length != 4){
                err++;
                alert("Angiv venligst en gyldig "+word+"dato på formatet dd/mm/åååå.");
                return;
            } 

            if ($('select[name=delivery_time_hour]').val() == "-1" || $('select[name=delivery_time_minute]').val() == "-1"){
                err++;
                alert("Angiv venligst "+word+"tidspunkt.");
                return;
            }
        } 

        if (err == 0){
            // document.forms[0].submit();
            $("a.flowbutton").hide();
            $("div.loading").show();
            $.post("/includes/plugins/x.php",  $("#form_step1").serialize(), function(data){
                if (!$.parseJSON(data) || $.parseJSON(data) == null){
                    alert("Der er sket en fejl: Din ordre er udløbet. Start venligst forfra.");
                    location = "/";
                } else {
                    $("#order_id_seq").val($.parseJSON(data).ORDERNUMBER_SEQ);
                    step_2();
                }
            });
        } 
    }

    if (v == 2){
        if (!$("#order_id_seq").val() || isNaN($("#order_id_seq").val())){
            alert("ERROR: Noget er gået galt. Der mangler et ordrenummer.");
            return;
        }
        if (next == 3){
            $("a.flowbutton").hide();
            $("div.loading").show();
            $.post("/includes/plugins/x.php",  $("#form_step1").serialize(), function(data){
                step_3();
            });
        }
        /*
        if (next == 1){
            $.post("/includes/plugins/x.php",  $("#form_step1").serialize(), function(data){
                step_1($("#product_id").val());
            });
        }*/

    }

    if (v == 3){
        err = 0;

        $("input.mandatory").each(function(){
            $(this).css("border", "1px solid #aaa");
            if (this.value == ""){
                $(this).css("border", "1px solid red");
                err++;
            }
        });
        if (err > 0){
            alert("Der er obligatoriske felter, der ikke er udfyldt (markeret med rød ramme).");
            return;                       
        }

        $("input.email").each(function(){
            $(this).css("border", "1px solid #aaa");
            if ($(this).val().indexOf("@") <= 0 || $(this).val().indexOf(".") <= 0 || $(this).val().indexOf(" ") >= 0 || $(this).val().split("@")[1].split(".").length <= 1){
                $(this).css("border", "1px solid red");
                err++;
            }
        });
        if (err > 0){
            alert("Angiv venligst en gyldig e-mail-adresse.");
            return;                       
        }

        $("input.phone").each(function(){
            $(this).css("border", "1px solid #aaa");
            if ($(this).val().length != 0 && ( $(this).val().length != 8 || isNaN($(this).val()))){
                $(this).css("border", "1px solid red");
                err++;
            }
        });
        if (err > 0){
            alert("Angiv venligst et gyldigt telefonnummer (otte cifre).");
            return;                       
        }

        $("input.zipcode").each(function(){
            $(this).css("border", "1px solid #aaa");
            if ($(this).val().length != 0 && ( $(this).val().length != 4 || isNaN($(this).val()))){
                $(this).css("border", "1px solid red");
                err++;
            }
        });
        if (err > 0){
            alert("Angiv venligst et gyldigt postnummer (fire cifre).");
            return;                       
        }

        if ($("input#terms_1:checked").length == 0){
            alert("Bekræft venligst, at du har læst og accepteret forretningsbetingelserne.");
            return false;                       
        }

        if ($("input#terms_2:checked").length == 0){
            alert("Bekræft venligst, at du er opmærksom på at ændring i antal deltagere skal meddeles senest 7 dage før levering.");
            return false;                       
        }

        $("a.flowbutton").hide();
        $("div.loading").show();
        
        $.post("/includes/plugins/x.php",  $("#form_step1").serialize(), function(data){
                final_step();
        });

    }

}

function step_1(id){

    $("#step1div").show();
    $("#step2div").hide();
    $("#step3div").hide();
    
    $("#step").val(1);
    
    $.get('/includes/plugins/x.php?pid='+id, function(data){    
        product = $.parseJSON(data)[0]; 
        $("#productdiv h1 span").text(product.NAME);
        $("#product_id").val(product.ID);
        $("#min_order").val(product.MINIMUM_ORDER);
        $("#pickup_only").val(product.PICKUP_ONLY);
        
        out = "";
        out += flow_steps(1, id);                                
        
        if (product.DESCRIPTION != ""){
            out += "<div class='product_alert'>"+product.DESCRIPTION+"</div>";
        }
            
        out += "<h2>Kuvertantal og levering</h2>";
        
        t =  "voksne, pr. person "+product.PRICE+",- ";
        if (id == tapas_id || product.PRICE_KIDS == 0){
            t = "kuverter ";
        }
        out += "<div class='orderfield'><div>Antal "+t+"</div><input type='text' name='count_adults' id='count_adults' class='mandatory integer' />";
        if (product.MINIMUM_ORDER > 0) out += "&nbsp;&nbsp;(minimum "+product.MINIMUM_ORDER+")";
        out += "</div>";
        
        if (id != tapas_id && product.PRICE_KIDS > 0){                                
            out += "<div class='orderfield'><div>Antal børn under 10 år</div><input type='text' name='count_kids' id='count_kids' class='integer' onblur='if(this.value > 0) kidsmenu(1); else kidsmenu(0)' /></div>";
            out += "<div class='orderfield' id='kidsmenu'><div>Vælg type af børnemenu</div><div class='oid'>\
                <input type='radio' name='kids_menu_type' value='1' />&nbsp; Voksenmenu som børneportion, pr. prs. kr. "+product.PRICE_KIDS+",-<br/>\
                <input type='radio' name='kids_menu_type' value='2' />&nbsp; Rejecocktail + Hjemmelavet lasagne, pr. prs. kr. 125,-<br/>\
                <input type='radio' name='kids_menu_type' value='3' />&nbsp; Kyllingeforret + Hjemmelavet lasagne, pr. prs. kr. 125,-<br/>\
            </div></div>";
        }
        out += "<div class='orderfield'><div>Antal hjemmebagt brød med smør, pr. person 20,-</div><input type='text' name='count_bread' id='count_bread' class='mandatory integer' /></div>";

        if (product.PICKUP_ONLY != 1){   
            out += "<div class='orderfield'><div>Levering eller hent selv</div><div class='oid'>\
                <input type='radio' name='delivery_type' value='1' onclick='delivery(this.value)' />&nbsp; Jeg ønsker levering (<a href='/index.php?pageid=24' class='ajax cboxElement'>kun til disse postnumre</a>)<br/>\
                <input type='radio' name='delivery_type' value='2' onclick='delivery(this.value)' />&nbsp; Jeg henter selv<br/>\
            </div></div>";
            out += "<div id='delivery_datewrap'>";
            out += "<div class='orderfield' id=''><div><span id='w1'></span></div><input type='text' name='delivery_date' id='delivery_date' class='date-pick' /></div>";
            out += "<div class='orderfield' id=''><div><span id='w2'></span></div><select name='delivery_time_hour' id='delivery_time_hour'><option value='-1'>Time</option>";
            for (i=6; i<=20; i++){
                hr = "";
                if (i < 10)
                    hr = "0"+i;
                else 
                    hr += i;
                out += "<option value='"+hr+"'>";
                out += hr
                out += "</option>";
            }
            out += "</select>:";
            out += "<select name='delivery_time_minute' id='delivery_time_minute'><option value='-1'>Minut</option><option value='00'>00</option><option value='15'>15</option><option value='30'>30</option><option value='45'>45</option></select>";
            out += "</div></div>";
        }
        
        out += "<div class='orderfield'><div>Afhentning af tom emballage & service, kr. 74,-</div><input type='checkbox' name='pickup_empty' id='pickup_empty' value='1' />&nbsp; Ja tak</div>";
        out += "<div class='nextstep'><a href='#' onclick='validate_step(1); return false' class='flowbutton'>Næste trin (2 af 3) >></a></div>";
        out += "<div class='loading'>Vent venligst...</div>";

        $("#step1div").append(out);
        $('.date-pick').datepicker({dateFormat:'dd/mm/yy', minDate:+2})
        $("input.integer").blur(intcheck); 
        $(".ajax").colorbox({"opacity": 0.5});
        
        _gaq.push(['_trackPageview', '/funnel_g1/order_step1.html']);
        
        $.get("/includes/plugins/x.php?retrieve="+$("#product_id").val(product.ID),
            function(data){
                order = $.parseJSON(data);
                if (!order.shop_orders_id){
                    $("#order_id_seq").val(0);
                } else if (order.shop_orders_id){
                    $("#order_id_seq").val(order.shop_orders_id);
                    $("#count_adults").val(order.count_adults);
                    $("#count_kids").val(order.count_kids);
                    if (order.count_kids > 0){
                        kidsmenu(1);
                        $('input:radio[name="kids_menu_type"]').filter('[value="'+order.kids_menu_type+'"]').attr('checked', true);
                    }
                    $("#count_bread").val(order.count_bread);
                    $('input:radio[name="delivery_type"]').filter('[value="'+order.delivery_type+'"]').attr('checked', true);
                    delivery(order.delivery_type);
                    dd = order.delivery_date.split(" ")[0].split("-");
                    dt = order.delivery_date.split(" ")[1].split(":")
                    $("#delivery_date").val(dd[2]+"/"+dd[1]+"/"+dd[0]);
                    $("#delivery_time_hour").val(dt[0]);
                    $("#delivery_time_minute").val(dt[1]);
                    if (order.pickup_empty == 1) $("#pickup_empty").attr("checked", true);
                }
            }); 

    });                                                        
}
    
function step_2(){
    
    $("#step1div").hide();
    $("#step2div").show();
    $("#step3div").hide();
                                
    id = $("#product_id").val();
    $("#step").val(2);

    out = "";
    out += flow_steps(2, id);

    if (id == 32){
        out += "<h2>Vælg forret, hovedret og dessert</h2>";
        out += "<div id='luksusmemu_choices'></div>";
    }

    out += "<h2>Flere lækre muligheder</h2>";
    
    submode = "&submode=addon";
    if (id == tapas_id) submode = "&submode=fullmenu"; 

    out += "<div class='orderfield'><div>Antal chokolade/petit four fra Summerbird á kr. 14,-</div><input type='text' name='count_chocolate' id='count_chocolate' class='integer' value='0' /></div>";
    out += "<div class='orderfield'><div>Antal Hjemmelavede salte mandler (skål til 6 per.) kr. 59,-</div><input type='text' name='count_almonds' id='count_almonds' class='integer' value='0' /></div>";
    out += "<div class='orderfield'><div>Antal Camillas hjemmelavede pesto (skål til 6-8 pers.) kr. 35,-</div><input type='text' name='count_pesto' id='count_pesto' class='integer' value='0' /></div>";
    
    if ($("#productgroup_id").val() == 1){
        out += "<div class='orderfield'><div>Natmad</div><select id='natmad' name='natmad'><option value='0'>Ingen natmad</option></select></div>";
	}

    if (id != tapas_id && !in_array(id, menuProdIds )){
        out += "<div class='orderfield' id='tapas_before'><div>Tilbehør til buffet/menu</div><a href='/includes/plugins/x.php?mode=tilbehoer"+submode+"' id='select_tapas' class='ajax' style='line-height:25px'>Klik her for at vælge tilbehør</a></div>";
        out += "<div class='orderfield' id='tapas_after'><div>Valgt tilbehør</div><p id='sel_tapas'><a href='/includes/plugins/x.php?mode=tilbehoer"+submode+"' id='select_tapas' class='ajax' style='line-height:25px'>Klik her for at vælge fra tapas-menu</a></p></div>";
	} else if (id == tapas_id){
        out += "<div class='orderfield' id='tapas_before'><div>Valg af tapas</div><a href='/includes/plugins/x.php?mode=tapas"+submode+"' id='select_tapas' class='ajax' style='line-height:25px; font-weight:bold'>Klik her for at vælge dine tapas</a></div>"; 							                           
        out += "<div class='orderfield' id='tapas_after'><div>Valgte tapas</div><p id='sel_tapas'><a href='/includes/plugins/x.php?mode=tapas"+submode+"' id='select_tapas' class='ajax' style='line-height:25px'>Klik her for at vælge fra tapas-menu</a></p></div>";
	}

    out += "<h2>Vine</h2>";
    out += "<div id='winewrap'></div>";
    
    out += "<div class='nextstep'><a href='#p/' onclick='validate_step(2, 3)' class='flowbutton'>Næste trin (3 af 3) >></a></div>";
    out += "<div class='loading'>Vent venligst...</div>";

    $("#step2div").append(out);
    $("#natmad").load("/includes/plugins/x.php?mode=natmad");

    if (id == 32){
        $("#luksusmemu_choices").load("/includes/plugins/x.php?mode=luksusmenu");
    }

    $(".ajax").colorbox({"opacity": 0.5});
    $("#winewrap").load("/includes/plugins/x.php?mode=wine", function(){$(".ajax").colorbox({"opacity": 0.7});$("input.integer").blur(intcheck); });
    $("input.integer").blur(intcheck); 
    
    $(document).bind('cbox_complete', function(){
        $("input.tapascount").each(function(){
            // if (tapas_ids[$(this).attr("name").split("_")[1]] > 0) this.value = tapas_ids[$(this).attr("name").split("_")[1]];
            if (tapas_ids[$(this).attr("name").split("_")[1]] > 0) this.checked = true;
        });
    });
    
    _gaq.push(['_trackPageview', '/funnel_g1/order_step2.html']);

    $.get("/includes/plugins/x.php?retrieve=2",
        function(data){
            order = $.parseJSON(data);
            if (!order.shop_orders_id){
                // $("#order_id_seq").val(0);
            } else if (order.shop_orders_id){
                $("#count_chocolate").val(order.count_chocolate);
                $("#count_almonds").val(order.count_almonds);
                $("#count_pesto").val(order.count_pesto);
                $("#tapas_summary").val(order.tapas_summary);
            }
        });

}

function step_3(){
    
    $("#step1div").hide();
    $("#step2div").hide();
    $("#step3div").show();
    
    id = $("#product_id").val();
    $("#step").val(3);

    out = "";
    out += flow_steps(3, id);

    out += "<h2>Totalpris</h2>";
    out += "<div id='totals'></div>";
    out += "<p><br/><em>Alle priser er inkl. moms.</em><br/><strong>Bemærk: Betaling sker kontant ved levering eller ved bankoverførsel.</strong></p>";

    out += "<h2>Fakturaadresse</h2>";
    out += "<p>Fakturaadressen skal udfyldes. Hvis leveringsadressen er en anden, kan du udfylde den nedenfor.</p>";

    out += "<div class='orderfield'><div>Navn</div><input type='text' name='address_name' value='' size='50' class='mandatory' /></div>";
    out += "<div class='orderfield'><div>Adresse</div><input type='text' name='address_street' value='' size='50' class='mandatory' /></div>";
    out += "<div class='orderfield'><div>Postnummer</div><input onblur=\"zipcity(this.value, 'address_city')\" type='text' name='address_zipcode' value='' size='8' class='mandatory zipcode' /></div>";
    out += "<div class='orderfield'><div>By</div><input type='text' name='address_city' id='address_city' value='' size='50' class='mandatory' /></div>";
    out += "<div class='orderfield'><div>Telefon</div><input type='text' name='address_phone' value='' size='25' class='phone'/></div>";
    out += "<div class='orderfield'><div>Mobiltelefon</div><input type='text' name='address_cellphone' value='' size='25' class='mandatory phone' /></div>";
    out += "<div class='orderfield'><div>E-mail</div><input type='text' name='address_email' value='' size='50' class='mandatory email' /></div>";
    out += "<div class='orderfield'><div>Kommentarer</div><textarea name='address_comments' class='mandatory email' cols='50' /></textarea></div>";

    out += "<p><input type='checkbox' onclick='if(this.checked){deladdr(1);return;}if(!this.checked)deladdr(0)' /> Leveringsadresse er forskellig fra fakturaadresse</p>"
                                
    out += "<div id='deladdr'>";
    out += "<h2>Leveringsadresse</h2>";
    out += "<div class='orderfield'><div>Adresse</div><input type='text' name='address2_street' value='' size='50' /></div>";
    out += "<div class='orderfield'><div>Postnummer</div><input id='deladdr_zip' type='text' name='address2_zipcode'  onblur=\"zipcity(this.value, 'address2_city')\" value='' size='8' class='zipcode' /></div>";
    out += "<div class='orderfield'><div>By</div><input type='text' name='address2_city' id='address2_city' value='' size='50' /></div>";
    out += "</div>";
                                                            
    out += "<h2></h2>";
    out += "<input type='checkbox' id='terms_1' /> Jeg har læst og accepteret <a href='/index.php?pageid=19' target='_blank'>forretningsbetingelserne</a><br/>";
    out += "<input type='checkbox' id='terms_2' /> Jeg er opmærksom på at ændring i antal deltagere skal meddeles senest 7 dage før levering";

    out += "<div class='nextstep'><a href='#' onclick='validate_step(3)' class='flowbutton'>Godkend bestilling >></a></div>";
    out += "<div class='loading'>Vent venligst...</div>";

    $("#stepdiv").append(out);
    
    _gaq.push(['_trackPageview', '/funnel_g1/order_step3.html']);

    $.get("/includes/plugins/x.php?retrieve",
        function(data){
            order = $.parseJSON(data);
            $("#sel_del_type").val(order.delivery_type);
        });
            
    $.get("/includes/plugins/x.php?orderlines",
        function(data){
            $("#totals").html(data);
        }
    );

    $("input.mandatory").each(function(){
       $(this).prev("div").html($(this).prev("div").html() + " *"); 
    });                            
}

function final_step(){
    $("#stepdiv").html("");
    id = $("#product_id").val();
    $("#step").val(4);          
    out = "";                
    out += "<div id='receipt'></div>";
    out += "<div class='nextstep'><a href='/' class='flowbutton'>Gå til forsiden</a></div>";

    $.get("/includes/plugins/x.php?receipt",
        function(data){
            $("#receipt").html(data);
        }
    );

    $("#stepdiv").append(out);

    _gaq.push(['_trackPageview', '/funnel_g1/order_complete.html']);
}
    
$(function(){
    $("#mainmenu li:last a").css("color", "#f00");
    $("#mainmenu li:last").css("margin-right", "0");
    $("#your_email").focus(function(){if(this.value=='Din e-mail'){this.value='';return}})
    $("#your_email").blur(function(){if(this.value==''){this.value='Din e-mail';return}})
    $("#nlsub").click(function(){location='/index.php?mode=newsletter&action=subscribe&newsletterid=1&email='+$("#your_email").val()})    
});



