$(document).ready(function () {
    /*
    $('.my-addtofav').mouseover(function () {
        document.body.style.cursor = 'pointer';
    });
    $('.my-addtofav').mouseout(function () {
        document.body.style.cursor = 'auto';
    });
    */
    $('.my-addtofav').click(function () {
        item_id = $(this).attr('id');
        var st = item_id.split('-');
        //$('#entry-'+st[1]).fadeTo('normal',0.5);
        $(this).text("Added to favorites").removeClass("magenta").addClass("blue").attr({
            href: "http://www.letmeknow.in/my/"
        }).removeClass("my-addtofav");;
        $.get(('http://www.letmeknow.in/my/addtofavorite/'), {
            id: st[1]
        }

        /*,
function(data)
{
	if(data=='1')
	{
		fbout="The opportunity was successfully added to your favorites.";
}
else if(data=='2')
{
fbout="The opportunity already exists in your favorites.";
}
else
{
fbout="Sorry! Could not add the opportunity.";
}
fbout+="<br/><br/><a href=\""+base_url+"/my/\">Click here to view your favorites</a>";
$.facebox(fbout);
$('#entry-'+st[1]).fadeTo('normal',1);
}*/
        );
    });

    $('.my-delfav').mouseover(function () {
        document.body.style.cursor = 'pointer';
    });
    $('.my-delfav').mouseout(function () {
        document.body.style.cursor = 'auto';
    });
    $('.my-delfav').click(function () {
        item_id = $(this).attr('id');
        var st = item_id.split('-');
        $('#listentry-' + st[1]).fadeTo('normal', 0.5);
        $.get(('http://www.letmeknow.in/my/deletefavorite/'), {
            id: st[1]
        }
        
        /*,

        function (data) {
            if (data == '1') {
                fbout = "The opportunity was successfully deleted from your favorites.";
            } else {
                fbout = "Sorry! Could not delete the opportunity.";
            }
            $.facebox(fbout);
            $('#listentry-' + st[1]).hide();
        }
        */
        );
    });
    $('#submit-comment').click(function () {
        var q = $('#form-comment').serialize();
        var submit_url ='http://www.letmeknow.in/my/postcomment';
        $('#form-comment').fadeTo('normal', 0.5);
        $('#form-comment').ajaxSubmit({
            url: submit_url,
            data: q,
            clearForm: true,
            success: function (responseText, successText) {
                if (responseText == '0') {
                    fbout = "Could not add the comment.";
                } else {
                    fbout = "Comment added successfully.";
                    $('#comments').append(responseText);
                }
                $.facebox(fbout);
                $('#form-comment').fadeTo('normal', 1);
            }
        });
    });
});