
// update the cached element
function changeElementValue (elementId, value){
    if(document.all){
       document.all[elementId].innerHTML = value;
    }
    else{
   	document.getElementById(elementId).innerHTML = value;
    }
}


// load and process the customer specific document
{
    var req;

    function loadXMLDoc(url) {
        // branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send(null);
            // branch for IE/Windows ActiveX version
        }
        else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = processReqChange;
                req.open("GET", url, true);
                req.send();
            }
        }
    }

    function processReqChange() {
        // only if req shows "complete"
        if (req.readyState == 4) {
            // only if "OK"
            if (req.status == 200) {
                // ...processing statements go here...
                response  = req.responseText;

                var tokens = response.split(":");

                var not_logged_in = tokens[0];
                var basket        = tokens[1];
                var country       = tokens[2];

                if( not_logged_in ){
                    changeElementValue ('signInText',' <a href="https://staging.net-a-porter.com/pws/secure/Signin.ice"><img src="/nap/build/8.19/images/top_nav/signIn.gif"\ alt="Sign In" /></a>');
                }
                else{
                    changeElementValue ('signInText', '<a href="http://staging.net-a-porter.com/pws/Logout.ice"><img src="/nap/build/8.19/images/top_nav/signOut.gif" alt=\"Sign Out" /></a> <a href="http://staging.net-a-porter.com/pws/secure/myaccount.nap"><img src="//nap/build/8.19/images/top_nav/myAccount.gif" alt="My Account" /></a>');

                }
                changeElementValue ('countryName', country );
                changeElementValue ('NoOfBasketItems', basket );
                
            }
            else {
                //alert("There was a problem retrieving the XML data:\n" + req.statusText);
            }
        }
    }
}

