<script type="text/javascript" src="catalog/javascript/en.js"></script>

<script type="text/javascript" src="catalog/javascript/vJqueryScore.js" ></script>

<script type="text/javascript" src="catalog/javascript/ajax/jquery.js"></script>

<!-- <script type="text/javascript" src="catalog/javascript/jquery-1.7.1.min.js"></script> -->

<div id="pro_reviews">

    <div id="customer-questions">

        <div class="productquestions-container">

            <div class="tab-content-title text-center">Questions and answers</div>

                <div class="cont tab-content">

                    <ul class="reviewDetails qa-list" id="qa-list">

                      <?php foreach ($product_questions as $question) { ?>

                    	<li class="question question-element clearfix">

                        	<div class="pr-qa">

                            	<b class="pr-question_nr">Q</b>

                                <div class="pr-question_title"><?php echo $question['text']; ?></div>

                                <div class="pr-question_author">

                                	<span class="pr-question_author_name">

                                    	<?php echo $question['author']; ?>

                                    </span>

                                <i class="pr-question_author_date">

                                <?php echo date("M j, Y", strtotime($question['date_added'])); ?> </i>

                                </div>

                            </div>

                        </li>

                        <?php if(!empty($question['reply_text'])){ ?>

                        <li class="answer question-element clearfix">

                            <div class="pr-qa hasVoting">

                                <b class="pr-question_nr">A</b>

                                <div class="pr-question_text answer"><?php echo $question['reply_text']?></div>

                                <div id="qr-238999" class="helpfulness">

                                   <div class="helpfulness_title">Was this question helpfull</div>

                                   <a title="Yes" onclick="voteQuestion('', '1'); return false;"><span><i class="icon-thumbs-o-up"></i></span> 0</a>

                                   <a title="No" onclick="voteQuestion('', '0'); return false;"><span><i class="icon-thumbs-o-down"></i></span> 0</a>

                                </div>

                            </div>

                        </li>

                       <?php }?>

                   <?php }?>

                    </ul>

                </div>

        </div>

    </div>



    <div id="customer-questions-form">

    	<div class="productquestions-container">

        	<div class="tab-content-title text-center">Ask Your Own Question</div>

            <div class="cont">

            <form action="<?php echo $action; ?>" id="productquestions-form" class="form-horizontal" onsubmit="return checkForm();" method="post" enctype="multipart/form-data">



            <div class="form-group">

                <label class="col-sm-7 control-label">Author</label>

                <div class="col-sm-12">

                    <input type="text" value="<?php echo $customer_name; ?>" placeholder="" name="question_author" id="ID_AUTHOR" class="form-control required-entry">

                    <span class="desc">(will NOT be displayed on site)</span>

                </div>

            </div>

            <div class="form-group">

                <label class="col-sm-7 control-label" for="question_author_email_field">Email</label>

                <div class="col-sm-12">

                    <input type="email" value="<?php echo $customer_email; ?>" placeholder="" name="question_email" id="ID_EMAIL" class="form-control required-entry">

                    <span class="desc">(will NOT be displayed on site)</span>

                </div>

            </div>

            <div class="form-group">

                <label class="col-sm-7 control-label" for="question_text_field">Question</label>

                <div class="col-sm-12">

                    <textarea class="textarea1 form-control required-entry" name="question_content" id="ID_QUESTION"></textarea>

                    <span class="desc">Please submit questions related to this product, for all other questions <a href="/index.php?controller=knowledge_base&knowledge_id=12/">contact us</a>.</span>

                </div>

			</div>

            <div class="form-group">

                <div class="col-sm-offset-7 col-sm-12 button-set">

                    <button type="button" id="ID_SUBMIT" class="btn btn-primary">Submit question</button>

                </div>

       </div>

<script type="text/javascript">

    $('#ID_SUBMIT').click(function() {

        var that = $(this);

        var author   = $("#ID_AUTHOR").val();

        var email    = $("#ID_EMAIL").val();

        var question = $("#ID_QUESTION").val();

        var date     = new Date();



        if ( author  == '' ) {

            alert("Author can not be empty, please input a author name");

            document.getElementById('ID_AUTHOR').focus();

            return false;

        }



        if (email == '' || email.indexOf("@") < 0 || email.indexOf(".") < 0) {

            alert("Email is not a vaild address, please input a correct email address!");

            document.getElementById('ID_EMAIL').focus();

            return false;

        }



        if ( question == '' && question.length < 2 || question.length > 255 ) {

            alert("Question must be greater than 2 and less than 255 characters!");

            document.getElementById('ID_QUESTION').focus();

            return false;

        }


        $("#loading-center").show();
        $(this).attr('disabled', 'disabled');
        $.post('<?php echo $ajax_questionaction; ?>',

               {question_author: author, question_email: email, question_content: question, question_date: date},

               function(data){
                    setTimeout('$("#loading-center").hide();alert("Posted question sucessfully, please be patient to wait our reply!");', 400);
                    $("#ID_AUTHOR").val('<?php echo $customer_name; ?>');
                    $("#ID_EMAIL").val('<?php echo $customer_email; ?>');
                    $("#ID_QUESTION").val('');
                    data.replace(/(^\s)|(\s$)/g, '');
                    $('#qa-list').append(data);
                    that.removeAttr('disabled');
               });
    });

 </script>

            </form>

            </div>

        </div>

    </div>

</div>

