﻿ function ClearChecks(CheckBoxListID)
 {
        //Loop though until we have uncheck all items
        var bMoreChecks = true
        var iIndex = 0;
        while (bMoreChecks && iIndex < 999)  //Count is failsafe to stop loop getting stuck
        {
            var chk = document.getElementById(CheckBoxListID + "_" + iIndex);
            //See if now run out, if we are at null than gone past the last one
            if (chk == null)
            {
               alert(iIndex);
                bMoreChecks = false;  //Exists the loop
            }
            else
            {
                chk.checked = false;
               
            }            
            iIndex++;
        }      
        alert(iIndex); 
         
    }
    

   function gotoResults()  
    {
         window.location ="#results";
         alert("test");
    }

    function ShowHideCriteria(CheckBox, CheckBoxListID)
    {
        //Get the number of the checkbox that is after the $ at the end of the name
        var checkID = CheckBox.name;
      
        checkID = checkID.substring(checkID.lastIndexOf("$") + 1, checkID.length);
        var divID = CheckBox.name.substring(0, CheckBox.name.lastIndexOf("chkSearch")) + "div_" + checkID;
        divID = divID.replace(/\$/g, "_");        
        
        //Now get the div that has the collection of criteria and then show or hide it
        
        var div = document.getElementById(divID);
        if (div == null)
        {
            //Page still loading show message to try again
            alert('The page is still loading, please click OK and try selecting this option again.');
            checkID.checked = false;
        }
        if (CheckBox.checked)
        {
            div.style.display = "inline";
        }
        else
        {
           div.style.display = "none";
           //Clear any checks already made
           //ClearChecks(CheckBoxListID);
        }
        
       
    
    }
