﻿var engine = null;
window.onload = function() {
    engine = new AjaxEngine();
}

// constructor
function AjaxEngine() {

    // ini objects
    this.iframe = document.getElementById("hiddenIFrame");
    this.nav = document.getElementById("navigation");
    //this.startcampaign = document.getElementById("divCampaign");
    //this.startnews = document.getElementById("divNews");
    //this.startsales = document.getElementById("divSales");
    //this.startnewsandsales = document.getElementById("rightcolLeftright");
    //this.categories = document.getElementById("divCategories");
    this.minicart = document.getElementById("spanCart");

    // get page name
    var path = window.location.pathname.split('/');
    var page = "";
    for (var i = 0; i < path.length; i++) {
        // only the last pair contains the '.' and we can extract the page-name
        var pair = path[i].split(".");
        if (pair[1] != null) {
            page = pair[0];
        }
    }
    // set class to navigation link
    var elementsA = this.nav.getElementsByTagName("a");
    for (var j = 0; j < elementsA.length; j++) {
        var id = elementsA[j].getAttribute("id");
        if (id == "nav" + page) {
            elementsA[j].setAttribute("class", "red"); // change name to activenav
        }
    }

    // handle ajax callbacks
    var mainquery = window.location.search.substring(1);
    this.iframe.src = "hiddenframe.html?callbackby=" + page + "&" + mainquery;
}

/* present one random campaign on the start page
AjaxEngine.prototype.getStartCampaign = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getcampaigns.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.startcampaign.innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
*/

/* present one random campaign on the start page
AjaxEngine.prototype.getStartNewsAndSales = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getstartnewsandsales.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.startnewsandsales.innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
*/

// present three random new products on the start page
AjaxEngine.prototype.getStartNews = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getstartnews.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.startnews.innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

// present three random sale products on the start page
AjaxEngine.prototype.getStartSales = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getstartsales.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.startsales.innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

/* present categories on the site
AjaxEngine.prototype.getCategories = function(parentcategory, childcategory) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getcategories.aspx?pc=" + parentcategory + "&cc=" + childcategory);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.categories.innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
*/

/* present product list for a specific category
AjaxEngine.prototype.getProducts = function(parentcategory, childcategory, orderby, xaction) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getproducts.aspx?pc=" + parentcategory + "&cc=" + childcategory + "&sortera=" + orderby + "&get=" + xaction);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                document.getElementById("divMain").innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
*/

/* present product list for a specific category
AjaxEngine.prototype.searchProducts = function(sokord, orderby) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/searchproducts.aspx?sokord=" + sokord + "&sortera=" + orderby);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                document.getElementById("divMain").innerHTML = oXmlHttp.responseText;
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
*/

// add product to cart
AjaxEngine.prototype.add2Cart = function(id, price, amount) {
    parent.engine.minicart.innerHTML = "<img src=\"img/ajax-loader.gif\" border=\"0\" alt=\"laddar...\"/>";
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/add2cart.aspx?id=" + id + "&price=" + price + "&amount=" + amount);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.minicart.innerHTML = EDEN_miniCart(oXmlHttp.responseText);
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

// remove product from cart
// only used from the cart popup
AjaxEngine.prototype.rem2Cart = function(id) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/rem2cart.aspx?id=" + id);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                var res = oXmlHttp.responseText;

                // expect numeric response else error message
                if (!isNaN(parseInt(res))) {
                    parent.engine.minicart.innerHTML = EDEN_miniCart(res);
                    parent.engine.getCart();
                }
                else {
                    document.getElementById("popuperrmsg").style.display = "block";
                    document.getElementById("popuperrmsg").innerHTML = "<p class=\"validationmsg\">" + res + "</p>";
                    document.getElementById("updtcart-ajax-loader").style.display = "none";
                }

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}


// add product to cart
AjaxEngine.prototype.updt2Cart = function(cart) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/updt2cart.aspx?cart=" + cart);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                parent.engine.minicart.innerHTML = EDEN_miniCart(oXmlHttp.responseText);

                // but we need to update the popup as well!
                parent.engine.iframe.src = "hiddenframe.html?callbackby=cart";

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

// add product to cart
AjaxEngine.prototype.getCartAmount = function() {
    parent.engine.minicart.innerHTML = "<img src=\"img/ajax-loader.gif\" border=\"0\" alt=\"laddar...\"/>";
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getcartamount.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                parent.engine.minicart.innerHTML = EDEN_miniCart(oXmlHttp.responseText);
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

// get the full cart with posibility to change amount and delete goods
AjaxEngine.prototype.getCart = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getcart.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // the cart content is always presented in a popup
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

// send message from the contact page
AjaxEngine.prototype.sendMessage = function(n, e, m) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/sendmessage.aspx?ce=" + escape(e) + "&cn=" + escape(n) + "&m=" + escape(m) + "&cont=true");
    //oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset:ISO-8859-1");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;
                var msg = "";

                if (res == "1") {
                    // error
                    // leave the fields as they are
                    msg = "Meddelandet har ej kunnat skickas pga ett oförutsett fel.";
                }
                else {
                    // no error
                    // empty fields
                    document.getElementById("txtNamn").value = "";
                    document.getElementById("txtEpost").value = "";
                    document.getElementById("txtMeddelande").value = "";
                    msg = "Meddelandet har skickats!<br/>Vår ambition är att svara så fort som möjligt.";
                }

                var html = "<div style=\"font-size: 12px; color: #4b4b4b; margin: 4px 4px 8px 4px;\">" + msg + "</div>";
                html += "<div style=\"padding: 8px 4px 0px 4px; text-align: center;\"><a class=\"button_black\" style=\"text-align: right; float: right;\" href=\"javascript:EDEN_closePopup();\"><span>Stäng</span></a></div>";
                document.getElementById("eden_popup").innerHTML = html;

            } else {
                EDEN_closePopup();
                alert("Meddelandet har ej kunnat skickas pga ett oförutsett fel: \n" + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}


// present the order confirmation if the user is logged in
AjaxEngine.prototype.confirmCart = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/confirmcart.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                
                // the cart content is always presented in a popup
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;

                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.isLoggedin = function(page) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/isloggedin.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {


                var res = oXmlHttp.responseText;
                if (res == "0") {
                    // not logged in, present log in popup
                    EDEN_loginFrm(page);
                }
                else {
                    // logged in, redirect to requested page
                    if (page == "account") {
                        location.href = "mittkonto.aspx";
                    }
                    else {
                        parent.engine.confirmCart();
                    }
                }

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.loginFrm = function(page) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getloginfrm.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                
                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText.replace("?page",page);
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.resetpwdFrm = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getresetpwdfrm.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.shopInactive = function () {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getshopinactive.aspx");

    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.updtpwdFrm = function() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getupdtpwdfrm.aspx");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.regcustFrm = function () {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getregcustfrm.aspx");

    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}

AjaxEngine.prototype.regCust = function(params) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("POST", "srv/regcust.aspx", true);

    oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset:ISO-8859-1");
    oXmlHttp.setRequestHeader("Content-length", params.length);
    oXmlHttp.setRequestHeader("Connection", "close");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;
                if (res == "0") {
                    // ok, present message to activate account
                    EDEN_createPopup("Laddar...");
                    document.getElementById("eden_popup").innerHTML = "<div style=\"width: 400px; line-height: 16px;\"><h2>Registreringen lyckades</h2><br/>Nu kan du logga in med det användarnamn och lösenord du valt.</div>";
                    //document.getElementById("eden_popup").innerHTML = "<div style=\"width: 400px; line-height: 16px;\"><h2>Registreringen lyckades</h2><br/>Nu behöver du aktivera kontot. En aktiveringslänk har skickats till dig via e-post. Klicka på den eller kopiera länken till adress fältet i ditt browser fönster för att avsluta registreringen.</div>";
                    //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                    EDEN_resetPopup();
                } else if (res == "-1") {
                    document.getElementById("popup-ajax-loader").style.display = "none";
                    document.getElementById("btnRegister").href = "javascript:EDEN_registerCustomer();";
                    //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                    document.getElementById("popuperrmsg").style.display = "block";
                    document.getElementById("popuperrmsg").innerHTML = "<p class=\"validationmsg\">Registreringen misslyckades! Angiven e-post adress finns redan registrerad! Ange en ny.</p>";
                } else {
                    document.getElementById("popup-ajax-loader").style.display = "none";
                    document.getElementById("btnRegister").href = "javascript:EDEN_registerCustomer();";
                    //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                    document.getElementById("popuperrmsg").style.display = "block";
                    document.getElementById("popuperrmsg").innerHTML = "<p class=\"validationmsg\">Registreringen misslyckades pga ett oförutsett fel. Försök igen, om felet upprepas kontakta Boutique Edens <a href=\"kontaktaoss.aspx\" class=\"red\">kundtjänst</a> och förklara problemet.</p>" + res;
                }
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(params);
}

AjaxEngine.prototype.updateCust = function(params) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("POST", "srv/updatecust.aspx", true);

    oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset:ISO-8859-1");
    oXmlHttp.setRequestHeader("Content-length", params.length);
    oXmlHttp.setRequestHeader("Connection", "close");

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;
                EDEN_closePopup();
                var pageMsg = document.getElementById("pageMsg");
                pageMsg.style.display = "block";
                var attClass = "validationmsg";
                var msg = "";
                if (res == "0") {
                    // ok, inform all is well
                    attClass = "validationgreenmsg";
                    msg = "Dina uppgifter har sparats.";
                } else if (res == "-1") {
                    // unsuccessfully tried to change email
                    msg = "E-post adressen du försökte ändra till finns redan registrerad av en annan kund!";
                } else {
                    // some other error
                    msg = "Ett oförutsett fel har inträffat! Försök igen lite senare. Om felet kvarstår kontakta oss.";
                }

                pageMsg.setAttribute("class", attClass);
                pageMsg.innerHTML = msg;

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(params);
}

AjaxEngine.prototype.validateLogin = function(params) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("POST", "srv/validatelogin.aspx", true);

    oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    oXmlHttp.setRequestHeader("Content-length", params.length);
    oXmlHttp.setRequestHeader("Connection", "close");


    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;
                if (res == "0") {
                    // ok, present message to activate account
                    location.href = "mittkonto.aspx";
                } else if (res == "1") {
                    parent.engine.confirmCart();
                } else {
                    document.getElementById("popup-ajax-loader").style.display = "none";
                    document.getElementById("btnLogin").href = "javascript:EDEN_validateLogin();";
                    //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                    document.getElementById("popuperrmsg").style.display = "block";
                    document.getElementById("popuperrmsg").innerHTML = "<p class=\"validationmsg\">Inloggningen misslyckades!</p>";
                }
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(params);
}

AjaxEngine.prototype.resetPwd = function(params) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("POST", "srv/resetpwd.aspx", true);

    oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    oXmlHttp.setRequestHeader("Content-length", params.length);
    oXmlHttp.setRequestHeader("Connection", "close");


    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;
                if (res == "0") {
                    EDEN_createPopup("Laddar...");

                    var html = "<div style=\"text-align: left;\">";
                    html += "<h3>Skapa nytt lösenord</h3>";
                    html += "<div class=\"textomradepopup\" style=\"white-space:nowrap;\"><p>Ett nytt lösenord har skickats till <span class=\"red\">" + params.replace("email=", "") + "</span></p></div>";
                    html += "<div class=\"clear\">&#32;</div>";
                    html += "<a class=\"button_black\" href=\"javascript:EDEN_closePopup();\"><span>Stäng</span></a>";
                    html += "</div>";
                    
                    document.getElementById("eden_popup").innerHTML = html;
                    //document.getElementById("btnClose").style.display = "none";
                    EDEN_resetPopup();
                } else {
                    document.getElementById("popup-ajax-loader").style.display = "none";
                    document.getElementById("btnResetPwd").href = "javascript:EDEN_resetPwd();";
                    //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                    document.getElementById("popuperrmsg").style.display = "block";
                    document.getElementById("popuperrmsg").innerHTML = "<p class=\"validationmsg\">Ett nytt lösenord skapades inte eftersom e-postadressen du angav inte hittades i vårt register!</p>";
                }
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(params);
}

AjaxEngine.prototype.updatePwd = function(params) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("POST", "srv/updatepwd.aspx", true);

    oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset:ISO-8859-1");
    oXmlHttp.setRequestHeader("Content-length", params.length);
    oXmlHttp.setRequestHeader("Connection", "close");


    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var res = oXmlHttp.responseText;

                document.getElementById("oldpassword").value = "";
                document.getElementById("password1").value = "";
                document.getElementById("password2").value = "";

                document.getElementById("popup-ajax-loader").style.display = "none";
                document.getElementById("btnUpdatePwd").href = "javascript:EDEN_updtPwd();";
                //document.getElementById("btnClose").href = "javascript:EDEN_closePopup();";
                document.getElementById("btnCancel").href = "javascript:EDEN_closePopup();";
                document.getElementById("popuperrmsg").style.display = "block";

                var msg = "";
                if (res == "0") {
                    msg = "<p class=\"validationgreenmsg\">Ditt lösenord har ändrats!</p>";
                } else {
                    msg = "<p class=\"validationmsg\">Ändringe misslyckades förmodligen för att det gamla lösenordet inte var korrekt.</p>";
                }

                document.getElementById("popuperrmsg").innerHTML = msg;
                
            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(params);
}


AjaxEngine.prototype.getwebOrder = function(id) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("GET", "srv/getweborder.aspx?id=" + id);

    oXmlHttp.onreadystatechange = function() {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {

                // return the login popup content
                document.getElementById("eden_popup").innerHTML = oXmlHttp.responseText;
                EDEN_resetPopup();

            } else {
                alert("FEL: " + oXmlHttp.statusText);
            }
        }
    }

    oXmlHttp.send(null);
}
