function createRequestObject() {
    var tmpXmlHttpObject;
    if (window.XMLHttpRequest) { 
        tmpXmlHttpObject = new XMLHttpRequest();
	
    } else if (window.ActiveXObject) { 
        tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return tmpXmlHttpObject;
}

var http5 = createRequestObject();

function UpdateLogonStatus() {
    http5.open('get', '/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_CheckStatus');
    http5.onreadystatechange = processResponse;
    http5.send(null);
}

function processResponse() {
    if(http5.readyState == 4){
        var response = http5.responseText;
		//alert('Response: '+response);
		if (response == '1') {
			//alert('LoggedIn')
			document.getElementById('LogonStatusText').innerHTML = "Sie sind angemeldet.";
			document.getElementById('wklinks').innerHTML = ' | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Entrance" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/account_ico.gif" border="0" style="margin-right:3px;">Kundenlogin</a> | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Logout" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/login_ico.gif" border="0" style="margin-right:3px;">abmelden</a>';
		} else {
			//alert('NotLoggedIn')
			document.getElementById('LogonStatusText').innerHTML = "Sie sind nicht angemeldet.";
			document.getElementById('wklinks').innerHTML = ' | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Entrance" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/login_ico.gif" border="0" style="margin-right:3px;">Kundenlogin</a>';
		}
    }
}

function setAttributeValue(id) {
	
	var row = document.getElementById("ln_"+id);
	
	if (row) {
		// creat a attribute node for the row
		row.style.fontSize = "20px";
		row.style.color = "#FFFFFF";
		
		row.firstChild.style.color ="#FFFFFF";
		row.firstChild.style.backgroundColor ="#668c66";
	}
}

function processPathResponse() {
    if(http5.readyState == 4){
        var response = http5.responseText;
		//alert('Response: '+response);
        var parts = response.split('|');
        var login = parts[0];
        var navi = parts[1];
        
        if (login == '1') {
			//alert('LoggedIn')
			document.getElementById('LogonStatusText').innerHTML = "Sie sind angemeldet.";
			document.getElementById('wklinks').innerHTML = ' | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Entrance" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/account_ico.gif" border="0" style="margin-right:3px;">Kundenlogin</a> | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Logout" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/login_ico.gif" border="0" style="margin-right:3px;">abmelden</a>';
		} else {
			//alert('NotLoggedIn')
			document.getElementById('LogonStatusText').innerHTML = "Sie sind nicht angemeldet.";
			document.getElementById('wklinks').innerHTML = ' | <a href="https://www.allnatura.de/shop/index.fxa?action=Flexsia_Application_Process_User_Customer_Entrance" class="pageheadlink" style="font-weight:bold;"><img src="/bild/pageheader/login_ico.gif" border="0" style="margin-right:3px;">Kundenlogin</a>';
		}
		setAttributeValue(navi);
    }
}


// Suchvorschlaege
var http_suggest = createRequestObject();
 
function sndSuggestReq(QueryString) {
    http_suggest.open('get', '/scripts/suggest/suggest.php?QueryString='+encodeURIComponent(QueryString));
    http_suggest.onreadystatechange = handleSuggestResponse;
    http_suggest.send(null);
}
 
function handleSuggestResponse() {
    if(http_suggest.readyState == 4){
        var response = http_suggest.responseText;
        var update = new Array();
 
        if(response.indexOf('|' != -1) && response.indexOf('li' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
			document.getElementById('results').style.display = 'block';
        } else {
			document.getElementById('results').style.display = 'none';
		}
		if (update[1]=='') {
			document.getElementById('results').style.display = 'none';
		}
    }
}
