
function GetArtistListing(SortFieldID, SortDirectionID)
    {
        var xmlArtistHttp;
        try
            {    // Firefox, Opera 8.0+, Safari    
                 xmlArtistHttp=new XMLHttpRequest();    
            }
        catch (e)
            {    
                 // Internet Explorer    
                 try
                    {      
                        xmlArtistHttp=new ActiveXObject("Msxml2.XMLHTTP");      
                    }
                catch (e)
                    {      
                        try
                            {        
                                xmlArtistHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                            }
                        catch (e)
                            {        
                                alert("Your browser does not support AJAX!");        
                                return false;        
                            }      
                     }    
             }

        xmlArtistHttp.onreadystatechange=function()
            {
                if(xmlArtistHttp.readyState==4)
                    {
                        // Process the results that we get from our call
                        var sResultText = xmlArtistHttp.responseText;
                        
                        // Trim off the spurious script block from the reply
                        if (sResultText.indexOf("/script")  > -1)
                            {
                                sResultText = sResultText.substr(sResultText.indexOf("/script") + 8);
                            }
                            
                        // Trim off the spaces and things
                        var sResultText = sResultText.replace(/^\s+|\s+$/g, '')

                        // Clear down any results that are currently being shown //
                        if (document.getElementById('ArtistListing'))
                            {
                                var objTableBody = document.getElementById('ArtistListing');
                                if (objTableBody.hasChildNodes())
                                    {
                                        while (objTableBody.childNodes.length >= 1)
                                            {
                                                objTableBody.removeChild(objTableBody.firstChild);
                                            }
                                    }
                            }

                        // Split the result up into the individual items
                        var asItemList = sResultText.split('|')

                        // Loop through all of the items and add them to our result table
                        for (iRecordLoop = 0; iRecordLoop < asItemList.length; iRecordLoop++)
                            {
                                var asSingleItem = asItemList[iRecordLoop].split('~');
                                
                                var sArtistID = asSingleItem[0];
                                var sArtistName = asSingleItem[1];
                                var sStateName = asSingleItem[2];
                                var sArtworkList
                                
                                if (asSingleItem[3]) { sArtworkList = asSingleItem[3]; }

                                // Create the result item for display //
                                CreateBrowseResult(sArtistID, sArtistName, sStateName, sArtworkList);
                                    
                            }

                    }
            }

        // Make the main request - pass the map bounds (split out) to the read page
        xmlArtistHttp.open('GET','/ArtistLounge/BrowseCallback.asp?F=' + SortFieldID + '&D=' + SortDirectionID,true);
        xmlArtistHttp.send(null);  
    
    }
    
function CreateBrowseResult(ArtistID, ArtistName, StateName, ArtworkItems)
    {
    
        // Create a new table row element //
        var objTableRow = document.createElement('tr');
        
        // Create and append the artist name cell //
        var objNameCell = document.createElement('td');
        objNameCell.setAttribute('align', 'left');
        objNameCell.setAttribute('valign', 'middle');
        
        var objNameLink = document.createElement('a');
        objNameLink.setAttribute('href', '/ArtistInfo/' + ArtistID);
        objNameLink.innerHTML = ArtistName;
        objNameCell.appendChild(objNameLink);
        
        // Create and append the state cell //
        var objStateCell = document.createElement('td');
        objStateCell.setAttribute('align', 'left');
        objStateCell.setAttribute('valign', 'middle');
        objStateCell.innerHTML = StateName;
        
        // Create and append the artwork list cell //
        var objArtworkCell = document.createElement('td');
        objArtworkCell.setAttribute('align', 'left');
        objArtworkCell.setAttribute('valign', 'middle');
        
        var asArtistItems = ArtworkItems.split(',');
        
        // Loop through all of the artwork items 
        for (iRecordLoop = 0; iRecordLoop < asArtistItems.length; iRecordLoop++)
            {
                var asSingleItem = asArtistItems[iRecordLoop].split('=');
                
                var sDescription = asSingleItem[0];
                var sIconPath = asSingleItem[1];
                
                // Create the result item for display //
                var objImage = document.createElement('img');
                objImage.setAttribute('alt', sDescription);
                objImage.setAttribute('title', sDescription);
                objImage.setAttribute('src', sIconPath);
                objImage.style.cssText = 'padding: 2px 2px 2px 2px;';

                objArtworkCell.appendChild(objImage);
                   
            }
        
        // Add these cells to the row //
        objTableRow.appendChild(objNameCell);
        objTableRow.appendChild(objStateCell);
        objTableRow.appendChild(objArtworkCell);
        
        // Append this row to the table //
        if (document.getElementById('ArtistListing'))
            {
                document.getElementById('ArtistListing').appendChild(objTableRow);
            }
    }

function FixSearchSelections()
    {
        var iSearchType = 0 
        
        for (iFindType = 0; iFindType < document.frmMain.optSearchType.length; iFindType++)
            {
                if (document.frmMain.optSearchType[iFindType].checked == true)
                    {
                        iSearchType = document.frmMain.optSearchType[iFindType].value;
                    }
            }
        
        for (iEnable = 0; iEnable < document.frmMain.chkSearchType.length; iEnable++)
            {
                document.frmMain.chkSearchType[iEnable].disabled = (iSearchType == 0) ? 'disabled' : '';
            }
    }    
