/**
 * @author ehandelsbureauet for fedepriser.dk
 * this script is copyrighted and is not allowed to be used in any way without permission
 */



   
function initSite(){
	categoryPictureList();
}








//CATEGORY FPAGESCRIPT //
function categoryPictureList(){

    var imgs = {}; // Map img tag from url to img object
    // Find all images in menu, swap their a hrefs title into the place of the image
    
    if (document.getElementById("ProductMenu_Table")) {
        var productMenu = document.getElementById("ProductMenu_Table");        
        var img = productMenu.getElementsByTagName("IMG");
		        
        for (var i = 0; i < img.length; i++) {
            var parent = img[i].parentNode; // The a tag
            var title = (parent.tagName == "B" ? parent.parentNode.title : parent.title); // title of a tag, which becomes link text
            var href = (parent.tagName == "B" ? parent.parentNode.href : parent.href)
            
            if (title) {
                imgs[href] = img[i];
                parent.innerHTML += title;
            }
        }
        
        // Find product list and move the image into that position
        var a = document.getElementsByTagName("A");
        
        for (var i = 0; i < a.length; i++) {
        
            if ((a[i].className == "SubCats_Prodlink")) {
            
                var img = imgs[a[i].href];
                
                if (img) {
                    var innerHTML = a[i].innerHTML;					
					
					
					a[i].innerHTML = "";
					a[i].innerHTML += innerHTML;
                    
					a[i].innerHTML += "";
					
					a[i].appendChild(img);
					
					a[i].innerHTML += "";
                    
                }
                
            }
        }
    }
}
