// **** jQuery INIT ****

// to avoid name conflict with prototype.js
jQuery.noConflict();
var $j = jQuery;

$j(document).ready(
	function()
	{
 		$j(".EIPcat").addClass("forum-catadmin-title").addClass("click-able").editInPlace(
 			{
				url: "_ajax/_scripts/forum_edittext.php?action=cattitle",
				saving_text: "Gemmer...",
				save_buttontext: "Gem",
				cancel_buttontext: "Fortryd",
				hover_text: "Klik for at rette"
			}
		); // end EIPcat

 		$j(".EIPforum").addClass("click-able").editInPlace(
 			{
				url: "_ajax/_scripts/forum_edittext.php?action=forumtitle",
				saving_text: "Gemmer...",
				save_buttontext: "Gem",
				cancel_buttontext: "Fortryd",
				hover_text: "Klik for at rette"
			}
		); // end EIPforum

 		$j(".EIPuser").addClass("forum-catadmin-title").addClass("click-able").editInPlace(
 			{
				url: "_ajax/_scripts/edituser.php?action=myprofile",
				saving_text: "Gemmer...",
				save_buttontext: "Gem",
				cancel_buttontext: "Fortryd",
				hover_text: "Klik for at rette"
			}
		); // end EIPuser

 		$j(".EIPforumdesc").addClass("click-able").editInPlace(
 			{
				url: "_ajax/_scripts/forum_edittext.php?action=forumdesc",
				field_type: "textarea",
				saving_text: "Gemmer...",
				save_buttontext: "Gem",
				cancel_buttontext: "Fortryd",
				hover_text: "Klik for at rette"
			}
		); // end EIPforumdesc

 		$j(".topicDel").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du slette indlęget ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_delete.php?action=deltopic",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					$j("#row"+data).remove();
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end topicDel

 		$j(".catDel").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du slette kategorien ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_delete.php?action=delcat",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					if(data == 'true')
			 					{
			 						document.location.reload();
			 					}
			 					else
			 					{
			 						alert("En fejl ved sletning");
			 					}
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end catDel

 		$j(".forumDel").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du slette forumet ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_delete.php?action=delforum",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					$j("#row-"+data).remove();
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end forumDel
		
 		$j(".postDel").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du slette posten ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_delete.php?action=delpost",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					document.location.reload();
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end postDel

 		$j(".catUp").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du flytte kategorien opad ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_move.php?action=catUp",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					if(data == 'true')
			 					{
			 						document.location.reload();
			 					}
			 					else
			 					{
			 						alert("En fejl ved flytning af kategori");
			 					}
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end catUp

 		$j(".catDown").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du flytte kategorien nedad ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_move.php?action=catDown",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					if(data == 'true')
			 					{
			 						document.location.reload();
			 					}
			 					else
			 					{
			 						alert("En fejl ved flytning af kategori");
			 					}
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end catDown

 		$j(".forumUp").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du flytte forumet opad ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_move.php?action=forumUp",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					if(data == 'true')
			 					{
			 						document.location.reload();
			 					}
			 					else
			 					{
			 						alert("En fejl ved flytning af forumet");
			 					}
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end forumUp

 		$j(".forumDown").addClass("click-able").click(function()
 			{
 				if(confirm('Vil du flytte forumet nedad ?'))
 				{
					$j.get(
						"_ajax/_scripts/forum_move.php?action=forumDown",
						{
							id: this.id
						},
						function(data)
						{
							if((data != "") && (data != "undefined"))
							{
			 					if(data == 'true')
			 					{
			 						document.location.reload();
			 					}
			 					else
			 					{
			 						alert("En fejl ved flytning af forumet");
			 					}
			 				}
			 				else
			 				{
			 					alert("Ups der var en fejl: " + data);
			 				}
						}
					);
				}
			}
		); // end forumDown

 		$j(".forumAdd").addClass("click-able").click(function()
 			{
				$j.get(
					"_ajax/_scripts/forum_add.php?action=forumAdd",
					{
						id: this.id
					},
					function(data)
					{
						if((data != "") && (data != "undefined"))
						{
		 					if(data == 'true')
		 					{
		 						document.location.reload();
		 					}
		 					else
		 					{
		 						alert("En fejl ved oprettelse af forum");
		 					}
		 				}
		 				else
		 				{
		 					alert("Ups der var en fejl: " + data);
		 				}
					}
				);
			}
		); // end forumAdd

 		$j(".topicAdd").addClass("click-able").click(function()
 			{
				$j.get(
					"_ajax/_scripts/forum_add.php?action=topicAdd",
					{
						id: this.id
					},
					function(data)
					{
						if((data != "") && (data != "undefined"))
						{
		 					alert("DEBUG: " + data);
		 					//$j("#row"+data).remove();
		 				}
		 				else
		 				{
		 					alert("Ups der var en fejl: " + data);
		 				}
					}
				);
			}
		); // end topicAdd

 		$j(".addCat").addClass("click-able").click(function()
 			{
				$j.get(
					"_ajax/_scripts/forum_add.php?action=catAdd",
					{
						id: this.id
					},
					function(data)
					{
						if((data != "") && (data != "undefined"))
						{
		 					document.location.reload();
		 				}
		 				else
		 				{
		 					alert("Ups der var en fejl: " + data);
		 				}
					}
				);
			}
		); // end addCat
	}
);

