﻿var oldSearchValue =""
var newSearchValue =""

//on page load check what to do with submit button
$(document).ready(function(){ 
    changeSubmitButtonStatus()  
});


function changeSubmitButtonStatus()
{
    //this has been totally changed by Stuart to simplify everything

    //on update, check previous search result label value with new AJAX-returned one       
    //returns true or false, which fires .net ajax animation only when values are different        


    //if the new value is greater than 0, enable submit button
    //find the number of search results
    newSearchValue = $('*[@id$=lblCount]').html(); 
    oldSearchValue = $('*[@id$=hdnOldCount]').val();  
    
    if (newSearchValue > 0)
    {//if there are results, enable submit
        $('input:submit.vacancyregister').attr("disabled", false).fadeTo("fast", 1)
    }
    else
    {// none - disable submit
        $('input:submit.vacancyregister').attr("disabled", true).fadeTo("fast", 0.35)
    }
      
    //compare the values and return back to conditional animation  
    if (newSearchValue != oldSearchValue)
    {   return true;   }
    else
    {   return false;  }
}
        
function checkCheckBoxes(strArea)
{//fired by conditional (on updated) script attached to each update panel
// checks for selected checkboxes and amends heading/image display as required
 
    var isChecked = "false"                  
        //grab all checkboxes within panel (specialism, region etc) 
        $("#" + strArea + " input[@type=checkbox]").each(function(i){
            //run fadeTo on parent h2 if any checkboxes are checked
            if ($("#" + strArea + " input[@type=checkbox]")[i].checked) 
           {          
                isChecked = "true"
                //find the h2 with the id matching the area and fade it
                //$("#regionContainer").fadeTo("fast", 1);                 
                
                //show the tick by going back to nearest sibling in DOM that's an image and swap classes
                $("#heading" + strArea).prev("img").addClass("complete").removeClass("hide");
            }

       })
       // none checked - ensure h2 is opaque
       if (isChecked == "false")  
            {        
                //$("#heading" + strArea).fadeTo("fast",1);
                //reset image classes to hide it
                $("#heading" + strArea).prev("img").addClass("hide").removeClass("complete");
                //$("#regionContainer").fadeTo("fast", 0.33);
            }    
 }  