﻿/// <reference path="jquery.vsdoc.js" />

$(document).ready(function(){
    $('input[name="chkRating"]').click(function(){
        $('#rating').val($(this).val());
        //$('#faqcomment').text($(this).val());
    });
    
    $('#faqcomment').focus(function(){
        if ($(this).text().indexOf('[Optional Comment]') == 0)
            $(this).text('');
    });
    
    $('#faqcomment').blur(function(){
        if ($(this).text().length == 0)
            $(this).text('[Optional Comment]');
    });
    
    $('#submitComments').click(function(){
        if($('#rating').val() == '0')
        {
            $('#alertmsg').html('<b>Please rate this article before submitting.</b>');
        }
        else
        {
            //submit comments
            $.get("/handlers/FAQsSaveComments.ashx", {faqid: $("input[title='faqid']").val(), comments: $('#faqcomment').val(), rating: $('#rating').val()})
            
            $('#commentstable').hide();
            $('#commentsmsg').fadeIn();
        }
    });
    
    $('#submitComments1').click(function(){
        if($('#rating').val() == '0')
        {
            $('#alertmsg').html('<b>Please rate this article before submitting.</b>');
        }
        else
        {
            //submit comments
            $.get("/handlers/FAQsSaveComments.ashx", {faqid: $("input[title='faqid']").val(), comments: $('#faqcomment').val(), rating: $('#rating').val()})
            
            $('#commentstable').hide();
            $('#commentsmsg').fadeIn();
        }
    });
    
    $('#submitComments2').click(function(){
        if($('#rating').val() == '0')
        {
            $('#alertmsg').html('<b>Please rate this article before submitting.</b>');
        }
        else
        {
            //submit comments
            $.get("/handlers/FAQsSaveComments.ashx", {faqid: $("input[title='faqid']").val(), comments: $('#faqcomment').val(), rating: $('#rating').val()})
            
            $('#commentstable').hide();
            $('#commentsmsg').fadeIn();
        }
    });
    
});