var checkOption = false;
$(document).ready(function(){
    $('.flagType').click(function(){
        //alert($(this).val());
        $('#flagTypeId').attr('value', $(this).val());
        checkOption = true;
    //$('#mydialog').addClass('errorSummary');
    //alert($('#flagTypeId').val());
    })
})
function checkFlag(){
    //alert($('#Flag_explanation').val());
    if($('#Flag_explanation').val() == '' && checkOption==false){
        showError("please chose one of the options below \n\n please write your explanation");
        $('#flagOption').addClass('errorSummary');
        $('#flagExplanation').addClass('errorSummary');
        return false;
    }
    if($('#Flag_explanation').val() == ''){
        showError("please write your explanation");
        $('#flagOption').removeClass('errorSummary');
        $('#flagExplanation').addClass('errorSummary');
        return false;
    }
    if(checkOption==false){
        showError("please chose one of the options below");
        $('#flagExplanation').removeClass('errorSummary');
        $('#flagOption').addClass('errorSummary');
        return false;
    }
    return true;
}

function showError(text){
    $('#errorMsg').addClass('errorSummary');
    $('#errorMsg').text(text);
}
