/* to dzialalo 
$(function() {
    $(".CodeToCopy").each(function() {
        var clip = new ZeroClipboard.Client();
        clip.glue(this);
        
        var truecode = $("#" + this.id + " a span:last");
        var falsecode = $("#" + this.id + " a span:first");
        var falseurl = $("#" + this.id + " a");
        
        clip.setText(truecode.text());
        clip.addEventListener( 'onMouseUp', function my_mouse_down_handler(client) {
                window.open(falseurl.attr('href')); 
        } );
        clip.addEventListener('complete', function(client, text) {
            //alert("Copied text to clipboard:\n" + text);
            //
            //setTimeout("window.open('" + truecode.attr('href') + "');", 4000);
            falsecode.hide(1000);
            truecode.show(2000);
            //alert(truecode.attr('href'));
            
        });
    });
});
*/ 
function LOG() {} 
function submitForm() {
    $.fck.update();
    $.post('/Ajax/PostComment.php',  $("form#submittable").serialize(), function(data, status) {
       if (!data) {
        alert('Error! Please correct the form!');
       }
       else {
        $("form#submittable").slideUp(1000);
        $("div#submitSuccess").slideDown(1000);
       }
    
    }, "json");
   /*$.post('/Ajax/PostComment.php', $("form#submittable").serialize(), function(data, status) {
        alert(data);    
    });*/ 
    return false;
}
function submitComment(id) {
    $.post('/Ajax/PostComment.php', $("form#submittable" + id).serialize(), function(data, status) {
       if (!data) {
        alert('Error! Please correct the form!');
       }
       else {
        $("form#submittable" + id).slideUp(1000);
        $("div#submitSuccess" + id).slideDown(1000);
       }
    
    }, "json");
    $.post('/Ajax/PostComment.php', $("form#submittable" + id).serialize(), function(data, status) {
        alert(data);    
    });
    return false;
}
function ShowReviewComments(ReviewID) {
    $.getJSON('/Ajax/ReviewComments.php?ReviewID=' + ReviewID, function(data) {
       var content = "";
        for (i = 0; i < data.Comments.length; i++) {
        //alert(ret[i]);
         //var elems = eval('(' + ret[i] + ')');
           var comm = data.Comments[i];
           var author = '';
           if (comm.Nick != null) {
            author = "<a href='/" + data.Config.ProfileSection + "/" + comm.URLNick + "'>" + comm.Nick + "</a>";
           }
           else {
            author = comm.Author;
           }
           content += '<div class="revised_date_img"><img src="/Static/Images/date_img_03.gif" alt="" /></div>';
           content +=    '<div class="revised_date_right">';
           content +=    '<div class="revised_date_1">Posted by:<span class="commentAuthor" > ' + author + '</span> @ ' + comm.Added + '</div>';
           content +=    '<div class="revised_date_2">' + comm.Body + '</div>';
           content += '</div>'
           content += '<div class="clear"></div>'
           content += '<div class="revised_bottom_border"><img src="/Static/Images/border_img.gif" alt="" /></div>'
      
       }
        $("#comments" + ReviewID).hide().html(content).slideDown(2000);

      
    });

    return false;
}

$(function() {
    $(".codeClickable").each(function() {
        var truecode = $("#" + this.id + " div.CodeToCopy div span:last");
        var falsecode = $("#" + this.id + " div.CodeToCopy div span:first");
        var falseurl = $("#" + this.id + " div.CodeToCopy div");
        var alwaysclickable = $("#" + this.id + " div.alwaysClickable");//.get(0);
        $(this).bind('click', function (ev) {
            falsecode.hide(1000);
            truecode.show(2000);
            window.open(falseurl.attr('href')); 
            $(this).unbind('click');
            $(alwaysclickable).bind('click', function (event) {
                window.open(falseurl.attr('href')); 
            });
        });
    });
    // revealing invalids 
    $("div.nyesTitleBg0.reveal1, div.isdeal1").each(function() {
        var truecode  = $(this).find("span:last");
        var falsecode = $(this).find("span:first");
            falsecode.hide(1);
            truecode.show(1);
    });
    
});