$(document).ready(function () {

    $('#selectAll').click(function () {
        var chx = $(".gridview input");

        chx.attr("checked", $(this).attr("checked"));
        if (chx.attr("checked") == true) {
            chx.parent().parent().parent().children().addClass('highlight-row');
        }
        else {
            chx.parent().parent().parent().children().removeClass('highlight-row');
        }
    });

    $('.gridview input').click(function () {
        var me = $(this);

        if (me.attr("checked") == true) {
            me.parent().parent().parent().children().addClass('highlight-row');
        } else {
            me.parent().parent().parent().children().removeClass('highlight-row');
        }
    });

});


$(function () {

    var datesBM = $(".txtDate1_bm, .txtDate2_bm").datepicker({
        //defaultDate: "+1w",
        changeMonth: true,
        onSelect: function (selectedDate) {
            var option = this.id.indexOf('txtDate1_bm') != -1 ? "minDate" : "maxDate",
					instance = $(this).data("datepicker");
            date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
            datesBM.not(this).datepicker("option", option, date);
        }
    });

    var datesCM = $(".txtDate1_cm, .txtDate2_cm").datepicker({
        //defaultDate: "+1w",
        changeMonth: true,
        onSelect: function (selectedDate) {
            var option = this.id.indexOf('txtDate1_cm') != -1 ? "minDate" : "maxDate",
					instance = $(this).data("datepicker");
            date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
            datesCM.not(this).datepicker("option", option, date);
        }
    });
//    $(".txtDate1_bm").datepicker();
//    $(".txtDate2_bm").datepicker();
//    $(".txtDate1_cm").datepicker();
//    $(".txtDate2_cm").datepicker();

});

var txtComment = 'Comment...';
function showHideComments(txtElem) {
    var elem = document.getElementById(txtElem);
    if (elem.style.display == '') {
        elem.style.display = 'none';
        if (elem.value == txtComment) {
            elem.value = '';
        }
    }
    else {
        elem.style.display = '';
        if (elem.value == '') {
            elem.value = txtComment;
        }
    }
}
function commentInputFocus(txtElem) {
    var elem = document.getElementById(txtElem);
    if (elem.value == txtComment) {
        elem.value = '';
    }
}
function commentInputBlur(txtElem) {
    var elem = document.getElementById(txtElem);
    if (elem.value == '') {
        elem.value = txtComment;
    }
}

