
jsRules.addRule("a.js_add_to_favorites",function(){
	whi.events.addEvent(this,"click",function(){
		if (this.is_logged != false){
			var idc = parseInt(this.id.replace("fav_anunt_","")) || 0;
			if (idc>0){
				ajax = new sack();
		 		ajax.requestFile = "/lib/add_favorite.php?id="+idc+"&type=anunt";
		 		ajax.onCompletion = function(){
					window.location.reload();
				}
				ajax.runAJAX();
	
				var div = document.createElement("b");
				div.innerHTML = "Anuntul a fost adaugat in lista ta de favorite";
	
				this.parentNode.replaceChild(div,this);
			}
		}
	});
	whi.events.addEvent(this,"mouseover",function(e){
		var a;
		if (a = document.getElementById("fav_login_text")){
			a.style.visibility = "visible";
		}
	});
	whi.events.addEvent(this.parentNode.parentNode,"mouseout",function(e){
 		var targ = whi.events.getTargetElement(e);
		if ((!whi.DOM.contains(this,targ) && this!=targ) || (targ.tagName.toLowerCase() == 'a' && targ.rel == 'hide_fav')){
			var a;
			if (a = document.getElementById("fav_login_text")){
				a.style.visibility = "hidden";
			}
		}
	});
});
