﻿$ektron(document).ready(function()
{

    $('.searchOption h3').click(function() 
    {
        $(this).next().toggle('normal');
        var hdnOpen = $(this).siblings(':input:hidden').val();
        if (hdnOpen == 0) {
            $(this).siblings(':input:hidden').val('1');
        } else {
            $(this).siblings(':input:hidden').val('0');
        }
        return false;
    });

    
    /*
    $('#ctl00_ctl00_MainContentPlaceHolder_CenterColumnPlaceHolder_btnSearch2').click(function(event)
    {
        
        var totalMediaTypesChecked = $("#ctl00_ctl00_MainContentPlaceHolder_CenterColumnPlaceHolder_lbMediaType input[type=checkbox]:checked").length;
        //alert("totalMediaTypesChecked = "+totalMediaTypesChecked);
        
        if(totalMediaTypesChecked<=0)
        {
            var HiddenValue = document.getElementById("<%= MyHiddenField.ClientID %>")
            alert('Please select at least one Media Type before searching.');
            event.preventDefault();
        }

    });
    
    // Used to toggle all option
    $('.optionList').each(function() {
       $(this).find(':checkbox:first').click(function() {
           var checkedState = this.checked;
           if (checkedState == true) {
                $(this).parents('.optionList').find(':checkbox:gt(0)').each(function() {
                    this.checked = false;
                });
            }
            $('.searchBTN').click();
        });

        $(this).find(':checkbox:gt(0)').click(function() {
            $(this).parents('.optionList').find(':checkbox:first').attr('checked', false);
            $('.searchBTN').click();
        });
    });

    $('.optionList :checkbox').click(function() {
        $('.searchBTN').click();
    });
    
    $('.removeicon').click(function() {
        var locationCoord = $(this).attr('id').split('_');
        var OptionCat = locationCoord[0];
        var OptionIndex = locationCoord[1];
        //alert("locationCoord = "+locationCoord +"\nOptionCat = "+OptionCat+"\nOptionIndex = "+OptionIndex);
        $('.searchOption:eq(' + OptionCat + ') td :input:eq(' + OptionIndex + ')').attr('checked', false);
        $('.searchBTN').click();
    });
    
    */
    
})
