﻿function showResultPage(page)
{
   var numResults = 25;
   var results = document.getElementsByName("Result");
   //Set all results to hide
   for (var i=0;i<results.length;i++)
   {
        results[i].style.display="none";
   }  
   
   //Show only the results that we want
   if (results.length > (page*numResults-numResults))
   {
       for (var i=page*numResults-numResults;i<page*numResults;i++)
       {
        if (results[i] != null)
            results[i].style.display="block";
       }  
       //Safari workaround, get the new html after the visiblity toggling
       // and set the display div to the new html and hide the original div
       var html = document.getElementById("raw").innerHTML;
       document.getElementById("raw").style.display = "none";
       document.getElementById("display").innerHTML = html;
   }
   var numTotalResults = document.getElementById("hidNumberOfResults").value;
   var pageStart = (page*numResults-numResults)+1;
   var pageEnd = page*numResults;
   if (pageEnd > numTotalResults)
    pageEnd = numTotalResults;
   var pageRange =  pageStart + " - " + pageEnd;
   if (numTotalResults > 0)
    document.getElementById("resultSummary").innerHTML = "Viewing " + pageRange + " of " + numTotalResults + " results";
 
}

    function radioValue(radio) {
        var i;
        for (i=0; i<radio.length; i++)
        if (radio[i].checked)
            return radio[i].value;
            // otherwise no radio button of the radio button group is selected
            return "undefined";
    }
	
	function launchSearch(objSearchBox,channel)
	{
        if (radioValue(document.forms[0].searchtype) != "undefined")
            channel = radioValue(document.forms[0].searchtype);
            window.location.href="http://www.taunton.com/finecooking/dtSearch/searchResults.aspx?searchfor=" + document.getElementById(objSearchBox).value + "&channel=" + channel + "&page=1"; 
    }

function checkEnter(e,objSearchBox,channel)
{ 
    var iAscii;
    if (window.event)
        iAscii = window.event.keyCode;
    else if (e)
        iAscii = e.which;

    if (iAscii == 13)
    {
        launchSearch(objSearchBox,channel);
        return false;
    }

    

}




	

