﻿$(document).ready(function() {
    // form validation call
    $("form").validationEngine();

    $(".disabled").css('opacity', 0.5);

    $('.checkbox').click(function() {
        if ($(this).attr('checked')) {
            //alert('checked');
            $(this).next().next().css('opacity', 1);
            $(this).next().next().attr("disabled", "");
        } else {

            //alert('not checked');
            $(this).next().next().css('opacity', 0.5);
            $(this).next().next().attr("disabled", "disabled");
            $(this).next().next().attr("value", "");
        };

    });
    // hover scripts for the nav
    $('#menu li').hover(
		    function() {
		        //show its submenu
		        $('ul', this).slideDown(100);
		    },
		    function() {
		        //hide its submenu
		        $('ul', this).slideUp(100);
		    }
	 );
    // ajax script for the branchfinder page
    $('#ajaxStatus').ajaxStart(function() {
        $(this).show();
    }).ajaxStop(function() {
        $('#branchInfo').slideDown(500);
        $(this).hide();
    });
    $('.branchDD').change(function() {
        // get the value from the drop down
        var ID = this.value;
        if (ID == "Select") {
            return false;
        } else {
            // call the data and pass the ID
            $('#branchInfo').load('branchinfo.aspx #data', { 'branchID': ID });
        };
    });

    // news section open / close
    $('.sectionInfo').hide();
    $('.closeSection').hide();
    $('.openSection').click(function() {
        $(this).hide().next().show();
        $(this).next().next().next().slideDown();
        return false;
    });
    $('.closeSection').click(function() {
        $(this).hide().prev().show();
        $(this).next().next().slideUp();
        return false;
    });

});


