// JavaScript Document
$(document).ready(function(){
	
    $('#add-comment').click(function() {
        try
        {
            $(".s-player").hide();
        }
        catch(err)
        {

        }
        $.blockUI({
            message: $('#add-comment-form'),
            css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#004E8B',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .9,
                color: '#fff',
                top:'25%',
                cursor:'auto'
            }
        });
    });
    $('#close').click(function(){
        $.unblockUI();
    });

    $('#addComment').click(function(){
        var nid = $('#nid').val();
        var name = $('#name').val();
        var country = $('#country').val();
        var comment = $('#comment').val();
		
        if( name == "" || country == "" || comment == ""){
            alert("عفواً .. جميع الحقول مطلوبة");
            return false;
        }
		
        //$('#add-comment-form input,textarea').attr("disabled", true);
        $('#add-loading').ajaxStart(function(){
            $(this).show()
        } );
        $('#add-loading').ajaxError(function(){
            $(this).hide()
        } );
        $.ajax({
            type:'POST',
            url:base_path+'addons/addComments.php?nid='+nid+'&name='+name+'&country='+country+'&comment='+comment,
            cache:false,
            error: function(xhr, ajaxOptions, thrownError){
                alert('error number: '+xhr.status);
            },
            success: function(msg){
                $('#add-loading').hide();
                $('#add-comment-message').stop().animate( {
                    "opacity": 1
                },{
                    duration:1
                }).animate( {
                    "top": 0
                },{
                    duration:1333
                });
                $('#add-comment-message').show().text(msg).animate( {
                    "opacity": "hide"
                }, {
                    duration:5500
                } ).css({
                    top:0
                });
                setTimeout($.unblockUI, 1000);
            }
        });
    });
})