﻿function Report() {
    this.reportForm = null;

    Report.prototype.init = function(reportFormId) {
        this.reportForm = $(reportFormId.toString());
    };
    
    this.show = function(contentType, link, comment){
        this.reportForm.dialog('open');
        this.reportForm.dialog('option', 'width', 330);
        if (contentType != undefined) {
            this.setContentType(contentType);
        }
        if (link != undefined) {
            this.setLink(link);
        }
        if (comment != undefined) {
            this.setComment(comment);
        }
        this.makeReadOnly(true, true, false);
    }

//    this.close = function() {
//        reportForm.dialog('close');
//    }

//    this.clear = function() {
//        this.setContentType('None');
//        this.setLink('');
//        this.setComment('');
//    }

//    this.makeActive = function(contentType, link, comment) {
//        if (contentType == true) {
//            $('#contentType', reportForm).removeAttr("disabled");
//        }
//        if (link == true) {
//            $('#link', reportForm).removeAttr("disabled");
//        }
//        if (comment == true) {
//            $('#comment', reportForm).removeAttr("disabled");
//        }
//    }

    this.makeReadOnly = function(contentType, link, comment) {
        if (contentType == true) {
            $('#contentType', this.reportForm).attr('disabled', 'disabled');
        }
        if (link == true) {
            //$('#link', this.reportForm).attr('disabled', 'disabled');
        }
        if (comment == true) {
            $('#comment', this.reportForm).attr('disabled', 'disabled');
        }
    }
    
    this.setContentType = function(value) {
        $('#contentType', this.reportForm).val(value);
    }

    this.getContentType = function() {
        return $('#contentType', this.reportForm).val();
    }

    this.setLink = function(value) {
        $('#link', this.reportForm).attr('href', value);
        $('#link', this.reportForm).text(value);
    }

    this.getLink = function() {
        return $('#link', this.reportForm).attr('href');
    }

    this.setComment = function(value) {
        $('#comment', this.reportForm).val(value);
    }

    this.getComment = function() {
        return $('#comment', reportForm).val();
    }
}