$(document).ready(function(){

	$(".item").mouseenter(function () {
		$(this).addClass("over");
	}).mouseleave(function () {
		$(this).removeClass("over");	
	});
	
	$(".bookmarks").mouseenter(function () {
		$(this).addClass("hover");
	}).mouseleave(function () {
		$(this).removeClass("hover");	
	});	 
	
	$(".bookmarks").each(function() {
		$(this).click(function () {
			var fav = $(this);
			
			if ($(this).hasClass('on')) {
			   	$.post("/main/removefav/" + $(this).attr("id"), { }, 
			   		function (data) {
						if (data == 'OK') {
							$.jGrowl("Объявление №"+fav.attr("id")+" убрано из закладок.");
							fav.removeClass("on");
						} else {
							$.jGrowl("Что-то пошло не так. Ошибка в БД!");										
						}	
				  	}
			   );
				return;
			}
			
			else {
			   $.post("/main/addfav/" + $(this).attr("id"), { }, 
			   		function (data) {
			   			if (data == 'OK') {
							fav.addClass("on");
							$.jGrowl("Объявление №"+fav.attr("id")+" добавлено в закладки.");										
						} else {
							$.jGrowl("Что-то пошло не так. Ошибка в БД!");										
						}
				  	}
			   );				
				return;				
			}
			
		});
	});	
	
	
});


function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}



$(document).ready(function() {
	var tr = false;
	
	$(".change_trigger").click(function () {
		$(this).toggleClass('on');
		$(".city_changer").fadeIn("slow");
	});  
	
	$("#city_close").click(function () {
		$(".change_trigger").toggleClass('on');
		$(".city_changer").fadeOut("slow");
	}); 
	
	
	//$(document).click(function () { $(".city_changer").toggle(); });					   	
	
});

// What is $(document).ready ? See: http://flowplayer.org/tools/documentation/basics.html#document_ready
$(document).ready(function() {
	$(".bookmarks").tooltip({
		// use div.tooltip as our tooltip
		tip: '.tooltip',
		// use the fade effect instead of the default
		effect: 'fade',
		// make fadeOutSpeed similar to the browser's default
		fadeOutSpeed: 100,
		// the time before the tooltip is shown
		predelay: 400,
		// tweak the position
		position: "bottom right",
		offset: [-50, -80]
	});
});



