function showBrands(url) {
    if(document){
        var brandList = document.getElementById("brandList");
        if(hasDivTags(brandList)){
            for(var j = brandList.childNodes.length -1; 0 <= j; j--){
                var brandNode = brandList.childNodes[j];
                if(brandNode && 'DIV' == brandNode.tagName){
                    brandList.removeChild(brandNode);
                }
            }
            return;
        }
    }

    var xmlhttp = getXMLHttpRequest();
    xmlhttp.onreadystatechange=function() {
         if (xmlhttp.readyState==4 && xmlhttp.status==200){
             setBrands(xmlhttp);
         }
    };


    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}



function hasDivTags(element){
    if(element && element.hasChildNodes()){
        for(var i = 0; i<element.childNodes.length; i++){
            var e = element.childNodes[i];
            if(e && 'DIV' == e.tagName){
                return true;
            }
        }
    }

    return false;
}

function getXMLHttpRequest() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    else {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
}

function setBrands(req) {
    if(!document){
        return;
    }
       
    var brandList = document.getElementById("brandList");
    if(hasDivTags(brandList)){
        return;
    }

	var brands = req.responseXML.getElementsByTagName('brand');
	for (var i=0;i<brands.length;i++)
	{
        var brand = brands[i];

        var div = document.createElement('div');
        div.className = 'brandNav';
        var a = document.createElement('a');      
        a.className = 'leftNav';

        a.setAttribute('href', brand.getAttribute('url'));
        a.appendChild(document.createTextNode(brand.getAttribute('name')));

        div.appendChild(a);

		document.getElementById('brandList').appendChild(div);
	}
}


