// JavaScript Document
var timer = "";
var click_obj = "";
function addToShortlist(e, id) {
	clearTimeout(timer);
	
	var obj = "";
	if (e != null) {
		obj = e.target;	
	}
	else {
		obj = event.srcElement;
	}	
	
	if (id == null) {
		
			
		id = obj.alt;
		if (id == "") {
			obj = obj.parentNode;
			id = obj.alt;
		}
	}
	
	click_obj = obj;
	
	$.post(
		   
		   	 path+"feeds/set_short_list.php",
		   { id: id},
		   
		   function (data) {
			   	if (data.match("added") != null) {
					click_obj.className = "short_list_button_over";
				}
				else {
					click_obj.className = "short_list_button";
				}
				showNotification(data);

				
		   },
		   "html"
		   )
}



function addToShortlist2(e, id) {
	clearTimeout(timer);
	
	var obj = "";
	if (e != null) {
		obj = e.target;	
	}
	else {
		obj = event.srcElement;
	}	
	
	if (id == null) {
		
			
		id = obj.alt;
		if (id == "") {
			obj = obj.parentNode;
			id = obj.alt;
		}
	}
	
	click_obj = obj;
	
	$.post(
		   
		   	 path+"feeds/set_short_list.php",
		   { id: id},
		   
		   function (data) {
			   	if (data.match("added") != null) {
					click_obj.className = "remove_shortlist";
				}
				else {
					click_obj.className = "add_shortlist";
				}
				showNotification(data);

				
		   },
		   "html"
		   )
}



function showNotification(data) {
	if (document.getElementById("notification") != null) {
		document.getElementById("site").removeChild(document.getElementById("notification"));		
	}
	var div = document.createElement("div");
	div.id = "notification";
	div.className = "notification";
	div.innerHTML = data;
	
	if (data.match("added") != null) {
		document.getElementById("short_list_num").innerHTML = parseInt(document.getElementById("short_list_num").innerHTML)+1;
	}
	else {
		document.getElementById("short_list_num").innerHTML = parseInt(document.getElementById("short_list_num").innerHTML)-1;
	}

	
	document.getElementById("site").appendChild(div);
	
	$("#notification").fadeIn(200, function () {
						timer = setTimeout("removeNotification()", 5000);
											 });

}

function removeNotification() {
	
	$("#notification").fadeOut(200, function() {
											 document.getElementById("site").removeChild(document.getElementById("notification"));	
											 });
	
	
}
