﻿
/*

 * author: http://240x400.net.ru
 * name: Удобное добавление материала в закладки

*/


imagesType = ['http://240x400.net.ru/decor_site/loader.gif','http://240x400.net.ru/decor_site/er.png','http://240x400.net.ru/decor_site/tick.png'] // изображения
function addEntry(title, idm, link) {
 $('#' + idm).html('<img src='+imagesType[0]+'>');
 $.get('/publ/0-0-0-0-17?' + Math.random(), function (data) {
if($('.countFav',data).size()>'50'){$('#' + idm).html('<img src='+imagesType[1]+'>');_uWnd.alert('<center><font color="red">Вы не можете хранить более <b>50</b> закладок</font></center>', 'Ошибка', {w: 300,h: 70});}
else{
 if ($('.idm' + idm, data).text().indexOf(title) != -1) {
 $('#' + idm).html('<img src='+imagesType[1]+'>');
 _uWnd.alert('<center><font color="red">Вы <b>уже</b> добавляли данный материал в закладки</font></center>', 'Ошибка', {
 w: 300,
 h: 70
 });
 }
 else {
 $.get('/publ/0-0-0-0-1', function (data) {
 var ssid = $('input[name="ssid"]', data).val();
 $.post('/publ/', {
 a: '12',
 jkd428: '1',
 jkd498: '1',
 ocat: '1',
 title: title,
 brief: link,
 aname: idm,
 brief: link,
 ssid: ssid
 },
 function (response) {
 r = $(response).text()
 if (r.indexOf('успешно') != -1) {
 $('#' + idm).html('<img src='+imagesType[2]+'>')
 }
 else {
 $('#' + idm).html('<img src='+imagesType[1]+'>')
 }
 });
 });
 }}
 });
}
$('#myfavorite').click(function() {
new _uWnd('favor',' ',400,100,{autosize:1,maxh:300,minh:100,align:0,close:1,oncontent:function() {
$.get('/publ/0-0-0-0-17?'+Math.random(),function(data){
if($('.resFav',data).text()){
$('div[class^="zkl"]',data).each(function() {
$('.ajaxFav').append($(this).html())
_uWnd.getbyname('favor').checksize();
});
}
else{$('.ajaxFav').html('<div style="margin:38px;text-align:center;">Вы ещё не добавляли материалы в закладки</div>')}
});
}},'<div class="ajaxFav" style="margin:4px;"></div>');
});
