﻿$('#form').submit(function(){
    $('input[type=submit]', this).attr('disabled', 'disabled');
});



$(document).ready(function() {
	$('#captcha').click(function() {
		$("#captcha").attr("src", "/?m=captcha&hp=1&ts="+ new Date().getTime());
	});
});

/* On site favorites */
function favorites() {
    $(".bookmark").click(function(event) {
            var request = $(this).parent.attr("id");
            var counter = parseInt($("#bookmarks sup").text());
            if ($(this).hasClass("ed")) {
                    //Remove bookmark
                    $.get("/account/favorites/delete/", //{ favid:request },
                                    function() {
                                            $("#bookmarks sup").text(--counter); // Decrease counter
                                            $(this).toggleClass("ed"); //Toggle class of clicked element
                                    });
            } else {
                    //Add bookmark
                    $.get("/account/favorites/add/", //{ favid:request },
                                    function() {
                                            $("#bookmarks sup").text(++counter); // Increase counter
                                            $(this).toggleClass("ed"); //Toggle class of clicked element
                                    });
            }
    });
}


  $(document).ready(function() {
    $('#report_ad').click(function() {
      alert('clicked');
      $.get("doquery.php", {id: 1, action: all}, function(result) {
        $("#report_ad").html(result);
      });
    });
  });



$(document).ready(function() {
	$('a.report_post').click(function(e) {
	if (confirm('Please flag with caution. Are you sure you want to flag this post?')) {	
		e.preventDefault();
		var parent = $(this).parent();
		$.ajax({
			type: 'get',
			url: '/?m=showad',
			data: 'p=reportabuse&adid=' + parent.attr('id').replace('record-',''),
			beforeSend: function() {
			parent.animate({'backgroundColor':'#fb6c6c'},300);
			},
			success: function() {
				parent.slideUp(300,function() {
				parent.remove();
				});
			}
		});
	}
	});
});
