﻿function swapImages() {
    var $active = $('#myGallery .active');
    var $next = ($('#myGallery .active').next().length > 0) ? $('#myGallery .active').next() : $('#myGallery img:first');
    $active.fadeOut(function () {
        $active.removeClass('active');
        $next.fadeIn().addClass('active');
    });
}

function CheckBoxListSelect(cbControl, state) {
    var chkBoxList = document.getElementById(cbControl);
    var chkBoxCount = chkBoxList.getElementsByTagName("input");
    for (var i = 0; i < chkBoxCount.length; i++) {
        chkBoxCount[i].checked = state;
    }
    return false;
    //Usage:
    /*
    انتخاب <a id="A3" href="#" onclick="javascript: CheckBoxListSelect ('<%= chklSections.ClientID %>',true)">
        همه</a> | <a id="A4" href="#" onclick="javascript: CheckBoxListSelect ('<%= chklSections.ClientID %>',false)">
            هیچکدام</a>
    */
}

function handleDefaultValues() {
    $('.default-value').each(function () {
        var default_value = this.value;
        $(this).css('color', '#666'); // this could be in the style sheet instead
        $(this).focus(function () {
            if (this.value == default_value) {
                this.value = '';
                $(this).css('color', '#333');
            }
        });
        $(this).blur(function () {
            if (this.value == '') {
                $(this).css('color', '#666');
                this.value = default_value;
            }
        });
    });
}
