function initSearch()
{
global_scrollHeight = 0;    
global_block = false;      
global_maxpage = 1;
global_maxarticleCount = 25;
global_page = 1;           
global_articleCount = 0;    

document.getElementById('PanelArticleList').style.display = 'none';
document.getElementById('ArticleNumberSummary').innerHTML = '';
document.getElementById('ResultBox').scrollTop = global_scrollHeight;

while(document.getElementById('ResultBox').firstChild)
    {
    document.getElementById('ResultBox').removeChild(document.getElementById('ResultBox').firstChild);
    }

global_searchString = document.getElementById('queryBox').value;

performSearch();  
}

function performSearch()
{
document.getElementById('Loader').style.display = 'block';
ShoppingMap.WebApp.AjaxWebservice.GetSearchResults(global_searchString, global_page, finishedSearch);
}

function finishedSearch(result)
{
if(result.TotalResults == 0) 
{
document.getElementById('Loader').style.display = 'none';
document.getElementById('PanelArticleList').style.display = 'block';
document.getElementById('ArticleNumberSummary').innerHTML = '[ Suchergebnis: ' + global_searchString + ' | 0 Ergebnisse gefunden ]';

return false;
}

document.getElementById('Loader').style.display = 'none';
document.getElementById('PanelArticleList').style.display = 'block';
global_maxpage = result.TotalPages;
global_maxarticleCount = result.TotalResults;

for(var i=0; i<result.ArticleResults.length; i++)
    {
    var aLink = document.createElement("a");
    aLink.setAttribute('href', result.ArticleResults[i].Url);
    
    var img = document.createElement("img");
    img.src = result.ArticleResults[i].PictureGallery[0].Url;
    img.className = 'ImageContainer';
    img.id = result.ArticleResults[i].Asin;
    aLink.appendChild(img);
    document.getElementById('ResultBox').appendChild(aLink);

    }
   
global_articleCount += result.ArticleResults.length;
global_page++;

var min = 1;
if(global_maxarticleCount == 0)
    {
    min = 0;
    }
document.getElementById('ArticleNumberSummary').innerHTML = '[ Suchergebnis: ' + global_searchString + ' | ' + min + ' - ' + global_articleCount + ' von ' + global_maxarticleCount + ' ]';
global_block = false;
return true;
}
