// WebServiceProxy.js


var mobjSearchProviderTable;
var mintPageSize = 15;
var mintPageIndex = 1;

function InitializeCoachesAsync(cbSuccess,cbFailed)
{
  Sys.Net.WebServiceProxy.invoke("/solutions/public/publiclistdata.asmx", 
        'GetCoaches', false,
        {},
        cbSuccess,cbFailed, "User Context",24000);
  
}


function InitializePicturesAsync(cbSuccess,cbFailed)
{
  Sys.Net.WebServiceProxy.invoke("/solutions/public/publiclistdata.asmx", 
        'GetPictures', false,
        {},
        cbSuccess,cbFailed, "User Context",24000);
  
}

function InitializeAnnouncementsAsync(cbSuccess,cbFailed)
{
  Sys.Net.WebServiceProxy.invoke("/solutions/public/publiclistdata.asmx", 
        'GetAnnouncements', false,
        {},
        cbSuccess,cbFailed, "User Context",24000);
  
}

function InitializeAnnouncements()
{
  Sys.Net.WebServiceProxy.invoke("/solutions/public/publiclistdata.asmx", 
        'GetAnnouncements', false,
        {},
        OnSucceededAnnouncements,OnFailedAnnouncements, "User Context",24000);
  
}


function OnSucceededAnnouncements(result, eventArgs)
{
 
 
      
       
  
}
function OnFailedAnnouncements(error)
{
    // Display the error.    
    var RsltElem = 
        document.getElementById("ResultId");
    RsltElem.innerHTML = 
    "Service Error: " + error.get_message();
}


function BindSearchResults(provider)
{

    
    //debugger;
    // Declare variables and create the header, footer, and caption.
    var oTable = document.createElement("TABLE");
    mobjSearchProviderTable = oTable;
    var oTHead = document.createElement("THEAD");
    var oTBody0 = document.createElement("TBODY");

    var oTFoot = document.createElement("TFOOT");
    var oCaption = document.createElement("CAPTION");
    var oRow, oCell;
    var i, j;


    // Insert the created elements into oTable.
    oTable.appendChild(oTHead);
    oTable.appendChild(oTBody0);

    oTable.appendChild(oTFoot);
    oTable.appendChild(oCaption);

    // Set the table's border width and colors.
    oTable.border=0;
    oTable.className="SearchResultsTable";

    // Insert a row into the header and set its background color.
    oRow = document.createElement("TR");
    oTHead.appendChild(oRow);
    oTHead.className = "SearchResultsHeader";


    oCell = document.createElement("TH");
    oCell.innerText = "Found " + provider.CurrentResult.estimatedTotalResultsCount + " results from the " + provider.SearchProviderTitle + ', ' + provider.SearchProviderDescription;
    oCell.title = "Click on each of the providers to see the search results."
    oRow.appendChild(oCell);


        var r;
        for (r=0;r<provider.CurrentResult.resultElements.length ;r++)
        {
            oRow = document.createElement("TR");
           // oRow.onclick = SearchResultClicked;
            oRow.className = "SearchResultRow";
            oTBody0.appendChild(oRow);
            oCell = document.createElement("TD");
            oCell.className = "SearchResultTitleCell"; 
            oCell.innerHTML = "<a href=\"javascript:GotoPage('" + provider.CurrentResult.resultElements[r].URL + "','" + provider.CurrentResult.resultElements[r].URLTarget + "')\" >" +  formatTitle(provider.CurrentResult.resultElements[r].title) + "</a>";
            oCell.title = provider.CurrentResult.resultElements[r].URL
           // oCell.setAttribute("SearchProviderID",provider.CurrentResult.resultElements[r].SearchProviderID)
            oRow.appendChild(oCell);
            
        }
        

    // Set the background color of the first body.
    oTBody0.className = "SearchResultsBody";



    // Create and insert rows and cells into the footer row.
    oRow = document.createElement("TR");
    oTFoot.appendChild(oRow);

    // Set the innerText of the caption and position it at the bottom of the table.
    oCaption.innerText = ""
    oCaption.style.fontSize = "10";
    oCaption.align = "bottom";

    // Insert the table into the document tree.


     var cont = 
            document.getElementById("SearchProviderResultsContainer");
        cont.innerHTML = "";
        cont.appendChild(oTable);
}



