(function($) {
$(function(e) {
// check to see if page/cat has been bookmarked, if so, remove the bookmark link
if ($("#ft_tnb_cat").length || $("#pdd_tnb_cat").length) {
$.post(
'/ps/pubint/mytnb.cgi', {
a: 'is_bookmarked',
cat: $("#ft_tnb_cat").text()
}, function(data) {
if (data.status>0) {
$(".bookmark").remove();
}
}, 'json'
);
} else {
$.post(
'/ps/pubint/mytnb.cgi', {
a: 'is_bookmarked',
bookmark_link: window.location.href
}, function(data) {
if (data.status==1) {
$(".bookmark").remove();
}
}, 'json'
);
}
$('
').appendTo("body");
$('#mytnb_status_dialog').dialog({
autoOpen:false,
modal: true,
width: 400,
height: 175,
buttons: {
OK: function() {
$(this).dialog("close");
}
}
});
$(".bookmark").click(function(e) {
e.preventDefault();
var $this=$(this);
// show bookmarking ajax indicator
$this.append('');
if ($("#ft_tnb_cat").length) {
$.post(
$this.attr('href'), {
a: 'bookmark_cat',
cat: $("#ft_tnb_cat").text(),
cat_desc: $("#description_text").text()
}, function(data) {
if (data.status==1) {
$(".bookmark")
.empty()
.append('Added to My TNB Stuff
')
.css({opacity: 0})
.animate({opacity: 1}, 1000)
.animate({opacity: 0}, 1000);
} else {
$("#mytnb_status_dialog").find("p").html((data.message || 'Error bookmarking Catalog#')).end().dialog("open");
$this.find("img").remove();
}
}, 'json'
);
} else if ($("#pdd_tnb_cat").length) {
$.post(
$this.attr('href'), {
a: 'bookmark_cat',
cat: $("#pdd_tnb_cat").text(),
cat_desc: $("#description_text").text()
}, function(data) {
if (data.status==1) {
$(".bookmark")
.empty()
.append('Added to My TNB Stuff
')
.css({opacity: 0})
.animate({opacity: 1}, 1000)
.animate({opacity: 0}, 1000);
} else {
$("#mytnb_status_dialog").find("p").html((data.message || 'Error bookmarking Catalog#')).end().dialog("open");
$this.find("img").remove();
}
}, 'json'
);
} else {
$.post(
$this.attr('href'), {
a: 'bookmark_page',
bookmark_title: $(document).attr('title'),
bookmark_link: window.location.href
}, function(data) {
if (data.status) {
$(".bookmark")
.empty()
.append('Added to My TNB Stuff
')
.css({opacity: 0})
.animate({opacity: 1}, 1000)
.animate({opacity: 0}, 1000);
} else {
$("#mytnb_status_dialog").find("p").html((data.message || 'Error bookmarking Page')).end().dialog("open");
$this.find("img").remove();
}
}, 'json'
);
}
});
// use the already initialized reg dialog for showing the profile
$("#mytnb_profile").click(function(e) {
e.preventDefault();
$("#reg-dialog").dialog("option", "title", "Edit MyTNB Profile" );
$("#reg-dialog").find("iframe").get(0).src = $(this).attr('href');
$("#reg-dialog").dialog("open");
});
// attach onclick event handlers to documents in prodlist
$("#node-943,#node-1334").find(".prodlist").find("a").click(function(e) {
e.preventDefault();
$.post('/ps/pubint/mytnb.cgi', {
a: 'bookmark_node',
node: $(this).attr('node')
}, function(data) {
$("#mytnb_status_dialog").find("p").html((data.message || 'Error bookmarking Catalog#')).end().dialog("open");
}, 'json'
);
});
$(".bookmark_node").click(function(e) {
e.preventDefault();
$.post('/ps/pubint/mytnb.cgi', {
a: 'bookmark_node',
node: $(this).attr('node')
}, function(data) {
$("#mytnb_status_dialog").find("p").html((data.message || 'Error bookmarking Catalog#')).end().dialog("open");
}, 'json'
);
});
});
}(jQuery));