function swatchShow(id) {

    var ulCount = Math.floor((imageArray.length / 3));
    var groupStart = 0;
    var groupEnd = 3;
    
    if (groupEnd > imageArray.length) { 
        
        groupEnd = imageArray.length; 
    }
    
    for (var i = 0; i < (ulCount + 1); i++) {
    
        var ul = document.createElement('ul');
        ul.className = 'swatches';
        ul.id = 'ul' + id + i;
        
        for (var j = groupStart; j < groupEnd; j++) {
            
            var img = document.createElement('img');
            img.src = imageArray[j].src;
            img.width = '117';
            img.height = '117';
            img.alt = '';
        
            var br = document.createElement('br');
            var span = document.createElement('span');
        
            if (imageArray[j].desc == '') { 
            
                imageArray[j].desc = '.'; 
                span.className = 'hidden';
            
            }
            
            var txt = document.createTextNode(imageArray[j].desc);
           
            var li = document.createElement('li');
            
            li.appendChild(img);
            li.appendChild(br);
            span.appendChild(txt);
            li.appendChild(span);
            
            ul.appendChild(li);
        }
        
        groupStart = (groupStart + 3);
        groupEnd = (groupEnd + 3);
        
        if (groupEnd > imageArray.length) { 
        
            groupEnd = imageArray.length; 
        }
        
        document.getElementById('item' + id).appendChild(ul);
    }
    
    document.getElementById('show' + id).style.display = 'none';
    document.getElementById('hide' + id).style.display = 'block';
}
    
function swatchHide(id) {

    var ulCount = Math.floor((imageArray.length / 3));
    
    for (var i = 0; i < (ulCount + 1); i++) {
    
        document.getElementById('item' + id).removeChild(document.getElementById('ul' + id + i));
    }
    
    document.getElementById('show' + id).style.display = 'block';
    document.getElementById('hide' + id).style.display = 'none';
}

function pageChange(href) {
    
    if (href != "null") { 
    
        window.location = href; 
    }
}